From fdc771981594aec39ddab55e50d6ee1a2ba6ac47 Mon Sep 17 00:00:00 2001 From: Chouchen Date: Mon, 20 Sep 2010 14:39:08 +0000 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20des=20scripts=20AJAX=20et?= =?UTF-8?q?=20des=20styles=20Ajout=20de=20la=20fonctionnalit=C3=A9=20"chan?= =?UTF-8?q?gement=20d'options"=20pour=20la=20clockAdvanced?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ajax/update.php | 16 ++++++ ajax/update_position_config.php | 15 ++---- blogs.php | 2 +- class/Blogs.php | 46 ++++++++++++++-- class/ClockAdvanced.php | 93 +++++++++++++++++++++++++++++++- class/Module.php | 8 ++- class/Notes.php | 6 ++- class/Todo.php | 46 ++++++++++++++-- class/Weather.php | 59 ++++++++++++++------ css/main.css | 4 +- css/todo.css | 8 +-- db/config.xml | 8 +-- images/interface/clock_edit.png | Bin 0 -> 967 bytes images/interface/error.png | Bin 0 -> 666 bytes js/getUncompletedTasks.php | 4 +- js/jquery.blogs.js | 14 +++-- js/jquery.jclockAdvanced.js | 27 +++++++++- js/jquery.weather.js | 11 ++-- 18 files changed, 306 insertions(+), 61 deletions(-) create mode 100644 ajax/update.php create mode 100644 images/interface/clock_edit.png create mode 100644 images/interface/error.png diff --git a/ajax/update.php b/ajax/update.php new file mode 100644 index 0000000..0c7a240 --- /dev/null +++ b/ajax/update.php @@ -0,0 +1,16 @@ +$valeur){ + if($indice == 'id') + $module .= $valeur; + else + $options[$indice] = $valeur; +} +include '../class/AccueilModules.php'; +echo AccueilModules::updateModule($module, $options); diff --git a/ajax/update_position_config.php b/ajax/update_position_config.php index 4c1ef6d..fb6710f 100644 --- a/ajax/update_position_config.php +++ b/ajax/update_position_config.php @@ -1,15 +1,7 @@ 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; */ ?> diff --git a/blogs.php b/blogs.php index 694c236..861972f 100644 --- a/blogs.php +++ b/blogs.php @@ -1,6 +1,6 @@ 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) { diff --git a/class/Blogs.php b/class/Blogs.php index 652606d..5bf5fe7 100644 --- a/class/Blogs.php +++ b/class/Blogs.php @@ -11,7 +11,8 @@ class blogs extends Module { public function __construct($params){ $this->setParams($params); require('blogs_last_post.php'); - echo ''; + echo ' +
'; echo ''; echo '
@@ -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); + } + } + } + + } \ No newline at end of file diff --git a/class/ClockAdvanced.php b/class/ClockAdvanced.php index ba93b5f..3e6ce58 100644 --- a/class/ClockAdvanced.php +++ b/class/ClockAdvanced.php @@ -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 ''; @@ -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); + } + } } } \ No newline at end of file diff --git a/class/Module.php b/class/Module.php index ad05a7a..616900c 100644 --- a/class/Module.php +++ b/class/Module.php @@ -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); + } + } + } } \ No newline at end of file diff --git a/class/Notes.php b/class/Notes.php index dac54e3..cf8c987 100644 --- a/class/Notes.php +++ b/class/Notes.php @@ -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); + } + } } } \ No newline at end of file diff --git a/class/Todo.php b/class/Todo.php index f0cc985..9b4eb82 100644 --- a/class/Todo.php +++ b/class/Todo.php @@ -20,7 +20,7 @@ class todo extends Module { $this->setToken($xmla->token); $this->setProjectName($xmla->name); $this->setProjectId($xmla->id); - echo '
'; + echo '
'; if($this->token == null || $this->project_id == null) echo 'Impossible de trouver votre configuration. Cliquez ici pour la mettre en place.
'; else{ @@ -30,7 +30,7 @@ class todo extends Module { } echo ''; }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); + } + } } } \ No newline at end of file diff --git a/class/Weather.php b/class/Weather.php index f494776..54fceac 100644 --- a/class/Weather.php +++ b/class/Weather.php @@ -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); + } + } + } } \ No newline at end of file diff --git a/css/main.css b/css/main.css index 228c7e3..a5f77a5 100644 --- a/css/main.css +++ b/css/main.css @@ -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); diff --git a/css/todo.css b/css/todo.css index ea2df8d..10df132 100644 --- a/css/todo.css +++ b/css/todo.css @@ -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;} diff --git a/db/config.xml b/db/config.xml index 5e3e91b..ffe9c0f 100644 --- a/db/config.xml +++ b/db/config.xml @@ -34,9 +34,9 @@ true 80 10 - 'Times New Roman, serial' - '20px' - '%A %d %B %Y - %H:%M:%S' - '#000' + Times New Roman, serial + 20px + %A %d %B %Y - %H:%M:%S + #000 diff --git a/images/interface/clock_edit.png b/images/interface/clock_edit.png new file mode 100644 index 0000000000000000000000000000000000000000..7d3571887a2d2f72b56dc0988ea21f9cb5d1f3f0 GIT binary patch literal 967 zcmV;&133JNP)KP1*PeeKQ4{WY z)c-0DYJ3AZ(*g5kH}$i`>V&}6$`p9nqZ8rDr8M zu-Ltj{5^vDE*l=n%V2ET5;BWFe?{5k#6_I1Q{Kq^or73wgOpYio*9n^Zzh}w(pbPB z2mVktW4JjDR(UZDb-Q4!`sP?dkY3xbzR<>@ro#d=t;|Q`@bf&X>Kou9kuMa2`dJB_ zFLU7;Y$w|UW(V7#FWWPj5FEO#ai48@g=@`5xB?N(gklKOM4qS!O)@#|-N}I4BtqDs zfKz<~0ZxXGV_I+xS;2(hKuL!?>plxn!vO652uWgaczn28b`#a**_e4!yqhTyv&;C)>Hb5$yZ z??T8d3cfpC{VieIRj9<-S`BLI#4!JLk+!Wt(3Xji{U|)NlcB2JNc*)3La&fn6bNiS zS(cqsD&ez!z6jHw`7n0e#yEQzye%DW!zB#-whup*NN}R~AuseU{tF8Oolcj+aU7)A zb^^XJ42uupW&SF3*Q7!z+K!C8a&&3CeOSYYtbpBV}~vsBnU!_?2tr-P=|^T zED%wc9ezHgW@NMb!^uT_|SvCpFLJylbx zY%bpaTGI8IYXMN$9w<3j9VkA~NYOKEQXsj?6a9_hcwfU$acAhJhB)zb_w@MVUEy@S zX&I>K-R!bhu3?(6bHWIg$HEl7{9g>>&l_qdd+UYb(1~BCo9LptNq&8>!yoJ3Ui(i5 zRJ|XnYBklL!{@$-7=3mJ>P@1c=7Oc79e-V7yf+%lD2!I;Y&nXBZ>=B!5?CB>LvEx6 znI%n)qqi$#X#wKB(U7XP2P=+4{b@j#r%9-K(8UqtSDk>0UKzf*HM9yqMZ1D!$2MdZ zR=`U>0zhOH1XqN?nY@AQqB7)Fp4{v&dKXvb43hZKvnN8;Po;+jY*}~*Z|W9Q0W%{D z^T}Cc<|r(Su=1K=P5>Z4 zg`et&Va}tdzBS-G-ZcO)zCWpJvGQwrHZ`@wpM420ac@bI5~KkTFfGEM3sPWO8co4^fI6lPnA)Y{ef%@{+SnoUk0+dW+*{8WvF8}}l07*qoM6N<$g7cXs A&j0`b literal 0 HcmV?d00001 diff --git a/js/getUncompletedTasks.php b/js/getUncompletedTasks.php index fb2c016..16c8cf4 100644 --- a/js/getUncompletedTasks.php +++ b/js/getUncompletedTasks.php @@ -11,7 +11,7 @@ function cbfunc2(o){ $('#uncompletedList').append('
  • '+o.content+' - '+o.date_string+'
  • '); } -$(document).ready(function(){ $('#todoList').resizable(); $('#todoList').draggable(); $('#todoList').append('
    '); +$(document).ready(function(){ $('#todo').resizable(); $('#todo').draggable(); $('#todo').append('
    '); var token = ""; var project_id = ""; var script = document.createElement('script'); @@ -52,5 +52,5 @@ $(document).ready(function(){ $('#todoList').resizable(); $('#todoList').dragg document.getElementsByTagName('head')[0].appendChild(script); $('#'+arrayId[1]).remove(); }); - + /* A helper function for converting a set of elements to draggables: */ make_draggable($('#todo')); var zIndex = 0; function make_draggable(elements) { /* Elements is a jquery object: */ elements.draggable({ containment:'parent', start:function(e,ui){ ui.helper.css('z-index',++zIndex); }, 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',{ x : ui.position.left, y : ui.position.top, id : ui.helper.attr('id') }); } }); } }); \ No newline at end of file diff --git a/js/jquery.blogs.js b/js/jquery.blogs.js index 3d22e8d..9852517 100644 --- a/js/jquery.blogs.js +++ b/js/jquery.blogs.js @@ -22,14 +22,20 @@ function make_draggable(elements) } //affichage des blogs -$('body').append('
    '); $("#blogs").html(" 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(' Délai dépassé !'); + }, + success:function(data){ + $("#blogs").html(data); + } + }); }); diff --git a/js/jquery.jclockAdvanced.js b/js/jquery.jclockAdvanced.js index 09586b6..49cbea1 100644 --- a/js/jquery.jclockAdvanced.js +++ b/js/jquery.jclockAdvanced.js @@ -209,4 +209,29 @@ }; })(jQuery); - +$(document).ready(function(){ +$('body').append('
    '); + $('#menu-bar').prepend($('#jclockAdvanced-menu')); + $('#jca').append('

    Options





    Enregistrer'); + $('#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('Fields can\'t be empty.'); + } + }); +}); \ No newline at end of file diff --git a/js/jquery.weather.js b/js/jquery.weather.js index aeb9103..8206a29 100644 --- a/js/jquery.weather.js +++ b/js/jquery.weather.js @@ -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('An error occured while changing city.'); - } }); }else{ $('#city').append('City can\'t be empty.'); @@ -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') }); } - });} + }); +} });