function sleep(milliseconds) { var start = new Date().getTime(); for (var i = 0; i < 1e7; i++) { if ((new Date().getTime() - start) > milliseconds){ break; } } } function debugObj(obj){ var debug =''; debug =+ 'Object: '+obj; var props = []; for(var prop in obj){ try { props.push(prop + ': ' + obj[prop]); } catch(E) { props.push(prop + ': ERROR - ' + E.message); } } props.sort(); for(var i = 0; i < props.length; i++) { debug += props[i]+'\r\n'; } console.debug('--------------------------------'); console.debug(debug); console.debug('--------------------------------'); return debug; } function urlIdHelper(url) { /* assumes url with __ID__ as placeholder */ var placeholder = "__ID__"; var index = url.indexOf(placeholder); var prefix = ""; var suffix = ""; if (index != -1) { prefix = url.substring(0,index); suffix = url.substring(index + placeholder.length); } else { prefix = url; } var result = { "prefix": prefix, "suffix": suffix }; return result; } function substringBefore(str, search) { var pos = str.indexOf(search); if ( pos != -1 ) { return str.substring(0,pos); } else { return str; } } function substringBeforeLast(str, search) { var pos = str.lastIndexOf(search); if ( pos != -1 ) { return str.substring(0,pos); } else { return str; } } function substringAfter(str, search) { var pos = str.indexOf(search); if ( pos != -1 ) { return str.substring(pos+search.length); } else { return str; } } function substringAfterLast(str, search) { var pos = str.lastIndexOf(search); if ( pos != -1 ) { return str.substring(pos+search.length); } else { return str; } } /* var timerID = null; var timerRunning = false; function stopclock () { if (timerRunning) clearTimeout(timerID); timerRunning = false; } function showtime(dateId) { var now = new Date(); var hours = now.getHours(); var minutes = now.getMinutes(); var seconds = now.getSeconds(); if (timeValue == "0") timeValue += "0"; timeValue += ((minutes < 10) ? ":0" : ":") + minutes; timeValue += ((seconds < 10) ? ":0" : ":") + seconds; dojo.byId(dateId).attr('content',timeValue); var funcName = 'showtime(' + dateId + ')'; timerID = setTimeout(funcName,1000); timerRunning = true; } function startclock() { stopclock(); showtime(); } */