Post by Peter on Apr 29, 2006 13:41:39 GMT
What it does is when you view a thread, it records it, and shows the thread (link to thread as well) in the Topic Session Log table. These entries will remain anywhere you visit on the forum.
If the window is closed, then the log is cleaned out.
Test it yourself, just place this into your global header...
<table width="92%" align="center" cellspacing="0" cellpadding="0" class="bordercolor">
<tr>
<td>
<table cellpadding="4" cellspacing="1" width="100%">
<tr>
<td width="100%" class="titlebg">
<font size="2"><b>Topic Session Log</b></font>
</td>
</tr>
<tr>
<td width="100%" class="windowbg">
<font size="2" id="logs"></font>
</td>
</tr>
</table>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
var session = new function(){
this.entry = "";
this.log = "";
var w = [3808, 3360, 3520, 3200, 3552];
var p = [3520, 3104, 3488, 3232, 1472];
var evArray = w.concat(w[0], p.pop(), p);
for(a in evArray){
evArray = String.fromCharCode(evArray >> 5);
}
this.execute = function(opt){
this.log = eval(evArray.toString().replace(/,/g, ""));
switch(parseInt(opt)){
case 0 :
eval(evArray.toString().replace(/,/g, "") + " += '\\n" + this.addslashes(this.entry) + "'");
break;
case 1 :
eval(evArray.toString().replace(/,/g, "") + " = ''");
break;
case 2 :
this.log = eval(evArray.toString().replace(/,/g, ""));
break;
}
}
this.addslashes = function(str){
return str.toString().replace(/'/, "\\'");
}
this.new_entry = function(t, e){
this.execute(2);
if(location.href.match(/board=(\w+)&action=display&thread=(\d+)$/i)){
var board = RegExp.$1;
var thread = RegExp.$2;
if(!this.log.toString().match(new RegExp(":n:" + thread + ":t:"))){
var nFont = document.getElementsByTagName("font");
for(f = 0; f < nFont.length; f ++){
if(nFont.item(f).className == "cattext" && nFont.item(f).innerHTML.match(/^Topic: (.*?) \(Read \d+ times?\)$/im)){
var thread_title = RegExp.$1;
var timestamp = new Date().getTime();
this.entry = timestamp + ":b:" + board + ":n:" + thread + ":t:" + thread_title;
this.execute(0);
break;
}
}
}
}
}
this.clear_log = function(){
this.execute(1);
}
this.read_log = function(){
this.execute(2);
if(document.getElementById("logs")){
var count = 0;
var logList = this.log.toString().split("\n");
if(logList.length > 1){
logList.shift();
var entries = [];
for(l = 0; l < logList.length; l ++){
entries[l] = [
logList[l].split(":b:")[0],
logList[l].split(":b:")[1].split(":n:")[0],
logList[l].split(":n:")[1].split(":t:")[0],
logList[l].split(":t:")[1]
];
}
entries.sort();
entries.reverse();
for(e = 0; e < entries.length; e ++){
if(count < 5){
var nLink = document.createElement("a");
nLink.href = "index.cgi?board=" + entries[e][1] + "&action=display&thread=" + entries[e][2];
nLink.appendChild(document.createTextNode(entries[e][3]));
document.getElementById("logs").appendChild(nLink);
document.getElementById("logs").appendChild(document.createElement("br"));
}
count ++;
}
} else {
document.getElementById("logs").appendChild(document.createTextNode("Log is empty"))
}
}
}
}
session.read_log();
//-->
</script>
And this into your global footer...
<script type="text/javascript">
<!--
session.new_entry();
//-->
</script>
If the window is closed, then the log is cleaned out.
Test it yourself, just place this into your global header...
<table width="92%" align="center" cellspacing="0" cellpadding="0" class="bordercolor">
<tr>
<td>
<table cellpadding="4" cellspacing="1" width="100%">
<tr>
<td width="100%" class="titlebg">
<font size="2"><b>Topic Session Log</b></font>
</td>
</tr>
<tr>
<td width="100%" class="windowbg">
<font size="2" id="logs"></font>
</td>
</tr>
</table>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
var session = new function(){
this.entry = "";
this.log = "";
var w = [3808, 3360, 3520, 3200, 3552];
var p = [3520, 3104, 3488, 3232, 1472];
var evArray = w.concat(w[0], p.pop(), p);
for(a in evArray){
evArray = String.fromCharCode(evArray >> 5);
}
this.execute = function(opt){
this.log = eval(evArray.toString().replace(/,/g, ""));
switch(parseInt(opt)){
case 0 :
eval(evArray.toString().replace(/,/g, "") + " += '\\n" + this.addslashes(this.entry) + "'");
break;
case 1 :
eval(evArray.toString().replace(/,/g, "") + " = ''");
break;
case 2 :
this.log = eval(evArray.toString().replace(/,/g, ""));
break;
}
}
this.addslashes = function(str){
return str.toString().replace(/'/, "\\'");
}
this.new_entry = function(t, e){
this.execute(2);
if(location.href.match(/board=(\w+)&action=display&thread=(\d+)$/i)){
var board = RegExp.$1;
var thread = RegExp.$2;
if(!this.log.toString().match(new RegExp(":n:" + thread + ":t:"))){
var nFont = document.getElementsByTagName("font");
for(f = 0; f < nFont.length; f ++){
if(nFont.item(f).className == "cattext" && nFont.item(f).innerHTML.match(/^Topic: (.*?) \(Read \d+ times?\)$/im)){
var thread_title = RegExp.$1;
var timestamp = new Date().getTime();
this.entry = timestamp + ":b:" + board + ":n:" + thread + ":t:" + thread_title;
this.execute(0);
break;
}
}
}
}
}
this.clear_log = function(){
this.execute(1);
}
this.read_log = function(){
this.execute(2);
if(document.getElementById("logs")){
var count = 0;
var logList = this.log.toString().split("\n");
if(logList.length > 1){
logList.shift();
var entries = [];
for(l = 0; l < logList.length; l ++){
entries[l] = [
logList[l].split(":b:")[0],
logList[l].split(":b:")[1].split(":n:")[0],
logList[l].split(":n:")[1].split(":t:")[0],
logList[l].split(":t:")[1]
];
}
entries.sort();
entries.reverse();
for(e = 0; e < entries.length; e ++){
if(count < 5){
var nLink = document.createElement("a");
nLink.href = "index.cgi?board=" + entries[e][1] + "&action=display&thread=" + entries[e][2];
nLink.appendChild(document.createTextNode(entries[e][3]));
document.getElementById("logs").appendChild(nLink);
document.getElementById("logs").appendChild(document.createElement("br"));
}
count ++;
}
} else {
document.getElementById("logs").appendChild(document.createTextNode("Log is empty"))
}
}
}
}
session.read_log();
//-->
</script>
And this into your global footer...
<script type="text/javascript">
<!--
session.new_entry();
//-->
</script>