diff options
author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-03-14 16:59:15 +0000 |
---|---|---|
committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-03-14 16:59:15 +0000 |
commit | c11f2158406332132f478cee1697e617a825dc93 (patch) | |
tree | a7fdb1e66d5363d4006d114a760ea619a551af82 | |
parent | 5e009a0ed6643f9af6016a4231fbcf5586def53b (diff) | |
download | zabbix-c11f2158406332132f478cee1697e617a825dc93.tar.gz zabbix-c11f2158406332132f478cee1697e617a825dc93.tar.xz zabbix-c11f2158406332132f478cee1697e617a825dc93.zip |
- [DEV-122] {beta} added time period to filter (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5494 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r-- | frontends/php/css.css | 1 | ||||
-rw-r--r-- | frontends/php/dashboard.php | 8 | ||||
-rw-r--r-- | frontends/php/events.php | 126 | ||||
-rw-r--r-- | frontends/php/include/classes/ccheckbox.inc.php | 1 | ||||
-rw-r--r-- | frontends/php/include/classes/ctextbox.inc.php | 1 | ||||
-rw-r--r-- | frontends/php/include/classes/cvar.inc.php | 2 | ||||
-rw-r--r-- | frontends/php/include/html.inc.php | 1 | ||||
-rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 2 | ||||
-rw-r--r-- | frontends/php/js/calendar.js | 807 | ||||
-rw-r--r-- | frontends/php/js/common.js | 71 | ||||
-rw-r--r-- | frontends/php/js/gmenu.js | 7 | ||||
-rw-r--r-- | frontends/php/styles/calendar.css | 113 | ||||
-rw-r--r-- | frontends/php/styles/div.css | 2 | ||||
-rw-r--r-- | frontends/php/styles/table.css | 6 |
14 files changed, 1084 insertions, 64 deletions
diff --git a/frontends/php/css.css b/frontends/php/css.css index cc068365..08e985b4 100644 --- a/frontends/php/css.css +++ b/frontends/php/css.css @@ -10,3 +10,4 @@ @import "styles/bar.css"; @import "styles/gmenu.css"; @import "styles/sbox.css"; +@import "styles/calendar.css"; diff --git a/frontends/php/dashboard.php b/frontends/php/dashboard.php index 69ba4daf..30dc2219 100644 --- a/frontends/php/dashboard.php +++ b/frontends/php/dashboard.php @@ -191,8 +191,8 @@ include_once "include/page_header.php"; show_table_header(array(S_DASHBOARD_BIG,SPACE),SPACE); $left_tab = new CTable(); - $left_tab->SetCellPadding(5); - $left_tab->SetCellSpacing(5); + $left_tab->SetCellPadding(3); + $left_tab->SetCellSpacing(3); $left_tab->AddOption('border',0); @@ -254,8 +254,8 @@ include_once "include/page_header.php"; $left_tab->AddRow(SPACE); $right_tab = new CTable(); - $right_tab->SetCellPadding(5); - $right_tab->SetCellSpacing(5); + $right_tab->SetCellPadding(3); + $right_tab->SetCellSpacing(3); $right_tab->AddOption('border',0); diff --git a/frontends/php/events.php b/frontends/php/events.php index 82ac00d3..06dd11c9 100644 --- a/frontends/php/events.php +++ b/frontends/php/events.php @@ -28,7 +28,7 @@ $page["title"] = "S_LATEST_EVENTS"; $page["file"] = "events.php"; $page['hist_arg'] = array('groupid','hostid'); - $page['scripts'] = array('url.js'); + $page['scripts'] = array('url.js','calendar.js'); define('ZBX_PAGE_DO_REFRESH', 1); @@ -45,15 +45,21 @@ include_once "include/page_header.php"; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields=array( "source"=> array(T_ZBX_INT, O_OPT, P_SYS, IN($allowed_sources), NULL), - "show_unknown"=> array(T_ZBX_INT, O_OPT, P_SYS, IN(array(0,1)), NULL), "groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL), "hostid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL), "triggerid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL), "start"=> array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0,65535)."({}%".PAGE_SIZE."==0)", NULL), "next"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), "prev"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), +// filter "filter_rst"=> array(T_ZBX_INT, O_OPT, P_SYS, IN(array(0,1)), NULL), "filter_set"=> array(T_ZBX_STR, O_OPT, P_SYS, null, NULL), + + "show_unknown"=> array(T_ZBX_INT, O_OPT, P_SYS, IN(array(0,1)), NULL), + + 'filter_timesince'=> array(T_ZBX_INT, O_OPT, P_UNSET_EMPTY, null, NULL), + 'filter_timetill'=> array(T_ZBX_INT, O_OPT, P_UNSET_EMPTY, null, NULL), + //ajax 'favobj'=> array(T_ZBX_STR, O_OPT, P_ACT, NULL, NULL), 'favid'=> array(T_ZBX_STR, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})'), @@ -61,22 +67,36 @@ include_once "include/page_header.php"; ); $_REQUEST['source'] = get_request('source', get_profile('web.events.source', 0)); - - check_fields($fields); - validate_sort_and_sortorder('e.eventid',ZBX_SORT_DOWN); + check_fields($fields); + validate_sort_and_sortorder('e.clock',ZBX_SORT_DOWN); // filter prepare if(isset($_REQUEST['filter_rst'])){ $_REQUEST['triggerid'] = 0; $_REQUEST['show_unknown'] = 0; + + $_REQUEST['filter_timesince'] = 0; + $_REQUEST['filter_timetill'] = 0; } - + $_REQUEST['triggerid'] = get_request('triggerid',get_profile('web.events.filter.triggerid',0)); $show_unknown = get_request('show_unknown',get_profile('web.events.filter.show_unknown',0)); - - if(isset($_REQUEST['filter_set'])){ + + $_REQUEST['filter_timesince'] = get_request('filter_timesince',get_profile('web.events.filter.timesince',0)); + $_REQUEST['filter_timetill'] = get_request('filter_timetill',get_profile('web.events.filter.timetill',0)); + + if(($_REQUEST['filter_timetill'] > 0) && ($_REQUEST['filter_timesince'] > $_REQUEST['filter_timetill'])){ + $tmp = $_REQUEST['filter_timesince']; + $_REQUEST['filter_timesince'] = $_REQUEST['filter_timetill']; + $_REQUEST['filter_timetill'] = $tmp; + } + + if(isset($_REQUEST['filter_set']) || isset($_REQUEST['filter_rst'])){ update_profile('web.events.filter.triggerid',$_REQUEST['triggerid']); update_profile('web.events.filter.show_unknown',$show_unknown); + + update_profile('web.events.filter.timesince',$_REQUEST['filter_timesince']); + update_profile('web.events.filter.timetill',$_REQUEST['filter_timetill']); } // -------------- @@ -247,10 +267,13 @@ include_once "include/page_header.php"; $trigger_list = '('.trim($trigger_list,',').')'; $sql_cond=($show_unknown == 0)?(' AND e.value<>'.TRIGGER_VALUE_UNKNOWN.' '):(''); + $sql_cond.=($_REQUEST['filter_timesince']>0)?' AND e.clock>'.$_REQUEST['filter_timesince']:' AND e.clock>100'; + $sql_cond.=($_REQUEST['filter_timetill']>0)?' AND e.clock<'.$_REQUEST['filter_timetill']:''; $table = new CTableInfo(S_NO_EVENTS_FOUND); $table->SetHeader(array( - make_sorting_link(S_TIME,'e.eventid'), +// make_sorting_link(S_TIME,'e.eventid'), + make_sorting_link(S_TIME,'e.clock'), is_show_subnodes() ? S_NODE : null, $_REQUEST["hostid"] == 0 ? S_HOST : null, S_DESCRIPTION, @@ -264,12 +287,11 @@ include_once "include/page_header.php"; if(!empty($triggers)){ $sql = 'SELECT e.eventid, e.objectid as triggerid, e.clock, e.value, e.acknowledged '. ' FROM events e '. - ' WHERE e.object='.EVENT_OBJECT_TRIGGER. + ' WHERE (e.object+0)='.EVENT_OBJECT_TRIGGER. ' AND e.objectid IN '.$trigger_list. $sql_cond. -// ' ORDER BY e.object DESC,e.objectid DESC,e.eventid DESC'; - order_by('e.eventid'); - + order_by('e.clock'); +//SDI($sql); $result = DBselect($sql,10*($_REQUEST['start']+PAGE_SIZE)); } @@ -422,22 +444,78 @@ include_once "include/page_header.php"; $next = new Clink('Next '.PAGE_SIZE, 'events.php?next=1'.url_param('start'),'styled'); } - $filterForm = new CFormTable(S_FILTER);//,'events.php?','POST',null,'sform'); + $filterForm = new CFormTable(S_FILTER);//,'events.php?filter_set=1','POST',null,'sform'); $filterForm->AddOption('name','zbx_filter'); $filterForm->AddOption('id','zbx_filter'); + $filterForm->SetMethod('get'); if(EVENT_SOURCE_TRIGGERS == $source){ -/* - $filterForm->AddRow(S_PERIOD,array( - S_FROM.SPACE, new CTextBox('filter_since_day','',2), - new CTextBox('filter_since_month','',2), - new CTextBox('filter_since_year','',4), - S_TILL.SPACE, new CTextBox('filter_till_day','',2), - new CTextBox('filter_till_month','',2), - new CTextBox('filter_till_year','',4), - )); -*/ + $script = new CScript("javascript: if(CLNDR['events_since'].clndr.setSDateFromOuterObj()){". + "$('filter_timesince').value = parseInt(CLNDR['events_since'].clndr.sdt.getTime()/1000);}". + "if(CLNDR['events_till'].clndr.setSDateFromOuterObj()){". + "$('filter_timetill').value = parseInt(CLNDR['events_till'].clndr.sdt.getTime()/1000);}" + ); + $filterForm->AddAction('onsubmit',$script); + + $filterForm->AddVar('filter_timesince',($_REQUEST['filter_timesince']>0)?$_REQUEST['filter_timesince']:''); + $filterForm->AddVar('filter_timetill',($_REQUEST['filter_timetill']>0)?$_REQUEST['filter_timetill']:''); +//* + $clndr_icon = new CImg('images/general/bar/cal.gif','calendar', 16, 12, null); + $clndr_icon->AddAction('onclick',"javascript: var pos = getPosition(this); pos.top+=10; pos.left+=16; CLNDR['events_since'].clndr.clndrshow(pos.top,pos.left);"); + + $filtertimetab = new CTable(); + $filtertimetab->AddOption('width','10%'); + $filtertimetab->SetCellPadding(0); + $filtertimetab->SetCellSpacing(0); +/* $filtertimetab->AddRow(array( + SPACE, + new CCol('D','center'), + new CCol('/','center'), + new CCol('M','center'), + new CCol('/','center'), + new CCol('Y','center'), + new CCol('H','center'), + new CCol(':','center'), + new CCol('M','center'), + SPACE + )); +*/ + $filtertimetab->AddRow(array( + S_FROM, + new CNumericBox('filter_since_day',(($_REQUEST['filter_timesince']>0)?date('d',$_REQUEST['filter_timesince']):''),2), + '/', + new CNumericBox('filter_since_month',(($_REQUEST['filter_timesince']>0)?date('m',$_REQUEST['filter_timesince']):''),2), + '/', + new CNumericBox('filter_since_year',(($_REQUEST['filter_timesince']>0)?date('Y',$_REQUEST['filter_timesince']):''),4), + new CNumericBox('filter_since_hour',(($_REQUEST['filter_timesince']>0)?date('H',$_REQUEST['filter_timesince']):''),2), + ':', + new CNumericBox('filter_since_minute',(($_REQUEST['filter_timesince']>0)?date('i',$_REQUEST['filter_timesince']):''),2), + $clndr_icon + )); + zbx_add_post_js('create_calendar(null,["filter_since_day","filter_since_month","filter_since_year","filter_since_hour","filter_since_minute"],"events_since");'); + + $clndr_icon->AddAction('onclick',"javascript: var pos = getPosition(this); pos.top+=10; pos.left+=16; CLNDR['events_till'].clndr.clndrshow(pos.top,pos.left);"); + $filtertimetab->AddRow(array( + S_TILL, + new CNumericBox('filter_till_day',(($_REQUEST['filter_timetill']>0)?date('d',$_REQUEST['filter_timetill']):''),2), + '/', + new CNumericBox('filter_till_month',(($_REQUEST['filter_timetill']>0)?date('m',$_REQUEST['filter_timetill']):''),2), + '/', + new CNumericBox('filter_till_year',(($_REQUEST['filter_timetill']>0)?date('Y',$_REQUEST['filter_timetill']):''),4), + new CNumericBox('filter_till_hour',(($_REQUEST['filter_timetill']>0)?date('H',$_REQUEST['filter_timetill']):''),2), + ':', + new CNumericBox('filter_till_minute',(($_REQUEST['filter_timetill']>0)?date('i',$_REQUEST['filter_timetill']):''),2), + $clndr_icon + )); + zbx_add_post_js('create_calendar(null,["filter_till_day","filter_till_month","filter_till_year","filter_till_hour","filter_till_minute"],"events_till");'); + + zbx_add_post_js('addListener($("filter_icon"),"click",CLNDR[\'events_since\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'events_since\'].clndr));'. + 'addListener($("filter_icon"),"click",CLNDR[\'events_till\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'events_till\'].clndr));' + ); + + $filterForm->AddRow(S_PERIOD, $filtertimetab); +//*/ $filterForm->AddVar('triggerid',$_REQUEST['triggerid']); if(isset($_REQUEST['triggerid']) && ($_REQUEST['triggerid']>0)){ diff --git a/frontends/php/include/classes/ccheckbox.inc.php b/frontends/php/include/classes/ccheckbox.inc.php index b22cb0ad..bed94b8a 100644 --- a/frontends/php/include/classes/ccheckbox.inc.php +++ b/frontends/php/include/classes/ccheckbox.inc.php @@ -29,6 +29,7 @@ $this->options['type'] = 'checkbox'; $this->options['value'] = $value; $this->options['name'] = $name; + $this->options['id'] = $name; $this->SetAction($action); $this->SetChecked($checked); } diff --git a/frontends/php/include/classes/ctextbox.inc.php b/frontends/php/include/classes/ctextbox.inc.php index a261f7dc..8c73648b 100644 --- a/frontends/php/include/classes/ctextbox.inc.php +++ b/frontends/php/include/classes/ctextbox.inc.php @@ -31,6 +31,7 @@ $this->tag_body_start = ''; $this->options['class'] = 'biginput'; $this->AddOption('name', $name); + $this->AddOption('id', $name); $this->AddOption('size', $size); $this->AddOption('value',$value); $this->SetReadonly($readonly); diff --git a/frontends/php/include/classes/cvar.inc.php b/frontends/php/include/classes/cvar.inc.php index 4d267ca3..d6e39fce 100644 --- a/frontends/php/include/classes/cvar.inc.php +++ b/frontends/php/include/classes/cvar.inc.php @@ -27,6 +27,8 @@ parent::CTag('input','no'); $this->options['type'] = 'hidden'; $this->options['name'] = $name; + $this->options['id'] = $name; + $this->SetValue($value); } function SetValue($value) diff --git a/frontends/php/include/html.inc.php b/frontends/php/include/html.inc.php index 37d5dfbf..a3c7ff08 100644 --- a/frontends/php/include/html.inc.php +++ b/frontends/php/include/html.inc.php @@ -161,6 +161,7 @@ $icon = new CDiv(SPACE,($state)?'filteropened':'filterclosed'); $icon->AddAction('onclick',new CScript("javascript: change_filter_state(this,'".$id."');")); $icon->AddOption('title',S_SHOW.'/'.S_HIDE.' '.S_FILTER); + $icon->AddAction('id','filter_icon'); $td_icon = new CCol($icon); $td_icon->AddOption('valign','bottom'); diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index f618aab1..e0b57341 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -1023,6 +1023,8 @@ 'S_PROBLEMS'=> 'Problems', 'S_PERCENTAGE'=> 'Percentage', 'S_SLA'=> 'SLA', + 'S_HOUR'=> 'Hour', + 'S_MINUTE'=> 'Minute', 'S_DAY'=> 'Day', 'S_MONTH'=> 'Month', 'S_YEAR'=> 'Year', diff --git a/frontends/php/js/calendar.js b/frontends/php/js/calendar.js new file mode 100644 index 00000000..16a320fd --- /dev/null +++ b/frontends/php/js/calendar.js @@ -0,0 +1,807 @@ +// JavaScript Document +/* +** ZABBIX +** Copyright (C) 2000-2008 SIA Zabbix +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +** +*/ + +// Title: calendar +// Author: Aly + +<!-- + +var CLNDR = new Array(); // calendar obj reference + +function create_calendar(time, objects, id){ + id = id || CLNDR.length; + + CLNDR[id] = new Object; + CLNDR[id].clndr = new calendar(time, objects); +} + +var calendar = Class.create(); + +calendar.prototype = { +dt: new Date(), //Date object on load time +cdt: new Date(), //Date object of current(viewed) date +sdt: new Date(), //Date object of a selected date + +//day: 1, //represents day number +month: 0, //represents month number +year: 2008, //represents year +day: 1, //represents days +hour: 12, //hours +minute: 00, //minutes + +timestamp: 0, //selected date in unix timestamp + +clndr_calendar: null, //html obj of calendar + +clndr_minute: null, //html from obj +clndr_hour: null, //html from obj +clndr_days: null, //html obj +clndr_month: null, //html obj +clndr_year: null, //html obj + +clndr_selectedday: null, //html obj, selected day + +clndr_monthup: null, //html bttn obj +clndr_monthdown: null, //html bttn obj +clndr_yearup: null, //html bttn obj +clndr_yeardown: null, //html bttn obj + +objects: new Array(), // object list where will be saved date +status: false, // status of objects + +visible: 0, //GMenu style state + +monthname: new Array('January','February','March','April','May','June','July','August','September','October','November','December'), // months + +initialize: function(stime, objects){ + + if(!(this.status=this.checkOuterObj(objects))){ + throw 'Calendar: constructor expects second parameter to be list of DOM nodes [d,M,Y,hh,i].'; + return false; + } + + this.calendarcreate(); + + addListener(this.clndr_monthdown,'click',this.monthdown.bindAsEventListener(this)); + addListener(this.clndr_monthup,'click',this.monthup.bindAsEventListener(this)); + + addListener(this.clndr_yeardown,'click',this.yeardown.bindAsEventListener(this)); + addListener(this.clndr_yearup,'click',this.yearup.bindAsEventListener(this)); + + addListener(this.clndr_hour,'blur',this.sethour.bindAsEventListener(this)); + addListener(this.clndr_minute,'blur',this.setminute.bindAsEventListener(this)); + + if(('undefined' != typeof(stime)) && !empty(stime)){ + this.sdt.setTime(stime*1000); + } + else{ + this.setSDateFromOuterObj(); + } + + this.cdt.setTime(this.sdt.getTime()); + this.cdt.setDate(1); + + this.syncBSDateBySDT(); + this.setCDate(); +}, + +ondateselected: function(){ // place any function; + this.setDateToOuterObj(); + this.clndrhide(); +}, + +clndrhide: function(e){ + if((typeof(e) != 'undefined')){ + cancelEvent(e); + } + + this.clndr_calendar.hide(); + this.visible = 0; +}, + +clndrshow: function(top,left){ + if(this.visible == 1){ + this.clndrhide(); + } + else{ + if(this.status){ + this.setSDateFromOuterObj(); + + this.cdt.setTime(this.sdt.getTime()); + this.cdt.setDate(1); + + this.syncBSDateBySDT(); + this.setCDate(); + } + + if(('undefined' != typeof(top)) && ('undefined' != typeof(left))){ + this.clndr_calendar.style.top = top + 'px'; + this.clndr_calendar.style.left = left + 'px'; + } + + this.clndr_calendar.show(); + this.visible = 1; + } +}, + +checkOuterObj: function(objects){ + if(('undefined' != typeof(objects)) && !empty(objects)){ + if(is_array(objects)){ + this.objects = objects; + } + else{ + this.objects.push(objects); + } + } + else{ + return false; + } + + for(var i=0; i < this.objects.length; i++){ + if(('undefined' != this.objects[i]) && !empty(this.objects[i])){ + this.objects[i] = $(this.objects[i]); + + if(empty(this.objects[i])) + return false; + } + } +return true; +}, + +setSDateFromOuterObj: function(){ + switch(this.objects.length){ + case 1: + var val = null; + var result = false; + + if(this.objects[0].tagName.toLowerCase() == 'input'){ + val = this.objects[0].value; + } + else{ + val = (IE)?this.objects[0].innerText:this.objects[0].textContent; + } + + if(is_string(val)){ + val = val.split('/'); + if(val.length == 3){ + result = this.setSDateDMY(val[0],val[1],val[2]); + } + } + + if(!result){ + return false; + } + + break; + case 3: + case 5: + var val = new Array(); + var result = true; + + for(var i=0; i < this.objects.length; i++){ + if(('undefined' != this.objects[i]) && !empty(this.objects[i])){ + if(this.objects[i].tagName.toLowerCase() == 'input'){ + val[i] = this.objects[i].value; + } + else{ + val[i] = (IE)?this.objects[i].innerText:this.objects[i].textContent; + } + } + else{ + result = false; + } + } + + if(result){ + result = this.setSDateDMY(val[0],val[1],val[2]); + + if(val.length>4){ + val[3] = parseInt(val[3]); + val[4] = parseInt(val[4]); + + if((val[3] > -1) && (val[3] < 24)){ + this.sdt.setHours(val[3]); + result = true; + } + + if((val[4] > -1) && (val[4] < 60)){ + this.sdt.setMinutes(val[4]); + result = true; + } + + } + } + + if(result){ + return true; + } + else{ + return false; + } + break; + default: + return false; + break; + } +}, + +setSDateDMY: function(d,m,y){ + d = parseInt(d); + m = parseInt(m); + y = parseInt(y); + + var result = false; + if((m > 0) && (m < 13)){ + this.sdt.setMonth(m-1); + result = true; + } + + if((y > 71) && (y < 1971)){ + this.sdt.setYear(y); + result = true; + } + + if((y > 1971) && (y < 10000)){ + this.sdt.setFullYear(y); + result = true; + } + + if((d>-1) && (d<29)){ + this.sdt.setDate(d); + result = true; + } + else if((d>28) && result){ + if(d <= this.daysInMonth(this.sdt.getMonth(), this.sdt.getYear())){ + this.sdt.setDate(d); + result = true; + } + } + +//alert(d+'/'+m+'/'+y+'/'+result); +//alert(this.sdt.getDate()+'/'+this.sdt.getMonth()+'/'+this.sdt.getFullYear()+'/'+result); +return result; +}, + +setDateToOuterObj: function(){ + switch(this.objects.length){ + case 1: + + if(this.objects[0].tagName.toLowerCase() == 'input'){ + this.objects[0].value = this.sdt.getDate()+'/'+(this.sdt.getMonth()+1)+'/'+this.sdt.getFullYear(); + } + else{ + if(IE) + this.objects[0].innerText = this.sdt.getDate()+'/'+(this.sdt.getMonth()+1)+'/'+this.sdt.getFullYear(); + else + this.objects[0].textContent = this.sdt.getDate()+'/'+(this.sdt.getMonth()+1)+'/'+this.sdt.getFullYear(); + } + break; + case 3: + case 5: +// Day + if(this.objects[0].tagName.toLowerCase() == 'input'){ + this.objects[0].value = this.sdt.getDate(); + } + else{ + if(IE) + this.objects[0].innerText = this.sdt.getDate(); + else + this.objects[0].textContent = this.sdt.getDate(); + } +// Month + if(this.objects[1].tagName.toLowerCase() == 'input'){ + this.objects[1].value = this.sdt.getMonth()+1; + } + else{ + if(IE) + this.objects[1].innerText = this.sdt.getMonth()+1; + else + this.objects[1].textContent = this.sdt.getMonth()+1; + } +// Year + if(this.objects[2].tagName.toLowerCase() == 'input'){ + this.objects[2].value = this.sdt.getFullYear(); + } + else{ + if(IE) + this.objects[2].innerText = this.sdt.getFullYear(); + else + this.objects[2].textContent = this.sdt.getFullYear(); + } + + if(this.objects.length > 4){ +// Hour + if(this.objects[3].tagName.toLowerCase() == 'input'){ + this.objects[3].value = this.sdt.getHours(); + } + else{ + if(IE) + this.objects[3].innerText = this.sdt.getHours(); + else + this.objects[3].textContent = this.sdt.getHours(); + } +// Minute + if(this.objects[4].tagName.toLowerCase() == 'input'){ + this.objects[4].value = this.sdt.getMinutes(); + } + else{ + if(IE) + this.objects[4].innerText = this.sdt.getMinutes(); + else + this.objects[4].textContent = this.sdt.getMinutes(); + } + } + break; + } +}, + +setminute: function(){ + var minute = parseInt(this.clndr_minute.value); + if((minute>-1) && (minute < 60)){ + this.minute = minute; + this.syncSDT(); + } + else{ + this.clndr_minute.value = this.minute; + } +}, + +sethour: function(){ + var hour = parseInt(this.clndr_hour.value); + if((hour>-1) && (hour < 24)){ + this.hour = hour; + this.syncSDT(); + } + else{ + this.clndr_hour.value = this.hour; + } +}, + +setday: function(e,day,month,year){ + + if(!is_null(this.clndr_selectedday)){ + this.clndr_selectedday.removeClassName('selected'); + } + + this.setSDT(day,month,year,this.hour,this.minute); + + var selectedday = Event.element(e); + Element.extend(selectedday); + + this.clndr_selectedday = selectedday; + this.clndr_selectedday.addClassName('selected'); + + this.ondateselected(); +}, + +monthup: function(){ +// var monthlastday = (this.day == this.daysInMonth(this.month,this.year)); + this.month++; + + if(this.month > 11){ + this.month = 0; + this.yearup(); + } + else{ + this.syncCDT(); + this.setCDate(); + } +}, + +monthdown: function(){ + + this.month--; + + if(this.month < 0){ + this.month = 11; + this.yeardown(); + } + else{ + this.syncCDT(); + this.setCDate(); + } +}, + +yearup: function(){ + + this.year++; + + this.syncCDT(); + this.setCDate(); +}, + +yeardown: function(){ + + if((this.year-1) < 1971){ // shouldn't be lower + return ; + } + + this.year--; + this.syncCDT(); + this.setCDate(); +}, + +setSDT: function(d,m,y,h,i){ + this.sdt.setMinutes(i); + this.sdt.setHours(h); + this.sdt.setDate(d); + this.sdt.setMonth(m); + this.sdt.setFullYear(y); +}, + +setCDT: function(d,m,y,h,i){ + this.cdt.setMinutes(i); + this.cdt.setHours(h); + this.cdt.setDate(d); + this.cdt.setMonth(m); + this.cdt.setFullYear(y); +}, + +syncBSDateBySDT: function(){ + this.minute = this.sdt.getMinutes(); + this.hour = this.sdt.getHours(); + this.day = this.sdt.getDate(); + this.month = this.sdt.getMonth(); + this.year = this.sdt.getFullYear(); +}, + +syncSDT: function(){ + this.setSDT(this.day,this.month,this.year,this.hour,this.minute); +}, + +syncCDT: function(){ + this.setCDT(1,this.month,this.year,this.hour,this.minute); +}, + +setCDate: function(){ + + this.clndr_minute.value = this.minute; + this.clndr_hour.value = this.hour; + + if(IE){ + this.clndr_month.innerText = this.monthname[this.month]; + this.clndr_year.innerText = this.year; + } + else{ + this.clndr_month.textContent = this.monthname[this.month]; + this.clndr_year.textContent = this.year; + } + + this.createDaysTab(); +}, + +daysInFeb: function(year){ + // February has 29 days in any year evenly divisible by four, + // EXCEPT for centurial years which are not also divisible by 400. + return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 ); +}, + +daysInMonth: function(m,y){ + m++; + var days = 31; + if (m==4 || m==6 || m==9 || m==11){ + days = 30; + } + else if(m==2){ + days = this.daysInFeb(y); + } + +return days; +}, + +// CALENDAR DAYS TAB + +createDaysTab: function(){ + + this.clndr_days.update(''); + + var table = document.createElement('table'); + this.clndr_days.appendChild(table); + + table.setAttribute('cellpadding','1'); + table.setAttribute('cellspacing','1'); + table.setAttribute('width','100%'); + table.className = 'calendartab'; + + var tbody = document.createElement('tbody'); + table.appendChild(tbody); + + var cur_month = this.cdt.getMonth(); + var prev_days = this.cdt.getDay(); + if(prev_days > 0){ + this.cdt.setTime(this.cdt.getTime() - (prev_days*86400000)); + } + + for(var y=0; y < 6; y++){ + + var tr = document.createElement('tr'); + tbody.appendChild(tr); + + for(var x=0; x < 7; x++){ + + var td = document.createElement('td'); + tr.appendChild(td); + + Element.extend(td); + + if(x > 4) td.className = 'hollyday'; + if(cur_month != this.cdt.getMonth()){ + td.addClassName('grey'); + } + + if( (this.sdt.getFullYear() == this.cdt.getFullYear()) && + (this.sdt.getMonth() == this.cdt.getMonth()) && + (this.sdt.getDate() == this.cdt.getDate())) + { + td.addClassName('selected'); + this.clndr_selectedday = td; + } + + addListener(td,'click',this.setday.bindAsEventListener(this,this.cdt.getDate(),this.cdt.getMonth(),this.cdt.getFullYear())); + + td.appendChild(document.createTextNode(this.cdt.getDate())); + + this.cdt.setTime(this.cdt.getTime() + (86400000)); // + 1day + } + } +}, + +/*-------------------------------------------------------------------------------------------------*\ +* CALENDAR CREATION * +\*-------------------------------------------------------------------------------------------------*/ +calendarcreate: function(){ + this.clndr_calendar = document.createElement('div'); + document.body.appendChild(this.clndr_calendar); + + Element.extend(this.clndr_calendar); + this.clndr_calendar.className = 'calendar'; + this.clndr_calendar.setStyle({display: 'none'}); + + addListener(this.clndr_calendar,'mousemove', deselectAll); + + //*********** CALENDAR HAT ****************************** + var line_div = document.createElement('div'); + this.clndr_calendar.appendChild(line_div); + + var table = document.createElement('table'); + line_div.appendChild(table); + +// table.setAttribute('border','1'); + table.setAttribute('cellpadding','2'); + table.setAttribute('cellspacing','0'); + table.setAttribute('width','100%'); + table.className = 'calendarhat'; + // YEAR + + var tbody = document.createElement('tbody'); + table.appendChild(tbody); + + var tr = document.createElement('tr'); + tbody.appendChild(tr); + + var td = document.createElement('td'); + tr.appendChild(td); + + this.clndr_yeardown = document.createElement('span'); + td.appendChild(this.clndr_yeardown); + + this.clndr_yeardown.className = 'clndr_left_arrow'; + + this.clndr_yeardown.appendChild(document.createTextNode('«')); + + var td = document.createElement('td'); + tr.appendChild(td); + + td.className = 'long'; + + this.clndr_year = document.createElement('span'); + td.appendChild(this.clndr_year); + + this.clndr_year.className = 'title'; + this.clndr_year.appendChild(document.createTextNode('2008')); + + var td = document.createElement('td'); + tr.appendChild(td); + + this.clndr_yearup = document.createElement('span'); + td.appendChild(this.clndr_yearup); + + this.clndr_yearup.className = 'clndr_right_arrow'; + + this.clndr_yearup.appendChild(document.createTextNode('»')); + + // MONTH + + var tr = document.createElement('tr'); + tbody.appendChild(tr); + + var td = document.createElement('td'); + tr.appendChild(td); + + this.clndr_monthdown = document.createElement('span'); + td.appendChild(this.clndr_monthdown); + + this.clndr_monthdown.className = 'clndr_left_arrow'; + + this.clndr_monthdown.appendChild(document.createTextNode('«')); + + var td = document.createElement('td'); + tr.appendChild(td); + + td.className = 'long'; + + this.clndr_month = document.createElement('span'); + td.appendChild(this.clndr_month); + + this.clndr_month.className = 'title'; + this.clndr_month.appendChild(document.createTextNode('March')); + + var td = document.createElement('td'); + tr.appendChild(td); + + this.clndr_monthup = document.createElement('span'); + td.appendChild(this.clndr_monthup); + + this.clndr_monthup.className = 'clndr_right_arrow'; + + this.clndr_monthup.appendChild(document.createTextNode('»')); + + // DAYS heading + var table = document.createElement('table'); + line_div.appendChild(table); + + table.setAttribute('cellpadding','2'); + table.setAttribute('cellspacing','0'); + table.setAttribute('width','100%'); + table.className = 'calendarhat'; + + var tbody = document.createElement('tbody'); + table.appendChild(tbody); + + var tr = document.createElement('tr'); + tbody.appendChild(tr); + + tr.className='header'; + + var td = document.createElement('td'); + tr.appendChild(td); + td.appendChild(document.createTextNode('M')); + + var td = document.createElement('td'); + tr.appendChild(td); + td.appendChild(document.createTextNode('T')); + + var td = document.createElement('td'); + tr.appendChild(td); + td.appendChild(document.createTextNode('W')); + + var td = document.createElement('td'); + tr.appendChild(td); + td.appendChild(document.createTextNode('T')); + + var td = document.createElement('td'); + tr.appendChild(td); + td.appendChild(document.createTextNode('F')); + + var td = document.createElement('td'); + tr.appendChild(td); + td.appendChild(document.createTextNode('S')); + + var td = document.createElement('td'); + tr.appendChild(td); + td.appendChild(document.createTextNode('S')); + //****************************************************** + + //******** DAYS CALENDAR ************* + this.clndr_days = document.createElement('div'); + Element.extend(this.clndr_days); + + this.clndr_calendar.appendChild(this.clndr_days); + + this.clndr_days.className = 'calendardays'; + + //************************************************ + + // TIME INPUT + + var line_div = document.createElement('div'); + this.clndr_calendar.appendChild(line_div); + + line_div.className = 'calendartime'; + + this.clndr_hour = document.createElement('input'); + line_div.appendChild(this.clndr_hour); + + this.clndr_hour.setAttribute('type','text'); + this.clndr_hour.setAttribute('name','hour'); + this.clndr_hour.setAttribute('value','hh'); + this.clndr_hour.setAttribute('maxlength','2'); + this.clndr_hour.className = 'calendar_textbox'; + + line_div.appendChild(document.createTextNode(' : ')); + + this.clndr_minute = document.createElement('input'); + line_div.appendChild(this.clndr_minute); + + this.clndr_minute.setAttribute('type','text'); + this.clndr_minute.setAttribute('name','minute'); + this.clndr_minute.setAttribute('value','mm'); + this.clndr_minute.setAttribute('maxlength','2'); + this.clndr_minute.className = 'calendar_textbox'; +} +} + + +/* +<!-- +<div class="calendar" onmousemove="javascript: deselectAll();"> +<div> + <table border="0" cellpadding="2" cellspacing="0" class="calendarhat" width="100%"> + <tbody> + <tr> + <td><span>«</span></td> + <td width="90%"><span class="title">2008</span></td> + <td><span>»</span></td> + </tr> + <tr> + <td><span>«</span></td> + <td><span class="title">September</span></td> + <td><span>»</span></td> + </tr> + </tbody> + </table> + + <table border="0" cellpadding="2" cellspacing="0" class="calendarhat" width="100%"> + <tbody> + <tr class="header"> + <td>M</td> + <td>T</td> + <td>W</td> + <td>T</td> + <td>F</td> + <td>S</td> + <td>S</td> + </tr> + </tbody> + </table> +</div> +<div class="calendardays"> +<table border="0" cellpadding="1" cellspacing="1" class="calendartab"> +<tbody> +<tr> + <td class="grey">30</td> + <td>1</td> + <td>2</td> + <td>3</td> + <td>4</td> + <td class="hollyday">5</td> + <td class="hollyday">6</td> +</tr> +</tbody> +</table> +</div> +<div class="calendartime"> + <input type="text" name="hour" value="hh" maxlength="2" class="calendar_textbox" /> : + <input type="text" name="minute" value="mm" maxlength="2" class="calendar_textbox" /> +</div> +</div> +--> +*/
\ No newline at end of file diff --git a/frontends/php/js/common.js b/frontends/php/js/common.js index 63c8cd1d..9d7d859c 100644 --- a/frontends/php/js/common.js +++ b/frontends/php/js/common.js @@ -54,13 +54,8 @@ function is_string(obj){ } function is_array(obj) { - if(obj.constructor == Array) - return true; - - if(obj.constructor.toString().indexOf("Array") == -1) - return false; - else - return true; + return obj != null && typeof obj == "object" && + 'splice' in obj && 'join' in obj; } if (!Array.prototype.forEach) @@ -172,32 +167,43 @@ function rm4favorites(favobj,favid,menu_rowid){ // json.onetime('dashboard.php?output=json&'+Object.toQueryString(params)); } -function get_scroll_pos() -{ +function getPosition(obj){ + var pos = {top: 0, left: 0}; + if(typeof(obj.offsetParent) != 'undefined') { + pos.left = obj.offsetLeft; + pos.top = obj.offsetTop; + while (obj = obj.offsetParent) { + pos.left += obj.offsetLeft; + pos.top += obj.offsetTop; + } + } +return pos; +} + +function get_scroll_pos(){ var scrOfX = 0, scrOfY = 0; - if( typeof( window.pageYOffset ) == 'number' ) - { //Netscape compliant +//Netscape compliant + if( typeof( window.pageYOffset ) == 'number' ){ scrOfY = window.pageYOffset; scrOfX = window.pageXOffset; } - else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) - { //DOM compliant +//DOM compliant + else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ){ scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft; } - else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) - { //IE6 standards compliant mode +//IE6 standards compliant mode + else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ){ scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft; } return [ scrOfX, scrOfY ]; } -function get_cursor_position(e) -{ +function get_cursor_position(e){ e = e || window.event; var cursor = {x:0, y:0}; - if (e.pageX || e.pageY) { + if(e.pageX || e.pageY){ cursor.x = e.pageX; cursor.y = e.pageY; } @@ -285,7 +291,10 @@ function ShowHide(obj,style){ var style = 'inline'; if(is_string(obj)) obj = document.getElementById(obj); - if(!obj) return false; + if(!obj){ + throw 'ShowHide(): Object not foun.'; + return false; + } if(obj.style.display != 'none'){ obj.style.display = 'none'; @@ -356,17 +365,19 @@ function openWinCentered(loc, winname, iwidth, iheight, params){ WinObjReferer.focus(); } -function getPosition(obj){ - var pos = {top: 0, left: 0}; - if(typeof(obj.offsetParent) != 'undefined') { - pos.left = obj.offsetLeft; - pos.top = obj.offsetTop; - while (obj = obj.offsetParent) { - pos.left += obj.offsetLeft; - pos.top += obj.offsetTop; - } - } -return pos; + +function addListener(element, eventname, expression, bubbling){ + bubbling = bubbling || false; + + if(window.addEventListener) { + element.addEventListener(eventname, expression, bubbling); + return true; + } + else if(window.attachEvent) { + element.attachEvent('on'+eventname, expression); + return true; + } + else return false; } function cancelEvent(e){ diff --git a/frontends/php/js/gmenu.js b/frontends/php/js/gmenu.js index 25621c05..5f074fab 100644 --- a/frontends/php/js/gmenu.js +++ b/frontends/php/js/gmenu.js @@ -285,10 +285,11 @@ minuteup: function(){ hourup: function(){ var hourinsec = 3600; + if((this.bstime+hourinsec+1+this.period)>=parseInt(this.dt.getTime()/1000)){ // max date is date when script has been loaded if((this.period - hourinsec) < this.period_min){ if(((this.dt.getTime()/1000) - (this.bstime+hourinsec)) < this.period_min) return; - this.period = ((this.dt.getTime()/1000) - (this.bstime+hourinsec)); + this.period = parseInt((this.dt.getTime()/1000) - (this.bstime+hourinsec)); } else{ this.period-=hourinsec; @@ -320,7 +321,7 @@ dayup: function(){ if((this.period - dayinsec) < this.period_min){ if(((this.dt.getTime()/1000) - (this.bstime+dayinsec)) < this.period_min) return; - this.period = ((this.dt.getTime()/1000) - (this.bstime+dayinsec)); + this.period = parseInt((this.dt.getTime()/1000) - (this.bstime+dayinsec)); } else{ this.period-=dayinsec; @@ -352,7 +353,7 @@ monthup: function(){ if((this.period - monthinsec) < this.period_min){ if(((this.dt.getTime()/1000) - (this.bstime+monthinsec)) < this.period_min) return; - this.period = ((this.dt.getTime()/1000) - (this.bstime+monthinsec)); + this.period = parseInt((this.dt.getTime()/1000) - (this.bstime+monthinsec)); } else{ this.period-=monthinsec; diff --git a/frontends/php/styles/calendar.css b/frontends/php/styles/calendar.css new file mode 100644 index 00000000..946e8a9d --- /dev/null +++ b/frontends/php/styles/calendar.css @@ -0,0 +1,113 @@ +/* CSS Document */ + +div.calendar{ + position: absolute; + width: 180px; + top: 10px; + right: 30px; + border: 1px blue solid; +} + +div.calendardays{ + border: 1px orange solid; +} + +div.calendartime{ + background-color: #DDEEFF; + text-align: center; + padding-top: 2px; + padding-bottom: 2px; +} + +table.calendarhat{ + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 11px; + text-align: center; + background-color:#DDEEFF; + font-weight: bold; +} + +table.calendarhat tr td{ + height: 18px; + width: 22px; +} + +table.calendarhat tr td.long{ + text-align:center; + width: 116px; + overflow: hidden; +} + +/* CELLS */ +table.calendartab{ + font-family:Verdana, Arial, Helvetica, sans-serif; + font-size: 11px; + text-align: center; + background-color:#EEEEEE; + border-spacing: 1px; +} + +table.calendartab tr.header td:hover{ + cursor:default; +} + +table.calendartab tr td{ + height: 18px; + width: 22px; + background-color:#FFFFFF; +} + +table.calendartab tr td:hover{ + cursor: pointer; +} + +table.calendartab tr td.hollyday{ + background-color:#AADDEE; +} + +table.calendartab tr td.grey{ + color:#AFAFAF; +} + +table.calendartab tr td.selected{ +/* + border-left: 1px #333333 groove; + border-top: 1px #333333 groove; +*/ + background-color: #008888; + color: #eeeeee; +} + +/* SPAN */ + +span.title{ + text-align:center; + color:#000099; +} + +span.clndr_left_arrow{ + padding-left: 5px; +} + +span.clndr_left_arrow:hover{ + cursor: pointer; +} + +span.clndr_right_arrow{ + padding-right: 5px; +} + +span.clndr_right_arrow:hover{ + cursor: pointer; +} + +/* INPUT */ + +input.calendar_textbox{ + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 11px; + text-align: center; + width: 26px; + height: 14px; + vertical-align:middle; +}
\ No newline at end of file diff --git a/frontends/php/styles/div.css b/frontends/php/styles/div.css index d2d23173..43d53029 100644 --- a/frontends/php/styles/div.css +++ b/frontends/php/styles/div.css @@ -107,7 +107,7 @@ div.filteropened{ background-repeat:no-repeat; } -div.filteropened:hover{ +div.filteropened:hover{ cursor:pointer; } diff --git a/frontends/php/styles/table.css b/frontends/php/styles/table.css index 896211c3..3134d19c 100644 --- a/frontends/php/styles/table.css +++ b/frontends/php/styles/table.css @@ -18,11 +18,13 @@ table.nowrap tr td { td,tr { font-family:Verdana, Arial, Helvetica, sans-serif; - font-size:8pt; + font-size: 8pt; text-decoration: none; } -td.center { text-align: center; } +td.center{ + text-align: center; +} /**************** PAGE TABLE ****************/ /* header */ |