Browse Source

Amélioration des scripts AJAX et des styles

Ajout de la fonctionnalité "changement d'options" pour la clockAdvanced
remotes/svn/ModulesALaMano
Chouchen 9 years ago
parent
commit
fdc7719815
18 changed files with 305 additions and 60 deletions
  1. +16
    -0
      ajax/update.php
  2. +3
    -12
      ajax/update_position_config.php
  3. +1
    -1
      blogs.php
  4. +42
    -2
      class/Blogs.php
  5. +92
    -1
      class/ClockAdvanced.php
  6. +7
    -1
      class/Module.php
  7. +5
    -1
      class/Notes.php
  8. +43
    -3
      class/Todo.php
  9. +44
    -15
      class/Weather.php
  10. +2
    -2
      css/main.css
  11. +4
    -4
      css/todo.css
  12. +4
    -4
      db/config.xml
  13. BIN
      images/interface/clock_edit.png
  14. BIN
      images/interface/error.png
  15. +2
    -2
      js/getUncompletedTasks.php
  16. +10
    -4
      js/jquery.blogs.js
  17. +26
    -1
      js/jquery.jclockAdvanced.js
  18. +4
    -7
      js/jquery.weather.js

+ 16
- 0
ajax/update.php View File

@@ -0,0 +1,16 @@
<?
// Error reporting
error_reporting(E_ALL^E_NOTICE);
// Escaping:
$options = array();
$module ='';
foreach($_GET as $indice=>$valeur){
if($indice == 'id')
$module .= $valeur;
else
$options[$indice] = $valeur;
}
include '../class/AccueilModules.php';
echo AccueilModules::updateModule($module, $options);

+ 3
- 12
ajax/update_position_config.php View File

@@ -1,15 +1,7 @@
<?php // Error reporting error_reporting(E_ALL^E_NOTICE);
// Validating the input data: if(!is_numeric($_GET['x']) || !is_numeric($_GET['y'])) die("0");
// Escaping: $id = $_GET['id']; $x = (int)$_GET['x']; $y = (int)$_GET['y'];
// Saving the position and z-index of the note: $xmla = simplexml_load_file('../db/config.xml');
/*if($id == "weather"){
$xmla->item[1]->y = $y;
$xmla->item[1]->x = $x;
$target = 1;
echo $id;
}*/
include '../class/AccueilModules.php'; echo AccueilModules::updateModule($id, array('x'=>$x, 'y'=>$y)); /*
$target = -1;
$i = 0;
@@ -22,6 +14,5 @@ $xmla->item[$target]->y = $y;
$xmla->item[$target]->x = $x;
$xmla->asXML('../db/config.xml');
echo $target; ?>
$xmla->asXML('../db/config.xml');
echo $target; */ ?>

+ 1
- 1
blogs.php View File

@@ -1,6 +1,6 @@
<?
require('blogs_last_post.php');
$opts = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_TIMEOUT => 10);
$opts = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_TIMEOUT => 10, CURLOPT_CONNECTTIMEOUT => 10);
$blogs = new Blogs_last_post();
foreach($blogs->getLinks() as $link)
{


+ 42
- 2
class/Blogs.php View File

@@ -11,7 +11,8 @@ class blogs extends Module {
public function __construct($params){
$this->setParams($params);
require('blogs_last_post.php');
echo '<script type="text/javascript" src="js/jquery.blogs.js"></script>';
echo '<script type="text/javascript" src="js/jquery.blogs.js"></script>
<div id="blogs" style="top:'.$params['y'].'; left :'.$params['x'].';"></div>';
echo '<a href="#blogLinksManager" id="blog-links-manager"><img src="images/interface/blogs_edit.png" /></a>';
echo '<div style="display:none;">
<div id="blogLinksManager">
@@ -39,7 +40,46 @@ class blogs extends Module {
$blogs = new blogs($params);
}
public static function updateConfig($updated){
public function setX($x){
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='blogs']");
$path[0]->x = $x;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setY($y){
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='blogs']");
$path[0]->y = $y;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setVisibility($visibility){
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='blogs']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
}

+ 92
- 1
class/ClockAdvanced.php View File

@@ -19,9 +19,13 @@ class clockAdvanced extends Module {
$options = '';
foreach (self::$paramsList as $paramName){
if(isset($this->params[$paramName]))
$options .= $paramName.' : '.$this->params[$paramName].',';
$options .= $paramName.' : "'.$this->params[$paramName].'",';
}
echo '<script>$(document).ready(function(){
$(\'#fontFamily\').val("'.$params['fontFamily'].'");
$(\'#fontSize\').val("'.$params['fontSize'].'");
$(\'#format\').val("'.$params['format'].'");
$(\'#color\').val("'.$params['color'].'");
$(\'.jclockAdvanced\').jclock({'.substr($options,0,-1).'});
});
</script>';
@@ -34,6 +38,93 @@ class clockAdvanced extends Module {
public static function start($params){
$clockAdvanced = new clockAdvanced($params);
}
public function setX($x){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='clockAdvanced']");
$path[0]->x = $x;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setY($y){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='clockAdvanced']");
$path[0]->y = $y;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='clockAdvanced']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setFontFamily($fontFamily){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='clockAdvanced']");
$path[0]->fontFamily = $fontFamily;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setFontSize($fontSize){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='clockAdvanced']");
$path[0]->fontSize = $fontSize;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setColor($color){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='clockAdvanced']");
$path[0]->color = $color;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setFormat($format){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='clockAdvanced']");
$path[0]->format = $format;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
}

+ 7
- 1
class/Module.php View File

@@ -21,6 +21,12 @@ abstract class Module
abstract static function start($params);
abstract static function updateConfig($updated);
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
}

+ 5
- 1
class/Notes.php View File

@@ -24,6 +24,10 @@ class notes extends Module {
}
public static function updateConfig($updated){
return;
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
}

+ 43
- 3
class/Todo.php View File

@@ -20,7 +20,7 @@ class todo extends Module {
$this->setToken($xmla->token);
$this->setProjectName($xmla->name);
$this->setProjectId($xmla->id);
echo '<div id="todoList">';
echo '<div id="todo" style="top:'.$params['y'].'; left :'.$params['x'].';">';
if($this->token == null || $this->project_id == null)
echo 'Impossible de trouver votre configuration. <a href="install-todoist.php">Cliquez ici</a> pour la mettre en place.</div>';
else{
@@ -30,7 +30,7 @@ class todo extends Module {
}
echo '<script>
$(document).ready(function(){
$(\'#todoList\').resizable();
$(\'#todo\').resizable();
});</script>';
}else{
echo 'baaaaad persistance...';
@@ -66,7 +66,47 @@ class todo extends Module {
$todo = new todo($params);
}
public function setX($x){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='todo']");
$path[0]->x = $x;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setY($y){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='todo']");
$path[0]->y = $y;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='todo']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
return;
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
}

+ 44
- 15
class/Weather.php View File

@@ -33,21 +33,6 @@ class weather extends Module {
public static function start($params){
$weather = new weather($params);
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$params)){
switch($what){
case 'city':
self::setCity($withWhat);
break;
default:
break;
}
}
}
}
/**
*
@@ -66,4 +51,48 @@ class weather extends Module {
echo "ok";
}
public function setX($x){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='weather']");
$path[0]->x = $x;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setY($y){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='weather']");
$path[0]->y = $y;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public function setVisibility($visibility){
// Saving the position and z-index of the note:
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
$path = $xmla->xpath("//item[@id='weather']");
$path[0]->visibility = $visibility;
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
echo "ok";
}
public static function updateConfig($updated){
foreach ($updated as $what=>$withWhat){
if(in_array($what, self::$paramsList)){
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
}
}
}
}

+ 2
- 2
css/main.css View File

@@ -217,7 +217,7 @@
#recherche{margin-top:70px;}
#config {width:300px;}
#config-menu, #blog-links-manager, #city-menu {float:right; margin:12px 10px 0 0;}
#config-menu, #blog-links-manager, #city-menu , #jclockAdvanced-menu{float:right; margin:12px 10px 0 0;}
/* Green button class: */
a.green-button,a.green-button:visited, span.green-button{
@@ -241,7 +241,7 @@ a.green-button:hover, span.green-button:hover{
}
.jclock {position:absolute; top:10px; right:10px;z-index:500; width:200px;background:#fff url(../images/interface/clock.png) top left no-repeat; padding:5px 0 0 5px; width:59px; height:21px;}
.jclockAdvanced{position:absolute; top:10px; right:80px; padding:5px 0 0 5px;}
.jclockAdvanced{position:absolute; top:10px; right:80px; padding:5px 0 0 5px; width:500px;}
#blogs {/*position:absolute; bottom:10px; left: 100px;*/padding:5px;width:350px;-webkit-border-radius: 5px;
-moz-border-radius: 5px;border: 1px solid rgba(0,0,0,0.3);


+ 4
- 4
css/todo.css View File

@@ -1,12 +1,12 @@
#todoList {padding:5px;width:350px;-webkit-border-radius: 5px;
#todo {padding:5px;width:350px;-webkit-border-radius: 5px;
-moz-border-radius: 5px;border: 1px solid rgba(0,0,0,0.3);
-webkit-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.15);
overflow:hidden;}
#todoList ul{list-style:none;}
#todoList ul li{white-space : nowrap; padding-left:16px;}
#todoList ul li div.puce{width: 16px; height: 16px; background:url(../images/interface/ui-icons_888888_256x240.png) -32px -48px no-repeat; display:inline-block;}
#todo ul{list-style:none;}
#todo ul li{white-space : nowrap; padding-left:16px;}
#todo ul li div.puce{width: 16px; height: 16px; background:url(../images/interface/ui-icons_888888_256x240.png) -32px -48px no-repeat; display:inline-block;}


+ 4
- 4
db/config.xml View File

@@ -34,9 +34,9 @@
<visibility>true</visibility>
<x>80</x>
<y>10</y>
<fontFamily>'Times New Roman, serial'</fontFamily>
<fontSize>'20px'</fontSize>
<format>'%A %d %B %Y - %H:%M:%S'</format>
<color>'#000'</color>
<fontFamily>Times New Roman, serial</fontFamily>
<fontSize>20px</fontSize>
<format>%A %d %B %Y - %H:%M:%S</format>
<color>#000</color>
</item>
</Config>

BIN
images/interface/clock_edit.png View File

Before After
Width: 16  |  Height: 16  |  Size: 967 B

BIN
images/interface/error.png View File

Before After
Width: 16  |  Height: 16  |  Size: 666 B

+ 2
- 2
js/getUncompletedTasks.php
File diff suppressed because it is too large
View File


+ 10
- 4
js/jquery.blogs.js View File

@@ -22,14 +22,20 @@ function make_draggable(elements)
}
//affichage des blogs
$('body').append('<div id="blogs"></div>');
$("#blogs").html("<img src=\"images/interface/ajax_load.gif\"/> Loading Blogs...");
var tmp;
/* A helper function for converting a set of elements to draggables: */
make_draggable($('#blogs'));
$.get("blogs.php", function(data){
$("#blogs").html(data);
});
$.ajax(
{url : "blogs.php",
timeout : 36000,
error: function(data){
$("#blogs").html('<img src="images/interface/error.png"/> Délai dépassé !');
},
success:function(data){
$("#blogs").html(data);
}
});
});

+ 26
- 1
js/jquery.jclockAdvanced.js View File

@@ -209,4 +209,29 @@
};
})(jQuery);
$(document).ready(function(){
$('body').append('<a href="#jca" id="jclockAdvanced-menu"><img src="images/interface/clock_edit.png" /></a><div style="display:none;"><div id="jca"></div></div>');
$('#menu-bar').prepend($('#jclockAdvanced-menu'));
$('#jca').append('<h3>Options</h3><br/><label for="fontFamily">Font Family : </label><input type="text" id="fontFamily" name="fontFamily"/><br/><label for="fontSize">Font Size : </label><input type="text" id="fontSize" name="fontSize"/><br/><label for="format">Format : </label><input type="text" id="format" name="format"/><br/><label for="color">Color : </label><input type="text" id="color" name="color"/><span id="jca-submit" class="green-button">Enregistrer</span>');
$('#jclockAdvanced-menu').fancybox({
'zoomSpeedIn' : 600,
'zoomSpeedOut' : 500,
'easingIn' : 'easeOutBack',
'easingOut' : 'easeInBack',
'hideOnContentClick': false,
'padding' : 15
});
$('#jca-submit').live('click', function(){
var fontFamily = $('#fontFamily').val();
var fontSize = $('#fontSize').val();
var format = $('#format').val();
var color = $('#color').val();
if(fontFamily != '' && fontSize != '' && format != '' && color != ''){
$.get('ajax/update.php', {id:'clockAdvanced', fontFamily: fontFamily, fontSize:fontSize, format:format, color:color}, function(msg){
location.reload();
});
}else{
$('#jca').append('<span class="error">Fields can\'t be empty.</span>');
}
});
});

+ 4
- 7
js/jquery.weather.js View File

@@ -13,12 +13,8 @@ $(document).ready(function(){
$('#city-submit').live('click', function(){
var ville = $('#cityChoice').val();
if(ville != '' || ville != null){
$.get('ajax/update-city.php', {city: ville}, function(msg){
if(msg=='ok'){
$.get('ajax/update.php', {id:'weather', city: ville}, function(msg){
location.reload();
}else{
$('#city').append('<span class="error">An error occured while changing city.</span>');
}
});
}else{
$('#city').append('<span class="error">City can\'t be empty.</span>');
@@ -41,11 +37,12 @@ function make_draggable(elements)
stop:function(e,ui){
/* Sending the z-index and positon of the note to update_position.php via AJAX GET: */
$.get('ajax/update_position_config.php',{
$.get('ajax/update.php',{
x : ui.position.left,
y : ui.position.top,
id : ui.helper.attr('id')
});
}
});}
});
}
});

Loading…
Cancel
Save