diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..ba1221f --- /dev/null +++ b/.htaccess @@ -0,0 +1 @@ +php 1 \ No newline at end of file diff --git a/CURL.php b/CURL.php new file mode 100644 index 0000000..59b7cc7 --- /dev/null +++ b/CURL.php @@ -0,0 +1,251 @@ +sessions[] = curl_init( $url ); + if( $opts != false ) + { + $key = count( $this->sessions ) - 1; + $this->setOpts( $opts, $key ); + } + } + + /** + * Sets an option to a cURL session + * @param $option constant, cURL option + * @param $value mixed, value of option + * @param $key int, session key to set option for + */ + public function setOpt( $option, $value, $key = 0 ) + { + curl_setopt( $this->sessions[$key], $option, $value ); + } + + /** + * Sets an array of options to a cURL session + * @param $options array, array of cURL options and values + * @param $key int, session key to set option for + */ + public function setOpts( $options, $key = 0 ) + { + curl_setopt_array( $this->sessions[$key], $options ); + } + + /** + * Executes as cURL session + * @param $key int, optional argument if you only want to execute one session + */ + public function exec( $key = false ) + { + $no = count( $this->sessions ); + + if( $no == 1 ) + $res = $this->execSingle(); + elseif( $no > 1 ) { + if( $key === false ) + $res = $this->execMulti(); + else + $res = $this->execSingle( $key ); + } + + if( $res ) + return $res; + } + + /** + * Executes a single cURL session + * @param $key int, id of session to execute + * @return array of content if CURLOPT_RETURNTRANSFER is set + */ + public function execSingle( $key = 0 ) + { + if( $this->retry > 0 ) + { + $retry = $this->retry; + $code = 0; + while( $retry >= 0 && ( $code[0] == 0 || $code[0] >= 400 ) ) + { + $res = curl_exec( $this->sessions[$key] ); + $code = $this->info( $key, CURLINFO_HTTP_CODE ); + + $retry--; + } + } + else + $res = curl_exec( $this->sessions[$key] ); + + return $res; + } + + /** + * Executes a stack of sessions + * @return array of content if CURLOPT_RETURNTRANSFER is set + */ + public function execMulti() + { + $mh = curl_multi_init(); + + #Add all sessions to multi handle + foreach ( $this->sessions as $i => $url ) + curl_multi_add_handle( $mh, $this->sessions[$i] ); + + do + $mrc = curl_multi_exec( $mh, $active ); + while ( $mrc == CURLM_CALL_MULTI_PERFORM ); + + while ( $active && $mrc == CURLM_OK ) + { + if ( curl_multi_select( $mh ) != -1 ) + { + do + $mrc = curl_multi_exec( $mh, $active ); + while ( $mrc == CURLM_CALL_MULTI_PERFORM ); + } + } + + if ( $mrc != CURLM_OK ) + echo "Curl multi read error $mrc\n"; + + #Get content foreach session, retry if applied + foreach ( $this->sessions as $i => $url ) + { + $code = $this->info( $i, CURLINFO_HTTP_CODE ); + if( $code[0] > 0 && $code[0] < 400 ) + $res[] = curl_multi_getcontent( $this->sessions[$i] ); + else + { + if( $this->retry > 0 ) + { + $retry = $this->retry; + $this->retry -= 1; + $eRes = $this->execSingle( $i ); + + if( $eRes ) + $res[] = $eRes; + else + $res[] = false; + + $this->retry = $retry; + echo '1'; + } + else + $res[] = false; + } + + curl_multi_remove_handle( $mh, $this->sessions[$i] ); + } + + curl_multi_close( $mh ); + + return $res; + } + + /** + * Closes cURL sessions + * @param $key int, optional session to close + */ + public function close( $key = false ) + { + if( $key === false ) + { + foreach( $this->sessions as $session ) + curl_close( $session ); + } + else + curl_close( $this->sessions[$key] ); + } + + /** + * Remove all cURL sessions + */ + public function clear() + { + foreach( $this->sessions as $session ) + curl_close( $session ); + unset( $this->sessions ); + } + + /** + * Returns an array of session information + * @param $key int, optional session key to return info on + * @param $opt constant, optional option to return + */ + public function info( $key = false, $opt = false ) + { + if( $key === false ) + { + foreach( $this->sessions as $key => $session ) + { + if( $opt ) + $info[] = curl_getinfo( $this->sessions[$key], $opt ); + else + $info[] = curl_getinfo( $this->sessions[$key] ); + } + } + else + { + if( $opt ) + $info[] = curl_getinfo( $this->sessions[$key], $opt ); + else + $info[] = curl_getinfo( $this->sessions[$key] ); + } + + return $info; + } + + /** + * Returns an array of errors + * @param $key int, optional session key to retun error on + * @return array of error messages + */ + public function error( $key = false ) + { + if( $key === false ) + { + foreach( $this->sessions as $session ) + $errors[] = curl_error( $session ); + } + else + $errors[] = curl_error( $this->sessions[$key] ); + + return $errors; + } + + /** + * Returns an array of session error numbers + * @param $key int, optional session key to retun error on + * @return array of error codes + */ + public function errorNo( $key = false ) + { + if( $key === false ) + { + foreach( $this->sessions as $session ) + $errors[] = curl_errno( $session ); + } + else + $errors[] = curl_errno( $this->sessions[$key] ); + + return $errors; + } + +} + +?> diff --git a/addSite.php b/addSite.php new file mode 100644 index 0000000..6eb26fe --- /dev/null +++ b/addSite.php @@ -0,0 +1,41 @@ + + + + + + + + + + + Ma Page d'accueil + + + + + +'; +require('blogs_last_post.php'); +$opts = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_TIMEOUT => 10); +$blogs = new Blogs_last_post(); +$blogs->addSession($url, $opts); +$result = $blogs->exec(); +echo $blogs->getAllImagesToChoose($result); +$blogs->clear(); diff --git a/add_note.html b/add_note.html new file mode 100644 index 0000000..4f0716c --- /dev/null +++ b/add_note.html @@ -0,0 +1,26 @@ +

Add a new note

+ + +
+
+
+
+ +
+ +
+
+ + + + + +
+
+
+ + +Enregistrer + +
+
diff --git a/ajax/addSiteXML.php b/ajax/addSiteXML.php new file mode 100644 index 0000000..7bd61f9 --- /dev/null +++ b/ajax/addSiteXML.php @@ -0,0 +1,25 @@ +note; + +$field_count = count($test); + +for($i=0;$i<$field_count;$i++){ + if($nb <= $test[$i]['id']) $nb = $test[$i]['id']+1; +} + +$newnote = $xmla->addChild('link'); +$newnote->addChild('name', $name); +$newnote->addChild('number', $number); +$newnote->addChild('url', $url); +$xmla->asXML('../db/blog_links.xml'); + +echo $nb; +?> diff --git a/ajax/delete-notes.php b/ajax/delete-notes.php new file mode 100644 index 0000000..ddf236e --- /dev/null +++ b/ajax/delete-notes.php @@ -0,0 +1,25 @@ +note as $s) { + if ($s['id']==$id) { $target = $i; break; } + $i++; +} +if ($target !== false) { + unset($xmla->note[$target]); +} + +$xmla->asXML('../db/notes.xml'); + +$target++; +echo $target; +?> diff --git a/ajax/post-config.php b/ajax/post-config.php new file mode 100644 index 0000000..0c6096d --- /dev/null +++ b/ajax/post-config.php @@ -0,0 +1,21 @@ +item; +$config_xml[0]->visibility = $clock; +$config_xml[1]->visibility = $meteo; +$config_xml[2]->visibility = $notes; +$config_xml[3]->visibility = $search; +$config_xml[4]->visibility = $links; +$config_xml[5]->visibility = $blogs; +$xmla->asXML('../db/config.xml'); + +echo "1"; +?> diff --git a/ajax/post-notes.php b/ajax/post-notes.php new file mode 100644 index 0000000..46b2661 --- /dev/null +++ b/ajax/post-notes.php @@ -0,0 +1,29 @@ +note); +/*foreach($xmla->note as $test){ + if($nb < $test['id']){$nb=$test['id'];} +}*/ + +$test = $xmla->note; +for($i=0;$i<$field_count;$i++){ + if($nb <= $test[$i]['id']) $nb = $test[$i]['id']+1; +} + +$newnote = $xmla->addChild('note'); +$newnote->addAttribute("id", $nb); +$newnote->addChild('text', $body); +$newnote->addChild('color', $color); +$newnote->addChild('zindex', $zindex); +$newnote->addChild('top', '0'); +$newnote->addChild('left', '0'); +$xmla->asXML('../db/notes.xml'); + +echo $nb; +?> diff --git a/ajax/saveTodoist.php b/ajax/saveTodoist.php new file mode 100644 index 0000000..e881b4c --- /dev/null +++ b/ajax/saveTodoist.php @@ -0,0 +1,21 @@ +addChild("token", $token); + +$xmla->asXML('../db/todoist.xml'); + +echo $token; +}else if(isset($_GET['name']) && isset($_GET['id'])){ + $name = trim($_GET['name']); + $id = trim($_GET['id']); + + $xmla->addChild("name", $name); + $xmla->addChild("id", $id); + + $xmla->asXML('../db/todoist.xml'); + +echo $id; +} \ No newline at end of file diff --git a/ajax/update_position.php b/ajax/update_position.php new file mode 100644 index 0000000..60e80d2 --- /dev/null +++ b/ajax/update_position.php @@ -0,0 +1,22 @@ +note as $s) { + if ($s['id']==$id) { $target = $i; break; } + $i++; +} + +$xmla->note[$target]->top = $y; +$xmla->note[$target]->left = $x; +$xmla->note[$target]->zindex = $z; + + +$xmla->asXML('../db/notes.xml'); + +echo $target; ?> diff --git a/ajax/update_position_config.php b/ajax/update_position_config.php new file mode 100644 index 0000000..4c1ef6d --- /dev/null +++ b/ajax/update_position_config.php @@ -0,0 +1,27 @@ +item[1]->y = $y; + $xmla->item[1]->x = $x; + $target = 1; + echo $id; +}*/ +$target = -1; +$i = 0; + +foreach ($xmla->item as $s) { + if ($s['id']==$id) { $target = $i; break; } + $i++; +} + +$xmla->item[$target]->y = $y; +$xmla->item[$target]->x = $x; + + +$xmla->asXML('../db/config.xml'); + +echo $target; ?> diff --git a/blogs.php b/blogs.php new file mode 100644 index 0000000..694c236 --- /dev/null +++ b/blogs.php @@ -0,0 +1,11 @@ + true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_TIMEOUT => 10); +$blogs = new Blogs_last_post(); +foreach($blogs->getLinks() as $link) +{ + $blogs->addSession($link['url'], $opts); +} +echo $blogs->getEverything(); +$blogs->clear(); + diff --git a/blogs_last_post.php b/blogs_last_post.php new file mode 100644 index 0000000..952afc4 --- /dev/null +++ b/blogs_last_post.php @@ -0,0 +1,177 @@ + 0, // penelope + 1 => 12, //explosm + 2 => 0, // margaux +); + +private $nomImages = array( + 0 => 'PenelopeBagieu', + 1 => 'CyanideAndHapiness', + 2 => 'MargauxMotin', +); + +public $link = array( + 0 => 'http://www.penelope-jolicoeur.com/', + 1 => 'http://www.explosm.net/comics/', + 2 => 'http://margauxmotin.typepad.fr/', +);*/ +private $link = array(); + + +function getResult() +{ + return $this->_result; +} + +public function getLinks(){ + if($linksXML = simplexml_load_file('db/blog_links.xml')){ + foreach($linksXML->link as $individualLink){ + $this->link[] = array('name'=>$individualLink->name, 'url'=>$individualLink->url, 'number'=>$individualLink->number); + } + return $this->link; + } + else + return; +} + +function getTitles() +{ + $xhtml = ""; + try{ + foreach($this->exec() as $result) + { + $xhtml .= $this->getTitle($result); + $xhtml .= '
'; + } + }catch(Exception $e) + { + $xhtml .= $this->error(); + } + return $xhtml; + +} + +function getTitle($result = null, $url = null) +{ + if(isset($result)) + { + preg_match( "/

(.*)<\/h3>/i", $result, $match ); + + if(isset($match[1])) + return utf8_decode(strip_tags($match[1])); + else{ + preg_match( "/(.*)<\/title>/i", $result, $title ); + if(isset($title[1])) + return $title[1]; + else + return 'Erreur : pas de titre de blog trouvé.'; + } + + } + //TODO en fonction de l'url et non du resultat du cURL +} + +function getPost() +{ + +} + +function createThumbnail($result, $title = 0) +{ + if(isset($result)) + { + + preg_match_all( "#<img[^>]+src=['|\"](.*?)['|\"][^>]*>#i", $result, $match ); + + /*$ret = file_put_contents('match.txt', var_export($match,true), FILE_APPEND); + if ($ret === false) + { + echo 'erreur'; + }*/ + $number = $this->link[$title]['number']; + $title = $this->link[$title]['name']; + if(isset($match[1][(int)$number])) + { + $source = @imagecreatefromjpeg($match[1][(int)$number]); + if($source == false) + $source = @imagecreatefrompng($match[1][(int)$number]); + + $wSource = @imagesx($source); + $hSource = @imagesy($source); + + $destination = imagecreatetruecolor(50, 50); + @imagecopyresampled($destination, $source, 0, 0, 0, 0, 50, 50, $wSource, $hSource); + @imagepng($destination, 'images/blogs/'.$title.'.png'); + return 'images/blogs/'.$title.'.png'; + } + + } +} + +function getImages($notFromGetImage = false) +{ + if($notFromGetImage){ + //TODO stuff + }else{ + $xhtml = ""; + $i = 0; + try{ + foreach($this->exec() as $result) + { + $xhtml .= '<img src="'.$this->createThumbnail($result, $i).'" />'; + $xhtml .= '<br/>'; + $i++; + } + }catch(Exception $e) + { + $xhtml .= $this->error(); + } + return $xhtml; + } +} + +function getAllImagesToChoose($result,$notFromGetImage = false) +{ + if($notFromGetImage){ + //TODO stuff + }else{ + preg_match_all( "#<img[^>]+src=['|\"](.*?)['|\"][^>]*>#i", $result, $match ); + $nbImages = count($match[1]); + $xhtml = 'Liste d\'images : <br/>'; + + for($i = 0; $i<$nbImages; $i++){ + $xhtml .= '<img src="'.$match[1][$i].'" id="n-'.$i.'" class="choose"/><br/>'; + } + return $xhtml; + } +} + +function getEverything() +{ + $temps_debut = microtime(true); + $xhtml = ""; + $i = 0; + try{ + foreach($this->exec() as $result) + { + $xhtml .= '<a href="'.$this->link[$i]['url'].'" target="_blank" class="blogLinks"><img src="'.$this->createThumbnail($result, $i).'" />  '.utf8_encode($this->getTitle($result))."</a>"; + $xhtml .= '<br/>'; + $i++; + } + }catch(Exception $e) + { + $xhtml .= $this->error(); + } + $temps_fin = microtime(true); + $xhtml .= 'Temps d\'execution : '.round($temps_fin - $temps_debut, 4).'s'; + return $xhtml; +} + + +} \ No newline at end of file diff --git a/calculator.html b/calculator.html new file mode 100644 index 0000000..91807a9 --- /dev/null +++ b/calculator.html @@ -0,0 +1,62 @@ +<html> + <head> + <title>Calculator + + + + +
+
+
+
+ + + + + + +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + diff --git a/config.php b/config.php new file mode 100644 index 0000000..aa54c3a --- /dev/null +++ b/config.php @@ -0,0 +1,12 @@ +
+
+

Modules configuration


+ Clock module : visibility == "true"){echo " checked";}?> />true  visibility == "false"){echo " checked";}?> />false

+ Meteo module : visibility == "true"){echo " checked";}?> />true  visibility == "false"){echo " checked";}?> />false

+ Notes module : visibility == "true"){echo " checked";}?> />true  visibility == "false"){echo " checked";}?> />false

+ Search module : visibility == "true"){echo " checked";}?> />true  visibility == "false"){echo " checked";}?> />false

+ Links module : visibility == "true"){echo " checked";}?> />true  visibility == "false"){echo " checked";}?> />false

+ Blogs module : visibility == "true"){echo " checked";}?> />true  visibility == "false"){echo " checked";}?> />false

+ Enregistrer +
+
\ No newline at end of file diff --git a/css/calculator.css b/css/calculator.css new file mode 100644 index 0000000..fb388a8 --- /dev/null +++ b/css/calculator.css @@ -0,0 +1,198 @@ +html, body { + margin: 0px; + padding: 0px; +} + +body { + width: 100%; + height: 100%; + overflow: hidden; +} + +#calculator { + height: 100%; + width: 100%; + display: table; + border-collapse: collapse; + background-color: #f8f8f8; +} + +#display { + font-family: Courier; + display: table-row; + background-color: white; +} + +#display_cell { + display: table-cell; + vertical-align: bottom; + background-image: -webkit-gradient(linear, left top, 15 top, from(#f3f3f3), color-stop(0.9, #f3f3f3), color-stop(0.9, white), to(white)); +} + +#display_scroll { + overflow: auto; +} + +#display_grid { + font-size: 14px; + width: 100%; +} + +#display_gutter { + width: 15px; +} + +#display_grid .line_number { + font-size: 10px; + vertical-align: top; + font-family: arial; + font-weight:bold; + padding: 10px 0px; +} + +#display_grid .expression_editor { + outline-style: none; + font-weight:bold; + font-size: 20px; + word-break: break-all; +} + +#display_grid .expression_cell { + padding: 10px 0px; +} + +#display_grid .result_cell { + padding: 10px 0px; + text-align: right; + vertical-align: bottom; +} + +.result_display { + border-radius: 6px; + -moz-border-radius: 6px; + -webkit-border-radius: 6px; + padding: 0px 7px; + color: #4993d2; + background-color: #e6eef9; + font-family: arial; + font-weight:bold; + font-size: 16px; +} + +#divide { + display: table-row; + height: 0.5em; +} + +#divide > div { + border-top: 1px solid #d0d0d0; + border-bottom: 1px solid #d0d0d0; +} + +#divide button { + border: 1px solid #f8f8f8; + display: block; + margin-right: auto; + margin-left: auto; + text-align: center; + font-size: xx-small; + background-color: #f8f8f8; + color: #909090; + cursor: hand; +} + +#divide button:hover { + border: 1px solid #acacac; + border-radius: 6px; + -moz-border-radius: 6px; + -webkit-border-radius: 6px; + background: -webkit-gradient(linear, left top, left bottom, from(#fafafa), to(#d0d0d0)); +} + +#divide button:active { + background: -webkit-gradient(linear, left top, left bottom, from(#d0d0d0), to(#fafafa)); +} + +#button_pad { + display: table-row; + height: 130px; +} + +#button_pad table { + border-collapse: collapse; + border-spacing: 0px; + margin: 5px auto; + border-style: none; +} + +#button_pad table td { + padding: 0px; +} + +.pad_button { + border-top: 1px solid #acacac; + border-left: 1px solid #acacac; + border-right: none; + border-bottom: none; + width: 45px; + height: 30px; + background: -webkit-gradient(linear, left top, left bottom, from(#fafafa), to(#d0d0d0)); + font-weight: bold; + text-align: center; + cursor: hand; + font-size: small; +} + +.round_pad_button { + border-radius: 20px; + -moz-border-radius: 20px; + -webkit-border-radius: 20px; + border: 1px solid #acacac; + width: 30px; + height: 28px; + margin: 1px 3px; +} + +#kp_7 { + border-top-left-radius: 10px; + -moz-border-top-left-radius: 10px; + -webkit-border-top-left-radius: 10px; +} + +#kp_9 { + border-top-right-radius: 10px; + -moz-border-top-right-radius: 10px; + -webkit-border-top-right-radius: 10px; +} + +#kp_3 { + border-bottom-right-radius: 10px; + -moz-border-bottom-right-radius: 10px; + -webkit-border-bottom-right-radius: 10px; +} + +#kp_0 { + border-bottom-right-radius: 10px; + border-bottom-left-radius: 10px; + -moz-border-bottom-right-radius: 10px; + -moz-border-bottom-left-radius: 10px; + -webkit-border-bottom-right-radius: 10px; + -webkit-border-bottom-left-radius: 10px; +} + +#kp_9, #kp_6, #kp_3, #kp_0 { + border-right: 1px solid #acacac; +} + +#kp_0, #kp_2, #kp_3 { + border-bottom: 1px solid #acacac; +} + +#kp_eq { + border-bottom: 1px solid #acacac; + width: 40px; +} + +.pad_button:active { + background: -webkit-gradient(linear, left top, left bottom, from(#d0d0d0), to(#fafafa)); +} \ No newline at end of file diff --git a/css/clock.css b/css/clock.css new file mode 100644 index 0000000..02e79a9 --- /dev/null +++ b/css/clock.css @@ -0,0 +1,152 @@ +#fancyClock{ + + margin:40px auto; + + height:100px; + + /*border:1px solid #111111;*/ + + width:300px; +float:left; + +} +#fancyClock:after{content: div;clear:both;} + +.clock{ + + /* The .clock div. Created dynamically by jQuery */ + background:url(../images/clock.png) top left no-repeat; + background-color:#FFF; + + height:100px; + + width:100px; + + position:relative; + + overflow:hidden; + + float:left; + +} + + + +.clock .rotate{ + + /* There are two .rotate divs - one for each half of the background */ + + position:absolute; + + width:100px; + + height:100px; + + top:0; + + left:0; + +} + + + +.rotate.right{ + + display:none; + + z-index:11; + +} + + + +.clock .bg, .clock .front{ + + width:50px; + + height:100px; + + background-color:#FFF; + + position:absolute; + + top:0; + +} + + + +.clock .display{ + + /* Holds the number of seconds, minutes or hours respectfully */ + + position:absolute; + + width:100px; + + font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif; + + z-index:20; + + color:#F5F5F5; + + font-size:30px; + + text-align:center; + + top:33px; + + left:0; + + + + /* CSS3 text shadow: */ + + text-shadow:4px 4px 5px #333333; + +} + + + +/* The left part of the background: */ + + + +.clock .bg.left{ left:0; } + + + +/* Individual styles for each color: */ + +.orange .bg.left{ background:url(../images/bg_orange.png) no-repeat left top; } + +.green .bg.left{ background:url(../images/bg_green.png) no-repeat left top; } + +.blue .bg.left{ background:url(../images/bg_blue.png) no-repeat left top; } + + + +/* The right part of the background: */ + +.clock .bg.right{ left:100px; } + + + +.orange .bg.right{ background:url(../images/bg_orange.png) no-repeat right top; } + +.green .bg.right{ background:url(../images/bg_green.png) no-repeat right top; } + +.blue .bg.right{ background:url(../images/bg_blue.png) no-repeat right top; } + + + + + +.clock .front.left{ + + left:0; + + z-index:10; + +} + diff --git a/css/jquery.fancybox-1.3.0.css b/css/jquery.fancybox-1.3.0.css new file mode 100644 index 0000000..9cd507e --- /dev/null +++ b/css/jquery.fancybox-1.3.0.css @@ -0,0 +1,333 @@ +/* + * FancyBox - jQuery Plugin + * Simple and fancy lightbox alternative + * + * Copyright (c) 20010 Janis Skarnelis + * Examples and documentation at: http://fancybox.net + * + * Version: 1.3.0 (02/02/2010) + * Requires: jQuery v1.3+ + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + */ + +#fancybox-loading { + position: fixed; + top: 50%; + left: 50%; + height: 40px; + width: 40px; + margin-top: -20px; + margin-left: -20px; + cursor: pointer; + overflow: hidden; + background: transparent; + z-index: 1104; + display: none; +} + +* html #fancybox-loading { /* IE6 */ + position: absolute; + margin-top: 0; +} + +#fancybox-loading div { + position: absolute; + top: 0; + left: 0; + width: 40px; + height: 480px; + background: transparent url('../images/fancy_loading.png') no-repeat; +} + +#fancybox-overlay { + position: fixed; + top: 0; + left: 0; + bottom: 0; + right: 0; + background: #000; + z-index: 1100; + display: none; +} + +* html #fancybox-overlay { /* IE6 */ + position: absolute; + width: 100%; +} + +#fancybox-tmp { + padding: 0; + margin: 0; + border: 0; + overflow: auto; + display: none; +} + +#fancybox-wrap { + position: absolute; + top: 0; + left: 0; + margin: 0; + padding: 20px; + z-index: 1101; + display: none; +} + +#fancybox-outer { + position: relative; + width: 100%; + height: 100%; + background: #FFF; +} + +#fancybox-inner { + position: absolute; + top: 0; + left: 0; + width: 1px; + height: 1px; + padding: 0; + margin: 0; + outline: none; + overflow: hidden; +} + +#fancybox-hide-sel-frame { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: transparent; +} + +#fancybox-close { + position: absolute; + top: -15px; + right: -15px; + width: 32px; + height: 32px; + background: url('../images/fancy_close.png') top left no-repeat; + cursor: pointer; + z-index: 1103; + display: none; +} + +#fancybox_error { + color: #444; + font: normal 12px/20px Arial; +} + +#fancybox-content { + height: auto; + width: auto; + padding: 0; + margin: 0; +} + +#fancybox-img { + width: 100%; + height: 100%; + padding: 0; + margin: 0; + border: none; + outline: none; + line-height: 0; + vertical-align: top; + -ms-interpolation-mode: bicubic; +} + +#fancybox-frame { + position: relative; + width: 100%; + height: 100%; + border: none; + display: block; +} + +#fancybox-title { + position: absolute; + bottom: 0; + left: 0; + font-family: Arial; + font-size: 12px; + z-index: 1102; +} + +.fancybox-title-inside { + padding: 10px 0; + text-align: center; + color: #333; +} + +.fancybox-title-outside { + padding-top: 5px; + color: #FFF; + text-align: center; + font-weight: bold; +} + +.fancybox-title-over { + color: #FFF; + text-align: left; +} + +#fancybox-title-over { + padding: 10px; + background: url('../images/fancy_title_over.png'); + display: block; +} + +#fancybox-title-wrap { + display: inline-block; +} + +#fancybox-title-wrap span { + height: 32px; + float: left; +} + +#fancybox-title-left { + padding-left: 15px; + background: transparent url('../images/fancy_title_left.png') repeat-x; +} + +#fancybox-title-main { + font-weight: bold; + line-height: 29px; + background: transparent url('../images/fancy_title_main.png') repeat-x; + color: #FFF; +} + +#fancybox-title-right { + padding-left: 15px; + background: transparent url('../images/fancy_title_right.png') repeat-x; +} + +#fancybox-left, #fancybox-right { + position: absolute; + bottom: 0px; + height: 100%; + width: 35%; + cursor: pointer; + outline: none; + background-image: url('../images/blank.gif'); + z-index: 1102; + display: none; +} + +#fancybox-left { + left: 0px; +} + +#fancybox-right { + right: 0px; +} + +#fancybox-left-ico, #fancybox-right-ico { + position: absolute; + top: 50%; + left: -9999px; + width: 30px; + height: 30px; + margin-top: -15px; + cursor: pointer; + z-index: 1102; + display: block; +} + +#fancybox-left-ico { + background: transparent url('../images/fancy_nav_left.png') no-repeat; +} + +#fancybox-right-ico { + background: transparent url('../images/fancy_nav_right.png') no-repeat; +} + +#fancybox-left:hover, #fancybox-right:hover { + visibility: visible; /* IE6 */ +} + +#fancybox-left:hover span { + left: 20px; +} + +#fancybox-right:hover span { + left: auto; + right: 20px; +} + +div.fancy-bg { + position: absolute; + padding: 0; + margin: 0; + border: 0; + z-index: 1001; +} + +div#fancy-bg-n { + top: -20px; + left: 0; + width: 100%; + height: 20px; + background: transparent url('../images/fancy_shadow_n.png') repeat-x; +} + +div#fancy-bg-ne { + top: -20px; + right: -20px; + width: 20px; + height: 20px; + background: transparent url('../images/fancy_shadow_ne.png') no-repeat; +} + +div#fancy-bg-e { + top: 0; + right: -20px; + height: 100%; + width: 20px; + background: transparent url('../images/fancy_shadow_e.png') repeat-y; +} + +div#fancy-bg-se { + bottom: -20px; + right: -20px; + width: 20px; + height: 20px; + background: transparent url('../images/fancy_shadow_se.png') no-repeat; +} + +div#fancy-bg-s { + bottom: -20px; + left: 0; + width: 100%; + height: 20px; + background: transparent url('../fancy_shadow_s.png') repeat-x; +} + +div#fancy-bg-sw { + bottom: -20px; + left: -20px; + width: 20px; + height: 20px; + background: transparent url('../images/fancy_shadow_sw.png') no-repeat; +} + +div#fancy-bg-w { + top: 0; + left: -20px; + height: 100%; + width: 20px; + background: transparent url('../images/fancy_shadow_w.png') repeat-y; +} + +div#fancy-bg-nw { + top: -20px; + left: -20px; + width: 20px; + height: 20px; + background: transparent url('../images/fancy_shadow_nw.png') no-repeat; +} diff --git a/css/main.css b/css/main.css new file mode 100644 index 0000000..869aaf0 --- /dev/null +++ b/css/main.css @@ -0,0 +1,316 @@ +/* Google Menu StyleSheet*/ + + * { + margin: 0; + padding: 0; + } + + body { + background: #FFFFFF; + font-family: "Droid Sans", Arial, Helvetica, sans-serif; + font-size: 12px; + color: #6B6B6B; + background:-webkit-gradient(linear, left top, left bottom, from(#fff), to(#ebeff9)); + } + + li a { + text-decoration: none; + } + a:link {color:#2D406D} + a:visited {color:#2D406D} + li.disabled {opacity:0.5;} + span.accelerator { + float:right; + color:#CCC; + padding-right:8px; + display:none; + } + + li img { + width:16px; + height:16px; + border:none; + vertical-align:top; + } + + .divider { + display:block; + font-size:1px; + border-width:0px; + border-style:solid; + border-top-width:1px; + margin:9px 0px 4px -2px; + border-color:#BFBFBF; + } + + #googlemenu { + width: 100%; + padding: 0 0 0 0; + margin-left: 0px; + margin-top: 5px; + overflow:auto; + height:395px; + } + + #googlemenu ul { + margin: 0; + padding: 0; + list-style: none; + } + + #googlemenu li.item { + margin-top: 0px; + margin-bottom: 0px; + padding-left: 4px; + padding-top: 2px; + padding-bottom: 2px; + height:18px; + border-color:white; + border-width:1px; + line-height:20px; + border-left:none; + border-right:none; + background-color:rgba(235,239,249,0.0); + + -webkit-transition: background-color 0.3s ease-out ; + } + + #googlemenu li.item:hover { + background-color:#ebeff9; + border-color:#BFCDF6; + + -webkit-transition: background-color 0s ease-out ; + } + + #googlemenu li.disabled { + background-color:#fff; + } + + #googlemenu li img { + margin-top: 2px; + margin-right:4px; + } + + #googlemenu li.empty { + margin-top: 0px; + margin-bottom: 0px; + padding-left: 4px; + padding-top: 2px; + padding-bottom: 2px; + } + + #googlemenu li.empty a:hover{ + text-decoration:underline; + } + + ul.iconlist li{ + display:inline-block; + text-align:center; + font-weight:bold; + color:#2D406D; + } + + ul.iconlist li a { + display:block; + padding:6px; + margin:0px; + text-align:center; + font-weight:bold; + + /*background-color:rgba(235,239,249,0.0);*/ + background-color:#FFFFFF; + cursor:pointer; + -webkit-border-radius: 10px; + width:96px; + /*height:86px;*/ + height:66px; + -webkit-transition: background-color 0.3s ease-out ; + + } + + ul.iconlist li a:hover { + background-color:#ebeff9; + -webkit-transition: background-color 0s ease-out ; + + } + + ul.iconlist li.disabled a:hover { + background-color:white; + opacity:0.5; + + } + + ul.iconlist li.disabled a { + background-color:white; + opacity:0.5; + cursor:default; + + } + + ul.iconlist li a img{ + x-webkit-transition: -webkit-transform 0.3s ease-out ; + + } + + ul.iconlist li a:hover img{ + x-webkit-transform: scale(1.1); + x-webkit-transition: -webkit-transform 0.0s ease-out ; + + + } + + ul.iconlist { + padding:5px; + } + + ul.iconlist img{ + width:64px; + height:64px; + margin-bottom:1px; + } + + div.sidemenu{ + xbackground:rgba(255,255,255,0.8); + x-webkit-border-radius: 5px; + xborder: 1px solid rgba(0,0,0,0.3); + x-webkit-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.15); + width:150px; + margin-left: 0px; + height:90%; + display:none; + float:left; + border-right:1px solid red; + } + + div.appscontainer { + width:750px; + margin:20px auto; + padding:0px; + /*background:red;*/ + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + xmargin-left:160px; + background:rgba(255,255,255,0.8); + overflow:auto; + + 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); + } + + hr { + border:none; + height:0px; + border-bottom:1px solid #eee; + } + + .label { + float:Right; + padding-top:6px; + padding-right:6px; + color:#fff; + } + + .fakelocation { + background:white; + height:38px; + background:-webkit-gradient(linear, left top, left bottom, from(#fff), to(#ebeff9)); + border-bottom:1px solid #eee; + padding:0; + display:none; + } + + a.getmore { + display:block; + text-align:right; + padding:10px; + + } + + div.url { + font-weight:normal; + opacity:0; + position:absolute; + text-align:center; + } + + ul.iconlist li:hover div.url { + opacity:.5; + } + li.selected { + background-color:#D6DEF7 !important; + } + + li.vseparator { + width:1px; + height:86px; + background-color:red; + } + + .searchfield, #q { + padding:2px 2px 2px 5px; + font-size:19px; + background:-webkit-gradient(linear, left top, left bottom, from(#eee), to(#fff), color-stop(0.15, #fff)); + margin:0px; + border:1px solid #ccc; + height:32px; + -webkit-border-bottom-left-radius:3px; + -webkit-border-top-left-radius:3px; + -moz-border-bottom-left-radius:3px; + -moz-border-top-left-radius:3px; + + } + + .searchbutton { + padding:2px 8px; + font-size:14px; + background:-webkit-gradient(linear, left top, left bottom, from(#fff), to(#eee)); + margin:0 0 -1px 0; + -webkit-border-bottom-right-radius:3px; + -webkit-border-top-right-radius:3px; + -moz-border-bottom-right-radius:3px; + -moz-border-top-right-radius:3px; + border:1px solid #ccc; + height:32px; + } + + #recherche{margin-top:70px;} + + #config {width:300px;} + #config-menu, #blog-links-manager {width:100px; margin:0 auto; text-align:center;display:block;} + + /* Green button class: */ +a.green-button,a.green-button:visited{ + color:black; + display:block; + font-size:10px; + font-weight:bold; + height:15px; + padding:6px 5px 4px; + text-align:center; + width:60px; + text-decoration:none; + + text-shadow:1px 1px 1px #DDDDDD; + background:url(../images/button_green.png) no-repeat left top; +} + +a.green-button:hover{ + text-decoration:none; + background-position:left bottom; +} + + .jclock {position:absolute; top:10px; right:10px;z-index:500; width:200px;background:#fff url(../images/clock.png) top left no-repeat; padding:5px 0 0 5px; width:59px; height:21px;} + + + #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); + -webkit-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.15); + -moz-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.15);} + .blogLinks{ + color:#2D406D; + font-weight:bold; + } + .blogLinks img{ + vertical-align:middle; + } diff --git a/css/neige.css b/css/neige.css new file mode 100644 index 0000000..dd0f325 --- /dev/null +++ b/css/neige.css @@ -0,0 +1 @@ +#weather .weatherpic{float:left; background:url(../images/pluie.png) top left no-repeat; width:53px; height:53px; margin-right:10px;} diff --git a/css/note.css b/css/note.css new file mode 100644 index 0000000..dcd6d57 --- /dev/null +++ b/css/note.css @@ -0,0 +1,118 @@ +.note{ + height:150px; + padding:10px; + width:150px; + position:absolute; + overflow:hidden; + cursor:move; + + font-family:Trebuchet MS,Tahoma,Myriad Pro,Arial,Verdana,sans-serif; + font-size:22px; + + /* Adding a CSS3 shadow below the note, in the browsers which support it: */ + -moz-box-shadow:2px 2px 0 #DDDDDD; + -webkit-box-shadow:2px 2px 0 #DDDDDD; + box-shadow:2px 2px 0 #DDDDDD; +} + +#fancy_ajax .note{ cursor:default; } + +/* Three styles for the notes: */ + +.yellow{ + background-color:#FDFB8C; + border:1px solid #DEDC65; +} + +.blue{ + background-color:#A6E3FC; + border:1px solid #75C5E7; +} + +.green{ + background-color:#A5F88B; + border:1px solid #98E775; +} + +/* Each note has a data span, which holds its ID */ +span.data{ display:none; } + +/* The "Add a note" button: */ +#addButton{ + position:absolute; + top:10px; + left:10; +} + + +.author{ + /* The author name on the note: */ + bottom:10px; + color:#666666; + font-family:Arial,Verdana,sans-serif; + font-size:12px; + position:absolute; + right:10px; +} + +#main{ + /* Contains all the notes and limits their movement: */ + margin:0 auto; + position:relative; + width:980px; + height:500px; + z-index:10; + background:url(../images/add_a_note_help.gif) no-repeat left top; +} + +h3.popupTitle{ + border-bottom:1px solid #DDDDDD; + color:#666666; + font-size:24px; + font-weight:normal; + padding:0 0 5px; +} + +#noteData{ + /* The input form in the pop-up: */ + height:200px; + margin:30px 0 0 200px; + width:350px; +} + +.note-form label{ + display:block; + font-size:10px; + font-weight:bold; + letter-spacing:1px; + text-transform:uppercase; + padding-bottom:3px; +} + +.note-form textarea, .note-form input[type=text]{ + background-color:#FCFCFC; + border:1px solid #AAAAAA; + font-family:Arial,Verdana,sans-serif; + font-size:16px; + height:60px; + padding:5px; + width:300px; + margin-bottom:10px; +} + +.note-form input[type=text]{ height:auto; } + +.color{ + /* The color swatches in the form: */ + cursor:pointer; + float:left; + height:10px; + margin:0 5px 0 0; + width:10px; +} + +#note-submit{ margin:20px auto; } +.delete {display:none; height:16px; width:16px; background:url(../images/delete.png) top left no-repeat; position:absolute; top:5px; right:5px; z-index:9999;} +.delete:hover{cursor:pointer !important;} + + diff --git a/css/nuage.css b/css/nuage.css new file mode 100644 index 0000000..6321b61 --- /dev/null +++ b/css/nuage.css @@ -0,0 +1 @@ +#weather .weatherpic{float:left; background:url(../images/nuage.png) top left no-repeat; width:53px; height:53px; margin-right:10px;} diff --git a/css/peunuage.css b/css/peunuage.css new file mode 100644 index 0000000..260b045 --- /dev/null +++ b/css/peunuage.css @@ -0,0 +1 @@ +#weather .weatherpic{float:left; background:url(../images/peu-nuageux.png) top left no-repeat; width:53px; height:53px; margin-right:10px;} diff --git a/css/pluie.css b/css/pluie.css new file mode 100644 index 0000000..dd0f325 --- /dev/null +++ b/css/pluie.css @@ -0,0 +1 @@ +#weather .weatherpic{float:left; background:url(../images/pluie.png) top left no-repeat; width:53px; height:53px; margin-right:10px;} diff --git a/css/soleil.css b/css/soleil.css new file mode 100644 index 0000000..5979def --- /dev/null +++ b/css/soleil.css @@ -0,0 +1 @@ +#weather .weatherpic{float:left; background:url(../images/soleil.png) top left no-repeat; width:53px; height:53px; margin-right:10px;} diff --git a/css/todo.css b/css/todo.css new file mode 100644 index 0000000..dbe936e --- /dev/null +++ b/css/todo.css @@ -0,0 +1,4 @@ +#todoList {/*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); + -webkit-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.15); + -moz-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.15);} \ No newline at end of file diff --git a/css/weather.css b/css/weather.css new file mode 100644 index 0000000..241e87e --- /dev/null +++ b/css/weather.css @@ -0,0 +1,4 @@ + #weather {position:absolute; top:10px; left: 100px;padding:5px;-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);} \ No newline at end of file diff --git a/db/blog_links.xml b/db/blog_links.xml new file mode 100644 index 0000000..844fd10 --- /dev/null +++ b/db/blog_links.xml @@ -0,0 +1,18 @@ + + + + 0 + PenelopeBagieu + http://www.penelope-jolicoeur.com/ + + + 12 + CyanideAndHapiness + http://www.explosm.net/comics/ + + + 0 + MargauxMotin + http://margauxmotin.typepad.fr/ + +testn-0http://blog-de-vincent.blogspot.com/ diff --git a/db/config.xml b/db/config.xml new file mode 100644 index 0000000..7f03b04 --- /dev/null +++ b/db/config.xml @@ -0,0 +1,32 @@ + + + + false + 950 + 42 + + + true + 488 + 658 + + + true + + + false + + + true + + + true + 79 + 137 + + + true + 130 + 138 + + diff --git a/db/notes.xml b/db/notes.xml new file mode 100644 index 0000000..789527e --- /dev/null +++ b/db/notes.xml @@ -0,0 +1,6 @@ + + + + + +Test de post-it.green115353/!\ C'est bien fait ? :)yellow1851038Des améliorations ?yellow12641038Application android pour les horaires et prix des trains à faireblue2586916 diff --git a/db/todoist.xml b/db/todoist.xml new file mode 100644 index 0000000..275f2a1 --- /dev/null +++ b/db/todoist.xml @@ -0,0 +1,4 @@ + + + + diff --git a/getProjectsList.php b/getProjectsList.php new file mode 100644 index 0000000..180ec35 --- /dev/null +++ b/getProjectsList.php @@ -0,0 +1,18 @@ +token== '' || $xmla->token == null) + header('Location: index.php'); +if($xmla->name == '' || $xmla->name == null):?> + + + Todoist : getProjects + + + + + + + + token== '' || $xmla->token == null) + header('Location: index.php'); +if($xmla->id != '' || $xmla->id != null): +$token = $xmla->token; +$id = $xmla->id;?> + + + item; +?> + + + + + + + + + + + + + visibility == "true"){?> + + visibility == "true"){?> + + + visibility == "true"){ + include 'meteo.php'; + ?> + visibility == "true") + echo ''; + if($config_xml[6]->visibility == "true") + echo ''; +?> + + Ma Page d'accueil + + + + + +visibility == "true"){?>
+ +visibility == "true"){?> +
+
+
+
+ +
+ +visibility == "true"){?> +Add a note + +visibility == "true"){?> +
+
+ +
+ + + + + + + + +
+
+
+ +visibility == "true"){?> +
+ Google Apps + +
+ + Media + +
+ + Desk Accessories + +
+ + Entertainment + +
+ +
+ + Configuration +
+
+
+

Modules configuration


+ attributes()?> module : visibility == "true"){echo " checked";}?> />true  visibility == "false"){echo " checked";}?> />false

+ attributes()?> module : visibility == "true"){echo " checked";}?> />true  visibility == "false"){echo " checked";}?> />false

+ attributes()?> module : visibility == "true"){echo " checked";}?> />true  visibility == "false"){echo " checked";}?> />false

+ attributes()?> module : visibility == "true"){echo " checked";}?> />true  visibility == "false"){echo " checked";}?> />false

+ attributes()?> module : visibility == "true"){echo " checked";}?> />true  visibility == "false"){echo " checked";}?> />false

+ attributes()?> module : visibility == "true"){echo " checked";}?> />true  visibility == "false"){echo " checked";}?> />false

+ Enregistrer +
+
+
+ visibility == "true"){require('blogs_last_post.php'); + echo 'Manage blog links';?> +
+
+

Blogs Management


+

Delete Site feed

+
    + getLinks() as $link) + echo '
  • '.$link['url'].'
  • ';?> +
+

Insert Site feed

+
+ + +
+
+
+ +visibility == "true"){ +$xmla = simplexml_load_file('db/todoist.xml'); +echo '
'; +if($xmla->token== '' || $xmla->token == null || $xmla->id == '' || $xmla->id == null) +echo 'Impossible de trouver votre configuration. Merci de bien vouloir la recommencer.'; +else{ +$token = $xmla->token; +$id = $xmla->id;?> + + + + + + diff --git a/js/calculator.js b/js/calculator.js new file mode 100644 index 0000000..6787ec4 --- /dev/null +++ b/js/calculator.js @@ -0,0 +1,537 @@ + +/** + * Binds a function to a this object for use by callbacks + * @param instance {!Object} The this object to bind to. + * @return A closure that will call the original function bound to the given + * instance parameter. + */ +Function.prototype.bind = function(instance) { + var self = this; + return function() { self.apply(instance, arguments); }; +}; + + +/**** + ** Start of temporary evaling logic + * + * To support expression evaluations in the short term, the strategry is to just + * use 'eval' with sanitized input. Long term, I'm working on using Antlr and + * a custom grammar to generate an appropriate lexer/parser to deal with the + * expressions. + * + * For now, sanitation consists of making sure only whitelisted characters are + * in the input (to restrict what you can do), and that all identifiers get a + * namespace prefix added to them so that they cannot access the global this. + * So "2 + myvar" turns into "2 + symbols.myvar" for evaling. + * + * To point out a more subtle aspect of this validation, periods are in the + * whitelist because of their use in decimals, however there is a special regex + * check to make sure that all uses of periods are just for decimals and not + * attribute access. + */ + +/** + * A regex that validates that only whitelisted characters are in the input. + * @type {RegExp} + */ +var textWhitelistValidator = new RegExp("[-a-zA-Z0-9.+*/()= ,]+"); + +/** + * Validates that the input text only contains whitelisted characters. + * @param text {string} The text to validate. + * @return {boolean} whether the input text is only whitelisted characters or + * not. + */ +function isTextClean(text) { + data = textWhitelistValidator.exec(text); + return data && data[0] && data[0].length > 0 && data[0].length == text.length; +} + +/** + * A regex that finds all uses of periods in decimals. + * @type {RegExp} + */ +var validPeriodUse = /\.(?:[0-9]|$)/g; + +/** + * Validates that all uses of periods within the input text are for decimals + * and not for attribute access. + * @param text {string} The intput text to validate. + * @return {boolean} Whether all period use is valid or not. + */ +function isPeriodUseValid(text) { + // Remove all valid uses of dot, and if there are any dots left over we know + // they are 'evil' property accesses + return text.replace(validPeriodUse, '').indexOf('.') == -1; +} + +/** + * The symbol table namespace all variables and functions are forced to be a + * part of. + * @type {!Object} + */ +var symbols = { +}; + +/** + * A regex that finds all identifiers within the input. + * @type {RegExp} + */ +var symbolRegex = /([a-zA-Z][a-zA-Z0-9]*)/g; + +/** + * Adds the 'symbol' namespace to all symbols within the input and returns + * the modified input. + * @param text {string} The input to namespace. + * @return {string} The input transformed so that all symbols are referenced + * through the 'symbol' namespace. + */ +function addNamespaceToSymbols(text) { + return text.replace(symbolRegex, 'symbols.$1'); +} + +/** + * A regex that finds all leading and trailing whitespace on a string. + * @type {RegExp} + */ +var trimWhitespaceRegex = /^\s+|\s+$/g; + +/** + * Evaluates a string input expression and returns the result. + * @param text {string} The text to evaluate. + * @return {*} the result of evaluating the expression, or the string '...' + * if there was any issue evaluating the input. + */ +function evalExpression(text) { + var result = ''; + if (text) { + text = text.replace(trimWhitespaceRegex, ''); + if(text != '') { + if (!isTextClean(text) || !isPeriodUseValid(text)) { + result = 'invalid'; + } else { + try { + result = eval(addNamespaceToSymbols(text)); + if (result === undefined) { //symbol that's never been assigned + result = ''; + } else if (isNaN(result)) { + result = '...'; + } + } catch (e) { + result = '...'; + } + } + } + } + return result; +} + +/** + * Registers a javascript function for use within calculator expressions. + * @param name {string} The name calcualtor expressions will use to call this + * function. + * @param func {Function} The function that will be called when the name is + * used in a calcualtor expression. + */ +function registerFunction(name, func) { + symbols[name] = func; + func.toString = function() { return Number.NaN; }; +} + +/** + * Updates the value of a variable in the symbol table. + * @param name {string} The name of the variable to update. + * @param value {*} The value to set for the variable. + */ +function updateVar(name, value) { + symbols[name] = value; +} + +/**** + ** End of temporary evaling logic + */ + +registerFunction('abs', function(number) { + return Math.abs(number); +}); + +registerFunction('acos', function(number) { + return Math.acos(number); +}); + +registerFunction('asin', function(number) { + return Math.asin(number); +}); + +registerFunction('atan', function(number) { + return Math.atan(number); +}); + +registerFunction('atan2', function(n1, n2) { + return Math.atan2(n1, n2); +}); + +registerFunction('ceil', function(number) { + return Math.ceil(number); +}); + +registerFunction('cos', function(number) { + return Math.cos(number); +}); + +registerFunction('floor', function(number) { + return Math.floor(number); +}); + +registerFunction('log', function(number) { + return Math.log(number); +}); + +registerFunction('max', function(n1, n2) { + return Math.max(n1, n2); +}); + +registerFunction('min', function(n1, n2) { + return Math.min(n1, n2); +}); + +registerFunction('pow', function(n1, n2) { + return Math.pow(n1, n2); +}); + +registerFunction('random', function() { + return Math.random(); +}); + +registerFunction('round', function(number) { + return Math.round(number); +}); + +registerFunction('sin', function(number) { + return Math.sin(number); +}); + +registerFunction('sqrt', function(number) { + return Math.sqrt(number); +}); + +registerFunction('tan', function(number) { + return Math.tan(number); +}); + + +/** + * Creates an expression object that manages an expression cell within the + * display area. + * @constructor + */ +function Expression() { + this.editDiv_ = document.createElement('div'); + this.editDiv_.className = 'expression_editor'; + this.editDiv_.contentEditable = true; +} + +/** + * Returns the HTML element that acts as the expression editor. + * @return {!Element} The editor element. + */ +Expression.prototype.getEditor = function() { + return this.editDiv_; +}; + +/** + * Returns the current expression as a string. + * @return {string} The current expression. + */ +Expression.prototype.getText = function() { + var children = this.editDiv_.childNodes; + if (children.length == 1) { + return children[0].nodeValue; + } else { + var contents = [] + for (var x = 0; x < children.length; ++x) { + contents.push(children[x].nodeValue); + } + return contents.join(''); + } +}; + + +/** + * Creates a result object that manages a result cell within the display area. + * @constructor. + */ +function Result() { + this.resultSpan_ = document.createElement('span'); + this.resultSpan_.className = 'result_display'; + this.resultSpan_.appendChild(document.createTextNode('')); +} + +/** + * Returns the HTML element that acts as the result display. + * @return {!Element} The display element. + */ +Result.prototype.getDisplay = function() { + return this.resultSpan_; +}; + +/** + * Returns the currently displayed result text. + * @return {string} The result text. + */ +Result.prototype.getText = function() { + return this.resultSpan_.childNodes[0].nodeValue; +}; + +/** + * Sets the currently displayed result text. + * @param text {string} The new text to display. + */ +Result.prototype.setText = function(text) { + return this.resultSpan_.childNodes[0].nodeValue = text; +}; + + +/** + * Creates a line in the display, which is composed of an expression and a + * result. + * @param lineNumber {number} The line number of this line. + * @param expressionChangedCallback {function(DisplayLine)} A callback to invoke + * when the expression has been changed by the user. This display line will + * be passed as the only input. + * @constructor + */ +function DisplayLine(lineNumber, expressionChangedCallback) { + this.lineNumber_ = lineNumber; + this.expression_ = new Expression(); + this.result_ = new Result(); + this.row_ = this.setupLayout_(); + this.setupExpressionHandling_(expressionChangedCallback); +} + +/** + * Returns the line number of this display line. + * @return {number} the line number. + */ +DisplayLine.prototype.getLineNumber = function() { + return this.lineNumber_; +}; + +/** + * Returns the expression of this display line. + * @return {Expression} The expression. + */ +DisplayLine.prototype.getExpression = function() { + return this.expression_; +}; + +/** + * Returns the result of this display line. + * @return {Result} The result. + */ +DisplayLine.prototype.getResult = function() { + return this.result_; +}; + +/** + * Returns the table row this display line manages. + * @return {Element} the table row element. + */ +DisplayLine.prototype.getRow = function() { + return this.row_; +}; + +/** + * Sets up detection of the user editing the expression. + * @param changeCallback {function(DisplayLine)} The callback to call when + * the user edits the expression. + * @private + */ +DisplayLine.prototype.setupExpressionHandling_ = function(changeCallback) { + var self = this; + function callback() { + changeCallback(self); + } + this.expression_.getEditor().addEventListener('keyup', callback, true); + this.expression_.getEditor().addEventListener('paste', callback, true); +}; + +/** + * Creates the table row needed by this display line instance. + * @return {!Element} the new table row this display line will use. + */ +DisplayLine.prototype.setupLayout_ = function() { + var row = document.createElement('tr'); + row.className = 'expression_row'; + + var lineNumberCell = document.createElement('td'); + lineNumberCell.className = 'line_number'; + lineNumberCell.appendChild(document.createTextNode(this.lineNumber_)); + row.appendChild(lineNumberCell); + + var editor = this.expression_.getEditor(); + var expressionCell = document.createElement('td'); + expressionCell.className = 'expression_cell'; + expressionCell.appendChild(editor) + row.appendChild(expressionCell); + + var resultCell = document.createElement('td'); + resultCell.className = 'result_cell'; + resultCell.appendChild(this.result_.getDisplay()); + resultCell.addEventListener('click', function() { + editor.focus(); + }, true); + row.appendChild(resultCell); + + return row; +}; + +/** + * Forces the browser to put cursor focus on this display line. + */ +DisplayLine.prototype.focus = function() { + this.expression_.getEditor().focus(); +}; + + +/** + * Creates a new calcualtor that manages the calculator page. Only one of these + * should be created per page. + * @constructor. + */ +function Calculator() { + this.lines_ = []; + this.displayInScrollingMode_ = false; + this.activeLine_ = null; +} + +/** + * Initializes the calcualtor once the page is finished loading. + */ +Calculator.prototype.init = function() { + window.addEventListener('resize', this.determineDisplayLayout.bind(this), true); + this.initializeKeypad_(); + this.initializeNextLine_(); +}; + +/** + * Configures a keypad button to insert the given text into the active line. + * @param buttonId {string} The DOM ID of the keypad button to configure. + * @param text {string} The text to insert into the active line when the keypad + * button is pressed. + * @private + */ +Calculator.prototype.hookInputButton_ = function(buttonId, text) { + var self = this; + document.getElementById(buttonId).addEventListener('click', function() { + if (self.activeLine_) { + document.execCommand('inserthtml', false, text); + self.handleExpressionChanged_(self.activeLine_); + } + }, true); +} + +/** + * Initializes the keypad to have working buttons that insert text into the + * current line. + * @private + */ +Calculator.prototype.initializeKeypad_ = function() { + for (var x = 0; x < 10; ++x) { + this.hookInputButton_('kp_' + x, '' + x); + } + this.hookInputButton_('kp_dot', '.'); + this.hookInputButton_('kp_div', '/'); + this.hookInputButton_('kp_mul', '*'); + this.hookInputButton_('kp_sub', '-'); + this.hookInputButton_('kp_add', '+'); + + document.getElementById('kp_eq').addEventListener( + 'click', + this.initializeNextLine_.bind(this), + false); +}; + +/** + * Creates a new display line and initializes it as the active line. + * @private + */ +Calculator.prototype.initializeNextLine_ = function() { + var nextLineNumber = this.lines_.length + 1; + var line = new DisplayLine(nextLineNumber, + this.handleExpressionChanged_.bind(this)); + + this.lines_.push(line); + this.hookLine_(line); + document.getElementById('display_grid_body').appendChild(line.getRow()); + this.determineDisplayLayout(); + line.focus(); +}; + +/** + * Handles live-updating of relevant display lines when the user is updating + * an expression. + * @param changedLine {number} the line number of the display line that is + * being changed. + * @private + */ +Calculator.prototype.handleExpressionChanged_ = function(changedLine) { + for (var x = changedLine.getLineNumber() - 1; x < this.lines_.length; ++x) { + var line = this.lines_[x]; + var val = evalExpression(line.getExpression().getText()); + updateVar('line' + line.getLineNumber(), val); + line.getResult().setText(val); + } +}; + +/** + * Hooks various user events on a display line that need to be handled at a + * higher level. Currently this handles making new lines when hitting enter, + * and tracking browser focus for determining the currently active line. + */ +Calculator.prototype.hookLine_ = function(line) { + var expression = line.getExpression(); + var self = this; + expression.getEditor().addEventListener('keydown', function(event) { + if (event.which == 13) { + event.preventDefault(); + event.stopPropagation(); + self.initializeNextLine_(); + } + }, true); + expression.getEditor().addEventListener('focus', function(event) { + self.activeLine_ = line; + }, true); +}; + +/** + * Called when the browser is resized to determine how to flow the display area. + * + * There are two flow modes: If the display is larger than the room the lines + * need, then the lines should be aligned to the bottom of the display. If the + * display is smaller than the room the lines need, then enable a scrolling + * behavior. + */ +Calculator.prototype.determineDisplayLayout = function() { + if (this.displayInScrollingMode_) { + // Determine if we have to take the display out of scrolling mode so that + // the text will align to the bottom + var displayScroll = document.getElementById('display_scroll'); + if (displayScroll.clientHeight == displayScroll.scrollHeight) { + // Revert the explicit height so that it shrinks to be only as high as + // needed, which will let the containing cell align it to the bottom. + displayScroll.style.height = 'auto'; + this.displayInScrollingMode_ = false; + } + } else { + // Determine if we have to put the display in scrolling mode because the + // content is too large for the cell size + var displayCell = document.getElementById('display_cell'); + var displayScroll = document.getElementById('display_scroll'); + if (displayScroll.clientHeight == displayCell.clientHeight) { + // Assign an explicit height so that the overflow css property kicks in. + displayScroll.style.height = '100%'; + this.displayInScrollingMode_ = true; + } + } +}; \ No newline at end of file diff --git a/js/getProjectsList.php b/js/getProjectsList.php new file mode 100644 index 0000000..3411298 --- /dev/null +++ b/js/getProjectsList.php @@ -0,0 +1,23 @@ + +function cbfunc(o){ + var name = o[0].name; + var id = o[0].id; + + if(id == undefined){ + $('body').append('ERROR'); + }else{ + $.get('saveTodoist.php', {name: name, id: id}, function(){ + window.location.reload(); + }); + } +} + +$(document).ready(function(){ + var token = ""; + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = 'https://todoist.com/API/getProjects?token='+token+'&format=json&callback=cbfunc'; + document.getElementsByTagName('head')[0].appendChild(script); +}); \ No newline at end of file diff --git a/js/getUncompletedTasks.php b/js/getUncompletedTasks.php new file mode 100644 index 0000000..81fbf80 --- /dev/null +++ b/js/getUncompletedTasks.php @@ -0,0 +1,60 @@ + +function cbfunc(o){ + $('#results').append('