/* StoryBoard(tm) Engine v1.0 */ /* Copyright Christopher Adams (c) 2010 */ /* All rights reserved. */ /* November 14, 2010 */ function dumpProps(obj, parent) { // Go through all the properties of the passed-in object for (var i in obj) { // if a parent (2nd parameter) was passed in, then use that to // build the message. Message includes i (the object's property name) // then the object's property value on a new line if (parent) { var msg = parent + "." + i + "\n" + obj[i]; } else { var msg = i + "\n" + obj[i]; } // Display the message. If the user clicks "OK", then continue. If they // click "CANCEL" then quit this level of recursion if (!confirm(msg)) { return; } // If this property (i) is an object, then recursively process the object if (typeof obj[i] == "object") { if (parent) { dumpProps(obj[i], parent + "." + i); } else { dumpProps(obj[i], i); } } } } function set_cookie( name, value ) { // thanks to http://techpatterns.com/downloads/javascript_cookies.php var expires = 7; var path = ''; var domain = document.domain; var secure = ''; // set time, it's in milliseconds var today = new Date(); today.setTime( today.getTime() ); /* if the expires variable is set, make the correct expires time, the current script below will set it for x number of days, to make it for hours, delete * 24, for minutes, delete * 60 * 24 */ if ( expires ) { expires = expires * 1000 * 60 * 60 * 24; } var expires_date = new Date( today.getTime() + (expires) ); document.cookie = name + "=" +escape( value ) + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + ( ( path ) ? ";path=" + path : "" ) + ( ( domain ) ? ";domain=" + domain : "" ) + ( ( secure ) ? ";secure" : "" ); } function delete_cookie( name ) { var path = ''; var domain = 'christopheradams.net'; if ( get_cookie( name ) ) document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; } function get_cookie( check_name ) { // first we'll split this cookie up into name/value pairs // note: document.cookie only returns name=value, not the other components var a_all_cookies = document.cookie.split( ';' ); var a_temp_cookie = ''; var cookie_name = ''; var cookie_value = ''; var b_cookie_found = false; // set boolean t/f default f for ( i = 0; i < a_all_cookies.length; i++ ) { // now we'll split apart each name=value pair a_temp_cookie = a_all_cookies[i].split( '=' ); // and trim left/right whitespace while we're at it cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, ''); // if the extracted name matches passed check_name if ( cookie_name == check_name ) { b_cookie_found = true; // we need to handle case where cookie has no value but exists (no = sign, that is): if ( a_temp_cookie.length > 1 ) { cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') ); } // note that in cases where cookie is initialized but no value, null is returned return cookie_value; break; } a_temp_cookie = null; cookie_name = ''; } if ( !b_cookie_found ) { return null; } } var server_ctime = "Thu Feb 23 06:02:51 2012"; function get_nice_date(datetime) { // alert("get_nice_date("+datetime+")"); var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var d = new Date(datetime); // calculate server difference in time with local time var server_time = new Date(server_ctime); var diff = server_time - new Date(); //console.log("server_ctime = " + server_ctime); //console.log("diff = " + diff + " ms"); //console.log("diff/1000/60/60 = " + diff/1000/60/60 + " hrs"); //console.log("d (before) = " + d); //d = new Date(d - 1000*60*60*5);//fix time server problems, assuming everyone is EST d = new Date(d - diff); //console.log("typeof diff = " + typeof diff); //console.log("d (after) = " + d); var thedate = d.getDate(); var themonth = d.getMonth(); var theyear = d.getFullYear(); var now = new Date(); var outp = ""; if (now - d < 60*1000) { // one minute outp = "under a minute ago" } else if (now - d < 60*60*1000) { // one hour outp = parseInt((now - d) / 60 / 1000) + " minute(s) ago"; } else if (now - d < 24*60*60*1000) { // one day outp = parseInt((now - d) / 60 / 60 / 1000) + " hour(s) ago"; } else if (now - d < 7*24*60*60*1000) { // one week outp = parseInt((now - d) / 24 / 60 / 60 / 1000) + " day(s) ago"; } else if (now - d < (14*24*60*60*1000)) { // two weeks outp = "one week ago"; } else if (now - d < (31*24*60*60*1000)) { // one month outp = parseInt((now - d) / 7 / 24 / 60 / 60 / 1000) + " weeks ago"; } else if (d.getFullYear() == now.getFullYear()) { // one year outp = m_names[themonth] + " " + thedate; } else { // more than one year outp = m_names[themonth] + " " + thedate + ", " + theyear; } return outp; }