Author: michiel
Date: 2010-03-19 16:55:44 +0100 (Fri, 19 Mar 2010)
New Revision: 41542
Modified:
mmbase/trunk/applications/vpro-wizards/src/main/webapp/mmbase/vpro-wizards/system/javascript/calendar/clock.js
Log:
propertly indented. Avoid NPE's
Modified:
mmbase/trunk/applications/vpro-wizards/src/main/webapp/mmbase/vpro-wizards/system/javascript/calendar/clock.js
===================================================================
---
mmbase/trunk/applications/vpro-wizards/src/main/webapp/mmbase/vpro-wizards/system/javascript/calendar/clock.js
2010-03-19 14:49:13 UTC (rev 41541)
+++
mmbase/trunk/applications/vpro-wizards/src/main/webapp/mmbase/vpro-wizards/system/javascript/calendar/clock.js
2010-03-19 15:55:44 UTC (rev 41542)
@@ -1,118 +1,120 @@
// Copyright 2006 Edwin Martin <[email protected]>
var clock = {
-currentId: false,
-timer: null,
-onchange: null,
-mouseover: false,
-create: function(min) {
- var ul = document.createElement("ul");
- ul.id = "clock";
- ul.onmouseover = clock.onMouseover;
- ul.onmouseout = clock.onMouseover;
- for (i=0; i < 24; i++) {
- for (m = 0; m < 60; m += min) {
- var li = document.createElement("li");
- ms = m < 10 ? "0"+m : m;
-// li.appendChild(document.createTextNode(i+":"+ms+":00"));
- li.appendChild(document.createTextNode(i+":"+ms));
- li.onclick = clock.onClick;
- li.onmouseover = clock.highlight;
- li.onmouseout = clock.highlight;
- ul.appendChild(li);
+ currentId: false,
+ timer: null,
+ onchange: null,
+ mouseover: false,
+ create: function(min) {
+ var ul = document.createElement("ul");
+ ul.id = "clock";
+ ul.onmouseover = clock.onMouseover;
+ ul.onmouseout = clock.onMouseover;
+ for (i=0; i < 24; i++) {
+ for (m = 0; m < 60; m += min) {
+ var li = document.createElement("li");
+ ms = m < 10 ? "0"+m : m;
+ //
li.appendChild(document.createTextNode(i+":"+ms+":00"));
+ li.appendChild(document.createTextNode(i+":"+ms));
+ li.onclick = clock.onClick;
+ li.onmouseover = clock.highlight;
+ li.onmouseout = clock.highlight;
+ ul.appendChild(li);
+ }
}
- }
- document.body.appendChild(ul);
-},
-attach: function(id) {
- var element = document.getElementById(id);
- element.onfocus = clock.fieldFocus;
- element.onblur = clock.fieldFocus;
-},
-fieldFocus: function(evt) {
- var event = evt || window.event;
- var element = event.target || event.srcElement;
- clock.clockFocus = event.type == "focus";
- if (clock.clockFocus)
- clock.show(element.id);
- else if (!clock.mouseover)
+ document.body.appendChild(ul);
+ },
+ attach: function(id) {
+ var element = document.getElementById(id);
+ if (clock != null && element != null) {
+ element.onfocus = clock.fieldFocus;
+ element.onblur = clock.fieldFocus;
+ }
+ },
+ fieldFocus: function(evt) {
+ var event = evt || window.event;
+ var element = event.target || event.srcElement;
+ clock.clockFocus = event.type == "focus";
+ if (clock.clockFocus)
+ clock.show(element.id);
+ else if (!clock.mouseover)
clock.hide();
-},
-show: function(field) {
- clock.disablePulldowns()
- var cal = document.getElementById("clock");
- var f = document.getElementById(field);
- cal.style.top = (clock.getTop(f)+f.offsetHeight)+'px'
- cal.style.left = (clock.getLeft(f))+'px';
- cal.style.width = f.offsetWidth+'px'
- cal.style.visibility = "visible";
- clock.currentId = field;
-},
-hide: function() {
- document.getElementById("clock").style.visibility = "hidden";
- clock.enablePulldowns()
- clock.currentId = false;
-},
-onMouseover: function(evt) {
- var event = evt || window.event;
- clock.mouseover = event.type == "mouseover";
- if (!clock.clockFocus)
- if (clock.mouseover)
- clearTimeout(clock.timer);
+ },
+ show: function(field) {
+ clock.disablePulldowns()
+ var cal = document.getElementById("clock");
+ var f = document.getElementById(field);
+ cal.style.top = (clock.getTop(f)+f.offsetHeight)+'px';
+ cal.style.left = (clock.getLeft(f))+'px';
+ cal.style.width = f.offsetWidth+'px';
+ cal.style.visibility = "visible";
+ clock.currentId = field;
+ },
+ hide: function() {
+ document.getElementById("clock").style.visibility = "hidden";
+ clock.enablePulldowns();
+ clock.currentId = false;
+ },
+ onMouseover: function(evt) {
+ var event = evt || window.event;
+ clock.mouseover = event.type == "mouseover";
+ if (!clock.clockFocus)
+ if (clock.mouseover)
+ clearTimeout(clock.timer);
else
clock.timer = setTimeout("clock.hide()", 100);
-},
-onClick: function(evt) {
- var event = evt || window.event;
- var elt = event.target || event.srcElement;
- document.getElementById(clock.currentId).value = elt.firstChild.nodeValue;
- document.getElementById("clock").style.visibility = "hidden";
- clock.enablePulldowns()
- clock.currentId = false;
- if(calendar.onclick)
- calendar.onclick();
-},
-highlight: function(evt) {
- var event = evt || window.event;
- var elt = event.target || event.srcElement;
- if (event.type == "mouseover") {
- elt.className = "highlight";
- } else {
- elt.className = "";
+ },
+ onClick: function(evt) {
+ var event = evt || window.event;
+ var elt = event.target || event.srcElement;
+ document.getElementById(clock.currentId).value =
elt.firstChild.nodeValue;
+ document.getElementById("clock").style.visibility = "hidden";
+ clock.enablePulldowns();
+ clock.currentId = false;
+ if(calendar.onclick)
+ calendar.onclick();
+ },
+ highlight: function(evt) {
+ var event = evt || window.event;
+ var elt = event.target || event.srcElement;
+ if (event.type == "mouseover") {
+ elt.className = "highlight";
+ } else {
+ elt.className = "";
+ }
+ },
+ getTop: function(obj) {
+ var top = 0;
+ do {
+ top += obj.offsetTop;
+ } while (obj = obj.offsetParent);
+ return top;
+ },
+ getLeft: function(obj) {
+ var left = 0;
+ do {
+ left += obj.offsetLeft;
+ } while (obj = obj.offsetParent);
+ return left;
+ },
+ disablePulldowns: function() {
+ /*
+ if (/MSIE/.exec(navigator.userAgent) &&
parseInt(navigator.appVersion) <= 6) {
+ var pd = document.getElementsByTagName('select');
+ for (var i=0; i<pd.length; i++)
+ if (pd[i].id != 'monthinput')
+ pd[i].style.visibility = 'hidden';
+ }
+ */
+ },
+ enablePulldowns: function() {
+ /*
+ if (/MSIE/.exec(navigator.userAgent) &&
parseInt(navigator.appVersion) <= 6) {
+ var pd = document.getElementsByTagName('select');
+ for (var i=0; i<pd.length; i++)
+ if (pd[i].id != 'monthinput')
+ pd[i].style.visibility = 'visible';
+ }
+ */
}
-},
-getTop: function(obj) {
- var top = 0;
- do {
- top += obj.offsetTop;
- } while (obj = obj.offsetParent);
- return top;
-},
-getLeft: function(obj) {
- var left = 0;
- do {
- left += obj.offsetLeft;
- } while (obj = obj.offsetParent);
- return left;
-},
-disablePulldowns: function() {
-/*
- if (/MSIE/.exec(navigator.userAgent) && parseInt(navigator.appVersion) <=
6) {
- var pd = document.getElementsByTagName('select');
- for (var i=0; i<pd.length; i++)
- if (pd[i].id != 'monthinput')
- pd[i].style.visibility = 'hidden';
- }
- */
-},
-enablePulldowns: function() {
-/*
- if (/MSIE/.exec(navigator.userAgent) && parseInt(navigator.appVersion) <=
6) {
- var pd = document.getElementsByTagName('select');
- for (var i=0; i<pd.length; i++)
- if (pd[i].id != 'monthinput')
- pd[i].style.visibility = 'visible';
- }
- */
-}
}
\ No newline at end of file
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs