[WTF CVS] wtf/static tracking.js,1.15,1.16
Brought to you by:
gryphonshafer
From: Gryphon S. <gry...@us...> - 2007-03-21 21:59:39
|
Update of /cvsroot/wtf-tracker/wtf/static In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv6944/static Modified Files: tracking.js Log Message: Feature add 1591668: Remember Last-Open Projects Group Index: tracking.js =================================================================== RCS file: /cvsroot/wtf-tracker/wtf/static/tracking.js,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** tracking.js 21 Mar 2007 18:30:16 -0000 1.15 --- tracking.js 21 Mar 2007 21:59:33 -0000 1.16 *************** *** 28,31 **** --- 28,43 ---- } } + + // if the page is the projects iframe, open any codelines + // that were previously open based on cookie data stored + if ( document.getElementById("open_projects_h4") ) { + var openCodelines = new Array(); + var cookie = getCookie("wtf_open_codelines"); + if (cookie) openCodelines = cookie.split(","); + + for ( var i in openCodelines ) { + expandCodelines( openCodelines[i], 1 ); + } + } } *************** *** 509,521 **** // expand/contract of specific codeline projects ! function expandCodelines( codeline_id, codeline_id_link ) { ! var codelineStyle = document.getElementById(codeline_id).style; // to open a codeline... ! if (codelineStyle.display == "none") { ! document.getElementById(codeline_id_link).className = "codeline_current"; // Internet Explorer requires display="block" whereas all good browsers understand "table" codelineStyle.display = ( document.all ) ? "block" : "table"; } --- 521,539 ---- // expand/contract of specific codeline projects ! function expandCodelines( id, noCookieWrite ) { ! var codelineStyle = document.getElementById( "codeline_" + id ).style; ! var openCodelines = new Array(); ! var cookie = getCookie("wtf_open_codelines"); ! if (cookie) openCodelines = cookie.split(","); // to open a codeline... ! if ( codelineStyle.display == "none" ) { ! document.getElementById( "codeline_" + id + "_link" ).className = "codeline_current"; // Internet Explorer requires display="block" whereas all good browsers understand "table" codelineStyle.display = ( document.all ) ? "block" : "table"; + + // add this codeline id to the list of open codelines + openCodelines.push(id); } *************** *** 523,528 **** else if ( codelineStyle.display == "block" || codelineStyle.display == "table" ) { codelineStyle.display = "none"; ! document.getElementById(codeline_id_link).className = "codeline_nav"; } } --- 541,558 ---- else if ( codelineStyle.display == "block" || codelineStyle.display == "table" ) { codelineStyle.display = "none"; ! document.getElementById( "codeline_" + id + "_link" ).className = "codeline_nav"; ! ! // remove instance of this codeline id from open codelines array ! for ( var i in openCodelines ) { ! if ( openCodelines[i] == id ) openCodelines.splice( i, 1 ); ! } } + + // set a cookie reprenting the open codeline ids + if ( ! noCookieWrite ) setCookie( + "wtf_open_codelines", + openCodelines.join(","), + new Date("October 25, 2073 03:15:00") + ); } *************** *** 671,676 **** "time from " + startDate + " through " + endDate + "?" ) ) { ! document.location.href = urlPath + ! "?date_start=" + startDate + "&date_end=" + endDate + "&action=delete"; } } --- 701,730 ---- "time from " + startDate + " through " + endDate + "?" ) ) { ! document.location.href = ! urlPath + "?date_start=" + startDate + "&date_end=" + endDate + "&action=delete"; } } + + function setCookie( name, value, expires, path, domain, secure ) { + var curCookie = name + "=" + escape(value) + + ( (expires) ? "; expires=" + expires.toGMTString() : "" ) + + ( (path) ? "; path=" + path : "" ) + + ( (domain) ? "; domain=" + domain : "" ) + + ( (secure) ? "; secure" : "" ); + document.cookie = curCookie; + } + + function getCookie(name) { + var dc = document.cookie; + var prefix = name + "="; + var begin = dc.indexOf( "; " + prefix ); + + if ( begin == -1 ) { + begin = dc.indexOf(prefix); + if (begin != 0) return null; + } else begin += 2; + + var end = document.cookie.indexOf( ";", begin ); + if ( end == -1 ) end = dc.length; + return unescape( dc.substring( begin + prefix.length, end ) ); + } |