pandorafms/pandora_console/include/javascript/jquery.countdown.js

7 lines
6.3 KiB
JavaScript
Raw Normal View History

2008-06-26 Esteban Sanchez <estebans@artica.es> * ajax.php: Sed id_user in config array. * godmode/menu.php, general/header.php, operation/menu.php: Replaced lang_label with lang_string(). * general/logon_ok.php: Reduced one indentation level. * godmode/agentes/agent_manager.php: Replaced lang_label with lang_string(). Use pandora functions. * include/functions_html.php, godmode/agentes/configurar_agente.php: Tab and blankspaces style correction. * godmode/reporting/map_builder.php: Complete rewritten to provide an intuitive way of build the maps. It's cool, useful and very simple. * godmode/reporting/reporting_builder.php: Deleted an output debug. * godmode/setup/setup.php: Rewritten to use pandora functions. Added a colorpicker for color settings. * include/config.php: Reset pandora password. We must solve things with this file... * include/functions.php: Check if input is an array on safe_input(). Use filename as id in array returned by list_files(). * include/functions_db.php: Renamed return_coordinate_* functions. Style correction. * include/javascript/jquery.js: Updated to 1.2.6. * include/javascript/jquery.ui.datepicker.js: Code minimized. * include/javascript/pandora.js: Style correction. * include/javascript/wz_jsgraphics.js: Added a class to the elements of a line, so it can be modified using javascript. * /include/styles/pandora.css: Added style to some tables dropdowns. Added new styles relative to visual map editor. * operation/reporting/reporting_viewer.php: Style correction. Added jQuery UI. * operation/visual_console/index.php: Use Pandora functions. * operation/visual_console/render_view.php: Drawing the map is now on functions_visual_map.php. Added a countdown if a refresh time is set. Use pandora functions. Style correction. * reporting/fgraph.php: Style correction. Use graphic_error() if there's no data on grafico_modulo_sparse(). * images/trash.png: Added to repository. Image used on trash area on visual map editor. * images/console/background/africa.jpg, images/console/background/asia.jpg, images/console/background/europe.jpg, images/console/background/north_america.jpg, images/console/background/oceania.jpg, images/console/background/shouth_america.jpg, images/console/background/world.jpg: Added to repository. Useful and cool map backgrounds. * include/functions_visual_map.php: Added to repository. Implements visual map functions like drawing the map. * include/javascript/jquery.colorpicker.js: Added to repository. Implements a color picker widget. * /include/javascript/jquery.countdown.js: Added to repository. Implements a countdown widget. * include/javascript/jquery.ui.core.js: Added to repository. jQuery UI core. * include/javascript/jquery.ui.draggable.js: Added to repository. jQuery draggable plugin. * include/javascript/jquery.ui.droppable.js: Added to repository. jQuery droppable plugin. * include/javascript/pandora_visual_console.js: Added to repository. Function useful to visual map interface. * include/languages/countdown_*.js: Added to repository. Countdown localization. * include/languages/date_es_la.js, include/languages/date_gl.js, include/languages/time_es_la.js, include/languages/time_gl.js: Added to repository. Missing localizations. * include/styles/color-picker.css: Added to repository. Colorpicker style sheet. * include/styles/countdown.css: Added to repository. Countdown style sheet. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@899 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-26 15:26:48 +02:00
/* http://keith-wood.name/countdown.html
Countdown for jQuery v1.2.2.
Written by Keith Wood (kbwood@virginbroadband.com.au) January 2008.
Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and
MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses.
Please attribute the author if you use it. */
(function($){function Countdown(){this._nextId=0;this._inst=[];this.regional=[];this.regional['']={labels:['Years','Months','Weeks','Days','Hours','Minutes','Seconds'],labelsSingle:['Year','Month','Week','Day','Hour','Minute','Second'],compactLabels:['y','m','w','d'],compactLabelsSingle:['y','m','w','d'],timeSeparator:':'};this._defaults={format:'dHMS',compact:false,description:'',expiryUrl:null,alwaysExpire:false,onExpiry:null,onTick:null,serverTime:null};$.extend(this._defaults,this.regional[''])}$.extend(Countdown.prototype,{markerClassName:'hasCountdown',_register:function(a){var b=this._nextId++;this._inst[b]=a;return b},_getInst:function(a){return this._inst[a]||a},setDefaults:function(a){extendRemove(this._defaults,a||{})},_attachCountdown:function(a,b){a=$(a);if(a.is('.'+this.markerClassName)){return}a.addClass(this.markerClassName);a[0]._cdnId=b._id;b._target=a;this._updateCountdown(b._id)},_updateCountdown:function(a){var b=this._getInst(a);b._target.html(b._generateHTML());var c=b._get('onTick');if(c){c.apply(b._target[0],[b._periods])}var d=(b._since?b._now.getTime()<=b._since.getTime():b._now.getTime()>=b._until.getTime());if(d){if(b._timer||b._get('alwaysExpire')){var e=b._get('onExpiry');if(e){e.apply(b._target[0],[])}var f=b._get('expiryUrl');if(f){window.location=f}}b._timer=null}else{var g=b._get('format');b._timer=setTimeout('$.countdown._updateCountdown('+b._id+')',(g.match('s|S')?1:(g.match('m|M')?30:600))*980)}},_changeCountdown:function(a,b){var c=this._getInst(a._cdnId);if(c){extendRemove(c._settings,b||{});c._adjustSettings();this._updateCountdown(c._id)}},_destroyCountdown:function(a){a=$(a);if(!a.is('.'+this.markerClassName)){return}a.removeClass(this.markerClassName);a.empty();clearTimeout(this._inst[a[0]._cdnId]._timer);this._inst[a[0]._cdnId]=null;a[0]._cdnId=undefined}});var Y=0;var O=1;var W=2;var D=3;var H=4;var M=5;var S=6;function CountdownInstance(a){this._id=$.countdown._register(this);this._target=null;this._timer=null;this._now=null;this._periods=[0,0,0,0,0,0,0];this._settings=extendRemove({},a||{});this._adjustSettings()}$.extend(CountdownInstance.prototype,{_get:function(a){return(this._settings[a]!=null?this._settings[a]:$.countdown._defaults[a])},_adjustSettings:function(){var a=new Date();var b=this._get('serverTime');this._offset=(b?b.getTime()-a.getTime():0);this._since=this._get('since');if(this._since){this._since=this._determineTime(this._since,null);this._since.setMilliseconds(0)}this._until=this._determineTime(this._get('until'),a);this._until.setMilliseconds(0)},_determineTime:function(k,l){var m=function(a){var b=new Date();b.setTime(b.getTime()+a*1000);return b};var n=function(a,b){return 32-new Date(a,b,32).getDate()};var o=function(a){var b=new Date();var c=b.getFullYear();var d=b.getMonth();var e=b.getDate();var f=b.getHours();var g=b.getMinutes();var h=b.getSeconds();var i=/([+-]?[0-9]+)\s*(s|S|m|M|h|H|d|D|w|W|o|O|y|Y)?/g;var j=i.exec(a);while(j){switch(j[2]||'s'){case's':case'S':h+=parseInt(j[1]);break;case'm':case'M':g+=parseInt(j[1]);break;case'h':case'H':f+=parseInt(j[1]);break;case'd':case'D':e+=parseInt(j[1]);break;case'w':case'W':e+=parseInt(j[1])*7;break;case'o':case'O':d+=parseInt(j[1]);e=Math.min(e,n(c,d));break;case'y':case'Y':c+=parseInt(j[1]);e=Math.min(e,n(c,d));break}j=i.exec(a)}b=new Date(c,d,e,f,g,h,0);return b};return(k==null?l:(typeof k=='string'?o(k):(typeof k=='number'?m(k):k)))},_generateHTML:function(){var b=this._get('format');var c=[];c[Y]=(b.match('y')?'?':(b.match('Y')?'!':null));c[O]=(b.match('o')?'?':(b.match('O')?'!':null));c[W]=(b.match('w')?'?':(b.match('W')?'!':null));c[D]=(b.match('d')?'?':(b.match('D')?'!':null));c[H]=(b.match('h')?'?':(b.match('H')?'!':null));c[M]=(b.match('m')?'?':(b.match('M')?'!':null));c[S]=(b.match('s')?'?':(b.match('S')?'!':null));this._periods=periods=this._calculatePeriods(c,new Date());var d=false;var e=0;for(var f=0;f<c.length;f++){d|=(c[f]=='?'&&periods[f]>0);c[f]=(c[f]=='?'&&!d?null:c[f]);e+=(c[f]?1:0)}var g=this._get('compact');var h=(g?this._get('compactLabels'):this._get('labels'));var i=(g?this.