File: common.js

package info (click to toggle)
lurker 2.1-7
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,800 kB
  • ctags: 1,088
  • sloc: cpp: 10,527; sh: 1,348; xml: 1,278; perl: 206; makefile: 198
file content (109 lines) | stat: -rw-r--r-- 2,144 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
var oldClass = "";

function rollOut(thisItem)
{
	thisItem.className = oldClass;
}

function rollIn(thisItem)
{
	oldClass = thisItem.className;
	thisItem.className = "rowover";
}

function twostr(num)
{
	var out = '';
	if (num < 10) out += '0';
	out += num.toString();
	return out;
}

function textdate(utc)
{
	var d = new Date(utc*1000);
	var s = d.getFullYear().toString()
		+ '-' + twostr(d.getMonth()+1)
		+ '-' + twostr(d.getDate())
		+ '&#160;' + twostr(d.getHours()) // don't wrap text
		+ ':' + twostr(d.getMinutes());
	document.write(s);
}

function titledate(thisItem, utc)
{
	var d = new Date(utc*1000);
	var s = thisItem.getAttribute('title');
	s =	s.substring(0, s.length-16)
		+ d.getFullYear().toString()
		+ '-' + twostr(d.getMonth()+1)
		+ '-' + twostr(d.getDate())
		+ ' ' + twostr(d.getHours()) // nbsp in titles is bad
		+ ':' + twostr(d.getMinutes());
	
	thisItem.setAttribute('title', s);
}

function timezone(utc)
{
	var d = new Date(utc*1000); // sadly the offset depends on the date
	var o = d.getTimezoneOffset(); // minutes, + = west

	var s = '';
	if (o < 0)
	{
		s += '+'; 
		o = 0 - o;
	}
	else	s += '-';
	
	var h = o / 60;
	var m = o % 60;
	s += h.toString() + twostr(m);
	document.write(s);
}

function form_timezone(form)
{
	var d = new Date(0);
	d.setSeconds(form.sec.value);
	d.setMinutes(form.min.value);
	d.setHours(form.hour.value);
	d.setDate(form.mday.value);
	d.setMonth(form.mon.value-1);
	d.setFullYear(form.year.value);
	form.utc.value = d.valueOf() / 1000;
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function trash(kill)
{
	if (readCookie('lurker-pass') == null)
	{
		var pass = prompt('Enter the admin password to confirm deletion');
		if (pass != null)
		{
			document.cookie = "lurker-pass="+escape(pass)+"; path=/";
			self.location = kill;
		}
	}
	else
	{
		if (confirm('Really delete this message?'))
		{
			self.location = kill;
		}
	}
}