├── api ├── config-global.php ├── util.php ├── config-local.php.template ├── manage.php ├── schema.sql └── api.php ├── web ├── offline.html ├── favicon.ico ├── apple-touch-icon.png ├── images │ ├── g_favicon.png │ ├── gnome_home.png │ ├── gnome_new.png │ ├── gnome_open.png │ ├── gnome_sync.png │ ├── gnome_text.png │ ├── gnome_delete.png │ ├── gnome_saving.png │ ├── gnome_system.png │ ├── gnome_syncing.png │ └── html5-badge-h-css3-semantics-storage.png ├── about │ ├── apple-touch-icon.png │ ├── .htaccess │ └── index.html ├── apple-touch-icon-precomposed.png ├── robots.txt ├── api │ └── index.php ├── 404.html ├── js │ ├── libs │ │ ├── autoresize.jquery.min.js │ │ ├── json2-min.js │ │ ├── autoresize.jquery.js │ │ └── jquery-1.4.2.min.js │ └── note5.js ├── .htaccess ├── css │ └── style.css └── index-src.php ├── doc └── cws │ ├── icon_128.png │ └── manifest.json ├── .gitignore ├── README.md └── lib └── openid.php /api/config-global.php: -------------------------------------------------------------------------------- 1 | getMessage(), "\n"; 5 | } 6 | -------------------------------------------------------------------------------- /web/about/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | RewriteCond %{HTTP_HOST} ^html5notepad.com 3 | RewriteRule (.*) http://www.html5notepad.com/$1 [R=301,L] 4 | -------------------------------------------------------------------------------- /web/images/html5-badge-h-css3-semantics-storage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonhanley/note5/HEAD/web/images/html5-badge-h-css3-semantics-storage.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.settings 2 | /.buildpath 3 | /.project 4 | /.idea 5 | /todo.txt 6 | /notes.txt 7 | /api/config-remote.php 8 | /api/config-local.php 9 | /web/index.html 10 | /web/cache.manifest 11 | /web/d.html 12 | /web/m.html 13 | /api/data.sql 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | note5: An HTML5 notepad 2 | ======================= 3 | 4 | Inspired by the iPad "Notes" application. 5 | 6 | Very simple. Just start typing. Everything is saved to your system automatically. 7 | 8 | By: [Jason M. Hanley](http://www.jasonhanley.com/) 9 | -------------------------------------------------------------------------------- /api/config-local.php.template: -------------------------------------------------------------------------------- 1 | $v) { 7 | unset($process[$key][$k]); 8 | if (is_array($v)) { 9 | $process[$key][stripslashes($k)] = $v; 10 | $process[] = &$process[$key][stripslashes($k)]; 11 | } else { 12 | $process[$key][stripslashes($k)] = stripslashes($v); 13 | } 14 | } 15 | } 16 | unset($process); 17 | } 18 | 19 | include "../../api/api.php"; 20 | ?> -------------------------------------------------------------------------------- /web/404.html: -------------------------------------------------------------------------------- 1 | 2 | not found 3 | 4 | 15 | 16 | 17 | 18 | 19 |
20 |

Not found

21 |

Try here

22 |
-------------------------------------------------------------------------------- /api/manage.php: -------------------------------------------------------------------------------- 1 | schema.sql'); 11 | 12 | } elseif(in_array('dump-data', $argv)) { 13 | 14 | system('mysqldump --user='.DBConfig::$dbuser. 15 | ' --password='.DBConfig::$dbpass. 16 | ' --no-create-db --no-create-info --complete-insert --compact '. 17 | DBConfig::$dbname.' > data.sql'); 18 | 19 | } elseif(in_array('load-sql', $argv)) { 20 | 21 | system('mysql --user='.DBConfig::$dbuser. 22 | ' --password='.DBConfig::$dbpass. 23 | ' '. 24 | DBConfig::$dbname.' < '.$argv[2]); 25 | 26 | } else { 27 | 28 | echo 'Commands: 29 | dump-schema 30 | dump-data 31 | load-sql [filename] 32 | '; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /web/js/libs/autoresize.jquery.min.js: -------------------------------------------------------------------------------- 1 | (function($){$.fn.autoResize=function(options){var settings=$.extend({onResize:function(){},animate:true,animateDuration:150,animateCallback:function(){},extraSpace:40,limit:10000,minHeight:100},options);this.filter('textarea').each(function(){var textarea=$(this).css({resize:'none','overflow-y':'hidden'}),origHeight=settings.minHeight,clone=(function(){var props=['height','width','lineHeight','textDecoration','letterSpacing','font-family','font-size','padding'],propOb={};$.each(props,function(i,prop){propOb[prop]=textarea.css(prop);});return textarea.clone().removeAttr('id').removeAttr('name').css({position:'absolute',top:0,left:-9999}).css(propOb).attr('tabIndex','-1').insertBefore(textarea);})(),lastScrollTop=null,updateSize=function(){clone.height(0).val($(this).val()).scrollTop(10000);var scrollTop=Math.max(clone.scrollTop(),settings.minHeight)+settings.extraSpace,toChange=$(this).add(clone);if(lastScrollTop===scrollTop){return;} 2 | lastScrollTop=scrollTop;if(scrollTop>=settings.limit){$(this).css('overflow-y','');return;} 3 | settings.onResize.call(this);settings.animate&&textarea.css('display')==='block'?toChange.stop().animate({height:scrollTop},settings.animateDuration,settings.animateCallback):toChange.height(scrollTop);};textarea.unbind('.dynSiz').bind('keyup.dynSiz',updateSize).bind('keydown.dynSiz',updateSize).bind('change.dynSiz',updateSize);});return this;};})(jQuery); -------------------------------------------------------------------------------- /api/schema.sql: -------------------------------------------------------------------------------- 1 | /*!40101 SET @saved_cs_client = @@character_set_client */; 2 | /*!40101 SET character_set_client = utf8 */; 3 | CREATE TABLE `action` ( 4 | `id` int(11) NOT NULL auto_increment, 5 | `created_at` timestamp NOT NULL default CURRENT_TIMESTAMP, 6 | `version` int(11) NOT NULL, 7 | `type` int(11) NOT NULL, 8 | `attrs` text collate latin1_general_ci NOT NULL, 9 | PRIMARY KEY (`id`) 10 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; 11 | /*!40101 SET character_set_client = @saved_cs_client */; 12 | /*!40101 SET @saved_cs_client = @@character_set_client */; 13 | /*!40101 SET character_set_client = utf8 */; 14 | CREATE TABLE `docs` ( 15 | `doc_id` varchar(40) collate latin1_general_ci NOT NULL, 16 | `created_at` timestamp NOT NULL default CURRENT_TIMESTAMP, 17 | `user_id` bigint(20) NOT NULL, 18 | `last_write` int(10) unsigned NOT NULL, 19 | `name` varchar(40) collate latin1_general_ci NOT NULL, 20 | `content` text collate latin1_general_ci NOT NULL, 21 | PRIMARY KEY (`doc_id`), 22 | KEY `user_id` (`user_id`), 23 | KEY `last_write` (`last_write`) 24 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; 25 | /*!40101 SET character_set_client = @saved_cs_client */; 26 | /*!40101 SET @saved_cs_client = @@character_set_client */; 27 | /*!40101 SET character_set_client = utf8 */; 28 | CREATE TABLE `user` ( 29 | `id` bigint(20) NOT NULL auto_increment, 30 | `created_at` timestamp NOT NULL default CURRENT_TIMESTAMP, 31 | `identity` varchar(1000) collate latin1_general_ci NOT NULL, 32 | `email` varchar(200) collate latin1_general_ci NOT NULL, 33 | `last_login` timestamp NOT NULL default '0000-00-00 00:00:00', 34 | `last_write` int(10) unsigned NOT NULL, 35 | `attrs` varchar(10000) collate latin1_general_ci NOT NULL, 36 | PRIMARY KEY (`id`), 37 | UNIQUE KEY `identity` (`identity`) 38 | ) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; 39 | /*!40101 SET character_set_client = @saved_cs_client */; 40 | /*!40101 SET @saved_cs_client = @@character_set_client */; 41 | /*!40101 SET character_set_client = utf8 */; 42 | CREATE TABLE `user_instance` ( 43 | `created_at` timestamp NOT NULL default CURRENT_TIMESTAMP, 44 | `user_id` bigint(20) NOT NULL, 45 | `instance` varchar(40) collate latin1_general_ci NOT NULL, 46 | UNIQUE KEY `instance` (`instance`) 47 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; 48 | /*!40101 SET character_set_client = @saved_cs_client */; 49 | -------------------------------------------------------------------------------- /web/js/libs/json2-min.js: -------------------------------------------------------------------------------- 1 | var JSON;if(!JSON){JSON={};} 2 | (function(){"use strict";function f(n){return n<10?'0'+n:n;} 3 | if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+ 4 | f(this.getUTCMonth()+1)+'-'+ 5 | f(this.getUTCDate())+'T'+ 6 | f(this.getUTCHours())+':'+ 7 | f(this.getUTCMinutes())+':'+ 8 | f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};} 9 | var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';} 10 | function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);} 11 | if(typeof rep==='function'){value=rep.call(holder,key,value);} 12 | switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';} 13 | gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i 2 | 3 | 4 | 5 | h5note: HTML5 Notepad 6 | 7 | 8 | 9 | 47 | 48 | 49 |
50 |

note5 HTML5 Notepad

51 | 52 | Inspired by the iPad "Notes" application. 53 |

54 | Very simple. Just start typing. Everything is saved to your system automatically. 55 |

56 | Try it now at: h5note.com 57 |

58 | Works on: Chrome, Firefox, Safari, Internet Explorer, iPad, iPhone, Android, Blackberry OS6+, and more! 59 |

60 | Author: Jason M. Hanley 61 |

62 | Also available at the Chrome Web Store 63 |

64 | Problems or suggestions? Report them here: http://bit.ly/n5support 65 |

66 | Source code available at: github.com/JasonHanley/note5 67 |

68 |
69 | 80 | 81 | -------------------------------------------------------------------------------- /web/js/libs/autoresize.jquery.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery autoResize (textarea auto-resizer) 3 | * @copyright James Padolsey http://james.padolsey.com/javascript/jquery-plugin-autoresize/ 4 | * @version 1.04 5 | */ 6 | 7 | (function($){ 8 | 9 | $.fn.autoResize = function(options) { 10 | 11 | // Just some abstracted details, 12 | // to make plugin users happy: 13 | var settings = $.extend({ 14 | onResize : function(){}, 15 | animate : true, 16 | animateDuration : 150, 17 | animateCallback : function(){}, 18 | extraSpace : 40, 19 | limit: 10000, 20 | minHeight: 100 21 | }, options); 22 | 23 | // Only textarea's auto-resize: 24 | this.filter('textarea').each(function(){ 25 | 26 | // Get rid of scrollbars and disable WebKit resizing: 27 | var textarea = $(this).css({resize:'none','overflow-y':'hidden'}), 28 | 29 | // Cache original height, for use later: 30 | origHeight = settings.minHeight, 31 | 32 | // Need clone of textarea, hidden off screen: 33 | clone = (function(){ 34 | 35 | // Properties which may effect space taken up by chracters: 36 | var props = ['height','width','lineHeight','textDecoration','letterSpacing', 'font-family', 'font-size', 'padding'], 37 | propOb = {}; 38 | 39 | // Create object of styles to apply: 40 | $.each(props, function(i, prop){ 41 | propOb[prop] = textarea.css(prop); 42 | }); 43 | 44 | // Clone the actual textarea removing unique properties 45 | // and insert before original textarea: 46 | return textarea.clone().removeAttr('id').removeAttr('name').css({ 47 | position: 'absolute', 48 | top: 0, 49 | left: -9999 50 | }).css(propOb).attr('tabIndex','-1').insertBefore(textarea); 51 | 52 | })(), 53 | lastScrollTop = null, 54 | updateSize = function() { 55 | 56 | // Prepare the clone: 57 | clone.height(0).val($(this).val()).scrollTop(10000); 58 | 59 | // Find the height of text: 60 | var scrollTop = Math.max(clone.scrollTop(), settings.minHeight) + settings.extraSpace, 61 | toChange = $(this).add(clone); 62 | 63 | // Don't do anything if scrollTip hasen't changed: 64 | if (lastScrollTop === scrollTop) { return; } 65 | lastScrollTop = scrollTop; 66 | 67 | // Check for limit: 68 | if ( scrollTop >= settings.limit ) { 69 | $(this).css('overflow-y',''); 70 | return; 71 | } 72 | // Fire off callback: 73 | settings.onResize.call(this); 74 | 75 | // Either animate or directly apply height: 76 | settings.animate && textarea.css('display') === 'block' ? 77 | toChange.stop().animate({height:scrollTop}, settings.animateDuration, settings.animateCallback) 78 | : toChange.height(scrollTop); 79 | }; 80 | 81 | // Bind namespaced handlers to appropriate events: 82 | textarea 83 | .unbind('.dynSiz') 84 | .bind('keyup.dynSiz', updateSize) 85 | .bind('keydown.dynSiz', updateSize) 86 | .bind('change.dynSiz', updateSize); 87 | 88 | }); 89 | 90 | // Chain: 91 | return this; 92 | 93 | }; 94 | 95 | 96 | 97 | })(jQuery); -------------------------------------------------------------------------------- /web/.htaccess: -------------------------------------------------------------------------------- 1 | # Apache configuration file 2 | # httpd.apache.org/docs/2.2/mod/quickreference.html 3 | 4 | # Techniques in here adapted from all over, including: 5 | # Kroc Camen: camendesign.com/.htaccess 6 | # perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/ 7 | 8 | 9 | # Force the latest IE version, in various cases when it may fall back to IE7 mode 10 | # github.com/rails/rails/commit/123eb25#commitcomment-118920 11 | # Use ChromeFrame if it's installed for a better experience for the poor IE folk 12 | 13 | 14 | BrowserMatch MSIE ie 15 | Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie 16 | 17 | 18 | 19 | 20 | # Because X-UA-Compatible isn't sent to non-IE (to save header bytes), 21 | # We need to inform proxies that content changes based on UA 22 | Header append Vary User-Agent 23 | # Cache control is set only if mod_headers is enabled, so that's unncessary to declare 24 | 25 | 26 | # hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/ 27 | # Disabled. Uncomment to serve cross-domain ajax requests 28 | # 29 | # Header set Access-Control-Allow-Origin "*" 30 | # 31 | 32 | 33 | 34 | 35 | # allow access from all domains for webfonts 36 | # alternatively you could only whitelist 37 | # your subdomains like "sub.domain.com" 38 | 39 | 40 | 41 | Header set Access-Control-Allow-Origin "*" 42 | 43 | 44 | 45 | 46 | # video 47 | AddType video/ogg ogg ogv 48 | AddType video/mp4 mp4 49 | AddType video/webm webm 50 | 51 | # Proper svg serving. Required for svg webfonts on iPad 52 | # twitter.com/FontSquirrel/status/14855840545 53 | AddType image/svg+xml svg svgz 54 | AddEncoding gzip svgz 55 | 56 | # webfonts 57 | AddType application/vnd.ms-fontobject eot 58 | AddType font/truetype ttf 59 | AddType font/opentype otf 60 | AddType font/woff woff 61 | 62 | # assorted types 63 | AddType image/vnd.microsoft.icon ico 64 | AddType image/webp webp 65 | AddType text/cache-manifest manifest 66 | AddType text/x-component htc 67 | AddType application/x-chrome-extension crx 68 | 69 | 70 | 71 | 72 | # allow concatenation from within specific js and css files 73 | 74 | # e.g. Inside of script.combined.js you could have 75 | # 76 | # 77 | # and they would be included into this single file 78 | 79 | # this is not in use in the boilerplate as it stands. you may 80 | # choose to name your files in this way for this advantage 81 | # or concatenate and minify them manually. 82 | # Disabled by default. 83 | 84 | # 85 | # Options +Includes 86 | # SetOutputFilter INCLUDES 87 | # 88 | 89 | 90 | 91 | 92 | 93 | # gzip compression. 94 | 95 | 96 | # html, txt, css, js, json, xml, htc: 97 | AddOutputFilterByType DEFLATE text/html text/plain text/css application/json 98 | AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript 99 | AddOutputFilterByType DEFLATE text/xml application/xml text/x-component 100 | 101 | # webfonts and svg: 102 | 103 | SetOutputFilter DEFLATE 104 | 105 | 106 | 107 | 108 | 109 | # these are pretty far-future expires headers 110 | # they assume you control versioning with cachebusting query params like 111 | # 27 | 34 | 35 | 41 | 42 | var note5fileVersion='.$ver.';'; 63 | 64 | ?> 65 | 66 | 67 | 68 | 69 | 70 | 71 | HTML5 Notepad 72 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 99 | 100 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 |
Loading h5note.com | Please wait...
112 | 113 | 257 | 258 | 259 | 260 | 285 | 286 | 287 | 298 | 299 | 300 | 301 | 302 | -------------------------------------------------------------------------------- /lib/openid.php: -------------------------------------------------------------------------------- 1 | 11 | * $openid = new LightOpenID; 12 | * $openid->identity = 'ID supplied by user'; 13 | * header('Location: ' . $openid->authUrl()); 14 | * 15 | * The provider then sends various parameters via GET, one of them is openid_mode. 16 | * Step two is verification: 17 | * 18 | * if ($this->data['openid_mode']) { 19 | * $openid = new LightOpenID; 20 | * echo $openid->validate() ? 'Logged in.' : 'Failed'; 21 | * } 22 | * 23 | * 24 | * Optionally, you can set $returnUrl and $realm (or $trustRoot, which is an alias). 25 | * The default values for those are: 26 | * $openid->realm = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST']; 27 | * $openid->returnUrl = $openid->realm . $_SERVER['REQUEST_URI']; 28 | * If you don't know their meaning, refer to any openid tutorial, or specification. Or just guess. 29 | * 30 | * AX and SREG extensions are supported. 31 | * To use them, specify $openid->required and/or $openid->optional before calling $openid->authUrl(). 32 | * These are arrays, with values being AX schema paths (the 'path' part of the URL). 33 | * For example: 34 | * $openid->required = array('namePerson/friendly', 'contact/email'); 35 | * $openid->optional = array('namePerson/first'); 36 | * If the server supports only SREG or OpenID 1.1, these are automaticaly 37 | * mapped to SREG names, so that user doesn't have to know anything about the server. 38 | * 39 | * To get the values, use $openid->getAttributes(). 40 | * 41 | * 42 | * The library requires PHP >= 5.1.2 with curl or http/https stream wrappers enabled. 43 | * @author Mewp 44 | * @copyright Copyright (c) 2010, Mewp 45 | * @license http://www.opensource.org/licenses/mit-license.php MIT 46 | */ 47 | class LightOpenID 48 | { 49 | public $returnUrl 50 | , $required = array() 51 | , $optional = array() 52 | , $verify_peer = null 53 | , $capath = null 54 | , $cainfo = null; 55 | private $identity, $claimed_id; 56 | protected $server, $version, $trustRoot, $aliases, $identifier_select = false 57 | , $ax = false, $sreg = false, $data; 58 | static protected $ax_to_sreg = array( 59 | 'namePerson/friendly' => 'nickname', 60 | 'contact/email' => 'email', 61 | 'namePerson' => 'fullname', 62 | 'birthDate' => 'dob', 63 | 'person/gender' => 'gender', 64 | 'contact/postalCode/home' => 'postcode', 65 | 'contact/country/home' => 'country', 66 | 'pref/language' => 'language', 67 | 'pref/timezone' => 'timezone', 68 | ); 69 | 70 | function __construct() 71 | { 72 | $this->trustRoot = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST']; 73 | $uri = rtrim(preg_replace('#((?<=\?)|&)openid\.[^&]+#', '', $_SERVER['REQUEST_URI']), '?'); 74 | $this->returnUrl = $this->trustRoot . $uri; 75 | 76 | $this->data = $_POST + $_GET; # OPs may send data as POST or GET. 77 | 78 | if(!function_exists('curl_init') && !in_array('https', stream_get_wrappers())) { 79 | throw new ErrorException('You must have either https wrappers or curl enabled.'); 80 | } 81 | } 82 | 83 | function __set($name, $value) 84 | { 85 | switch ($name) { 86 | case 'identity': 87 | if (strlen($value = trim((String) $value))) { 88 | if (preg_match('#^xri:/*#i', $value, $m)) { 89 | $value = substr($value, strlen($m[0])); 90 | } elseif (!preg_match('/^(?:[=@+\$!\(]|https?:)/i', $value)) { 91 | $value = "http://$value"; 92 | } 93 | if (preg_match('#^https?://[^/]+$#i', $value, $m)) { 94 | $value .= '/'; 95 | } 96 | } 97 | $this->$name = $this->claimed_id = $value; 98 | break; 99 | case 'trustRoot': 100 | case 'realm': 101 | $this->trustRoot = trim($value); 102 | } 103 | } 104 | 105 | function __get($name) 106 | { 107 | switch ($name) { 108 | case 'identity': 109 | # We return claimed_id instead of identity, 110 | # because the developer should see the claimed identifier, 111 | # i.e. what he set as identity, not the op-local identifier (which is what we verify) 112 | return $this->claimed_id; 113 | case 'trustRoot': 114 | case 'realm': 115 | return $this->trustRoot; 116 | case 'mode': 117 | return empty($this->data['openid_mode']) ? null : $this->data['openid_mode']; 118 | } 119 | } 120 | 121 | /** 122 | * Checks if the server specified in the url exists. 123 | * 124 | * @param $url url to check 125 | * @return true, if the server exists; false otherwise 126 | */ 127 | function hostExists($url) 128 | { 129 | if (strpos($url, '/') === false) { 130 | $server = $url; 131 | } else { 132 | $server = @parse_url($url, PHP_URL_HOST); 133 | } 134 | 135 | if (!$server) { 136 | return false; 137 | } 138 | 139 | return !!gethostbynamel($server); 140 | } 141 | 142 | protected function request_curl($url, $method='GET', $params=array()) 143 | { 144 | $params = http_build_query($params, '', '&'); 145 | $curl = curl_init($url . ($method == 'GET' && $params ? '?' . $params : '')); 146 | curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 147 | curl_setopt($curl, CURLOPT_HEADER, false); 148 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 149 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 150 | curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/xrds+xml, */*')); 151 | 152 | if($this->verify_peer !== null) { 153 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verify_peer); 154 | if($this->capath) { 155 | curl_setopt($curl, CURLOPT_CAPATH, $this->capath); 156 | } 157 | 158 | if($this->cainfo) { 159 | curl_setopt($curl, CURLOPT_CAINFO, $this->cainfo); 160 | } 161 | } 162 | 163 | if ($method == 'POST') { 164 | curl_setopt($curl, CURLOPT_POST, true); 165 | curl_setopt($curl, CURLOPT_POSTFIELDS, $params); 166 | } elseif ($method == 'HEAD') { 167 | curl_setopt($curl, CURLOPT_HEADER, true); 168 | curl_setopt($curl, CURLOPT_NOBODY, true); 169 | } else { 170 | curl_setopt($curl, CURLOPT_HTTPGET, true); 171 | } 172 | $response = curl_exec($curl); 173 | 174 | if($method == 'HEAD') { 175 | $headers = array(); 176 | foreach(explode("\n", $response) as $header) { 177 | $pos = strpos($header,':'); 178 | $name = strtolower(trim(substr($header, 0, $pos))); 179 | $headers[$name] = trim(substr($header, $pos+1)); 180 | } 181 | 182 | # Updating claimed_id in case of redirections. 183 | $effective_url = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL); 184 | if($effective_url != $url) { 185 | $this->identity = $this->claimed_id = $effective_url; 186 | } 187 | 188 | return $headers; 189 | } 190 | 191 | if (curl_errno($curl)) { 192 | throw new ErrorException(curl_error($curl), curl_errno($curl)); 193 | } 194 | 195 | return $response; 196 | } 197 | 198 | protected function request_streams($url, $method='GET', $params=array()) 199 | { 200 | if(!$this->hostExists($url)) { 201 | throw new ErrorException('Invalid request.'); 202 | } 203 | 204 | $params = http_build_query($params, '', '&'); 205 | switch($method) { 206 | case 'GET': 207 | $opts = array( 208 | 'http' => array( 209 | 'method' => 'GET', 210 | 'header' => 'Accept: application/xrds+xml, */*', 211 | 'ignore_errors' => true, 212 | ) 213 | ); 214 | $url = $url . ($params ? '?' . $params : ''); 215 | break; 216 | case 'POST': 217 | $opts = array( 218 | 'http' => array( 219 | 'method' => 'POST', 220 | 'header' => 'Content-type: application/x-www-form-urlencoded', 221 | 'content' => $params, 222 | 'ignore_errors' => true, 223 | ) 224 | ); 225 | break; 226 | case 'HEAD': 227 | # We want to send a HEAD request, 228 | # but since get_headers doesn't accept $context parameter, 229 | # we have to change the defaults. 230 | $default = stream_context_get_options(stream_context_get_default()); 231 | stream_context_get_default( 232 | array('http' => array( 233 | 'method' => 'HEAD', 234 | 'header' => 'Accept: application/xrds+xml, */*', 235 | 'ignore_errors' => true, 236 | )) 237 | ); 238 | 239 | $url = $url . ($params ? '?' . $params : ''); 240 | $headers_tmp = get_headers ($url); 241 | if(!$headers_tmp) { 242 | return array(); 243 | } 244 | 245 | # Parsing headers. 246 | $headers = array(); 247 | foreach($headers_tmp as $header) { 248 | $pos = strpos($header,':'); 249 | $name = strtolower(trim(substr($header, 0, $pos))); 250 | $headers[$name] = trim(substr($header, $pos+1)); 251 | 252 | # Following possible redirections. The point is just to have 253 | # claimed_id change with them, because get_headers() will 254 | # follow redirections automatically. 255 | # We ignore redirections with relative paths. 256 | # If any known provider uses them, file a bug report. 257 | if($name == 'location') { 258 | if(strpos($headers[$name], 'http') === 0) { 259 | $this->identity = $this->claimed_id = $headers[$name]; 260 | } elseif($headers[$name][0] == '/') { 261 | $parsed_url = parse_url($this->claimed_id); 262 | $this->identity = 263 | $this->claimed_id = $parsed_url['scheme'] . '://' 264 | . $parsed_url['host'] 265 | . $headers[$name]; 266 | } 267 | } 268 | } 269 | 270 | # And restore them. 271 | stream_context_get_default($default); 272 | return $headers; 273 | } 274 | 275 | if($this->verify_peer) { 276 | $opts += array('ssl' => array( 277 | 'verify_peer' => true, 278 | 'capath' => $this->capath, 279 | 'cafile' => $this->cainfo, 280 | )); 281 | } 282 | 283 | $context = stream_context_create ($opts); 284 | 285 | return file_get_contents($url, false, $context); 286 | } 287 | 288 | protected function request($url, $method='GET', $params=array()) 289 | { 290 | if(function_exists('curl_init') && !ini_get('safe_mode') && !ini_get('open_basedir')) { 291 | return $this->request_curl($url, $method, $params); 292 | } 293 | return $this->request_streams($url, $method, $params); 294 | } 295 | 296 | protected function build_url($url, $parts) 297 | { 298 | if (isset($url['query'], $parts['query'])) { 299 | $parts['query'] = $url['query'] . '&' . $parts['query']; 300 | } 301 | 302 | $url = $parts + $url; 303 | $url = $url['scheme'] . '://' 304 | . (empty($url['username'])?'' 305 | :(empty($url['password'])? "{$url['username']}@" 306 | :"{$url['username']}:{$url['password']}@")) 307 | . $url['host'] 308 | . (empty($url['port'])?'':":{$url['port']}") 309 | . (empty($url['path'])?'':$url['path']) 310 | . (empty($url['query'])?'':"?{$url['query']}") 311 | . (empty($url['fragment'])?'':"#{$url['fragment']}"); 312 | return $url; 313 | } 314 | 315 | /** 316 | * Helper function used to scan for / tags and extract information 317 | * from them 318 | */ 319 | protected function htmlTag($content, $tag, $attrName, $attrValue, $valueName) 320 | { 321 | preg_match_all("#<{$tag}[^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*$valueName=['\"](.+?)['\"][^>]*/?>#i", $content, $matches1); 322 | preg_match_all("#<{$tag}[^>]*$valueName=['\"](.+?)['\"][^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*/?>#i", $content, $matches2); 323 | 324 | $result = array_merge($matches1[1], $matches2[1]); 325 | return empty($result)?false:$result[0]; 326 | } 327 | 328 | /** 329 | * Performs Yadis and HTML discovery. Normally not used. 330 | * @param $url Identity URL. 331 | * @return String OP Endpoint (i.e. OpenID provider address). 332 | * @throws ErrorException 333 | */ 334 | function discover($url) 335 | { 336 | if (!$url) throw new ErrorException('No identity supplied.'); 337 | # Use xri.net proxy to resolve i-name identities 338 | if (!preg_match('#^https?:#', $url)) { 339 | $url = "https://xri.net/$url"; 340 | } 341 | 342 | # We save the original url in case of Yadis discovery failure. 343 | # It can happen when we'll be lead to an XRDS document 344 | # which does not have any OpenID2 services. 345 | $originalUrl = $url; 346 | 347 | # A flag to disable yadis discovery in case of failure in headers. 348 | $yadis = true; 349 | 350 | # We'll jump a maximum of 5 times, to avoid endless redirections. 351 | for ($i = 0; $i < 5; $i ++) { 352 | if ($yadis) { 353 | $headers = $this->request($url, 'HEAD'); 354 | 355 | $next = false; 356 | if (isset($headers['x-xrds-location'])) { 357 | $url = $this->build_url(parse_url($url), parse_url(trim($headers['x-xrds-location']))); 358 | $next = true; 359 | } 360 | 361 | if (isset($headers['content-type']) 362 | && (strpos($headers['content-type'], 'application/xrds+xml') !== false 363 | || strpos($headers['content-type'], 'text/xml') !== false) 364 | ) { 365 | # Apparently, some providers return XRDS documents as text/html. 366 | # While it is against the spec, allowing this here shouldn't break 367 | # compatibility with anything. 368 | # --- 369 | # Found an XRDS document, now let's find the server, and optionally delegate. 370 | $content = $this->request($url, 'GET'); 371 | 372 | preg_match_all('#(.*?)#s', $content, $m); 373 | foreach($m[1] as $content) { 374 | $content = ' ' . $content; # The space is added, so that strpos doesn't return 0. 375 | 376 | # OpenID 2 377 | $ns = preg_quote('http://specs.openid.net/auth/2.0/'); 378 | if(preg_match('#\s*'.$ns.'(server|signon)\s*#s', $content, $type)) { 379 | if ($type[1] == 'server') $this->identifier_select = true; 380 | 381 | preg_match('#(.*)#', $content, $server); 382 | preg_match('#<(Local|Canonical)ID>(.*)#', $content, $delegate); 383 | if (empty($server)) { 384 | return false; 385 | } 386 | # Does the server advertise support for either AX or SREG? 387 | $this->ax = (bool) strpos($content, 'http://openid.net/srv/ax/1.0'); 388 | $this->sreg = strpos($content, 'http://openid.net/sreg/1.0') 389 | || strpos($content, 'http://openid.net/extensions/sreg/1.1'); 390 | 391 | $server = $server[1]; 392 | if (isset($delegate[2])) $this->identity = trim($delegate[2]); 393 | $this->version = 2; 394 | 395 | $this->server = $server; 396 | return $server; 397 | } 398 | 399 | # OpenID 1.1 400 | $ns = preg_quote('http://openid.net/signon/1.1'); 401 | if (preg_match('#\s*'.$ns.'\s*#s', $content)) { 402 | 403 | preg_match('#(.*)#', $content, $server); 404 | preg_match('#<.*?Delegate>(.*)#', $content, $delegate); 405 | if (empty($server)) { 406 | return false; 407 | } 408 | # AX can be used only with OpenID 2.0, so checking only SREG 409 | $this->sreg = strpos($content, 'http://openid.net/sreg/1.0') 410 | || strpos($content, 'http://openid.net/extensions/sreg/1.1'); 411 | 412 | $server = $server[1]; 413 | if (isset($delegate[1])) $this->identity = $delegate[1]; 414 | $this->version = 1; 415 | 416 | $this->server = $server; 417 | return $server; 418 | } 419 | } 420 | 421 | $next = true; 422 | $yadis = false; 423 | $url = $originalUrl; 424 | $content = null; 425 | break; 426 | } 427 | if ($next) continue; 428 | 429 | # There are no relevant information in headers, so we search the body. 430 | $content = $this->request($url, 'GET'); 431 | $location = $this->htmlTag($content, 'meta', 'http-equiv', 'X-XRDS-Location', 'content'); 432 | if ($location) { 433 | $url = $this->build_url(parse_url($url), parse_url($location)); 434 | continue; 435 | } 436 | } 437 | 438 | if (!$content) $content = $this->request($url, 'GET'); 439 | 440 | # At this point, the YADIS Discovery has failed, so we'll switch 441 | # to openid2 HTML discovery, then fallback to openid 1.1 discovery. 442 | $server = $this->htmlTag($content, 'link', 'rel', 'openid2.provider', 'href'); 443 | $delegate = $this->htmlTag($content, 'link', 'rel', 'openid2.local_id', 'href'); 444 | $this->version = 2; 445 | 446 | if (!$server) { 447 | # The same with openid 1.1 448 | $server = $this->htmlTag($content, 'link', 'rel', 'openid.server', 'href'); 449 | $delegate = $this->htmlTag($content, 'link', 'rel', 'openid.delegate', 'href'); 450 | $this->version = 1; 451 | } 452 | 453 | if ($server) { 454 | # We found an OpenID2 OP Endpoint 455 | if ($delegate) { 456 | # We have also found an OP-Local ID. 457 | $this->identity = $delegate; 458 | } 459 | $this->server = $server; 460 | return $server; 461 | } 462 | 463 | throw new ErrorException('No servers found!'); 464 | } 465 | throw new ErrorException('Endless redirection!'); 466 | } 467 | 468 | protected function sregParams() 469 | { 470 | $params = array(); 471 | # We always use SREG 1.1, even if the server is advertising only support for 1.0. 472 | # That's because it's fully backwards compatibile with 1.0, and some providers 473 | # advertise 1.0 even if they accept only 1.1. One such provider is myopenid.com 474 | $params['openid.ns.sreg'] = 'http://openid.net/extensions/sreg/1.1'; 475 | if ($this->required) { 476 | $params['openid.sreg.required'] = array(); 477 | foreach ($this->required as $required) { 478 | if (!isset(self::$ax_to_sreg[$required])) continue; 479 | $params['openid.sreg.required'][] = self::$ax_to_sreg[$required]; 480 | } 481 | $params['openid.sreg.required'] = implode(',', $params['openid.sreg.required']); 482 | } 483 | 484 | if ($this->optional) { 485 | $params['openid.sreg.optional'] = array(); 486 | foreach ($this->optional as $optional) { 487 | if (!isset(self::$ax_to_sreg[$optional])) continue; 488 | $params['openid.sreg.optional'][] = self::$ax_to_sreg[$optional]; 489 | } 490 | $params['openid.sreg.optional'] = implode(',', $params['openid.sreg.optional']); 491 | } 492 | return $params; 493 | } 494 | 495 | protected function axParams() 496 | { 497 | $params = array(); 498 | if ($this->required || $this->optional) { 499 | $params['openid.ns.ax'] = 'http://openid.net/srv/ax/1.0'; 500 | $params['openid.ax.mode'] = 'fetch_request'; 501 | $this->aliases = array(); 502 | $counts = array(); 503 | $required = array(); 504 | $optional = array(); 505 | foreach (array('required','optional') as $type) { 506 | foreach ($this->$type as $alias => $field) { 507 | if (is_int($alias)) $alias = strtr($field, '/', '_'); 508 | $this->aliases[$alias] = 'http://axschema.org/' . $field; 509 | if (empty($counts[$alias])) $counts[$alias] = 0; 510 | $counts[$alias] += 1; 511 | ${$type}[] = $alias; 512 | } 513 | } 514 | foreach ($this->aliases as $alias => $ns) { 515 | $params['openid.ax.type.' . $alias] = $ns; 516 | } 517 | foreach ($counts as $alias => $count) { 518 | if ($count == 1) continue; 519 | $params['openid.ax.count.' . $alias] = $count; 520 | } 521 | 522 | # Don't send empty ax.requied and ax.if_available. 523 | # Google and possibly other providers refuse to support ax when one of these is empty. 524 | if($required) { 525 | $params['openid.ax.required'] = implode(',', $required); 526 | } 527 | if($optional) { 528 | $params['openid.ax.if_available'] = implode(',', $optional); 529 | } 530 | } 531 | return $params; 532 | } 533 | 534 | protected function authUrl_v1() 535 | { 536 | $returnUrl = $this->returnUrl; 537 | # If we have an openid.delegate that is different from our claimed id, 538 | # we need to somehow preserve the claimed id between requests. 539 | # The simplest way is to just send it along with the return_to url. 540 | if($this->identity != $this->claimed_id) { 541 | $returnUrl .= (strpos($returnUrl, '?') ? '&' : '?') . 'openid.claimed_id=' . $this->claimed_id; 542 | } 543 | 544 | $params = array( 545 | 'openid.return_to' => $returnUrl, 546 | 'openid.mode' => 'checkid_setup', 547 | 'openid.identity' => $this->identity, 548 | 'openid.trust_root' => $this->trustRoot, 549 | ) + $this->sregParams(); 550 | 551 | return $this->build_url(parse_url($this->server) 552 | , array('query' => http_build_query($params, '', '&'))); 553 | } 554 | 555 | protected function authUrl_v2($identifier_select) 556 | { 557 | $params = array( 558 | 'openid.ns' => 'http://specs.openid.net/auth/2.0', 559 | 'openid.mode' => 'checkid_setup', 560 | 'openid.return_to' => $this->returnUrl, 561 | 'openid.realm' => $this->trustRoot, 562 | ); 563 | if ($this->ax) { 564 | $params += $this->axParams(); 565 | } 566 | if ($this->sreg) { 567 | $params += $this->sregParams(); 568 | } 569 | if (!$this->ax && !$this->sreg) { 570 | # If OP doesn't advertise either SREG, nor AX, let's send them both 571 | # in worst case we don't get anything in return. 572 | $params += $this->axParams() + $this->sregParams(); 573 | } 574 | 575 | if ($identifier_select) { 576 | $params['openid.identity'] = $params['openid.claimed_id'] 577 | = 'http://specs.openid.net/auth/2.0/identifier_select'; 578 | } else { 579 | $params['openid.identity'] = $this->identity; 580 | $params['openid.claimed_id'] = $this->claimed_id; 581 | } 582 | 583 | return $this->build_url(parse_url($this->server) 584 | , array('query' => http_build_query($params, '', '&'))); 585 | } 586 | 587 | /** 588 | * Returns authentication url. Usually, you want to redirect your user to it. 589 | * @return String The authentication url. 590 | * @param String $select_identifier Whether to request OP to select identity for an user in OpenID 2. Does not affect OpenID 1. 591 | * @throws ErrorException 592 | */ 593 | function authUrl($identifier_select = null) 594 | { 595 | if (!$this->server) $this->discover($this->identity); 596 | 597 | if ($this->version == 2) { 598 | if ($identifier_select === null) { 599 | return $this->authUrl_v2($this->identifier_select); 600 | } 601 | return $this->authUrl_v2($identifier_select); 602 | } 603 | return $this->authUrl_v1(); 604 | } 605 | 606 | /** 607 | * Performs OpenID verification with the OP. 608 | * @return Bool Whether the verification was successful. 609 | * @throws ErrorException 610 | */ 611 | function validate() 612 | { 613 | $this->claimed_id = isset($this->data['openid_claimed_id'])?$this->data['openid_claimed_id']:$this->data['openid_identity']; 614 | $params = array( 615 | 'openid.assoc_handle' => $this->data['openid_assoc_handle'], 616 | 'openid.signed' => $this->data['openid_signed'], 617 | 'openid.sig' => $this->data['openid_sig'], 618 | ); 619 | 620 | if (isset($this->data['openid_ns'])) { 621 | # We're dealing with an OpenID 2.0 server, so let's set an ns 622 | # Even though we should know location of the endpoint, 623 | # we still need to verify it by discovery, so $server is not set here 624 | $params['openid.ns'] = 'http://specs.openid.net/auth/2.0'; 625 | } elseif (isset($this->data['openid_claimed_id']) 626 | && $this->data['openid_claimed_id'] != $this->data['openid_identity'] 627 | ) { 628 | # If it's an OpenID 1 provider, and we've got claimed_id, 629 | # we have to append it to the returnUrl, like authUrl_v1 does. 630 | $this->returnUrl .= (strpos($this->returnUrl, '?') ? '&' : '?') 631 | . 'openid.claimed_id=' . $this->claimed_id; 632 | } 633 | 634 | if ($this->data['openid_return_to'] != $this->returnUrl) { 635 | # The return_to url must match the url of current request. 636 | # I'm assuing that noone will set the returnUrl to something that doesn't make sense. 637 | return false; 638 | } 639 | 640 | $server = $this->discover($this->claimed_id); 641 | 642 | foreach (explode(',', $this->data['openid_signed']) as $item) { 643 | # Checking whether magic_quotes_gpc is turned on, because 644 | # the function may fail if it is. For example, when fetching 645 | # AX namePerson, it might containg an apostrophe, which will be escaped. 646 | # In such case, validation would fail, since we'd send different data than OP 647 | # wants to verify. stripslashes() should solve that problem, but we can't 648 | # use it when magic_quotes is off. 649 | $value = $this->data['openid_' . str_replace('.','_',$item)]; 650 | $params['openid.' . $item] = get_magic_quotes_gpc() ? stripslashes($value) : $value; 651 | 652 | } 653 | 654 | $params['openid.mode'] = 'check_authentication'; 655 | 656 | $response = $this->request($server, 'POST', $params); 657 | 658 | return preg_match('/is_valid\s*:\s*true/i', $response); 659 | } 660 | 661 | protected function getAxAttributes() 662 | { 663 | $alias = null; 664 | if (isset($this->data['openid_ns_ax']) 665 | && $this->data['openid_ns_ax'] != 'http://openid.net/srv/ax/1.0' 666 | ) { # It's the most likely case, so we'll check it before 667 | $alias = 'ax'; 668 | } else { 669 | # 'ax' prefix is either undefined, or points to another extension, 670 | # so we search for another prefix 671 | foreach ($this->data as $key => $val) { 672 | if (substr($key, 0, strlen('openid_ns_')) == 'openid_ns_' 673 | && $val == 'http://openid.net/srv/ax/1.0' 674 | ) { 675 | $alias = substr($key, strlen('openid_ns_')); 676 | break; 677 | } 678 | } 679 | } 680 | if (!$alias) { 681 | # An alias for AX schema has not been found, 682 | # so there is no AX data in the OP's response 683 | return array(); 684 | } 685 | 686 | $attributes = array(); 687 | foreach ($this->data as $key => $value) { 688 | $keyMatch = 'openid_' . $alias . '_value_'; 689 | if (substr($key, 0, strlen($keyMatch)) != $keyMatch) { 690 | continue; 691 | } 692 | $key = substr($key, strlen($keyMatch)); 693 | if (!isset($this->data['openid_' . $alias . '_type_' . $key])) { 694 | # OP is breaking the spec by returning a field without 695 | # associated ns. This shouldn't happen, but it's better 696 | # to check, than cause an E_NOTICE. 697 | continue; 698 | } 699 | $key = substr($this->data['openid_' . $alias . '_type_' . $key], 700 | strlen('http://axschema.org/')); 701 | $attributes[$key] = $value; 702 | } 703 | return $attributes; 704 | } 705 | 706 | protected function getSregAttributes() 707 | { 708 | $attributes = array(); 709 | $sreg_to_ax = array_flip(self::$ax_to_sreg); 710 | foreach ($this->data as $key => $value) { 711 | $keyMatch = 'openid_sreg_'; 712 | if (substr($key, 0, strlen($keyMatch)) != $keyMatch) { 713 | continue; 714 | } 715 | $key = substr($key, strlen($keyMatch)); 716 | if (!isset($sreg_to_ax[$key])) { 717 | # The field name isn't part of the SREG spec, so we ignore it. 718 | continue; 719 | } 720 | $attributes[$sreg_to_ax[$key]] = $value; 721 | } 722 | return $attributes; 723 | } 724 | 725 | /** 726 | * Gets AX/SREG attributes provided by OP. should be used only after successful validaton. 727 | * Note that it does not guarantee that any of the required/optional parameters will be present, 728 | * or that there will be no other attributes besides those specified. 729 | * In other words. OP may provide whatever information it wants to. 730 | * * SREG names will be mapped to AX names. 731 | * * @return Array Array of attributes with keys being the AX schema names, e.g. 'contact/email' 732 | * @see http://www.axschema.org/types/ 733 | */ 734 | function getAttributes() 735 | { 736 | if (isset($this->data['openid_ns']) 737 | && $this->data['openid_ns'] == 'http://specs.openid.net/auth/2.0' 738 | ) { # OpenID 2.0 739 | # We search for both AX and SREG attributes, with AX taking precedence. 740 | return $this->getAxAttributes() + $this->getSregAttributes(); 741 | } 742 | return $this->getSregAttributes(); 743 | } 744 | } 745 | -------------------------------------------------------------------------------- /web/js/note5.js: -------------------------------------------------------------------------------- 1 | //Note5 Document class 2 | var Note5Doc = function() { 3 | var date = new Date(); 4 | this.name = date.get8601Date() + ' ' + date.get8601Time(); 5 | this.content = ''; 6 | this.docId = guidGenerator(); 7 | this.lastWrite = null; 8 | this.isDirty = true; 9 | }; 10 | 11 | //Note5 Application static class 12 | var Note5 = { 13 | updateTime: 4950, 14 | localStorageKey: 'Note5.notes', 15 | lastWrite: -1, 16 | instanceId: null, 17 | currentEmail: '', 18 | init: function() { 19 | //window.onerror = this.errorHandler; *** Completely disable error handling until we can figure out how to make it work offline 20 | this.doc.view = this.view; 21 | this.view.doc = this.doc; 22 | 23 | $('#button_login').hide(); 24 | $('#button_sync').hide(); 25 | 26 | // Generate or load application unique identifier 27 | this.getInstanceId(); 28 | 29 | if('localStorage' in window && window['localStorage'] !== null) { // http://diveintohtml5.org/detect.html 30 | // Load notes from local storage 31 | this.doc.loadLocal(); 32 | } else { 33 | $('#main').html('Error: Sorry, your browser does not support saving notes locally. Please upgrade :('); 34 | $('#login').html(''); 35 | return; 36 | } 37 | 38 | // Set up note change handler 39 | $('textarea#note') 40 | .unbind('.noteChange') 41 | //.bind('keyup.noteChange', this.view.noteChanged) 42 | .bind('keydown.noteChange', this.view.noteChanged) 43 | .bind('change.noteChange', this.view.noteChanged); 44 | 45 | // Attach main button handlers 46 | this.setupButtonHandlers(); 47 | 48 | // If there are no notes, create one 49 | if(this.doc.notes.length < 1) { 50 | this.cmdNew(); 51 | } 52 | 53 | $('#loading').hide(); 54 | $('#container').show(); 55 | 56 | // Set up vertical auto resize handler 57 | if(mobileMode) { 58 | $('textarea#note').autoResize({}); 59 | } else { 60 | this.onresizeDesktop(); 61 | $(window).resize(function() { 62 | Note5.onresizeDesktop(); 63 | }); 64 | } 65 | 66 | var currentNote = this.doc.getCurrentNote(); 67 | if(currentNote) { 68 | this.view.refreshNote(); 69 | this.cmdMakeActive(currentNote.docId); 70 | } 71 | 72 | // Force a refresh immediately 73 | Note5.view.autoRefreshPage(true); 74 | 75 | // In mobile mode, make the document list active upon load 76 | if(mobileMode) { 77 | $('#button_saved').click(); 78 | } 79 | 80 | // Make sure the current note is saved upon closing the window 81 | window.onbeforeunload = function() { 82 | Note5.doc.updateCurrent($('#note').val()); 83 | Note5.doc.saveCurrent(); 84 | }; 85 | 86 | // Indicate that initialization is complete 87 | $('#note').removeAttr('disabled'); 88 | 89 | // Check to see if we're logged in (do this last to minimize loading delay) 90 | $.get('api/?action=checklogin&instanceId='+Note5.instanceId, function(data) {Note5.setLoggedIn(data);}, 'html'); 91 | }, 92 | 93 | //Document subclass 94 | doc: { 95 | view: null, 96 | notes: [], 97 | docIds: [], 98 | currentNoteIndex: -1, 99 | setIndex: function(i) { this.currentNoteIndex = i; }, 100 | setIndexById: function(docId) { this.currentNoteIndex = this.findIndexById(docId); }, 101 | add: function(doc) { return this.notes.push(doc); }, 102 | getNote: function(i) { return notes[i]; }, 103 | getNoteById: function(docId) { 104 | var index = this.findIndexById(docId); 105 | if(index >= 0) { 106 | return this.notes[index]; 107 | } 108 | 109 | return null; 110 | }, 111 | getCurrentNote: function() { 112 | if(this.currentNoteIndex >= 0) 113 | return this.notes[this.currentNoteIndex]; 114 | return null; 115 | }, 116 | updateCurrent: function(content) { 117 | if(this.currentNoteIndex >= 0) { 118 | this.notes[this.currentNoteIndex].content = content; 119 | //this.view.refreshNote(); 120 | } 121 | }, 122 | 123 | // Used by old loadLocal routine 124 | findIndexByName: function(name) { 125 | for(var i = 0; i < this.notes.length; i++) { 126 | if(this.notes[i].name == name) 127 | return i; 128 | } 129 | return -1; 130 | }, 131 | 132 | // Find index in notes array *** May be different than docIds array index 133 | findIndexById: function(docId) { 134 | for(var i = 0; i < this.notes.length; i++) { 135 | if(this.notes[i].docId == docId) 136 | return i; 137 | } 138 | return -1; 139 | }, 140 | 141 | // Find index in docIds array 142 | findDocIdIndex: function(docId) { 143 | for(var i = 0; i < this.notes.length; i++) { 144 | if(this.docIds[i] == docId) 145 | return i; 146 | } 147 | return -1; 148 | }, 149 | 150 | // Save to local storage (requires HTML5 support) 151 | saveLocal: function() { 152 | // Old routine (for reference) 153 | /*currentNoteName = ''; 154 | if(this.currentNoteIndex >= 0) 155 | currentNoteName = this.notes[this.currentNoteIndex].name; 156 | data = { notes: this.notes, currentNoteName: currentNoteName }; 157 | json = JSON.stringify(data); 158 | localStorage.setItem(Note5.localStorageKey, json); 159 | */ 160 | // New routine 161 | for(var i = 0; i < this.docIds.length; i++) { 162 | json = JSON.stringify(this.notes[i]); 163 | localStorage.setItem(this.notes[i].docId, json); 164 | } 165 | json = JSON.stringify(this.docIds); 166 | localStorage.setItem('Note5.docIds', json); 167 | if(this.currentNoteIndex >= 0) 168 | localStorage.setItem('Note5.currentDocId', this.notes[this.currentNoteIndex].docId); 169 | localStorage.setItem('Note5.lastWrite', Note5.lastWrite); 170 | }, 171 | 172 | // Save current document to local storage 173 | saveCurrent: function() { 174 | currentNote = this.getCurrentNote(); 175 | json = JSON.stringify(currentNote); 176 | localStorage.setItem(currentNote['docId'], json); 177 | localStorage.setItem('Note5.currentDocId', this.notes[this.currentNoteIndex].docId); 178 | }, 179 | 180 | // Load from local storage (requires HTML5 support) 181 | loadLocal: function() { 182 | // Old routine 183 | json = localStorage.getItem(Note5.localStorageKey); 184 | if(json) { 185 | data = JSON.parse(json); 186 | if(data) { 187 | this.notes = data.notes; 188 | currentNoteName = data.currentNoteName; 189 | this.currentNoteIndex = this.findIndexByName(currentNoteName); 190 | 191 | // Update docId list 192 | for(var i = 0; i < this.notes.length; i++) { 193 | if(!this.notes[i].docId) 194 | this.notes[i].docId = guidGenerator(); // Set id if not already set 195 | docId = this.notes[i].docId; 196 | this.docIds.push(docId); 197 | } 198 | } 199 | 200 | // Save to new format 201 | this.saveLocal(); 202 | 203 | // Delete old format 204 | localStorage.removeItem(Note5.localStorageKey); 205 | this.notes = []; 206 | this.currentNoteIndex = -1; 207 | this.docIds = []; 208 | } 209 | 210 | // New routine 211 | json = localStorage.getItem('Note5.docIds'); 212 | if(json) { 213 | var data = JSON.parse(json); 214 | if(data) { 215 | this.docIds = data; 216 | 217 | for(var i = 0; i < data.length; i++) { 218 | var json = localStorage.getItem(data[i]); 219 | if(json) { 220 | var note = JSON.parse(json); 221 | if(note) { 222 | // Upgrade old format notes 223 | if(note.docId == undefined) { 224 | note.docId = guidGenerator(); 225 | } 226 | if(note.lastWrite == undefined) { 227 | note.lastWrite = null; 228 | } 229 | if(note.isDirty == undefined) { 230 | note.isDirty = true; 231 | } 232 | 233 | this.notes.push(note); 234 | } 235 | } 236 | } 237 | 238 | // List documents sorted by name 239 | this.sortNotes(); 240 | } 241 | } 242 | var currentDocId = localStorage.getItem('Note5.currentDocId'); 243 | var lastWrite = localStorage.getItem('Note5.lastWrite'); 244 | if(lastWrite) 245 | Note5.lastWrite = lastWrite; 246 | this.currentNoteIndex = this.findIndexById(currentDocId); 247 | 248 | // If it can't find the correct current note, set it to the last 249 | if(this.currentNoteIndex < 0 && this.notes.length > 0) 250 | this.currentNoteIndex = 0; 251 | }, 252 | 253 | sortNotes: function() { 254 | this.notes.sort( function(a,b) {return stringSortReverse(a.name,b.name);} ); 255 | }, 256 | 257 | removeNote: function(docId) { 258 | 259 | // Delete the note from memory 260 | var oldDocId = this.getCurrentNote().docId; 261 | removeIndex = this.findIndexById(docId); 262 | removeIdIndex = this.findDocIdIndex(docId); 263 | if(removeIndex >= 0 && removeIdIndex >= 0) { 264 | this.notes.splice(removeIndex, 1); 265 | this.docIds.splice(removeIdIndex, 1); 266 | } 267 | 268 | // Reset current index appropriately 269 | oldIndex = this.findIndexById(oldDocId); 270 | if(oldIndex >= 0) { 271 | this.setIndex(oldIndex); 272 | } else if(this.notes.length) { 273 | this.setIndex(0); 274 | } else { 275 | this.setIndex(-1); 276 | } 277 | 278 | // Update local storage 279 | localStorage.removeItem(docId); 280 | this.saveLocal(); 281 | } 282 | 283 | }, 284 | 285 | //View subclass 286 | view: { 287 | doc: null, 288 | updateRunning: false, 289 | noteChangedRunning: false, 290 | pageDirty: false, 291 | 292 | // Called when the note text area is changed 293 | noteChanged: function() { 294 | if(Note5.view.noteChangedRunning) return; 295 | Note5.view.noteChangedRunning = true; 296 | 297 | debugLog('noteChanged()'); 298 | 299 | var noteVal = $('#note').val(); 300 | 301 | var currentNote = Note5.doc.getCurrentNote(); 302 | if(currentNote == null || noteVal == currentNote.content) { 303 | Note5.view.noteChangedRunning = false; 304 | return; 305 | } 306 | 307 | // Mark note changed 308 | currentNote.isDirty = true; 309 | 310 | // Save contents to memory 311 | Note5.doc.updateCurrent(noteVal); 312 | 313 | Note5.view.pageDirty = true; 314 | $('#status_saving').show(); 315 | 316 | Note5.view.noteChangedRunning = false; 317 | }, 318 | 319 | // Copy from memory to note area 320 | refreshNote: function() { 321 | debugLog('refreshNote()'); 322 | 323 | $('#note').val(this.doc.getCurrentNote().content); 324 | $('#note').keydown(); // resize textarea 325 | }, 326 | 327 | // Refresh everything that needs to be updated every updateTime milliseconds 328 | // The first one is forced if force==true 329 | autoRefreshPage: function(force) { 330 | //debugLog('autoRefreshPage('+force+')'); 331 | Note5.view.refreshPage(force); 332 | setTimeout('Note5.view.autoRefreshPage(false)', Note5.updateTime); 333 | }, 334 | 335 | // Refresh the page and do a sync if necessary 336 | refreshPage: function(force) { 337 | 338 | if(Note5.view.updateRunning) return; 339 | Note5.view.updateRunning = true; 340 | 341 | //debugLog('refreshPage('+force+')?'); 342 | 343 | // If text hasn't changed since last update, return 344 | var noteVal = $('#note').val(); 345 | if(!force && !this.pageDirty) { 346 | Note5.view.updateRunning = false; 347 | return; 348 | } 349 | debugLog('refreshPage('+force+')'); 350 | 351 | // Save note content to localStorage 352 | this.doc.saveCurrent(); 353 | this.pageDirty = false; 354 | $('#status_saving').hide(); 355 | 356 | // Update list of saved documents 357 | this.refreshSavedArea(); 358 | 359 | // If we are logged in, start the sync process 360 | if(Note5.currentEmail.length) { 361 | $('#button_sync').hide(); 362 | $('#status_syncing').show(); 363 | 364 | // ServerToLocal API update 365 | $.get('api/?action=stl&i='+Note5.instanceId+'&llw='+Note5.lastWrite, Note5.view.serverToLocalProcess); 366 | } 367 | 368 | //date = new Date(); 369 | //console.log('refreshPage '+date.get8601Date() + '.' + date.get8601Time()); 370 | 371 | Note5.view.updateRunning = false; 372 | }, 373 | 374 | serverToLocalProcess: function(data) { 375 | debugLog('serverToLocalProcess()'); 376 | 377 | //$('#last-write').html(Note5.lastWrite); 378 | //$('#status-message').append(data+'
'); 379 | 380 | try { 381 | serverData = JSON.parse(data); 382 | } catch(err) { 383 | serverData = null; 384 | } 385 | 386 | // Cancel sync if we don't get valid JSON 387 | if(!serverData) { 388 | $('#status_syncing').hide(); 389 | 390 | // Re-check to see if we're logged in 391 | $.get('api/?action=checklogin&instanceId='+Note5.instanceId, function(data) {Note5.setLoggedIn(data);}, 'html'); 392 | 393 | return; 394 | } 395 | 396 | var oldDocId = Note5.doc.getCurrentNote().docId; 397 | 398 | var lastWriteServer = serverData['lws']; 399 | var newLastWriteServer = serverData['nlws']; 400 | var oldDocs = serverData['oldDocs']; 401 | var newDocs = serverData['newDocs']; 402 | 403 | var deleteList = []; 404 | var updateList = []; 405 | 406 | // Loop through new server notes for ones we don't have yet 407 | for(var i = 0; i < newDocs.length; i++) { 408 | var doc = newDocs[i]; 409 | 410 | // If we don't have a new document locally, add it 411 | if(jQuery.inArray(doc['doc_id'], Note5.doc.docIds) == -1) { 412 | var newDoc = new Note5Doc(); 413 | newDoc.docId = doc['doc_id']; 414 | newDoc.name = doc['name']; 415 | newDoc.content = doc['content']; 416 | newDoc.lastWrite = doc['last_write']; 417 | Note5.doc.add(newDoc); 418 | Note5.doc.docIds.push(newDoc.docId); 419 | } 420 | } 421 | 422 | // Loop through old server notes 423 | for(var i = 0; i < oldDocs.length; i++) { 424 | var doc = oldDocs[i]; 425 | 426 | // If we don't have an old document locally, it should be deleted from the server 427 | if(jQuery.inArray(doc['doc_id'], Note5.doc.docIds) == -1) { 428 | deleteList.push(doc['doc_id']); 429 | } 430 | } 431 | 432 | var deleteLocalList = [] 433 | 434 | // Loop through all local notes 435 | for(var i = 0; i < Note5.doc.docIds.length; i++) { 436 | var note = Note5.doc.notes[i]; 437 | 438 | // If our note is out of date, and we find a match, update our copy 439 | if(note.isDirty == false && note.lastWrite < lastWriteServer) { 440 | var found = false; 441 | for(var j = 0; j < newDocs.length; j++) { 442 | doc = newDocs[j]; 443 | if(note.docId == doc['doc_id']) { 444 | found = true; 445 | if(note.lastWrite < doc['last_write']) { 446 | Note5.doc.notes[i].name = doc['name']; 447 | Note5.doc.notes[i].content = doc['content']; 448 | Note5.doc.notes[i].lastWrite = doc['last_write']; 449 | } 450 | } 451 | } 452 | 453 | // Check the old docs array too 454 | for(var j = 0; j < oldDocs.length; j++) { 455 | doc = oldDocs[j]; 456 | if(note.docId == doc['doc_id']) { 457 | found = true; 458 | } 459 | } 460 | 461 | // If the note no longer exists on the server, delete it locally 462 | if(!found) { 463 | deleteLocalList.push(note.docId); 464 | } 465 | } else { 466 | // Figure out if we need to send the file to the server 467 | if(note.isDirty) { 468 | 469 | var found = false; 470 | for(var j = 0; j < newDocs.length; j++) { 471 | doc = newDocs[j]; 472 | if(note.docId == doc['doc_id']) { 473 | found = true; 474 | // If the server doc is old, update it 475 | if(doc['last_write'] < note.lastWrite ) { 476 | note.lastWrite = newLastWriteServer; 477 | updateList.push(note); 478 | note.isDirty = false; 479 | } 480 | } 481 | } 482 | 483 | // If the server doesn't have the doc, add it to the update list 484 | if(!found) { 485 | note.lastWrite = newLastWriteServer; 486 | updateList.push(note); 487 | note.isDirty = false; 488 | } 489 | } 490 | } 491 | } 492 | 493 | if(deleteLocalList.length > 0) { 494 | if(confirm("Sync is about to delete "+deleteLocalList.length+ 495 | " document(s). This cannot be undone.\n\nPress Ok to confirm.")) { 496 | 497 | // Delete old local documents not found on server 498 | for(var i = 0; i < deleteLocalList.length; i++) { 499 | docId = deleteLocalList[i]; 500 | Note5.doc.removeNote(docId); 501 | } 502 | 503 | } 504 | } 505 | 506 | var jsonUp = JSON.stringify(updateList); 507 | var jsonDel = JSON.stringify(deleteList); 508 | 509 | Note5.lastWrite = newLastWriteServer; 510 | 511 | // Make sure notes are sorted before getting indices 512 | Note5.doc.sortNotes(); 513 | 514 | oldIndex = Note5.doc.findIndexById(oldDocId); 515 | currentIndex = Note5.doc.currentNoteIndex; 516 | 517 | if(currentIndex != oldIndex) { 518 | if(oldIndex >= 0) { 519 | Note5.doc.setIndex(oldIndex); 520 | Note5.view.refreshNote(); 521 | } else if(Note5.doc.notes.length) { 522 | Note5.doc.setIndex(0); 523 | Note5.view.refreshNote(); 524 | } else { 525 | Note5.doc.setIndex(-1); 526 | Note5.cmdNew(); 527 | } 528 | } 529 | 530 | Note5.doc.saveLocal(); // Persist docIdList 531 | 532 | Note5.view.refreshSavedArea(); 533 | 534 | $.post('api/?action=lts', {i: Note5.instanceId, lslw: newLastWriteServer, up: jsonUp, del: jsonDel}, 535 | function(data) { 536 | //$('#last-write').html(Note5.lastWrite); 537 | //$('#status-message').append(data+'
'); 538 | $('#status_syncing').hide(); 539 | $('#button_sync').show(); 540 | } ); 541 | }, 542 | 543 | //Refresh the 'Saved' tab 544 | refreshSavedArea: function() { 545 | debugLog('refreshSavedArea()'); 546 | 547 | var savedList = ''; 548 | 549 | for(var i = 0; i < this.doc.notes.length; i++) { 550 | var note = this.doc.notes[i]; 551 | var content = note.content; 552 | var name = note.name; 553 | var docId = note.docId; 554 | var activeTxt = ''; 555 | if(this.doc.currentNoteIndex == i) 556 | activeTxt = ' active'; 557 | var maxLength = 32; 558 | if(content.length > maxLength) 559 | content = content.substr(0, maxLength) + '...'; 560 | savedList += ''+ 561 | ''; 562 | 563 | if(!mobileMode) { 564 | savedList += ''; 570 | } 571 | 572 | savedList += '' + 575 | ''; 576 | } 577 | savedList += '
'+name+'
'+content+'
'+ 565 | '' + 566 | '' + 567 | '
'+ 568 | '
' + 569 | 'Download
'+ 573 | '
' + 574 | 'Remove
'+"\n"; 578 | $('#saved_docs').html(savedList); 579 | 580 | // Update 'Saved' icon with # of documents 581 | //var numDocs = this.doc.notes.length; 582 | //if(numDocs == 0) numDocs = ''; 583 | //$('#num_saved').html(numDocs); 584 | } 585 | 586 | }, 587 | 588 | //Command: Create a new note 589 | cmdNew: function() { 590 | var newDoc = new Note5Doc(); 591 | this.doc.add(newDoc); 592 | this.doc.docIds.push(newDoc.docId); 593 | this.doc.saveLocal(); // Update docIdList 594 | this.doc.sortNotes(); 595 | this.doc.setIndexById(newDoc.docId); 596 | $('#note').val(''); 597 | this.view.refreshPage(true); 598 | this.cmdMakeActive(newDoc.docId); 599 | }, 600 | 601 | //Command: Make the selected note active 602 | cmdMakeActive: function(docId) { 603 | var currentNote = this.doc.getCurrentNote(); 604 | if(currentNote) { 605 | this.view.noteChanged(); 606 | $('#'+currentNote.docId).removeClass('active'); 607 | } 608 | 609 | var index = this.doc.findIndexById(docId); 610 | if(index >= 0 ) { 611 | this.doc.setIndex(index); 612 | $('#'+docId).addClass('active'); 613 | this.showNote(); 614 | this.view.refreshNote(); 615 | this.doc.saveCurrent(); 616 | $('#note').focus(); 617 | $('#note').putCursorAtEnd(); 618 | } 619 | }, 620 | 621 | cmdRemoveConfirm: function(docId) { 622 | if(confirm("This item will be permanently deleted.\n\nPress Ok to confirm.")) { 623 | Note5.cmdRemove(docId); 624 | } 625 | }, 626 | 627 | //Command: Remove the selected note 628 | cmdRemove: function(docId) { 629 | this.doc.removeNote(docId); 630 | 631 | if(this.doc.currentNoteIndex == -1) { 632 | this.cmdNew(); 633 | } else { 634 | this.view.refreshNote(); 635 | this.view.refreshPage(true); 636 | } 637 | }, 638 | 639 | showNote: function() { 640 | if(mobileMode) $('#main').show(); 641 | if(mobileMode) $('#saved').hide(); 642 | if(mobileMode) $('#config').hide(); 643 | }, 644 | 645 | //Utility functions 646 | setupButtonHandlers: function() { 647 | $('#button_saved').click( function() { 648 | // Home 649 | Note5.view.refreshPage(); 650 | if(mobileMode) $('#main').hide(); 651 | $('#saved').show(); 652 | if(!mobileMode) $('#main_table').show(); 653 | if(!mobileMode) $('#main').show(); 654 | $('#config').hide(); 655 | $('saved_docs').focus(); 656 | }); 657 | $('#button_config').click( function() { 658 | if(!mobileMode) $('#main_table').hide(); 659 | $('#main').hide(); 660 | $('#saved').hide(); 661 | $('#config').show(); 662 | }); 663 | $('#button_new').click( function() { 664 | Note5.cmdNew(); 665 | }); 666 | $('#button_sync').click( function() { 667 | Note5.view.refreshPage(true); 668 | }); 669 | $('#button_login').click( function() { 670 | window.location = 'api/?action=glogin&instanceId='+Note5.instanceId; 671 | }); 672 | }, 673 | 674 | resetApplication: function() { 675 | // Reset localstorage 676 | localStorage.clear(); 677 | $('#saved_message').html('Application has been reset: '+(new Date()).get8601Time()); 678 | }, 679 | 680 | importOld: function() { 681 | var json = $('#import_data').val(); 682 | if(json) { 683 | data = JSON.parse(json); 684 | if(data) { 685 | for(var i = 0; i < data.length; i++) { 686 | var newDoc = new Note5Doc(); 687 | newDoc.name = data[i].name; 688 | newDoc.content = data[i].content; 689 | Note5.doc.setIndex(Note5.doc.add(newDoc)-1); 690 | Note5.doc.docIds.push(newDoc.docId); 691 | } 692 | } 693 | 694 | Note5.doc.saveLocal(); // Update docIdList 695 | Note5.view.refreshPage(true); 696 | } 697 | 698 | $('#import_old').hide(); 699 | $('#button_saved').click(); 700 | }, 701 | 702 | onresizeDesktop : function() { 703 | var menuHeight = $('#menu_bar').height(); 704 | var viewportHeight = $(window).height(); 705 | var elementHeight = viewportHeight - menuHeight; 706 | if(adsMode) 707 | elementHeight -= 100; 708 | $('#saved').height(elementHeight); 709 | $('#note').height(elementHeight-16); 710 | $('#saved_td').height(elementHeight); 711 | $('#note_td').height(elementHeight-16); 712 | }, 713 | 714 | //Resize the app window width as necessary 715 | onresize: function() { 716 | 717 | // Width 718 | var docWidth=window.innerWidth; 719 | //var docWidth=$('#note_table').width(); 720 | $('#note').css('width', docWidth-32); 721 | 722 | // Height 723 | //var docHeight=window.innerHeight; 724 | //var navHeight=$('#nav').height(); 725 | //$('#note').css('height', docHeight-navHeight-40); 726 | }, 727 | 728 | errorHandler: function(errMsg, errUrl, errLine) { 729 | var errData = { 730 | version: note5fileVersion, 731 | type: -1, 732 | msg: errMsg, 733 | url: errUrl, 734 | line: errLine, 735 | appCodeName: navigator.appCodeName, 736 | appName: navigator.appName, 737 | appVersion: navigator.appVersion, 738 | cookieEnabled: navigator.cookieEnabled, 739 | platform: navigator.platform, 740 | userAgent: navigator.userAgent 741 | }; 742 | 743 | if(typeof(errData.msg) != 'string') 744 | errData.msg = 'Unknown (not string)'; 745 | 746 | jsonData = JSON.stringify(errData); 747 | 748 | data = jsonData.urlEncode(); 749 | 750 | $.get('api/?action=log&type=-1&data='+data, function(data) {$('#error-return').html(data)} ); 751 | 752 | /* Quiet errors for now 753 | $( "#dialog-error" ).dialog({ 754 | resizable: false, 755 | //height:'15em', 756 | modal: true, 757 | buttons: { 758 | "Argh!": function() { 759 | $( this ).dialog( "close" ); 760 | } 761 | } 762 | }); 763 | */ 764 | 765 | }, 766 | 767 | getInstanceId: function() { 768 | if(window.localStorage) { 769 | var data = window.localStorage.getItem('Note5.instanceId'); 770 | if(data) { 771 | this.instanceId = data; 772 | } 773 | else { 774 | this.instanceId = guidGenerator(); 775 | window.localStorage.setItem('Note5.instanceId', this.instanceId); 776 | } 777 | 778 | $('#login').html('Sign in'); 779 | } 780 | }, 781 | 782 | setLoggedIn: function(email) { 783 | oldEmail = Note5.currentEmail; 784 | Note5.currentEmail = email; 785 | if(Note5.currentEmail) { 786 | $('#login').html(Note5.currentEmail+' | Sign out'); 788 | 789 | // Hide the login button 790 | $('#button_login').hide(); 791 | 792 | // Show the sync button 793 | $('#button_sync').show(); 794 | 795 | if(oldEmail != Note5.currentEmail) { 796 | // Do a sync, if the login status has changed 797 | Note5.view.refreshPage(true); 798 | } 799 | } else { 800 | $('#login').html('Sign in'); 801 | 802 | // Hide the sync button 803 | $('#button_sync').hide(); 804 | 805 | // Show the login button 806 | $('#button_login').show(); 807 | } 808 | }, 809 | 810 | dummy: null 811 | }; 812 | 813 | -------------------------------------------------------------------------------- /web/js/libs/jquery-1.4.2.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery JavaScript Library v1.4.2 3 | * http://jquery.com/ 4 | * 5 | * Copyright 2010, John Resig 6 | * Dual licensed under the MIT or GPL Version 2 licenses. 7 | * http://jquery.org/license 8 | * 9 | * Includes Sizzle.js 10 | * http://sizzlejs.com/ 11 | * Copyright 2010, The Dojo Foundation 12 | * Released under the MIT, BSD, and GPL Licenses. 13 | * 14 | * Date: Sat Feb 13 22:33:48 2010 -0500 15 | */ 16 | (function(A,w){function ma(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(ma,1);return}c.ready()}}function Qa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,j){var i=a.length;if(typeof b==="object"){for(var o in b)X(a,o,b[o],f,e,d);return a}if(d!==w){f=!j&&f&&c.isFunction(d);for(o=0;o)[^>]*$|^#([\w-]+)$/,Ua=/^.[^:#\[\.,]*$/,Va=/\S/, 21 | Wa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Xa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,R=Array.prototype.slice,ya=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(a==="body"&&!b){this.context=s;this[0]=s.body;this.selector="body";this.length=1;return this}if(typeof a==="string")if((d=Ta.exec(a))&& 22 | (d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Xa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=sa([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}return c.merge(this,a)}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return T.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a);return c.merge(this, 23 | a)}else return!b||b.jquery?(b||T).find(a):c(b).find(a);else if(c.isFunction(a))return T.ready(a);if(a.selector!==w){this.selector=a.selector;this.context=a.context}return c.makeArray(a,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){var f=c();c.isArray(a)?ba.apply(f,a):c.merge(f,a);f.prevObject=this;f.context=this.context;if(b=== 24 | "find")f.selector=this.selector+(this.selector?" ":"")+d;else if(b)f.selector=this.selector+"."+b+"("+d+")";return f},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this, 25 | function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,j,i,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b
a"; 34 | var e=d.getElementsByTagName("*"),j=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!j)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(j.getAttribute("style")),hrefNormalized:j.getAttribute("href")==="/a",opacity:/^0.55$/.test(j.style.opacity),cssFloat:!!j.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:s.createElement("select").appendChild(s.createElement("option")).selected, 35 | parentNode:d.removeChild(d.appendChild(s.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(i){}a.insertBefore(b,a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}try{delete b.test}catch(o){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function k(){c.support.noCloneEvent= 36 | false;d.detachEvent("onclick",k)});d.cloneNode(true).fireEvent("onclick")}d=s.createElement("div");d.innerHTML="";a=s.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var k=s.createElement("div");k.style.width=k.style.paddingLeft="1px";s.body.appendChild(k);c.boxModel=c.support.boxModel=k.offsetWidth===2;s.body.removeChild(k).style.display="none"});a=function(k){var n= 37 | s.createElement("div");k="on"+k;var r=k in n;if(!r){n.setAttribute(k,"return;");r=typeof n[k]==="function"}return r};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=j=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ya=0,za={};c.extend({cache:{},expando:G,noData:{embed:true,object:true, 38 | applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var f=a[G],e=c.cache;if(!f&&typeof b==="string"&&d===w)return null;f||(f=++Ya);if(typeof b==="object"){a[G]=f;e[f]=c.extend(true,{},b)}else if(!e[f]){a[G]=f;e[f]={}}a=e[f];if(d!==w)a[b]=d;return typeof b==="string"?a[b]:a}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{if(c.support.deleteExpando)delete a[c.expando]; 39 | else a.removeAttribute&&a.removeAttribute(c.expando);delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===w){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===w&&this.length)f=c.data(this[0],a);return f===w&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this, 40 | a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b=== 41 | w)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var Aa=/[\n\t]/g,ca=/\s+/,Za=/\r/g,$a=/href|src|style/,ab=/(button|input)/i,bb=/(button|input|object|select|textarea)/i, 42 | cb=/^(a|area)$/i,Ba=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(n){var r=c(this);r.addClass(a.call(this,n,r.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d-1)return true;return false},val:function(a){if(a===w){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var j=b?d:0;for(d=b?d+1:e.length;j=0;else if(c.nodeName(this,"select")){var u=c.makeArray(r);c("option",this).each(function(){this.selected= 47 | c.inArray(c(this).val(),u)>=0});if(!u.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return w;if(f&&b in c.attrFn)return c(a)[b](d);f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==w;b=f&&c.props[b]||b;if(a.nodeType===1){var j=$a.test(b);if(b in a&&f&&!j){if(e){b==="type"&&ab.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed"); 48 | a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:bb.test(a.nodeName)||cb.test(a.nodeName)&&a.href?0:w;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&j?a.getAttribute(b,2):a.getAttribute(b);return a===null?w:a}return c.style(a,b,d)}});var O=/\.(.*)$/,db=function(a){return a.replace(/[^\w\s\.\|`]/g, 49 | function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==A&&!a.frameElement)a=A;var e,j;if(d.handler){e=d;d=e.handler}if(!d.guid)d.guid=c.guid++;if(j=c.data(a)){var i=j.events=j.events||{},o=j.handle;if(!o)j.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,arguments):w};o.elem=a;b=b.split(" ");for(var k,n=0,r;k=b[n++];){j=e?c.extend({},e):{handler:d,data:f};if(k.indexOf(".")>-1){r=k.split("."); 50 | k=r.shift();j.namespace=r.slice(0).sort().join(".")}else{r=[];j.namespace=""}j.type=k;j.guid=d.guid;var u=i[k],z=c.event.special[k]||{};if(!u){u=i[k]=[];if(!z.setup||z.setup.call(a,f,r,o)===false)if(a.addEventListener)a.addEventListener(k,o,false);else a.attachEvent&&a.attachEvent("on"+k,o)}if(z.add){z.add.call(a,j);if(!j.handler.guid)j.handler.guid=d.guid}u.push(j);c.event.global[k]=true}a=null}}},global:{},remove:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){var e,j=0,i,o,k,n,r,u,z=c.data(a), 51 | C=z&&z.events;if(z&&C){if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(e in C)c.event.remove(a,e+b)}else{for(b=b.split(" ");e=b[j++];){n=e;i=e.indexOf(".")<0;o=[];if(!i){o=e.split(".");e=o.shift();k=new RegExp("(^|\\.)"+c.map(o.slice(0).sort(),db).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(r=C[e])if(d){n=c.event.special[e]||{};for(B=f||0;B=0){a.type= 53 | e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return w;a.result=w;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d,b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(j){}if(!a.isPropagationStopped()&& 54 | f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){f=a.target;var i,o=c.nodeName(f,"a")&&e==="click",k=c.event.special[e]||{};if((!k._default||k._default.call(d,a)===false)&&!o&&!(f&&f.nodeName&&c.noData[f.nodeName.toLowerCase()])){try{if(f[e]){if(i=f["on"+e])f["on"+e]=null;c.event.triggered=true;f[e]()}}catch(n){}if(i)f["on"+e]=i;c.event.triggered=false}}},handle:function(a){var b,d,f,e;a=arguments[0]=c.event.fix(a||A.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive; 55 | if(!b){d=a.type.split(".");a.type=d.shift();f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)")}e=c.data(this,"events");d=e[a.type];if(e&&d){d=d.slice(0);e=0;for(var j=d.length;e-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},fa=function(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Fa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data", 63 | e);if(!(f===w||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:fa,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return fa.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return fa.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a, 64 | "_change_data",Fa(a))}},setup:function(){if(this.type==="file")return false;for(var a in ea)c.event.add(this,a+".specialChange",ea[a]);return da.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return da.test(this.nodeName)}};ea=c.event.special.change.filters}s.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,f)}c.event.special[b]={setup:function(){this.addEventListener(a, 65 | d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var j in d)this[b](j,f,d[j],e);return this}if(c.isFunction(f)){e=f;f=w}var i=b==="one"?c.proxy(e,function(k){c(this).unbind(k,i);return e.apply(this,arguments)}):e;if(d==="unload"&&b!=="one")this.one(d,f,e);else{j=0;for(var o=this.length;j0){y=t;break}}t=t[g]}m[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, 71 | e=0,j=Object.prototype.toString,i=false,o=true;[0,0].sort(function(){o=false;return 0});var k=function(g,h,l,m){l=l||[];var q=h=h||s;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||typeof g!=="string")return l;for(var p=[],v,t,y,S,H=true,M=x(h),I=g;(f.exec(""),v=f.exec(I))!==null;){I=v[3];p.push(v[1]);if(v[2]){S=v[3];break}}if(p.length>1&&r.exec(g))if(p.length===2&&n.relative[p[0]])t=ga(p[0]+p[1],h);else for(t=n.relative[p[0]]?[h]:k(p.shift(),h);p.length;){g=p.shift();if(n.relative[g])g+=p.shift(); 72 | t=ga(g,t)}else{if(!m&&p.length>1&&h.nodeType===9&&!M&&n.match.ID.test(p[0])&&!n.match.ID.test(p[p.length-1])){v=k.find(p.shift(),h,M);h=v.expr?k.filter(v.expr,v.set)[0]:v.set[0]}if(h){v=m?{expr:p.pop(),set:z(m)}:k.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=v.expr?k.filter(v.expr,v.set):v.set;if(p.length>0)y=z(t);else H=false;for(;p.length;){var D=p.pop();v=D;if(n.relative[D])v=p.pop();else D="";if(v==null)v=h;n.relative[D](y,v,M)}}else y=[]}y||(y=t);y||k.error(D|| 73 | g);if(j.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))l.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&l.push(t[g]);else l.push.apply(l,y);else z(y,l);if(S){k(S,q,l,m);k.uniqueSort(l)}return l};k.uniqueSort=function(g){if(B){i=o;g.sort(B);if(i)for(var h=1;h":function(g,h){var l=typeof h==="string";if(l&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,q=g.length;m=0))l||m.push(v);else if(l)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()}, 80 | CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,l,m,q,p){h=g[1].replace(/\\/g,"");if(!p&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,l,m,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,h);else{g=k.filter(g[3],h,l,true^q);l||m.push.apply(m, 81 | g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,l){return!!k(l[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)}, 82 | text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}}, 83 | setFilters:{first:function(g,h){return h===0},last:function(g,h,l,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,l){return hl[3]-0},nth:function(g,h,l){return l[3]-0===h},eq:function(g,h,l){return l[3]-0===h}},filter:{PSEUDO:function(g,h,l,m){var q=h[1],p=n.filters[q];if(p)return p(g,l,h,m);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h= 84 | h[3];l=0;for(m=h.length;l=0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var l=h[1];g=n.attrHandle[l]?n.attrHandle[l](g):g[l]!=null?g[l]:g.getAttribute(l);l=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m=== 86 | "="?l===h:m==="*="?l.indexOf(h)>=0:m==="~="?(" "+l+" ").indexOf(h)>=0:!h?l&&g!==false:m==="!="?l!==h:m==="^="?l.indexOf(h)===0:m==="$="?l.substr(l.length-h.length)===h:m==="|="?l===h||l.substr(0,h.length+1)===h+"-":false},POS:function(g,h,l,m){var q=n.setFilters[h[2]];if(q)return q(g,l,h,m)}}},r=n.match.POS;for(var u in n.match){n.match[u]=new RegExp(n.match[u].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[u]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[u].source.replace(/\\(\d+)/g,function(g, 87 | h){return"\\"+(h-0+1)}))}var z=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){z=function(g,h){h=h||[];if(j.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var l=0,m=g.length;l";var l=s.documentElement;l.insertBefore(g,l.firstChild);if(s.getElementById(h)){n.find.ID=function(m,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(m[1]))?q.id===m[1]||typeof q.getAttributeNode!=="undefined"&& 90 | q.getAttributeNode("id").nodeValue===m[1]?[q]:w:[]};n.filter.ID=function(m,q){var p=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&p&&p.nodeValue===q}}l.removeChild(g);l=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,l){l=l.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;l[m];m++)l[m].nodeType===1&&h.push(l[m]);l=h}return l};g.innerHTML=""; 91 | if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=k,h=s.createElement("div");h.innerHTML="

";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){k=function(m,q,p,v){q=q||s;if(!v&&q.nodeType===9&&!x(q))try{return z(q.querySelectorAll(m),p)}catch(t){}return g(m,q,p,v)};for(var l in g)k[l]=g[l];h=null}}(); 92 | (function(){var g=s.createElement("div");g.innerHTML="
";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}: 93 | function(g,h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ga=function(g,h){var l=[],m="",q;for(h=h.nodeType?[h]:h;q=n.match.PSEUDO.exec(g);){m+=q[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;q=0;for(var p=h.length;q=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f0)for(var j=d;j0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,j= 96 | {},i;if(f&&a.length){e=0;for(var o=a.length;e-1:c(f).is(e)){d.push({selector:i,elem:f});delete j[i]}}f=f.parentNode}}return d}var k=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,r){for(;r&&r.ownerDocument&&r!==b;){if(k?k.index(r)>-1:c(r).is(a))return r;r=r.parentNode}return null})},index:function(a){if(!a||typeof a=== 97 | "string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(qa(a[0])||qa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode", 98 | d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")? 99 | a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);eb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||gb.test(f))&&fb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||a.nodeType!==1||!c(a).is(d));){a.nodeType=== 100 | 1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ja=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ka=/(<([\w:]+)[^>]*?)\/>/g,hb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,La=/<([\w:]+)/,ib=/"},F={option:[1,""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div
","
"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d= 102 | c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this}, 103 | wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})}, 104 | prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b, 105 | this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,f;(f=this[d])!=null;d++)if(!a||c.filter(a,[f]).length){if(!b&&f.nodeType===1){c.cleanData(f.getElementsByTagName("*"));c.cleanData([f])}f.parentNode&&f.parentNode.removeChild(f)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild); 106 | return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ja,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ra(this,b);ra(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Ja, 107 | ""):null;else if(typeof a==="string"&&!ta.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(La.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ka,Ma);try{for(var b=0,d=this.length;b0||e.cacheable||this.length>1?k.cloneNode(true):k)}o.length&&c.each(o,Qa)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);var e=this.length===1&&this[0].parentNode;if(e&&e.nodeType===11&&e.childNodes.length===1&&d.length===1){d[b](this[0]); 111 | return this}else{e=0;for(var j=d.length;e0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),i);f=f.concat(i)}return this.pushStack(f,a,d.selector)}}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;for(var e=[],j=0,i;(i=a[j])!=null;j++){if(typeof i==="number")i+="";if(i){if(typeof i==="string"&&!jb.test(i))i=b.createTextNode(i);else if(typeof i==="string"){i=i.replace(Ka,Ma);var o=(La.exec(i)||["", 112 | ""])[1].toLowerCase(),k=F[o]||F._default,n=k[0],r=b.createElement("div");for(r.innerHTML=k[1]+i+k[2];n--;)r=r.lastChild;if(!c.support.tbody){n=ib.test(i);o=o==="table"&&!n?r.firstChild&&r.firstChild.childNodes:k[1]===""&&!n?r.childNodes:[];for(k=o.length-1;k>=0;--k)c.nodeName(o[k],"tbody")&&!o[k].childNodes.length&&o[k].parentNode.removeChild(o[k])}!c.support.leadingWhitespace&&V.test(i)&&r.insertBefore(b.createTextNode(V.exec(i)[0]),r.firstChild);i=r.childNodes}if(i.nodeType)e.push(i);else e= 113 | c.merge(e,i)}}if(d)for(j=0;e[j];j++)if(f&&c.nodeName(e[j],"script")&&(!e[j].type||e[j].type.toLowerCase()==="text/javascript"))f.push(e[j].parentNode?e[j].parentNode.removeChild(e[j]):e[j]);else{e[j].nodeType===1&&e.splice.apply(e,[j+1,0].concat(c.makeArray(e[j].getElementsByTagName("script"))));d.appendChild(e[j])}return e},cleanData:function(a){for(var b,d,f=c.cache,e=c.event.special,j=c.support.deleteExpando,i=0,o;(o=a[i])!=null;i++)if(d=o[c.expando]){b=f[d];if(b.events)for(var k in b.events)e[k]? 114 | c.event.remove(o,k):Ca(o,k,b.handle);if(j)delete o[c.expando];else o.removeAttribute&&o.removeAttribute(c.expando);delete f[d]}}});var kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,Na=/alpha\([^)]*\)/,Oa=/opacity=([^)]*)/,ha=/float/i,ia=/-([a-z])/ig,lb=/([A-Z])/g,mb=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob={position:"absolute",visibility:"hidden",display:"block"},pb=["Left","Right"],qb=["Top","Bottom"],rb=s.defaultView&&s.defaultView.getComputedStyle,Pa=c.support.cssFloat?"cssFloat":"styleFloat",ja= 115 | function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!kb.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter= 116 | Na.test(a)?a.replace(Na,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Oa.exec(f.filter)[1])/100+"":""}if(ha.test(b))b=Pa;b=b.replace(ia,ja);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,j=b==="width"?pb:qb;function i(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(j,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a, 117 | "border"+this+"Width",true))||0})}a.offsetWidth!==0?i():c.swap(a,ob,i);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Oa.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ha.test(b))b=Pa;if(!d&&e&&e[b])f=e[b];else if(rb){if(ha.test(b))b="float";b=b.replace(lb,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f= 118 | a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ia,ja);f=a.currentStyle[b]||a.currentStyle[d];if(!mb.test(f)&&nb.test(f)){b=e.left;var j=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=j}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b= 119 | a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var sb=J(),tb=//gi,ub=/select|textarea/i,vb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,N=/=\?(&|$)/,ka=/\?/,wb=/(\?|&)_=.*?(&|$)/,xb=/^(\w+:)?\/\/([^\/?#]+)/,yb=/%20/g,zb=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!== 120 | "string")return zb.call(this,a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);f="POST"}var j=this;c.ajax({url:a,type:f,dataType:"html",data:b,complete:function(i,o){if(o==="success"||o==="notmodified")j.html(e?c("
").append(i.responseText.replace(tb,"")).find(e):i.responseText);d&&j.each(d,[i.responseText,o,i])}});return this}, 121 | serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||ub.test(this.nodeName)||vb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), 122 | function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href, 123 | global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:A.XMLHttpRequest&&(A.location.protocol!=="file:"||!A.ActiveXObject)?function(){return new A.XMLHttpRequest}:function(){try{return new A.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&& 124 | e.success.call(k,o,i,x);e.global&&f("ajaxSuccess",[x,e])}function d(){e.complete&&e.complete.call(k,x,i);e.global&&f("ajaxComplete",[x,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}function f(q,p){(e.context?c(e.context):c.event).trigger(q,p)}var e=c.extend(true,{},c.ajaxSettings,a),j,i,o,k=a&&a.context||e,n=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,e.traditional);if(e.dataType==="jsonp"){if(n==="GET")N.test(e.url)||(e.url+=(ka.test(e.url)? 125 | "&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!N.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&N.test(e.data)||N.test(e.url))){j=e.jsonpCallback||"jsonp"+sb++;if(e.data)e.data=(e.data+"").replace(N,"="+j+"$1");e.url=e.url.replace(N,"="+j+"$1");e.dataType="script";A[j]=A[j]||function(q){o=q;b();d();A[j]=w;try{delete A[j]}catch(p){}z&&z.removeChild(C)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache=== 126 | false&&n==="GET"){var r=J(),u=e.url.replace(wb,"$1_="+r+"$2");e.url=u+(u===e.url?(ka.test(e.url)?"&":"?")+"_="+r:"")}if(e.data&&n==="GET")e.url+=(ka.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");r=(r=xb.exec(e.url))&&(r[1]&&r[1]!==location.protocol||r[2]!==location.host);if(e.dataType==="script"&&n==="GET"&&r){var z=s.getElementsByTagName("head")[0]||s.documentElement,C=s.createElement("script");C.src=e.url;if(e.scriptCharset)C.charset=e.scriptCharset;if(!j){var B= 127 | false;C.onload=C.onreadystatechange=function(){if(!B&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){B=true;b();d();C.onload=C.onreadystatechange=null;z&&C.parentNode&&z.removeChild(C)}}}z.insertBefore(C,z.firstChild);return w}var E=false,x=e.xhr();if(x){e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async);try{if(e.data||a&&a.contentType)x.setRequestHeader("Content-Type",e.contentType);if(e.ifModified){c.lastModified[e.url]&&x.setRequestHeader("If-Modified-Since", 128 | c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}r||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(ga){}if(e.beforeSend&&e.beforeSend.call(k,x,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");x.abort();return false}e.global&&f("ajaxSend",[x,e]);var g=x.onreadystatechange=function(q){if(!x||x.readyState===0||q==="abort"){E|| 129 | d();E=true;if(x)x.onreadystatechange=c.noop}else if(!E&&x&&(x.readyState===4||q==="timeout")){E=true;x.onreadystatechange=c.noop;i=q==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";var p;if(i==="success")try{o=c.httpData(x,e.dataType,e)}catch(v){i="parsererror";p=v}if(i==="success"||i==="notmodified")j||b();else c.handleError(e,x,i,p);d();q==="timeout"&&x.abort();if(e.async)x=null}};try{var h=x.abort;x.abort=function(){x&&h.call(x); 130 | g("abort")}}catch(l){}e.async&&e.timeout>0&&setTimeout(function(){x&&!E&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||a,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status=== 131 | 1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;e&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b=== 132 | "json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(i,o){if(c.isArray(o))c.each(o,function(k,n){b||/\[\]$/.test(i)?f(i,n):d(i+"["+(typeof n==="object"||c.isArray(n)?k:"")+"]",n)});else!b&&o!=null&&typeof o==="object"?c.each(o,function(k,n){d(i+"["+k+"]",n)}):f(i,o)}function f(i,o){o=c.isFunction(o)?o():o;e[e.length]=encodeURIComponent(i)+"="+encodeURIComponent(o)}var e=[];if(b===w)b=c.ajaxSettings.traditional; 133 | if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var j in a)d(j,a[j]);return e.join("&").replace(yb,"+")}});var la={},Ab=/toggle|show|hide/,Bb=/^([+-]=)?([\d+-.]+)(.*)$/,W,va=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a||a===0)return this.animate(K("show",3),a,b);else{a=0;for(b=this.length;a").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();la[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:K("show",1),slideUp:K("hide",1),slideToggle:K("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration=== 139 | "number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]|| 140 | c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(j){return e.step(j)}this.startTime=J();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start; 141 | this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!W)W=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=J(),d=true;if(a||b>=this.options.duration+this.startTime){this.now= 142 | this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem, 143 | e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b
"; 149 | a.insertBefore(b,a.firstChild);d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==j;a.removeChild(b); 150 | c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),j=parseInt(c.curCSS(a,"top",true),10)||0,i=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a, 151 | d,e);d={top:b.top-e.top+j,left:b.left-e.left+i};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top- 152 | f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||s.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],j;if(!e)return null;if(f!==w)return this.each(function(){if(j=wa(this))j.scrollTo(!a?f:c(j).scrollLeft(),a?f:c(j).scrollTop());else this[d]=f});else return(j=wa(e))?"pageXOffset"in j?j[a?"pageYOffset": 153 | "pageXOffset"]:c.support.boxModel&&j.document.documentElement[d]||j.document.body[d]:e[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;if(c.isFunction(f))return this.each(function(j){var i=c(this);i[d](f.call(this,j,i[d]()))});return"scrollTo"in 154 | e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===w?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});A.jQuery=A.$=c})(window); 155 | --------------------------------------------------------------------------------