Amélioration des scripts AJAX et des styles

Ajout de la fonctionnalité "changement d'options" pour la clockAdvanced
This commit is contained in:
Chouchen 2010-09-20 14:39:08 +00:00
parent 136be98daa
commit fdc7719815
18 changed files with 306 additions and 61 deletions

16
ajax/update.php Normal file
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);

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;
@ -23,5 +15,4 @@ $xmla->item[$target]->x = $x;
$xmla->asXML('../db/config.xml');
echo $target; ?>
echo $target; */ ?>

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)
{

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 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);
}
}
}
}
}

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);
}
}
}
}

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);
}
}
}
}

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);
}
}
}
}

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);
}
}
}
}

View File

@ -34,21 +34,6 @@ class weather extends Module {
$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;
}
}
}
}
/**
*
* Modifie la ville
@ -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);
}
}
}
}

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);

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;}

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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 967 B

BIN
images/interface/error.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

View File

@ -11,7 +11,7 @@ function cbfunc2(o){
$('#uncompletedList').append('<li id="'+o.id+'">'+o.content+' - '+o.date_string+' <img src="images/interface/delete.png" id="delete-'+o.id+'"/> <img src="images/interface/complete.png" class="completeTask" id="complete-'+o.id+'"/> </li>');
}
$(document).ready(function(){ $('#todoList').resizable(); $('#todoList').draggable(); $('#todoList').append('<div id="results"></div><img src="images/interface/add.png" id="showNewTask"/><fieldset id="newTaskFieldset" style="display:none; width:200px;"><input type="text" name="newtask" id="newtask"/> <select id="priority"><option id="1" value="1">1</option><option id="2" value="2">2</option><option id="3" value="3">3</option><option id="4" value="4">4</option></select> <br/><input type="text" name="date_string" id="date_string"/> <img src="images/interface/add.png" id="addTask"/></fieldset>');
$(document).ready(function(){ $('#todo').resizable(); $('#todo').draggable(); $('#todo').append('<div id="results"></div><img src="images/interface/add.png" id="showNewTask"/><fieldset id="newTaskFieldset" style="display:none; width:200px;"><input type="text" name="newtask" id="newtask"/> <select id="priority"><option id="1" value="1">1</option><option id="2" value="2">2</option><option id="3" value="3">3</option><option id="4" value="4">4</option></select> <br/><input type="text" name="date_string" id="date_string"/> <img src="images/interface/add.png" id="addTask"/></fieldset>');
var token = "<?=$token?>";
var project_id = "<?=$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') }); } }); }
});

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){
$.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);
}
});
});

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>');
}
});
});

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')
});
}
});}
});
}
});