// Copyright 2000-2007, Newsfutures, Inc. All Rights Reserved. // Confidential and Proprietary Information of Newsfutures, Inc. // %Z%%M%, %I%, %G% /* default init function does nothing */ function init() { } function doNothing() {} function handleUnload() {} function theTime() { var d = new Date(); var minutes = d.getMinutes(); if (minutes < 10) { minutes = "0" + d.getMinutes() +""; } document.write(d.getHours()+ ":" + minutes + " "); } function roundIt (num, d) { // rounds num to d digits and print to document document.write(new Number(num).toFixed(d)); } function roundTo (num, d) { // rounds num to d digits, and returns number return new Number(num).toFixed(d); } function roundPrint (num, dec) { var res = (dec > 1) ? (Math.round(num * dec) / dec) : Math.round(num); document.write(res); } function round (num, dec) { var res = (dec > 1) ? (Math.round(num * dec) / dec) : Math.round(num); return res; } function colorMsg (msg, color) { return msg ? msg.fontcolor(color) : msg; } function stayPut (delay) { // waits for milliseconds d = new Date() while (1) { mill = new Date() diff = mill-d if (diff > delay) {break;} } } function confirmDelete(f, what) { if (confirm("Are you sure you want to delete this "+what+"?")) { f.submit(); } } function confirmAction(f, what) { if (confirm("Are you sure you want to "+what+"?")) { f.submit(); } } function checkNum(f, name, what) { if (isNaN(parseInt(f.elements[name].value, 10))) { alert("Invalid "+what); } else { f.submit(); } } // This function sets the HTML block with id='name' to have the content 'value'. // It allows block content to be modified from an input object eventHandler // (eg.onChange="setBlockById('foo','weather is nice');") function setBlockById(name, value) { document.getElementById(name).innerHTML=value; } // converts a timestamp to iso date and/or time (yyyy-mm-dd hh:mm) function tsToIsoDateTime(ts, showDate, showTime) { var date = new Date(); date.setTime(ts); var res = ''; var x; if(showDate) { res += date.getFullYear() + '-'; x = date.getMonth() + 1; res += ((x < 10) ? ('0' + x) : x) + '-'; x = date.getDate(); res += ((x < 10) ? ('0' + x) : x); if(showTime) res += ' '; } if(showTime) { x = date.getHours(); res += ((x < 10) ? ('0' + x) : x) + ':'; x = date.getMinutes(); res += ((x < 10) ? ('0' + x) : x); } return res; } // parse a date yyyy-mm-dd[ hh:mm[:ss]] to a Date object // if there's a syntax error, return null function isoDateToTs(str) { try { str = trim(str); var dt = str.split(" "); if((dt.length < 1) || (dt.length > 2)) return null; var ymd = dt[0].split("-"); if(ymd.length != 3) { ymd = dt[0].split("/"); if(ymd.length != 3) return null; } if(ymd[0] < 1900) return null; var d = new Date(); d.setFullYear(ymd[0]); d.setMonth(ymd[1]-1); d.setDate(ymd[2]); if(dt.length == 2) { var hm = dt[1].split(":"); if((hm.length < 2) || (hm.length > 3)) return null; d.setHours(hm[0], hm[1], (hm.length == 3) ? hm[2] : 0, 0); } else { d.setTime(12 * 3600 * 1000); } return d.getTime(); } catch(err) { return null; } } // number of secs in a day var daySecs = 24 * 3600; // convert a number of millisecs into a time span function tsToTimeSpan(ts) { var res = ""; ts /= 1000; var days = Math.floor(ts / daySecs); var hours = Math.floor(ts / 3600) % 24; var mins = Math.floor(ts / 60) % 60; var secs = Math.floor(ts % 60); if(days > 0) { if(days > 1) { res = days + " days"; } else { res = "1 day"; if(hours > 0) res += " " + hours + " hour" + addPlural(hours); } } else if(ts < 60) { res = ts + " seconds"; } else { if(hours > 0) res = hours + " hour" + addPlural(hours); if(mins > 0) res += " " + mins + " minute" + addPlural(mins); if(ts < 300) res += " " + secs + " second(s)"; } return res; } function addPlural(n) { return (n > 1) ? "s" : ""; } // trim a string function trim(s) { var i = 0; while((i < s.length) && (s.charAt(i) <= ' ')) i++; if(i > 0) s = s.substr(i); i = s.length; while((i-- > 0) && (s.charAt(i) <= ' ')); s = s.substr(0,i+1); return s; } //////////////////////// // simple stringbuffer implementation //////////////////////// function StringBuffer() { this.buffer = []; } StringBuffer.prototype.append = function(string) { this.buffer.push(string); return this; } StringBuffer.prototype.toString = function() { return this.buffer.join(""); } //////////////////////// // Cookie handling //////////////////////// function setCookie(name,value,days) { if(!days) days = 100000; var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); document.cookie = name+"="+value+expires+"; path=/"; } function deleteCookie(name) { setCookie(name, "", -1); } function getCookie(name) { var res = ""; if(document.cookie.length> 0) { var start = document.cookie.indexOf(name + "=") if(start > -1) { start = start + name.length + 1; var end = document.cookie.indexOf( ";", start); if(end == -1) end = document.cookie.length; res = unescape(document.cookie.substring(start, end)); } } return res; } //////////////////////// // simple screen messaging system //////////////////////// function setMsg(msg) { document.getElementById('msgBox').innerHTML = msg; } function addMsg(msg) { document.getElementById('msgBox').innerHTML += msg; } function clearMsg(msg) { document.getElementById('msgBox').innerHTML = ""; } function hasMsg(msg) { document.getElementById('msgBox').innerHTML != ""; } // simple errors: for now popup msg function error(msg) { window.alert(msg); } //////////////////// // Highlight a DOM object temporarily by setting its background to red, // then progressively to white and finally transparent. //////////////////// function highlight(elId) { setTimeout("highlight0('" + elId + "',32)", 100); } function highlight0(elId, color) { var el = document.getElementById(elId); if(color >= 256) { el.style.backgroundColor = "transparent"; } else { el.style.backgroundColor = "#FF" + color.toString(16) + color.toString(16); setTimeout("highlight0('" + elId + "'," + (color+40) + ")", 100); } } /////////////////////////////// // Lookup words in the 'terms' dict and return or write the localized name. ////////////////////////////// var terms = {}; function writeTerm(term) { document.write(xlateTerm(term)); } function xlateTerm(term) { var c0 = term.charAt(0); var capitalize = (c0 >= 'A') && (c0 <= 'Z'); var s = terms[term.toLowerCase()]; if(s == null) return term; if(capitalize) s = s.substring(0,1).toUpperCase() + s.substring(1); return s; } //////////////////////////////////////////////////////////// function popProfile (login) { // Pops up a user's public profile var url = "/iehm/user/publicProfile.html?login=" + login + "&cSym=&format=pop"; window.open(url,'_blank','scrollbars=yes,status=no,width=500,height=500,top=50,left=50'); return false; } ////////////// Resizable IFRAME function genNFIFrameHTML(frameId, w, h, src) { var s = "[+] " + "[-]
" + "