init
This commit is contained in:
110
livejournal/htdocs/js/browserdetect.js
Executable file
110
livejournal/htdocs/js/browserdetect.js
Executable file
@@ -0,0 +1,110 @@
|
||||
// Browser Detect Lite v2.1.4
|
||||
// http://www.dithered.com/javascript/browser_detect/index.html
|
||||
// modified by Chris Nott (chris@NOSPAMdithered.com - remove NOSPAM)
|
||||
// Modified further to detect rich text support
|
||||
|
||||
function BrowserDetectLite() {
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
|
||||
// browser name
|
||||
this.isGecko = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
|
||||
this.isMozilla = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
|
||||
this.isNS = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
|
||||
this.isIE = ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) );
|
||||
this.isSafari = (ua.indexOf('safari') != - 1);
|
||||
this.isOpera = (ua.indexOf('opera') != -1);
|
||||
this.isKonqueror = (ua.indexOf('konqueror') != -1 && !this.isSafari);
|
||||
this.isIcab = (ua.indexOf('icab') != -1);
|
||||
this.isAol = (ua.indexOf('aol') != -1);
|
||||
this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);
|
||||
|
||||
// spoofing and compatible browsers
|
||||
this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
|
||||
this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
|
||||
|
||||
// browser version
|
||||
this.versionMinor = parseFloat(navigator.appVersion);
|
||||
|
||||
// correct version number
|
||||
if (this.isNS && this.isGecko) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
|
||||
}
|
||||
else if (this.isIE && this.versionMinor >= 4) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
|
||||
}
|
||||
else if (this.isMozilla) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
|
||||
}
|
||||
else if (this.isSafari) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
|
||||
}
|
||||
else if (this.isOpera) {
|
||||
if (ua.indexOf('opera/') != -1) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) );
|
||||
}
|
||||
else {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) );
|
||||
}
|
||||
}
|
||||
else if (this.isKonqueror) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
|
||||
}
|
||||
else if (this.isIcab) {
|
||||
if (ua.indexOf('icab/') != -1) {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) );
|
||||
}
|
||||
else {
|
||||
this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) );
|
||||
}
|
||||
}
|
||||
|
||||
this.versionMajor = parseInt(this.versionMinor);
|
||||
this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
|
||||
// GECKO REVISION
|
||||
this.geckoRevision = -1;
|
||||
if (this.isGecko) {
|
||||
temp = ua.split("rv:");
|
||||
this.geckoRevision = parseFloat(temp[1]);
|
||||
}
|
||||
|
||||
// dom support
|
||||
this.isDOM1 = (document.getElementById);
|
||||
this.isDOM2Event = (document.addEventListener && document.removeEventListener);
|
||||
|
||||
// css compatibility mode
|
||||
this.mode = document.compatMode ? document.compatMode : 'BackCompat';
|
||||
|
||||
// platform
|
||||
this.isWin = (ua.indexOf('win') != -1);
|
||||
this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
|
||||
this.isMac = (ua.indexOf('mac') != -1);
|
||||
this.isUnix = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
|
||||
this.isLinux = (ua.indexOf('linux') != -1);
|
||||
|
||||
// specific browser shortcuts
|
||||
this.isNS4x = (this.isNS && this.versionMajor == 4);
|
||||
this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
|
||||
this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
|
||||
this.isNS4up = (this.isNS && this.versionMinor >= 4);
|
||||
this.isNS6x = (this.isNS && this.versionMajor == 6);
|
||||
this.isNS6up = (this.isNS && this.versionMajor >= 6);
|
||||
this.isNS7x = (this.isNS && this.versionMajor == 7);
|
||||
this.isNS7up = (this.isNS && this.versionMajor >= 7);
|
||||
|
||||
this.isIE4x = (this.isIE && this.versionMajor == 4);
|
||||
this.isIE4up = (this.isIE && this.versionMajor >= 4);
|
||||
this.isIE5x = (this.isIE && this.versionMajor == 5);
|
||||
this.isIE55 = (this.isIE && this.versionMinor == 5.5);
|
||||
this.isIE55up = (this.isIE && this.versionMinor >= 5.5);
|
||||
this.isIE5up = (this.isIE && this.versionMajor >= 5);
|
||||
this.isIE6x = (this.isIE && this.versionMajor == 6);
|
||||
this.isIE6up = (this.isIE && this.versionMajor >= 6);
|
||||
|
||||
this.isIE4xMac = (this.isIE4x && this.isMac);
|
||||
|
||||
this.isRichText = this.isIE55up ? true : false;
|
||||
if (this.isGecko || this.isAppleWebKit) {
|
||||
if (document.designMode && document.execCommand) { this.isRichText = true; }
|
||||
}
|
||||
}
|
||||
var browser = new BrowserDetectLite();
|
||||
404
livejournal/htdocs/js/colorpicker.js
Executable file
404
livejournal/htdocs/js/colorpicker.js
Executable file
@@ -0,0 +1,404 @@
|
||||
|
||||
// A nutty little DHTML Color Picker
|
||||
// By Martin Atkins aka Mart
|
||||
|
||||
var colpic_imgprefix = '/img';
|
||||
|
||||
// spawnPicker - create a picker window
|
||||
function spawnPicker(dataobject, displayobject, des) {
|
||||
var p = window.open("","colorpick_"+dataobject.name,"width=560,height=450");
|
||||
var d = p.document;
|
||||
|
||||
// declare the data storage object in the picker's scope
|
||||
d.write('<script language="JavaScript"> var picker = new Object; </script>');
|
||||
|
||||
var dat = p.picker;
|
||||
dat.dataobject = dataobject;
|
||||
dat.displayobject = displayobject;
|
||||
dat.current = ''+dataobject.value;
|
||||
dat.r = 0;
|
||||
dat.g = 0;
|
||||
dat.b = 0;
|
||||
dat.h = 0;
|
||||
dat.s = 0;
|
||||
dat.v = 0;
|
||||
|
||||
// Copy some functions into the picker's scope so events can hit them
|
||||
p._HSVtoRGB = _HSVtoRGB;
|
||||
p._varstoform = _varstoform;
|
||||
p.setBGColor = setBGColor;
|
||||
p.findel = findel;
|
||||
|
||||
d.write("<title>"+des+"</title>");
|
||||
_createInterface(p);
|
||||
d.close();
|
||||
|
||||
findel('spectrum',d).onclick=function(evt) {
|
||||
if (! evt) { evt = p.event; }
|
||||
var x, y;
|
||||
if (evt.offsetX != null) {
|
||||
x = evt.offsetX;
|
||||
y = evt.offsetY;
|
||||
} else if (evt.pageX != null) {
|
||||
x = evt.pageX - 6;
|
||||
y = evt.pageY - 6;
|
||||
} else if (evt.clientX != null) {
|
||||
x = evt.clientX - 6;
|
||||
y = evt.clientY - 6;
|
||||
} else {
|
||||
p.alert('Your mouseclick could not be handled. Sorry.');
|
||||
}
|
||||
// var x = evt.offsetX || (evt.pageX ? evt.pageX - 6 : false) || (evt.clientX - 6);
|
||||
// var y = evt.offsetY || (evt.pageY ? evt.pageX - 6 : false) || (evt.clientY - 6);
|
||||
p.picker.h = Math.abs(p.Math.floor(x / 2) % 256);
|
||||
p.picker.s = Math.abs(y % 255);
|
||||
p._HSVtoRGB(p);
|
||||
p._varstoform(p);
|
||||
};
|
||||
findel('brightness',d).onclick=function(evt) {
|
||||
if (! evt) { evt = p.event; }
|
||||
p.picker.v = Math.abs((evt.offsetY || (evt.pageY - 6)) % 255);
|
||||
p._HSVtoRGB(p);
|
||||
p._varstoform(p);
|
||||
};
|
||||
|
||||
findel('btnCancel',d).onclick=function() {
|
||||
p.close();
|
||||
};
|
||||
|
||||
findel('btnOK',d).onclick=function() {
|
||||
dataobject.value=p.picker.current;
|
||||
p.setBGColor(displayobject,p.picker.current);
|
||||
p.close();
|
||||
};
|
||||
|
||||
// The crosshair prevents clicks under it, so fake events for it
|
||||
findel('crosshair',d).onclick=function(evt) {
|
||||
if (! evt) { evt = p.event; }
|
||||
var fakeevt = new Object;
|
||||
fakeevt.pageX = evt.pageX;
|
||||
fakeevt.pageY = evt.pageY;
|
||||
fakeevt.clientX = evt.clientX;
|
||||
fakeevt.clientY = evt.clientY;
|
||||
findel('spectrum',p.document).onclick(fakeevt);
|
||||
};
|
||||
|
||||
findel('fr',d).onchange=
|
||||
findel('fg',d).onchange=
|
||||
findel('fb',d).onchange=function() {
|
||||
dat.r = Math.abs(findel('fr',d).value % 256);
|
||||
dat.g = Math.abs(findel('fg',d).value % 256);
|
||||
dat.b = Math.abs(findel('fb',d).value % 256);
|
||||
|
||||
_RGBtoHSV(p);
|
||||
_varstoform(p);
|
||||
}
|
||||
|
||||
findel('fh',d).onchange=
|
||||
findel('fs',d).onchange=
|
||||
findel('fv',d).onchange=function() {
|
||||
dat.h = Math.abs(findel('fh',d).value % 255);
|
||||
dat.s = Math.abs(findel('fs',d).value % 256);
|
||||
dat.v = Math.abs(findel('fv',d).value % 256);
|
||||
|
||||
_HSVtoRGB(p);
|
||||
_varstoform(p);
|
||||
}
|
||||
|
||||
_setcolor(p,dat.current);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function setBGColor(displayobject, colorstring) {
|
||||
displayobject.style.backgroundColor = colorstring;
|
||||
}
|
||||
|
||||
function findel(id,doc) {
|
||||
if (! doc) {
|
||||
doc = document;
|
||||
}
|
||||
return doc.getElementById(id);
|
||||
}
|
||||
|
||||
function _varstoform(p) {
|
||||
var d = p.document;
|
||||
var dat = p.picker;
|
||||
findel("fr",d).value=dat.r;
|
||||
findel("fg",d).value=dat.g;
|
||||
findel("fb",d).value=dat.b;
|
||||
findel("fh",d).value=dat.h;
|
||||
findel("fs",d).value=dat.s;
|
||||
findel("fv",d).value=dat.v;
|
||||
|
||||
dat.current = "#"+_hex(dat.r)+
|
||||
_hex(dat.g)+
|
||||
_hex(dat.b);
|
||||
setBGColor(findel('preview',p.document),dat.current);
|
||||
|
||||
_updatebrightnessgrad(p);
|
||||
_placeindicators(p);
|
||||
}
|
||||
|
||||
function _updatebrightnessgrad(p) {
|
||||
var grad = findel("brightness",p.document);
|
||||
var fbc = new Object;
|
||||
fbc.h=p.picker.h;
|
||||
fbc.s=p.picker.s;
|
||||
fbc.v=255;
|
||||
_HSVtoRGB(p,fbc);
|
||||
gradclr = _hex(fbc.r)+
|
||||
_hex(fbc.g)+
|
||||
_hex(fbc.b);
|
||||
var newgradurl = "/palimg/colorpicker/longgrad.gif/pg00000000ff"+gradclr.toLowerCase();
|
||||
var oldgradurl = grad.src;
|
||||
if (oldgradurl != newgradurl) {
|
||||
grad.src = newgradurl;
|
||||
}
|
||||
}
|
||||
function _placeindicators(p) {
|
||||
var d = p.document;
|
||||
var pointer = findel('pointer',d);
|
||||
var crosshair = findel('crosshair',d);
|
||||
pointer.style.top = (p.picker.v + 3)+"px";
|
||||
|
||||
crosshair.style.top = (p.picker.s - 1)+"px";
|
||||
crosshair.style.left = ((p.picker.h * 2) - 1)+"px";
|
||||
|
||||
pointer.style.display = '';
|
||||
crosshair.style.display = '';
|
||||
}
|
||||
|
||||
function _setcolor(p,htmlcolor) {
|
||||
p.picker.current = htmlcolor;
|
||||
|
||||
var clrparts = _colorfromstring(htmlcolor);
|
||||
|
||||
p.picker.r = clrparts[1];
|
||||
p.picker.g = clrparts[2];
|
||||
p.picker.b = clrparts[3];
|
||||
|
||||
_RGBtoHSV(p);
|
||||
_varstoform(p);
|
||||
|
||||
}
|
||||
|
||||
function _RGBtoHSV(p,dat) {
|
||||
if (! dat) {
|
||||
dat = p.picker;
|
||||
}
|
||||
var r = dat.r;
|
||||
var g = dat.g;
|
||||
var b = dat.b;
|
||||
|
||||
r = (r % 256) / 255;
|
||||
g = (g % 256) / 255;
|
||||
b = (b % 256) / 255;
|
||||
|
||||
var min = 255, max = 0, h, s, v, hi, diff;
|
||||
|
||||
var rgb = new Array(0,r,g,b);
|
||||
for (var i = 1; i <= 3; i++) {
|
||||
if (rgb[i] > max) {
|
||||
max = rgb[i];
|
||||
hi = 1;
|
||||
}
|
||||
if (rgb[i] < min) {
|
||||
min = rgb[i];
|
||||
}
|
||||
}
|
||||
diff = max - min;
|
||||
v = max;
|
||||
if (max == 0) {
|
||||
s = 0;
|
||||
} else {
|
||||
s = diff / max;
|
||||
}
|
||||
if (s == 0) {
|
||||
h = 0;
|
||||
} else {
|
||||
switch (hi) {
|
||||
case 1:
|
||||
h = (g - b) / diff;
|
||||
break;
|
||||
case 2:
|
||||
h = 2 + (b - r) / diff;
|
||||
break;
|
||||
case 3:
|
||||
h = 4 + (r - g) / diff;
|
||||
break;
|
||||
}
|
||||
h = h / 6;
|
||||
if (h < 0) {
|
||||
h = h + 1;
|
||||
}
|
||||
}
|
||||
dat.h = Math.floor(h * 255);
|
||||
dat.s = Math.floor(s * 255);
|
||||
dat.v = Math.floor(v * 255);
|
||||
}
|
||||
function _HSVtoRGB(p,dat) {
|
||||
if (! dat) {
|
||||
dat = p.picker;
|
||||
}
|
||||
|
||||
var h = dat.h;
|
||||
var s = dat.s;
|
||||
var v = dat.v;
|
||||
|
||||
// If value is zero, return black.
|
||||
if (v == 0) {
|
||||
dat.r =
|
||||
dat.g =
|
||||
dat.b = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// If there's no saturation, return a grey.
|
||||
if (s == 0) {
|
||||
dat.r =
|
||||
dat.g =
|
||||
dat.b = v;
|
||||
return;
|
||||
}
|
||||
|
||||
h = (h % 255) / 255;
|
||||
s = (s % 256) / 255;
|
||||
v = (v % 256) / 255;
|
||||
|
||||
var t, aa, bb, cc, r, g, b;
|
||||
|
||||
t = p.Math.floor(h * 6); // Find which color's range we're in.
|
||||
f = (h * 6) - t;
|
||||
aa = v * (1 - s);
|
||||
bb = v * (1 - s * f);
|
||||
cc = v * (1 - (s * (1 - f)));
|
||||
|
||||
switch (t) {
|
||||
case 0:
|
||||
r=v;
|
||||
g=cc;
|
||||
b=aa;
|
||||
break;
|
||||
case 1:
|
||||
r=bb;
|
||||
g=v;
|
||||
b=aa;
|
||||
break;
|
||||
case 2:
|
||||
r=aa;
|
||||
g=v;
|
||||
b=cc;
|
||||
break;
|
||||
case 3:
|
||||
r=aa;
|
||||
g=bb;
|
||||
b=v;
|
||||
break;
|
||||
case 4:
|
||||
r=cc;
|
||||
g=aa;
|
||||
b=v;
|
||||
break;
|
||||
default:
|
||||
r=v;
|
||||
g=aa;
|
||||
b=bb;
|
||||
break;
|
||||
}
|
||||
|
||||
dat.r = p.Math.floor(r * 255) % 256;
|
||||
dat.g = p.Math.floor(g * 255) % 256;
|
||||
dat.b = p.Math.floor(b * 255) % 256;
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// Fun with Regular Expressions
|
||||
function _colorfromstring(strcolor) {
|
||||
var clrparts;
|
||||
strcolor = strcolor.toLowerCase();
|
||||
if ((clrparts = strcolor.match(
|
||||
/^#([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/
|
||||
)) != null) {
|
||||
for (var i=1; i<=3; i++) {
|
||||
clrparts[i] = parseInt(clrparts[i],16);
|
||||
}
|
||||
return clrparts;
|
||||
} else if ((clrparts = strcolor.match(
|
||||
/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/
|
||||
)) != null) {
|
||||
for (var i=1; i<=3; i++) {
|
||||
if (clrparts[i]<0 || clrparts[i]>255) {
|
||||
return [0,0,0,0];
|
||||
}
|
||||
return clrparts;
|
||||
}
|
||||
}
|
||||
return [0,255,255,255];
|
||||
}
|
||||
|
||||
function _hex(i) {
|
||||
var r = '';
|
||||
var h = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
|
||||
|
||||
for (var x = 0; x < 32; x++) {
|
||||
if (Math.pow( 16, x + 1 ) > i)
|
||||
break;
|
||||
}
|
||||
|
||||
for ( var y = x; y >= 0; y-- ) {
|
||||
var z = Math.pow( 16, y );
|
||||
r += h[ Math.floor ( i / z ) ];
|
||||
i = i % z;
|
||||
}
|
||||
|
||||
r = ( r.length == 0 ) ? '0' : r;
|
||||
while ( r.length < 2 ) {
|
||||
r = '0' + r;
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
function _createInterface(p) {
|
||||
var curclr = p.picker.current;
|
||||
var d = p.document;
|
||||
d.write('<style type="text/css">\n'+
|
||||
'body { border: 0; padding: 0; margin: 0; background: ButtonFace; color: ButtonText; font: caption; }\n'+
|
||||
'button { width: 5em; margin: 5px;}\n'+
|
||||
'img { border: 1px solid #000000; padding: 0; margin: 0; }\n'+
|
||||
'</style>');
|
||||
d.write('<table cellspacing="5" cellpadding="0" border="0">\n');
|
||||
d.write('<tr><td><img src="' + colpic_imgprefix + '/colorpicker/spectrum.png" '+
|
||||
'ismap width="512" height="256" id="spectrum"></td>\n');
|
||||
d.write('<td><img src="/palimg/colorpicker/longgrad.gif" '+
|
||||
'ismap width="25" height="256" id="brightness"></td></tr></table>\n');
|
||||
d.write('<form action="about:blank" method="GET" onsubmit="return false;">\n');
|
||||
d.write('<center><table cellspacing="5" cellpadding="0" border="0" width="95%">\n');
|
||||
d.write('<tr><td rowspan="3"><div id="preview" style="background-color: '+curclr+'; '+
|
||||
'border: 1px solid #000000; width: 50px; height: 50px; margin-left: 25%;"> </div></td>\n');
|
||||
_writeControlRow(d,'Hue','fh');
|
||||
_writeControlRow(d,'Red','fr');
|
||||
d.write('</tr><tr>\n');
|
||||
_writeControlRow(d,'Saturation','fs');
|
||||
_writeControlRow(d,'Green','fg');
|
||||
d.write('</tr><tr>\n');
|
||||
_writeControlRow(d,'Lightness','fv');
|
||||
_writeControlRow(d,'Blue','fb');
|
||||
d.write('</tr></table></center>\n');
|
||||
d.write('<div style="text-align: center;">'+
|
||||
'<button id="btnOK">OK</button> <button id="btnCancel">Cancel</button>'+
|
||||
'</div>');
|
||||
d.write('</form>\n');
|
||||
d.write('<img style="position: absolute; display: none; border: 0; left: 0; top: 0;" id="crosshair" src="' + colpic_imgprefix + '/colorpicker/crosshair.gif">\n');
|
||||
d.write('<img style="position: absolute; display: none; border: 0; left: 552px; top: 0;" id="pointer" src="' + colpic_imgprefix + '/colorpicker/pointer.gif">\n');
|
||||
}
|
||||
function _writeControlRow(doc,caption,name) {
|
||||
doc.write('<td align="right" width="25%"><nobr><label accesskey="'+caption.substring(0,1)+'">'+caption+
|
||||
': <input type="text" size="3" maxlength="3" name="'+name+'" id="'+name+'"></label></nobr></td>\n');
|
||||
}
|
||||
|
||||
function colPic_set_imgprefix(prefix) {
|
||||
colpic_imgprefix = prefix;
|
||||
}
|
||||
618
livejournal/htdocs/js/commentmanage.js
Executable file
618
livejournal/htdocs/js/commentmanage.js
Executable file
@@ -0,0 +1,618 @@
|
||||
var LJVAR;
|
||||
if (! LJVAR) LJVAR = new Object();
|
||||
|
||||
// called by S2:
|
||||
function setStyle (did, attr, val) {
|
||||
if (! document.getElementById) return;
|
||||
var de = document.getElementById(did);
|
||||
if (! de) return;
|
||||
if (de.style)
|
||||
de.style[attr] = val
|
||||
}
|
||||
|
||||
// called by S2:
|
||||
function setInner (did, val) {
|
||||
if (! document.getElementById) return;
|
||||
var de = document.getElementById(did);
|
||||
if (! de) return;
|
||||
de.innerHTML = val;
|
||||
}
|
||||
|
||||
// called by S2:
|
||||
function hideElement (did) {
|
||||
if (! document.getElementById) return;
|
||||
var de = document.getElementById(did);
|
||||
if (! de) return;
|
||||
de.style.display = 'none';
|
||||
}
|
||||
|
||||
// called by S2:
|
||||
function setAttr (did, attr, classname) {
|
||||
if (! document.getElementById) return;
|
||||
var de = document.getElementById(did);
|
||||
if (! de) return;
|
||||
de.setAttribute(attr, classname);
|
||||
}
|
||||
|
||||
function getXTR () {
|
||||
var xtr;
|
||||
var ex;
|
||||
|
||||
if (typeof(XMLHttpRequest) != "undefined") {
|
||||
xtr = new XMLHttpRequest();
|
||||
} else {
|
||||
try {
|
||||
xtr = new ActiveXObject("Msxml2.XMLHTTP.4.0");
|
||||
} catch (ex) {
|
||||
try {
|
||||
xtr = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch (ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// let me explain this. Opera 8 does XMLHttpRequest, but not setRequestHeader.
|
||||
// no problem, we thought: we'll test for setRequestHeader and if it's not present
|
||||
// then fall back to the old behavior (treat it as not working). BUT --- IE6 won't
|
||||
// let you even test for setRequestHeader without throwing an exception (you need
|
||||
// to call .open on the .xtr first or something)
|
||||
try {
|
||||
if (xtr && ! xtr.setRequestHeader)
|
||||
xtr = null;
|
||||
} catch (ex) { }
|
||||
|
||||
return xtr;
|
||||
}
|
||||
|
||||
// push new element 'ne' after sibling 'oe' old element
|
||||
function addAfter (oe, ne) {
|
||||
if (oe.nextSibling) {
|
||||
oe.parentNode.insertBefore(ne, oe.nextSibling);
|
||||
} else {
|
||||
oe.parentNode.appendChild(ne);
|
||||
}
|
||||
}
|
||||
|
||||
// hsv to rgb
|
||||
// h, s, v = [0, 1), [0, 1], [0, 1]
|
||||
// r, g, b = [0, 255], [0, 255], [0, 255]
|
||||
function hsv_to_rgb (h, s, v)
|
||||
{
|
||||
if (s == 0) {
|
||||
v *= 255;
|
||||
return [v,v,v];
|
||||
}
|
||||
|
||||
h *= 6;
|
||||
var i = Math.floor(h);
|
||||
var f = h - i;
|
||||
var p = v * (1 - s);
|
||||
var q = v * (1 - s * f);
|
||||
var t = v * (1 - s * (1 - f));
|
||||
|
||||
v = Math.floor(v * 255 + 0.5);
|
||||
t = Math.floor(t * 255 + 0.5);
|
||||
p = Math.floor(p * 255 + 0.5);
|
||||
q = Math.floor(q * 255 + 0.5);
|
||||
|
||||
if (i == 0) return [v,t,p];
|
||||
if (i == 1) return [q,v,p];
|
||||
if (i == 2) return [p,v,t];
|
||||
if (i == 3) return [p,q,v];
|
||||
if (i == 4) return [t,p,v];
|
||||
return [v,p,q];
|
||||
}
|
||||
|
||||
// stops the bubble
|
||||
function stopBubble (e) {
|
||||
if (e.stopPropagation)
|
||||
e.stopPropagation();
|
||||
if ("cancelBubble" in e)
|
||||
e.cancelBubble = true;
|
||||
}
|
||||
|
||||
// stops the bubble, as well as the default action
|
||||
function stopEvent (e) {
|
||||
stopBubble(e);
|
||||
if (e.preventDefault)
|
||||
e.preventDefault();
|
||||
if ("returnValue" in e)
|
||||
e.returnValue = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
function scrollTop () {
|
||||
if (window.innerHeight)
|
||||
return window.pageYOffset;
|
||||
if (document.documentElement && document.documentElement.scrollTop)
|
||||
return document.documentElement.scrollTop;
|
||||
if (document.body)
|
||||
return document.body.scrollTop;
|
||||
}
|
||||
|
||||
function scrollLeft () {
|
||||
if (window.innerWidth)
|
||||
return window.pageXOffset;
|
||||
if (document.documentElement && document.documentElement.scrollLeft)
|
||||
return document.documentElement.scrollLeft;
|
||||
if (document.body)
|
||||
return document.body.scrollLeft;
|
||||
}
|
||||
|
||||
function getElementPos (obj)
|
||||
{
|
||||
var pos = new Object();
|
||||
if (!obj)
|
||||
return null;
|
||||
|
||||
var it;
|
||||
|
||||
it = obj;
|
||||
pos.x = 0;
|
||||
if (it.offsetParent) {
|
||||
while (it.offsetParent) {
|
||||
pos.x += it.offsetLeft;
|
||||
it = it.offsetParent;
|
||||
}
|
||||
}
|
||||
else if (it.x)
|
||||
pos.x += it.x;
|
||||
|
||||
it = obj;
|
||||
pos.y = 0;
|
||||
if (it.offsetParent) {
|
||||
while (it.offsetParent) {
|
||||
pos.y += it.offsetTop;
|
||||
it = it.offsetParent;
|
||||
}
|
||||
}
|
||||
else if (it.y)
|
||||
pos.y += it.y;
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
// returns the mouse position of the event, or failing that, the top-left
|
||||
// of the event's target element. (or the fallBack element, which takes
|
||||
// precendence over the event's target element if specified)
|
||||
function getEventPos (e, fallBack)
|
||||
{
|
||||
var pos = { x:0, y:0 };
|
||||
|
||||
if (!e) var e = window.event;
|
||||
if (e.pageX && e.pageY) {
|
||||
// useful case (relative to document)
|
||||
pos.x = e.pageX;
|
||||
pos.y = e.pageY;
|
||||
}
|
||||
else if (e.clientX && e.clientY) {
|
||||
// IE case (relative to viewport, so need scroll info)
|
||||
pos.x = e.clientX + scrollLeft();
|
||||
pos.y = e.clientY + scrollTop();
|
||||
} else {
|
||||
var targ = fallBack || getTarget(e);
|
||||
var pos = getElementPos(targ);
|
||||
return pos;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
var curPopup = null;
|
||||
var curPopup_id = 0;
|
||||
|
||||
function killPopup () {
|
||||
if (!curPopup)
|
||||
return true;
|
||||
|
||||
var popup = curPopup;
|
||||
curPopup = null;
|
||||
|
||||
var opp = 1.0;
|
||||
|
||||
var fade = function () {
|
||||
opp -= 0.15;
|
||||
|
||||
if (opp <= 0.1) {
|
||||
popup.parentNode.removeChild(popup);
|
||||
} else {
|
||||
popup.style.filter = "alpha(opacity=" + Math.floor(opp * 100) + ")";
|
||||
popup.style.opacity = opp;
|
||||
window.setTimeout(fade, 20);
|
||||
}
|
||||
};
|
||||
fade();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
var pendingReqs = new Object ();
|
||||
|
||||
function deleteComment (ditemid) {
|
||||
|
||||
var hasopt = function (opt) {
|
||||
var el = document.getElementById("ljpopdel" + ditemid + opt);
|
||||
if (!el) return false;
|
||||
if (el.checked) return true;
|
||||
return false;
|
||||
};
|
||||
var opt_delthread = hasopt("thread");
|
||||
var opt_ban = hasopt("ban");
|
||||
var opt_spam = hasopt("spam");
|
||||
|
||||
killPopup();
|
||||
|
||||
var todel = document.getElementById("ljcmt" + ditemid);
|
||||
|
||||
var col = 0;
|
||||
var pulse = 0;
|
||||
var is_deleted = 0;
|
||||
var is_error = 0;
|
||||
|
||||
var xtr = getXTR();
|
||||
if (! xtr) {
|
||||
alert("JS_ASSERT: no xtr now, but earlier?");
|
||||
return false;
|
||||
}
|
||||
pendingReqs[ditemid] = xtr;
|
||||
|
||||
var state_callback = function () {
|
||||
if (xtr.readyState != 4)
|
||||
return;
|
||||
|
||||
if (xtr.status == 200) {
|
||||
var val = eval(xtr.responseText);
|
||||
is_deleted = val;
|
||||
if (! is_deleted) is_error = 1;
|
||||
} else {
|
||||
alert("Error contacting server to delete comment.");
|
||||
is_error = 1;
|
||||
}
|
||||
};
|
||||
|
||||
var error_callback = function () {
|
||||
alert("Error deleting " + ditemid);
|
||||
is_error = 1;
|
||||
};
|
||||
|
||||
xtr.onreadystatechange = state_callback;
|
||||
xtr.open("POST", "/delcomment.bml?mode=js&journal=" + LJ_cmtinfo.journal + "&id=" + ditemid, true);
|
||||
var postdata = "confirm=1";
|
||||
if (opt_ban) postdata += "&ban=1";
|
||||
if (opt_spam) postdata += "&spam=1";
|
||||
if (opt_delthread) postdata += "&delthread=1";
|
||||
|
||||
xtr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xtr.send(postdata);
|
||||
|
||||
var flash = function () {
|
||||
var rgb = hsv_to_rgb(0, Math.cos((pulse + 1) / 2), 1);
|
||||
pulse += 3.14159 / 5;
|
||||
var color = "rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + ")";
|
||||
|
||||
todel.style.border = "2px solid " + color;
|
||||
if (is_error) {
|
||||
todel.style.border = "";
|
||||
// and let timer expire
|
||||
} else if (is_deleted) {
|
||||
removeComment(ditemid, opt_delthread);
|
||||
} else {
|
||||
window.setTimeout(flash, 50);
|
||||
}
|
||||
};
|
||||
|
||||
window.setTimeout(flash, 5);
|
||||
}
|
||||
|
||||
function removeComment (ditemid, killChildren) {
|
||||
var todel = document.getElementById("ljcmt" + ditemid);
|
||||
if (todel) {
|
||||
todel.style.display = 'none';
|
||||
|
||||
var userhook = window["userhook_delete_comment_ARG"];
|
||||
if (userhook)
|
||||
userhook(ditemid);
|
||||
}
|
||||
if (killChildren) {
|
||||
var com = LJ_cmtinfo ? LJ_cmtinfo[ditemid] : null;
|
||||
for (var i = 0; i < com.rc.length; i++) {
|
||||
removeComment(com.rc[i], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function docClicked (e) {
|
||||
if (!curPopup)
|
||||
return true;
|
||||
killPopup();
|
||||
return true;
|
||||
}
|
||||
|
||||
function createDeleteFunction (ae, dItemid) {
|
||||
return function (e) {
|
||||
if (!e) e = window.event;
|
||||
var FS = arguments.callee;
|
||||
|
||||
var finalHeight = 100;
|
||||
|
||||
if (e.shiftKey || (curPopup && curPopup_id != dItemid)) {
|
||||
killPopup();
|
||||
}
|
||||
|
||||
var doIT = 0;
|
||||
// immediately delete on shift key
|
||||
if (e.shiftKey) {
|
||||
doIT = 1;
|
||||
} else {
|
||||
if (! LJ_cmtinfo)
|
||||
return true;
|
||||
|
||||
var com = LJ_cmtinfo[dItemid];
|
||||
var remoteUser = LJ_cmtinfo["remote"];
|
||||
if (!com || !remoteUser)
|
||||
return true;
|
||||
var canAdmin = LJ_cmtinfo["canAdmin"];
|
||||
|
||||
var clickTarget = getTarget(e);
|
||||
var used_keyboard = clickTarget.nodeName == "A";
|
||||
|
||||
var pos = used_keyboard ? getElementPos(ae) : getEventPos(e);
|
||||
var lx = pos.x + 5 - 250;
|
||||
if (lx < 5) lx = 5;
|
||||
var de;
|
||||
|
||||
if (curPopup && curPopup_id == dItemid) {
|
||||
de = curPopup;
|
||||
de.style.left = lx + "px";
|
||||
de.style.top = (pos.y + 5) + "px";
|
||||
return stopEvent(e);
|
||||
}
|
||||
|
||||
de = document.createElement("div");
|
||||
de.style.textAlign = "left";
|
||||
de.className = 'ljcmtmanage';
|
||||
de.style.height = "10px";
|
||||
de.style.overflow = "hidden";
|
||||
de.style.position = "absolute";
|
||||
de.style.left = lx + "px";
|
||||
de.style.top = (pos.y + 5) + "px";
|
||||
de.style.width = "250px";
|
||||
regEvent(de, "click", function (e) {
|
||||
e = e || window.event;
|
||||
stopBubble(e);
|
||||
return true;
|
||||
});
|
||||
|
||||
var inHTML = "<form style='display: inline' id='ljdelopts" + dItemid + "'><span style='font-face: Arial; font-size: 8pt'><b>Delete comment?</b><br />";
|
||||
var lbl;
|
||||
if (remoteUser != "" && com.u != "" && com.u != remoteUser && canAdmin) {
|
||||
lbl = "ljpopdel" + dItemid + "ban";
|
||||
inHTML += "<input type='checkbox' value='ban' id='" + lbl + "'> <label for='" + lbl + "'>Ban <b>" + com.u + "</b> from commenting</label><br />";
|
||||
} else {
|
||||
finalHeight -= 15;
|
||||
}
|
||||
|
||||
if (remoteUser != com.u && canAdmin) {
|
||||
lbl = "ljpopdel" + dItemid + "spam";
|
||||
inHTML += "<input type='checkbox' value='spam' id='" + lbl + "'> <label for='" + lbl + "'>Mark this comment as spam</label><br />";
|
||||
} else {
|
||||
finalHeight -= 15;
|
||||
}
|
||||
|
||||
if (com.rc && com.rc.length && canAdmin) {
|
||||
lbl = "ljpopdel" + dItemid + "thread";
|
||||
inHTML += "<input type='checkbox' value='thread' id='" + lbl + "'> <label for='" + lbl + "'>Delete thread (all subcomments)</label><br />";
|
||||
} else {
|
||||
finalHeight -= 15;
|
||||
}
|
||||
inHTML += "<input type='button' value='Delete' onclick='deleteComment(" + dItemid + ");' /> <input type='button' value='Cancel' onclick='killPopup()' /></span><br /><span style='font-face: Arial; font-size: 8pt'><i>shift-click to delete without options</i></span></form>";
|
||||
de.innerHTML = inHTML;
|
||||
|
||||
// we do this so keyboard tab order is correct:
|
||||
addAfter(ae, de);
|
||||
|
||||
curPopup = de;
|
||||
curPopup_id = dItemid;
|
||||
|
||||
var height = 10;
|
||||
var grow = function () {
|
||||
height += 7;
|
||||
if (height > finalHeight) {
|
||||
de.style.height = null;
|
||||
de.style.filter = "";
|
||||
de.style.opacity = 1.0;
|
||||
} else {
|
||||
de.style.height = height + "px";
|
||||
window.setTimeout(grow, 20);
|
||||
}
|
||||
};
|
||||
grow();
|
||||
|
||||
}
|
||||
|
||||
if (doIT) {
|
||||
deleteComment(dItemid);
|
||||
}
|
||||
|
||||
return stopEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
function poofAt (pos) {
|
||||
var de = document.createElement("div");
|
||||
de.style.position = "absolute";
|
||||
de.style.background = "#FFF";
|
||||
de.style.overflow = "hidden";
|
||||
var opp = 1.0;
|
||||
|
||||
var top = pos.y;
|
||||
var left = pos.x;
|
||||
var width = 5;
|
||||
var height = 5;
|
||||
document.body.appendChild(de);
|
||||
|
||||
var fade = function () {
|
||||
opp -= 0.15;
|
||||
width += 10;
|
||||
height += 10;
|
||||
top -= 5;
|
||||
left -= 5;
|
||||
|
||||
if (opp <= 0.1) {
|
||||
de.parentNode.removeChild(de);
|
||||
} else {
|
||||
de.style.left = left + "px";
|
||||
de.style.top = top + "px";
|
||||
de.style.height = height + "px";
|
||||
de.style.width = width + "px";
|
||||
de.style.filter = "alpha(opacity=" + Math.floor(opp * 100) + ")";
|
||||
de.style.opacity = opp;
|
||||
window.setTimeout(fade, 20);
|
||||
}
|
||||
};
|
||||
fade();
|
||||
}
|
||||
|
||||
function getTarget (ev) {
|
||||
var target;
|
||||
if (ev.target)
|
||||
target = ev.target;
|
||||
else if (ev.srcElement)
|
||||
target = ev.srcElement;
|
||||
|
||||
// Safari bug:
|
||||
if (target && target.nodeType == 3)
|
||||
target = target.parentNode;
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
function updateLink (ae, resObj, clickTarget) {
|
||||
ae.href = resObj.newurl;
|
||||
var userhook = window["userhook_" + resObj.mode + "_comment_ARG"];
|
||||
var did_something = 0;
|
||||
|
||||
if (clickTarget && clickTarget.src && clickTarget.src == resObj.oldimage) {
|
||||
clickTarget.src = resObj.newimage;
|
||||
did_something = 1;
|
||||
}
|
||||
|
||||
if (userhook) {
|
||||
userhook(resObj.id);
|
||||
did_something = 1;
|
||||
}
|
||||
|
||||
// if all else fails, at least remove the link so they're not as confused
|
||||
if (! did_something) {
|
||||
if (ae && ae.style)
|
||||
ae.style.display = 'none';
|
||||
if (clickTarget && clickTarget.style)
|
||||
clickTarget.style.dispay = 'none';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var tsInProg = new Object(); // dict of { ditemid => 1 }
|
||||
function createModerationFunction (ae, dItemid) {
|
||||
return function (e) {
|
||||
if (!e) e = window.event;
|
||||
|
||||
if (tsInProg[dItemid])
|
||||
return stopEvent(e);
|
||||
tsInProg[dItemid] = 1;
|
||||
|
||||
var clickTarget = getTarget(e);
|
||||
|
||||
var used_keyboard = clickTarget.nodeName == "A";
|
||||
|
||||
var imgTarget;
|
||||
var imgs = ae.getElementsByTagName("img");
|
||||
if (imgs.length)
|
||||
imgTarget = imgs[0]
|
||||
|
||||
if (! clickTarget || typeof(clickTarget) != "object")
|
||||
return true;
|
||||
|
||||
var clickPos = used_keyboard ? getElementPos(imgTarget || ae) : getEventPos(e);
|
||||
|
||||
var de = document.createElement("img");
|
||||
de.style.position = "absolute";
|
||||
de.width = 17;
|
||||
de.height = 17;
|
||||
de.src = LJVAR.imgprefix + "/hourglass.gif";
|
||||
de.style.top = (clickPos.y - 8) + "px";
|
||||
de.style.left = (clickPos.x - 8) + "px";
|
||||
document.body.appendChild(de);
|
||||
|
||||
var xtr = getXTR();
|
||||
var state_callback = function () {
|
||||
if (xtr.readyState != 4) return;
|
||||
|
||||
document.body.removeChild(de);
|
||||
var rpcRes;
|
||||
|
||||
if (xtr.status == 200) {
|
||||
var resObj = eval(xtr.responseText);
|
||||
if (resObj) {
|
||||
poofAt(clickPos);
|
||||
updateLink(ae, resObj, imgTarget);
|
||||
tsInProg[dItemid] = 0;
|
||||
} else {
|
||||
tsInProg[dItemid] = 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
alert("Error contacting server.");
|
||||
tsInProg[dItemid] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
xtr.onreadystatechange = state_callback;
|
||||
|
||||
var postUrl = ae.href.replace(/http:\/\/.+?\//, "/");
|
||||
xtr.open("POST", postUrl + "&jsmode=1", true);
|
||||
|
||||
var postdata = "confirm=Y";
|
||||
|
||||
xtr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xtr.send(postdata);
|
||||
|
||||
return stopEvent(e);
|
||||
};
|
||||
}
|
||||
|
||||
function setupAjax () {
|
||||
var ct = document.links.length;
|
||||
for (var i=0; i<ct; i++) {
|
||||
var ae = document.links[i];
|
||||
if (ae.href.indexOf("talkscreen.bml") != -1) {
|
||||
ae.onclick = createModerationFunction(ae, dItemid);
|
||||
|
||||
} else if (ae.href.indexOf("delcomment.bml") != -1) {
|
||||
|
||||
var findIDre = /id=(\d+)/;
|
||||
var reMatch = findIDre.exec(ae.href);
|
||||
if (! reMatch) return true;
|
||||
|
||||
var dItemid = reMatch[1];
|
||||
var todel = document.getElementById("ljcmt" + dItemid);
|
||||
if (! todel) return true;
|
||||
|
||||
ae.onclick = createDeleteFunction(ae, dItemid);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function regEvent (target, evt, func) {
|
||||
if (! target) return;
|
||||
if (target.attachEvent)
|
||||
target.attachEvent("on"+evt, func);
|
||||
if (target.addEventListener)
|
||||
target.addEventListener(evt, func, false);
|
||||
}
|
||||
|
||||
if (document.getElementById && getXTR()) {
|
||||
regEvent(window, "load", setupAjax);
|
||||
regEvent(document, "click", docClicked);
|
||||
document.write("<style> div.ljcmtmanage { color: #000; background: #e0e0e0; border: 2px solid #000; padding: 3px; }</style>");
|
||||
}
|
||||
233
livejournal/htdocs/js/entry.js
Executable file
233
livejournal/htdocs/js/entry.js
Executable file
@@ -0,0 +1,233 @@
|
||||
var layout_mode = "thin";
|
||||
var sc_old_border_style;
|
||||
var shift_init = "true";
|
||||
|
||||
function shift_contents() {
|
||||
if (! document.getElementById) { return false; }
|
||||
var infobox = document.getElementById("infobox");
|
||||
var column_one = document.getElementById("column_one_td");
|
||||
var column_two = document.getElementById("column_two_td");
|
||||
var column_one_table = document.getElementById("column_one_table");
|
||||
var column_two_table = document.getElementById("column_two_table");
|
||||
|
||||
var shifting_rows = new Array();
|
||||
|
||||
if (shift_init == "true") {
|
||||
shift_init = "false";
|
||||
bsMacIE5Fix = document.createElement("tr");
|
||||
bsMacIE5Fix.style.display = "none";
|
||||
sc_old_border_style = column_one.style.borderRight;
|
||||
}
|
||||
|
||||
var width;
|
||||
if (self.innerWidth) {
|
||||
width = self.innerWidth;
|
||||
} else if (document.documentElement && document.documentElement.clientWidth) {
|
||||
width = document.documentElement.clientWidth;
|
||||
} else if (document.body) {
|
||||
width = document.body.clientWidth;
|
||||
}
|
||||
|
||||
if (width < 1000) {
|
||||
if (layout_mode == "thin" && shift_init == "true") { return true; }
|
||||
|
||||
layout_mode = "thin";
|
||||
column_one.style.borderRight = "0";
|
||||
column_two.style.display = "none";
|
||||
|
||||
infobox.style.display = "none";
|
||||
column_two_table.lastChild.appendChild(bsMacIE5Fix);
|
||||
|
||||
column_one_table.lastChild.appendChild(document.getElementById("backdate_row"));
|
||||
column_one_table.lastChild.appendChild(document.getElementById("comment_settings_row"));
|
||||
column_one_table.lastChild.appendChild(document.getElementById("comment_screen_settings_row"));
|
||||
if (document.getElementById("userpic_list_row")) {
|
||||
column_one_table.lastChild.appendChild(document.getElementById("userpic_list_row"));
|
||||
}
|
||||
} else {
|
||||
if (layout_mode == "wide") { return false; }
|
||||
layout_mode = "wide";
|
||||
column_one.style.borderRight = sc_old_border_style;
|
||||
column_two.style.display = "block";
|
||||
|
||||
infobox.style.display = "block";
|
||||
column_one_table.lastChild.appendChild(bsMacIE5Fix);
|
||||
|
||||
column_two_table.lastChild.appendChild(document.getElementById("backdate_row"));
|
||||
column_two_table.lastChild.appendChild(document.getElementById("comment_settings_row"));
|
||||
column_two_table.lastChild.appendChild(document.getElementById("comment_screen_settings_row"));
|
||||
if (document.getElementById("userpic_list_row")) {
|
||||
column_two_table.lastChild.appendChild(document.getElementById("userpic_list_row"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function enable_rte () {
|
||||
if (! document.getElementById) return false;
|
||||
|
||||
f = document.updateForm;
|
||||
if (! f) return false;
|
||||
f.switched_rte_on.value = 1;
|
||||
f.submit();
|
||||
return false;
|
||||
}
|
||||
// Maintain entry through browser navigations.
|
||||
// IE does this onBlur, Gecko onUnload.
|
||||
function save_entry () {
|
||||
if (! document.getElementById) return false;
|
||||
|
||||
f = document.updateForm;
|
||||
if (! f) return false;
|
||||
rte = document.getElementById('rte');
|
||||
if (! rte) return false;
|
||||
content = document.getElementById('rte').contentWindow.document.body.innerHTML;
|
||||
f.saved_entry.value = content;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Restore saved_entry text across platforms.
|
||||
// This is only used for IE, Gecko browser support is in the RTE library.
|
||||
function restore_entry () {
|
||||
if (! document.getElementById) return false;
|
||||
f = document.updateForm;
|
||||
if (! f) return false;
|
||||
rte = document.getElementById('rte');
|
||||
if (! rte) return false;
|
||||
if (document.updateForm.saved_entry.value == "") return false;
|
||||
setTimeout(
|
||||
function () {
|
||||
document.getElementById('rte').contentWindow.document.body.innerHTML =
|
||||
document.updateForm.saved_entry.value;
|
||||
}, 100);
|
||||
return false;
|
||||
}
|
||||
|
||||
function pageload (dotime) {
|
||||
restore_entry();
|
||||
|
||||
if (dotime) settime();
|
||||
if (!document.getElementById) return false;
|
||||
|
||||
var remotelogin = document.getElementById('remotelogin');
|
||||
if (! remotelogin) return false;
|
||||
var remotelogin_content = document.getElementById('remotelogin_content');
|
||||
if (! remotelogin_content) return false;
|
||||
remotelogin_content.onclick = altlogin;
|
||||
|
||||
f = document.updateForm;
|
||||
if (! f) return false;
|
||||
|
||||
var userbox = f.user;
|
||||
if (! userbox) return false;
|
||||
if (userbox.value) altlogin();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function customboxes (e) {
|
||||
if (! e) var e = window.event;
|
||||
if (! document.getElementById) return false;
|
||||
|
||||
f = document.updateForm;
|
||||
if (! f) return false;
|
||||
|
||||
var custom_boxes = document.getElementById('custom_boxes');
|
||||
if (! custom_boxes) return false;
|
||||
|
||||
if (f.security.selectedIndex != 3) {
|
||||
custom_boxes.style.display = 'none';
|
||||
return false;
|
||||
}
|
||||
|
||||
var altlogin_username = document.getElementById('altlogin_username');
|
||||
if (altlogin_username != undefined && (altlogin_username.style.display == 'table-row' ||
|
||||
altlogin_username.style.display == 'block')) {
|
||||
f.security.selectedIndex = 0;
|
||||
custom_boxes.style.display = 'none';
|
||||
alert("Custom security is only available when posting as the logged in user.");
|
||||
} else {
|
||||
custom_boxes.style.display = 'block';
|
||||
}
|
||||
|
||||
if (e) {
|
||||
e.cancelBubble = true;
|
||||
if (e.stopPropagation) e.stopPropagation();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function altlogin (e) {
|
||||
var agt = navigator.userAgent.toLowerCase();
|
||||
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
|
||||
|
||||
if (! e) var e = window.event;
|
||||
if (! document.getElementById) return false;
|
||||
|
||||
var altlogin_username = document.getElementById('altlogin_username');
|
||||
if (! altlogin_username) return false;
|
||||
if (is_ie) { altlogin_username.style.display = 'block'; } else { altlogin_username.style.display = 'table-row'; }
|
||||
|
||||
var altlogin_password = document.getElementById('altlogin_password');
|
||||
if (! altlogin_password) return false;
|
||||
if (is_ie) { altlogin_password.style.display = 'block'; } else { altlogin_password.style.display = 'table-row'; }
|
||||
|
||||
var remotelogin = document.getElementById('remotelogin');
|
||||
if (! remotelogin) return false;
|
||||
remotelogin.style.display = 'none';
|
||||
|
||||
var usejournal_list = document.getElementById('usejournal_list');
|
||||
if (! usejournal_list) return false;
|
||||
usejournal_list.style.display = 'none';
|
||||
|
||||
var readonly = document.getElementById('readonly');
|
||||
var userbox = f.user;
|
||||
if (!userbox.value && readonly) {
|
||||
readonly.style.display = 'none';
|
||||
}
|
||||
|
||||
var userpic_list = document.getElementById('userpic_list_row');
|
||||
if (userpic_list) {
|
||||
userpic_list.style.display = 'none';
|
||||
var userpic_preview = document.getElementById('userpic_preview');
|
||||
userpic_preview.style.display = 'none';
|
||||
}
|
||||
|
||||
var mood_preview = document.getElementById('mood_preview');
|
||||
mood_preview.style.display = 'none';
|
||||
|
||||
f = document.updateForm;
|
||||
if (! f) return false;
|
||||
f.action = 'update.bml?altlogin=1';
|
||||
|
||||
var custom_boxes = document.getElementById('custom_boxes');
|
||||
if (! custom_boxes) return false;
|
||||
custom_boxes.style.display = 'none';
|
||||
f.security.selectedIndex = 0;
|
||||
f.security.removeChild(f.security.childNodes[3]);
|
||||
|
||||
if (e) {
|
||||
e.cancelBubble = true;
|
||||
if (e.stopPropagation) e.stopPropagation();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
function settime() {
|
||||
function twodigit (n) {
|
||||
if (n < 10) { return "0" + n; }
|
||||
else { return n; }
|
||||
}
|
||||
|
||||
now = new Date();
|
||||
if (! now) return false;
|
||||
f = document.updateForm;
|
||||
if (! f) return false;
|
||||
|
||||
f.date_ymd_yyyy.value = now.getYear() < 1900 ? now.getYear() + 1900 : now.getYear();
|
||||
f.date_ymd_mm.selectedIndex = twodigit(now.getMonth());
|
||||
f.date_ymd_dd.value = twodigit(now.getDate());
|
||||
f.hour.value = twodigit(now.getHours());
|
||||
f.min.value = twodigit(now.getMinutes());
|
||||
|
||||
return false;
|
||||
}
|
||||
393
livejournal/htdocs/js/md5.js
Executable file
393
livejournal/htdocs/js/md5.js
Executable file
@@ -0,0 +1,393 @@
|
||||
/*
|
||||
* md5.jvs 1.0b 27/06/96
|
||||
*
|
||||
* Javascript implementation of the RSA Data Security, Inc. MD5
|
||||
* Message-Digest Algorithm.
|
||||
*
|
||||
* Copyright (c) 1996 Henri Torgemane. All Rights Reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software
|
||||
* and its documentation for any purposes and without
|
||||
* fee is hereby granted provided that this copyright notice
|
||||
* appears in all copies.
|
||||
*
|
||||
* Of course, this soft is provided "as is" without express or implied
|
||||
* warranty of any kind.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function array(n) {
|
||||
for(i=0;i<n;i++) this[i]=0;
|
||||
this.length=n;
|
||||
}
|
||||
|
||||
/* Some basic logical functions had to be rewritten because of a bug in
|
||||
* Javascript.. Just try to compute 0xffffffff >> 4 with it..
|
||||
* Of course, these functions are slower than the original would be, but
|
||||
* at least, they work!
|
||||
*/
|
||||
|
||||
function integer(n) { return n%(0xffffffff+1); }
|
||||
|
||||
function shr(a,b) {
|
||||
a=integer(a);
|
||||
b=integer(b);
|
||||
if (a-0x80000000>=0) {
|
||||
a=a%0x80000000;
|
||||
a>>=b;
|
||||
a+=0x40000000>>(b-1);
|
||||
} else
|
||||
a>>=b;
|
||||
return a;
|
||||
}
|
||||
|
||||
function shl1(a) {
|
||||
a=a%0x80000000;
|
||||
if (a&0x40000000==0x40000000)
|
||||
{
|
||||
a-=0x40000000;
|
||||
a*=2;
|
||||
a+=0x80000000;
|
||||
} else
|
||||
a*=2;
|
||||
return a;
|
||||
}
|
||||
|
||||
function shl(a,b) {
|
||||
a=integer(a);
|
||||
b=integer(b);
|
||||
for (var i=0;i<b;i++) a=shl1(a);
|
||||
return a;
|
||||
}
|
||||
|
||||
function and(a,b) {
|
||||
a=integer(a);
|
||||
b=integer(b);
|
||||
var t1=(a-0x80000000);
|
||||
var t2=(b-0x80000000);
|
||||
if (t1>=0)
|
||||
if (t2>=0)
|
||||
return ((t1&t2)+0x80000000);
|
||||
else
|
||||
return (t1&b);
|
||||
else
|
||||
if (t2>=0)
|
||||
return (a&t2);
|
||||
else
|
||||
return (a&b);
|
||||
}
|
||||
|
||||
function or(a,b) {
|
||||
a=integer(a);
|
||||
b=integer(b);
|
||||
var t1=(a-0x80000000);
|
||||
var t2=(b-0x80000000);
|
||||
if (t1>=0)
|
||||
if (t2>=0)
|
||||
return ((t1|t2)+0x80000000);
|
||||
else
|
||||
return ((t1|b)+0x80000000);
|
||||
else
|
||||
if (t2>=0)
|
||||
return ((a|t2)+0x80000000);
|
||||
else
|
||||
return (a|b);
|
||||
}
|
||||
|
||||
function xor(a,b) {
|
||||
a=integer(a);
|
||||
b=integer(b);
|
||||
var t1=(a-0x80000000);
|
||||
var t2=(b-0x80000000);
|
||||
if (t1>=0)
|
||||
if (t2>=0)
|
||||
return (t1^t2);
|
||||
else
|
||||
return ((t1^b)+0x80000000);
|
||||
else
|
||||
if (t2>=0)
|
||||
return ((a^t2)+0x80000000);
|
||||
else
|
||||
return (a^b);
|
||||
}
|
||||
|
||||
function not(a) {
|
||||
a=integer(a);
|
||||
return (0xffffffff-a);
|
||||
}
|
||||
|
||||
/* Here begin the real algorithm */
|
||||
|
||||
var state = new array(4);
|
||||
var count = new array(2);
|
||||
count[0] = 0;
|
||||
count[1] = 0;
|
||||
var buffer = new array(64);
|
||||
var transformBuffer = new array(16);
|
||||
var digestBits = new array(16);
|
||||
|
||||
var S11 = 7;
|
||||
var S12 = 12;
|
||||
var S13 = 17;
|
||||
var S14 = 22;
|
||||
var S21 = 5;
|
||||
var S22 = 9;
|
||||
var S23 = 14;
|
||||
var S24 = 20;
|
||||
var S31 = 4;
|
||||
var S32 = 11;
|
||||
var S33 = 16;
|
||||
var S34 = 23;
|
||||
var S41 = 6;
|
||||
var S42 = 10;
|
||||
var S43 = 15;
|
||||
var S44 = 21;
|
||||
|
||||
function F(x,y,z) {
|
||||
return or(and(x,y),and(not(x),z));
|
||||
}
|
||||
|
||||
function G(x,y,z) {
|
||||
return or(and(x,z),and(y,not(z)));
|
||||
}
|
||||
|
||||
function H(x,y,z) {
|
||||
return xor(xor(x,y),z);
|
||||
}
|
||||
|
||||
function I(x,y,z) {
|
||||
return xor(y ,or(x , not(z)));
|
||||
}
|
||||
|
||||
function rotateLeft(a,n) {
|
||||
return or(shl(a, n),(shr(a,(32 - n))));
|
||||
}
|
||||
|
||||
function FF(a,b,c,d,x,s,ac) {
|
||||
a = a+F(b, c, d) + x + ac;
|
||||
a = rotateLeft(a, s);
|
||||
a = a+b;
|
||||
return a;
|
||||
}
|
||||
|
||||
function GG(a,b,c,d,x,s,ac) {
|
||||
a = a+G(b, c, d) +x + ac;
|
||||
a = rotateLeft(a, s);
|
||||
a = a+b;
|
||||
return a;
|
||||
}
|
||||
|
||||
function HH(a,b,c,d,x,s,ac) {
|
||||
a = a+H(b, c, d) + x + ac;
|
||||
a = rotateLeft(a, s);
|
||||
a = a+b;
|
||||
return a;
|
||||
}
|
||||
|
||||
function II(a,b,c,d,x,s,ac) {
|
||||
a = a+I(b, c, d) + x + ac;
|
||||
a = rotateLeft(a, s);
|
||||
a = a+b;
|
||||
return a;
|
||||
}
|
||||
|
||||
function transform(buf,offset) {
|
||||
var a=0, b=0, c=0, d=0;
|
||||
var x = transformBuffer;
|
||||
|
||||
a = state[0];
|
||||
b = state[1];
|
||||
c = state[2];
|
||||
d = state[3];
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
x[i] = and(buf[i*4+offset],0xff);
|
||||
for (j = 1; j < 4; j++) {
|
||||
x[i]+=shl(and(buf[i*4+j+offset] ,0xff), j * 8);
|
||||
}
|
||||
}
|
||||
|
||||
/* Round 1 */
|
||||
a = FF ( a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
|
||||
d = FF ( d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
|
||||
c = FF ( c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
|
||||
b = FF ( b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
|
||||
a = FF ( a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
|
||||
d = FF ( d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
|
||||
c = FF ( c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
|
||||
b = FF ( b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
|
||||
a = FF ( a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
|
||||
d = FF ( d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
|
||||
c = FF ( c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
|
||||
b = FF ( b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
|
||||
a = FF ( a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
|
||||
d = FF ( d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
|
||||
c = FF ( c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
|
||||
b = FF ( b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
|
||||
|
||||
/* Round 2 */
|
||||
a = GG ( a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
|
||||
d = GG ( d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
|
||||
c = GG ( c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
|
||||
b = GG ( b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
|
||||
a = GG ( a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
|
||||
d = GG ( d, a, b, c, x[10], S22, 0x2441453); /* 22 */
|
||||
c = GG ( c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
|
||||
b = GG ( b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
|
||||
a = GG ( a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
|
||||
d = GG ( d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
|
||||
c = GG ( c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
|
||||
b = GG ( b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
|
||||
a = GG ( a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
|
||||
d = GG ( d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
|
||||
c = GG ( c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
|
||||
b = GG ( b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
|
||||
|
||||
/* Round 3 */
|
||||
a = HH ( a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
|
||||
d = HH ( d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
|
||||
c = HH ( c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
|
||||
b = HH ( b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
|
||||
a = HH ( a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
|
||||
d = HH ( d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
|
||||
c = HH ( c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
|
||||
b = HH ( b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
|
||||
a = HH ( a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
|
||||
d = HH ( d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
|
||||
c = HH ( c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
|
||||
b = HH ( b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
|
||||
a = HH ( a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
|
||||
d = HH ( d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
|
||||
c = HH ( c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
|
||||
b = HH ( b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
|
||||
|
||||
/* Round 4 */
|
||||
a = II ( a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
|
||||
d = II ( d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
|
||||
c = II ( c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
|
||||
b = II ( b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
|
||||
a = II ( a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
|
||||
d = II ( d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
|
||||
c = II ( c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
|
||||
b = II ( b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
|
||||
a = II ( a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
|
||||
d = II ( d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
|
||||
c = II ( c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
|
||||
b = II ( b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
|
||||
a = II ( a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
|
||||
d = II ( d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
|
||||
c = II ( c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
|
||||
b = II ( b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
|
||||
|
||||
state[0] +=a;
|
||||
state[1] +=b;
|
||||
state[2] +=c;
|
||||
state[3] +=d;
|
||||
|
||||
}
|
||||
|
||||
function init() {
|
||||
count[0]=count[1] = 0;
|
||||
state[0] = 0x67452301;
|
||||
state[1] = 0xefcdab89;
|
||||
state[2] = 0x98badcfe;
|
||||
state[3] = 0x10325476;
|
||||
for (i = 0; i < digestBits.length; i++)
|
||||
digestBits[i] = 0;
|
||||
}
|
||||
|
||||
function update(b) {
|
||||
var index,i;
|
||||
|
||||
index = and(shr(count[0],3) , 0x3f);
|
||||
if (count[0]<0xffffffff-7)
|
||||
count[0] += 8;
|
||||
else {
|
||||
count[1]++;
|
||||
count[0]-=0xffffffff+1;
|
||||
count[0]+=8;
|
||||
}
|
||||
buffer[index] = and(b,0xff);
|
||||
if (index >= 63) {
|
||||
transform(buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function finish() {
|
||||
var bits = new array(8);
|
||||
var padding;
|
||||
var i=0, index=0, padLen=0;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
bits[i] = and(shr(count[0],(i * 8)), 0xff);
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
bits[i+4]=and(shr(count[1],(i * 8)), 0xff);
|
||||
}
|
||||
index = and(shr(count[0], 3) ,0x3f);
|
||||
padLen = (index < 56) ? (56 - index) : (120 - index);
|
||||
padding = new array(64);
|
||||
padding[0] = 0x80;
|
||||
for (i=0;i<padLen;i++)
|
||||
update(padding[i]);
|
||||
for (i=0;i<8;i++)
|
||||
update(bits[i]);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (j = 0; j < 4; j++) {
|
||||
digestBits[i*4+j] = and(shr(state[i], (j * 8)) , 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* End of the MD5 algorithm */
|
||||
|
||||
function hexa(n) {
|
||||
var hexa_h = "0123456789abcdef";
|
||||
var hexa_c="";
|
||||
var hexa_m=n;
|
||||
for (hexa_i=0;hexa_i<8;hexa_i++) {
|
||||
hexa_c=hexa_h.charAt(Math.abs(hexa_m)%16)+hexa_c;
|
||||
hexa_m=Math.floor(hexa_m/16);
|
||||
}
|
||||
return hexa_c;
|
||||
}
|
||||
|
||||
|
||||
var ascii="01234567890123456789012345678901" +
|
||||
" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"+
|
||||
"[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
|
||||
|
||||
function MD5(entree)
|
||||
{
|
||||
var l,s,k,ka,kb,kc,kd;
|
||||
|
||||
init();
|
||||
for (k=0;k<entree.length;k++) {
|
||||
l=entree.charAt(k);
|
||||
update(ascii.lastIndexOf(l));
|
||||
}
|
||||
finish();
|
||||
ka=kb=kc=kd=0;
|
||||
for (i=0;i<4;i++) ka+=shl(digestBits[15-i], (i*8));
|
||||
for (i=4;i<8;i++) kb+=shl(digestBits[15-i], ((i-4)*8));
|
||||
for (i=8;i<12;i++) kc+=shl(digestBits[15-i], ((i-8)*8));
|
||||
for (i=12;i<16;i++) kd+=shl(digestBits[15-i], ((i-12)*8));
|
||||
s=hexa(kd)+hexa(kc)+hexa(kb)+hexa(ka);
|
||||
return s;
|
||||
}
|
||||
|
||||
/* This implement the MD5 test suite */
|
||||
var testOk=false;
|
||||
function teste() {
|
||||
if (testOk) return;
|
||||
document.test.o1.value=MD5(document.test.i1.value);
|
||||
document.test.o2.value=MD5(document.test.i2.value);
|
||||
document.test.o3.value=MD5(document.test.i3.value);
|
||||
document.test.o4.value=MD5(document.test.i4.value);
|
||||
document.test.o5.value=MD5(document.test.i5.value);
|
||||
document.test.o6.value=MD5(document.test.i6.value);
|
||||
document.test.o7.value=MD5(document.test.i7.value);
|
||||
testOk=true;
|
||||
}
|
||||
357
livejournal/htdocs/js/richtext.js
Executable file
357
livejournal/htdocs/js/richtext.js
Executable file
@@ -0,0 +1,357 @@
|
||||
// Cross-Browser Rich Text Editor v2.0
|
||||
// http://www.kevinroth.com/rte/demo.htm
|
||||
// Written by Kevin Roth (kevin@NOSPAMkevinroth.com - remove NOSPAM)
|
||||
// Modifications by Kevin Phillips and Mahlon E. Smith for LiveJournal.com
|
||||
|
||||
//init variables
|
||||
var isRichText = false;
|
||||
var rng;
|
||||
var currentRTE;
|
||||
var textsize = 3;
|
||||
|
||||
function writeRichText(rte, postvar, html, width, height, buttons) {
|
||||
if (isRichText) {
|
||||
writeRTE(rte, postvar, html, width, height, buttons);
|
||||
setTimeout('updateRTE("' + rte + '");', 1000);
|
||||
} else {
|
||||
writeDefault(postvar, html, width, height, buttons);
|
||||
}
|
||||
}
|
||||
|
||||
function initRTE() {
|
||||
isRichText = browser.isRichText;
|
||||
}
|
||||
|
||||
function writeRTE(rte, postvar, html, width, height, buttons) {
|
||||
if (buttons == true) {
|
||||
document.writeln('<style type="text/css">');
|
||||
document.writeln('.btnImage {cursor: pointer; cursor: hand;}');
|
||||
document.writeln('</style>');
|
||||
document.writeln('<table cellpadding="1" cellspacing="0" border="0">');
|
||||
document.writeln(' <tr>');
|
||||
document.writeln(' <td><img class="btnImage" src="/img/rte/post_button_bold.gif" width="25" height="24" alt="Bold" title="Bold" onClick="FormatText(\'' + rte + '\', \'bold\', \'\')"></td>');
|
||||
document.writeln(' <td><img class="btnImage" src="/img/rte/post_button_italic.gif" width="25" height="24" alt="Italic" title="Italic" onClick="FormatText(\'' + rte + '\', \'italic\')"></td>');
|
||||
document.writeln(' <td><img class="btnImage" src="/img/rte/post_button_underline.gif" width="25" height="24" alt="Underline" title="Underline" onClick="FormatText(\'' + rte + '\', \'underline\', \'\')"></td>');
|
||||
document.writeln(' <td> </td>');
|
||||
document.writeln(' <td><img class="btnImage" src="/img/rte/post_button_text_smaller.gif" width="25" height="24" alt="Smaller Text" title="Smaller Text" onClick="FormatText(\'' + rte + '\', \'fontsize\', ChangeTSize(\'-\'));"></td>');
|
||||
document.writeln(' <td><img class="btnImage" src="/img/rte/post_button_text_normal.gif" width="25" height="24" alt="Normal Text" title="Normal Text" onClick="textsize = 3; FormatText(\'' + rte + '\', \'fontsize\', textsize);"></td>');
|
||||
document.writeln(' <td><img class="btnImage" src="/img/rte/post_button_text_larger.gif" width="25" height="24" alt="Larger Text" title="Larger Text" onClick="FormatText(\'' + rte + '\', \'fontsize\', ChangeTSize(\'+\'));"></td>');
|
||||
document.writeln(' <td> </td>');
|
||||
document.writeln(' <td><div id="forecolor"><img class="btnImage" src="/img/rte/post_button_textcolor.gif" width="25" height="24" alt="Text Color" title="Text Color" onClick="FormatText(\'' + rte + '\', \'forecolor\', \'\')"></div></td>');
|
||||
document.writeln(' <td> </td>');
|
||||
document.writeln(' <td><img class="btnImage" src="/img/rte/post_button_numbered_list.gif" width="25" height="24" alt="Ordered List" title="Ordered List" onClick="FormatText(\'' + rte + '\', \'insertorderedlist\', \'\')"></td>');
|
||||
document.writeln(' <td><img class="btnImage" src="/img/rte/post_button_list.gif" width="25" height="24" alt="Unordered List" title="Unordered List" onClick="FormatText(\'' + rte + '\', \'insertunorderedlist\', \'\')"></td>');
|
||||
document.writeln(' <td> </td>');
|
||||
document.writeln(' <td><img class="btnImage" src="/img/rte/post_button_hyperlink.gif" width="25" height="24" alt="Insert Link" title="Insert Link" onClick="FormatText(\'' + rte + '\', \'createlink\')"></td>');
|
||||
document.writeln(' <td><img class="btnImage" src="/img/rte/post_button_image.gif" width="25" height="24" alt="Add Image" title="Add Image" onClick="AddImage(\'' + rte + '\')"></td>');
|
||||
document.writeln(' <td> </td>');
|
||||
document.writeln(' <td><img class="btnImage" src="/img/rte/post_button_ljuser.gif" width="25" height="24" alt="Add LJ User" title="Add LJ User" onClick="AddLJTag(\'' + rte + '\', \'user\')"></td>');
|
||||
document.writeln(' <td><img class="btnImage" src="/img/rte/post_button_ljcut.gif" width="25" height="24" alt="Add LJ Cut" title="Add LJ Cut" onClick="AddLJTag(\'' + rte + '\', \'cut\')"></td>');
|
||||
document.writeln(' <td> </td>');
|
||||
document.writeln(' <td><img class="btnImage" src="/img/rte/post_button_undo.gif" width="25" height="24" alt="Undo" title="Undo" onClick="FormatText(\'' + rte + '\', \'undo\')"></td>');
|
||||
document.writeln(' <td><img class="btnImage" src="/img/rte/post_button_redo.gif" width="25" height="24" alt="Redo" title="Redo" onClick="FormatText(\'' + rte + '\', \'redo\')"></td>');
|
||||
document.writeln(' </tr>');
|
||||
document.writeln('</table>');
|
||||
}
|
||||
document.writeln('<iframe onblur="save_entry();" name="event" id="' + rte + '" width="' + width + 'px" height="' + height + 'px" src="/rte/blank.html"></iframe>');
|
||||
document.writeln('<iframe width="254" height="174" id="cp' + rte + '" src="/rte/palette.html" marginwidth="0" marginheight="0" scrolling="no" style="visibility:hidden; position: absolute;"></iframe>');
|
||||
document.writeln('<input type="hidden" id="hdn' + rte + '" name="' + postvar + '" value="">');
|
||||
if (browser.isIE55up) {
|
||||
enableDesignMode(rte, html);
|
||||
} else {
|
||||
setTimeout(function(){ enableDesignMode(rte, html); }, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
function writeDefault(rte, html, width, height, buttons) {
|
||||
document.writeln('<textarea name="' + rte + '" id="' + rte + '" style="width: ' + width + '; height: ' + height + 'px;">' + html + '</textarea>');
|
||||
}
|
||||
|
||||
function enableDesignMode(rte, html) {
|
||||
var content = document.getElementById('rte');
|
||||
var saved_entry = document.updateForm.saved_entry.value;
|
||||
if (saved_entry != "") html = saved_entry; // only for gecko browsers
|
||||
|
||||
if (browser.isIE55up) {
|
||||
frames[rte].document.designMode = "On";
|
||||
setTimeout(function(){ content.contentWindow.document.body.innerHTML = html; }, 100);
|
||||
}
|
||||
else {
|
||||
document.getElementById(rte).contentDocument.designMode = "on"
|
||||
setTimeout(function(){ content.contentWindow.document.body.innerHTML = html; }, 100);
|
||||
setTimeout(function(){ content.contentDocument.designMode = 'on'; }, 200);
|
||||
}
|
||||
}
|
||||
|
||||
//Change textsize within boundries allowed by midas. (1 .. 7)
|
||||
function ChangeTSize(dir) {
|
||||
if (dir == "-") {
|
||||
if (textsize == 1) return textsize;
|
||||
textsize--;
|
||||
}
|
||||
if (dir == "+") {
|
||||
if (textsize == 7) return textsize;
|
||||
textsize++;
|
||||
}
|
||||
return textsize;
|
||||
}
|
||||
|
||||
// Check for allowed lj user characters
|
||||
function goodChars(str) {
|
||||
var pattern = /^\w{1,15}$/i;
|
||||
return pattern.test(str);
|
||||
}
|
||||
|
||||
// lj-user text
|
||||
function make_ljuser (res, type) {
|
||||
if (type != null) { // gecko
|
||||
// manually build lj user node
|
||||
var span = document.createElement("span");
|
||||
span.setAttribute("class", "ljuser");
|
||||
|
||||
var img = document.createElement("img");
|
||||
img.setAttribute("src", siteroot + "/img/userinfo.gif");
|
||||
img.setAttribute("alt", "userinfo");
|
||||
img.setAttribute("width", "17");
|
||||
img.setAttribute("height", "17");
|
||||
img.setAttribute("style", "vertical-align: bottom; border: 0;");
|
||||
|
||||
var uinfo_link = document.createElement("a");
|
||||
uinfo_link.setAttribute("href", siteroot + '/userinfo.bml?user=' + res);
|
||||
uinfo_link.appendChild(img);
|
||||
|
||||
var userlink = document.createTextNode(res);
|
||||
var bold = document.createElement("b");
|
||||
var ujournal_link = document.createElement("a");
|
||||
ujournal_link.setAttribute("href", siteroot + '/users/' + res + '/');
|
||||
bold.appendChild(userlink);
|
||||
ujournal_link.appendChild(bold);
|
||||
|
||||
span.appendChild(uinfo_link);
|
||||
span.appendChild(ujournal_link);
|
||||
|
||||
rng.insertNode(span);
|
||||
} else { // ie
|
||||
return "<span class=\"ljuser\" style='white-space: nowrap;'><a href='" + siteroot + "/userinfo.bml?user=" + res + "'><img src='" + siteroot + "/img/userinfo.gif' alt='userinfo' width='17' height='17' style='vertical-align: bottom; border: 0;' /></a><a href='" + siteroot + "/users/" + res + "/'><b>" + res + "</b></a></span> ";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Add LJ specific tags - lj user and lj-cut.
|
||||
function AddLJTag(rte, type) {
|
||||
var cw = document.getElementById(rte).contentWindow;
|
||||
var res;
|
||||
|
||||
// Get current user selection
|
||||
if (cw.window.getSelection) { // gecko
|
||||
res = cw.window.getSelection();
|
||||
rng = cw.window.getSelection().getRangeAt(0);
|
||||
} else if (cw.document.selection) { // ie
|
||||
rng = cw.document.selection.createRange();
|
||||
res = rng.text;
|
||||
}
|
||||
|
||||
// lj-user
|
||||
if (type == 'user') {
|
||||
if (res == "" || res.length == 0) {
|
||||
// Nothing selected or totally unsupported
|
||||
res = prompt('Enter a username', '');
|
||||
if ((res != null) && (res != "")) {
|
||||
if (! goodChars(res)) {
|
||||
alert("Invalid characters in username.");
|
||||
return;
|
||||
}
|
||||
cw.focus();
|
||||
// tack onto the existing text
|
||||
cw.document.body.innerHTML += make_ljuser(res);
|
||||
return;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (! goodChars(res)) {
|
||||
alert("Invalid characters in username.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (rng.pasteHTML) { // ie
|
||||
rng.pasteHTML(make_ljuser(res));
|
||||
} else { // gecko
|
||||
var username = rng.toString();
|
||||
rng.deleteContents();
|
||||
make_ljuser(username, "node");
|
||||
}
|
||||
}
|
||||
|
||||
// lj-cut
|
||||
if (type == 'cut') {
|
||||
var cut = prompt('Optional cut caption', '');
|
||||
if (cut != null) {
|
||||
var cuttag;
|
||||
var cutend = "\n</lj-cut>\n";
|
||||
cw.focus();
|
||||
|
||||
if (cut == "") {
|
||||
cuttag = '<lj-cut>' + "\n";
|
||||
} else {
|
||||
cuttag = '<lj-cut text="' + cut + '">' + "\n";
|
||||
}
|
||||
|
||||
if (rng.text && rng.text != "") { // ie
|
||||
rng.text = cuttag + rng.text;
|
||||
if (res.length > 0) rng.text += cutend;
|
||||
} else if (rng.insertNode && rng.toString() != "") { // gecko
|
||||
var content = document.createTextNode(rng.toString());
|
||||
var cut_s = document.createTextNode(cuttag);
|
||||
var cut_e = document.createTextNode(cutend);
|
||||
rng.deleteContents();
|
||||
rng.insertNode(cut_e);
|
||||
rng.insertNode(content);
|
||||
rng.insertNode(cut_s);
|
||||
} else { // nothing selected or totally unsupported
|
||||
if (cut == "") {
|
||||
cuttag = '<lj-cut>' + "\n";
|
||||
} else {
|
||||
cuttag = '<lj-cut text="' + cut + '">' + "\n";
|
||||
}
|
||||
cw.document.body.innerHTML += cuttag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cw.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//Function to format text in the text box
|
||||
function FormatText(rte, command, option) {
|
||||
if ((command == "forecolor") || (command == "hilitecolor")) {
|
||||
parent.command = command;
|
||||
buttonElement = document.getElementById(command);
|
||||
document.getElementById('cp' + rte).style.left = getOffsetLeft(buttonElement) + "px";
|
||||
document.getElementById('cp' + rte).style.top = (getOffsetTop(buttonElement) + buttonElement.offsetHeight) + "px";
|
||||
if (document.getElementById('cp' + rte).style.visibility == "hidden")
|
||||
document.getElementById('cp' + rte).style.visibility="visible";
|
||||
else {
|
||||
document.getElementById('cp' + rte).style.visibility="hidden";
|
||||
}
|
||||
|
||||
//get current selected rte
|
||||
currentRTE = rte;
|
||||
|
||||
//get current selected range
|
||||
var sel = document.getElementById(rte).contentWindow.document.selection;
|
||||
if (sel!=null) {
|
||||
rng = sel.createRange();
|
||||
}
|
||||
}
|
||||
else if (command == "createlink") { // && browser.isIE55up == false
|
||||
var szURL = prompt("Enter a URL:", "http://");
|
||||
document.getElementById(rte).contentWindow.document.execCommand("Unlink",false,null);
|
||||
if ((szURL != "http://") && (szURL != "")) {
|
||||
document.getElementById(rte).contentWindow.document.execCommand("CreateLink",false,szURL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
document.getElementById(rte).contentWindow.focus();
|
||||
document.getElementById(rte).contentWindow.document.execCommand(command, false, option);
|
||||
document.getElementById(rte).contentWindow.focus();
|
||||
}
|
||||
}
|
||||
|
||||
//Function to set color
|
||||
function setColor(color) {
|
||||
var parentCommand = parent.command;
|
||||
var rte = currentRTE;
|
||||
|
||||
if (browser.isIE55up) {
|
||||
//retrieve selected range
|
||||
var sel = document.getElementById(rte).contentWindow.document.selection;
|
||||
if (parentCommand == "hilitecolor") parentCommand = "backcolor";
|
||||
if (sel!=null) {
|
||||
var newRng = sel.createRange();
|
||||
newRng = rng;
|
||||
newRng.select();
|
||||
}
|
||||
}
|
||||
else {
|
||||
document.getElementById(rte).contentWindow.focus();
|
||||
}
|
||||
document.getElementById(rte).contentWindow.document.execCommand(parentCommand, false, color);
|
||||
document.getElementById(rte).contentWindow.focus();
|
||||
document.getElementById('cp' + rte).style.visibility="hidden";
|
||||
}
|
||||
|
||||
//Function to add image
|
||||
function AddImage(rte) {
|
||||
imagePath = prompt('Enter Image URL:', 'http://');
|
||||
if ((imagePath != null) && (imagePath != "") && (imagePath != "http://")) {
|
||||
document.getElementById(rte).contentWindow.focus()
|
||||
document.getElementById(rte).contentWindow.document.execCommand('InsertImage', false, imagePath);
|
||||
}
|
||||
document.getElementById(rte).contentWindow.focus()
|
||||
}
|
||||
|
||||
//Function to clear form
|
||||
function ResetForm(rte) {
|
||||
if (window.confirm('<%=strResetFormConfirm%>')) {
|
||||
document.getElementById(rte).contentWindow.focus()
|
||||
document.getElementById(rte).contentWindow.document.body.innerHTML = '';
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getOffsetTop(elm) {
|
||||
var mOffsetTop = elm.offsetTop;
|
||||
var mOffsetParent = elm.offsetParent;
|
||||
|
||||
while(mOffsetParent){
|
||||
mOffsetTop += mOffsetParent.offsetTop;
|
||||
mOffsetParent = mOffsetParent.offsetParent;
|
||||
}
|
||||
|
||||
return mOffsetTop;
|
||||
}
|
||||
|
||||
function getOffsetLeft(elm) {
|
||||
var mOffsetLeft = elm.offsetLeft;
|
||||
var mOffsetParent = elm.offsetParent;
|
||||
|
||||
while(mOffsetParent) {
|
||||
mOffsetLeft += mOffsetParent.offsetLeft;
|
||||
mOffsetParent = mOffsetParent.offsetParent;
|
||||
}
|
||||
|
||||
return mOffsetLeft;
|
||||
}
|
||||
|
||||
function Select(rte, selectname)
|
||||
{
|
||||
var cursel = document.getElementById(selectname).selectedIndex;
|
||||
// First one is always a label
|
||||
if (cursel != 0) {
|
||||
var selected = document.getElementById(selectname).options[cursel].value;
|
||||
document.getElementById(rte).contentWindow.document.execCommand(selectname, false, selected);
|
||||
document.getElementById(selectname).selectedIndex = 0;
|
||||
}
|
||||
document.getElementById(rte).contentWindow.focus();
|
||||
}
|
||||
|
||||
function updateRTE(rte) {
|
||||
//set message value
|
||||
var oHdnMessage = document.getElementById('hdn' + rte);
|
||||
var oMessageFrame = document.getElementById(rte);
|
||||
|
||||
if (isRichText) {
|
||||
if (oHdnMessage.value == null) oHdnMessage.value = "";
|
||||
oHdnMessage.value = oMessageFrame.contentWindow.document.body.innerHTML;
|
||||
|
||||
//exception for Mozilla
|
||||
if (oHdnMessage.value.indexOf('<br>') > -1 && oHdnMessage.value.length == 8) oHdnMessage.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
initRTE();
|
||||
201
livejournal/htdocs/js/tags.js
Executable file
201
livejournal/htdocs/js/tags.js
Executable file
@@ -0,0 +1,201 @@
|
||||
|
||||
function initTagPage()
|
||||
{
|
||||
// initial page load - setup page elements based on
|
||||
// what is selected in the option list.
|
||||
// (initial page load has nothing selected, of course,
|
||||
// but we need to check anyway for 'back' button stuff.)
|
||||
var list = document.getElementById("tags");
|
||||
if (list) tagselect(list);
|
||||
}
|
||||
|
||||
function toggle_actions(enable, just_rename)
|
||||
{
|
||||
var form = document.getElementById("tagform");
|
||||
if (! form) return;
|
||||
|
||||
// names of form elements to disable/enable
|
||||
// on item selections
|
||||
var toggle_elements = new Array("rename", "rename_field", "delete", "show posts");
|
||||
|
||||
for ( $i = 0; $i < toggle_elements.length; $i++ ) {
|
||||
var ele = form.elements[ toggle_elements[$i] ];
|
||||
if (just_rename && $i > 1) continue; // FIXME: remove after merge is decided
|
||||
ele.disabled = ! enable;
|
||||
}
|
||||
}
|
||||
|
||||
function tagselect(list)
|
||||
{
|
||||
if (! list) return;
|
||||
|
||||
var selected_num = 0; // counter
|
||||
var selected = new Array(); // tagnames, for display
|
||||
|
||||
var selected_id; // tag id if only one selected
|
||||
var id_re = /^\d+/;
|
||||
|
||||
for ( $i = 0; $i < list.options.length; $i++ ) {
|
||||
if (list.options[$i].selected) {
|
||||
var val = list.options[$i].value;
|
||||
selected[selected_num] = val.substring( val.indexOf('_')+1 );
|
||||
selected_num++;
|
||||
selected_id = val.match(id_re);
|
||||
}
|
||||
}
|
||||
|
||||
var form = document.getElementById("tagform");
|
||||
if (! form) return;
|
||||
|
||||
var tagfield = document.getElementById("selected_tags");
|
||||
var tagprops = document.getElementById("tag_props");
|
||||
var rename_btn = form.elements[ "rename" ];
|
||||
if (! tagfield || ! tagprops || ! rename_btn) return;
|
||||
|
||||
// reset any 'red' fields
|
||||
reset_field( form.elements[ "rename_field" ]);
|
||||
reset_field( form.elements[ "add_field" ]);
|
||||
|
||||
// no selections
|
||||
if (! selected_num) {
|
||||
toggle_actions(false);
|
||||
rename_btn.value = "Rename";
|
||||
show_props(tagprops);
|
||||
} else {
|
||||
toggle_actions(true);
|
||||
tagfield.innerHTML = selected.join(", ");
|
||||
|
||||
// exactly one selection
|
||||
if (selected_num == 1) {
|
||||
rename_btn.value = "Rename";
|
||||
show_props(tagprops, selected_id);
|
||||
}
|
||||
|
||||
// multiple items selected
|
||||
else {
|
||||
// FIXME: enable after merging is decided
|
||||
//rename_btn.value = "Merge";
|
||||
toggle_actions(false, 1); // FIXME: delete after merging is decided
|
||||
show_props(tagprops);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// just check for word characters or 'bad phrase',
|
||||
// change css on problems.
|
||||
function validate_input(btn, field_name, badtext)
|
||||
{
|
||||
var form = document.getElementById("tagform");
|
||||
if (! form) return true; // let submit happen
|
||||
var field = form.elements[ field_name ];
|
||||
if (! field) return true;
|
||||
|
||||
var re = /\w/;
|
||||
if (! field.value.match(re) || field.value.indexOf(badtext) != -1) {
|
||||
field.className = 'tagfield_error';
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function reset_field(field, resettext)
|
||||
{
|
||||
if ( !field ) return;
|
||||
field.className = 'tagfield';
|
||||
if (resettext && field.value.indexOf(resettext) != -1) field.value = '';
|
||||
}
|
||||
|
||||
// update tag properties - display with
|
||||
// security counts. right now, we have a
|
||||
// JS array with everything in tags.bml.
|
||||
// eventually, this needs to be some xml-rpc goodness,
|
||||
// with JS caching on the results of rpc calls.
|
||||
function show_props(div, id)
|
||||
{
|
||||
var tag = tags[id];
|
||||
var out;
|
||||
|
||||
if (! tag) tag = [ 'n/a', 'n/a', '-', '-', '-', '-', '-' ];
|
||||
|
||||
var secimg = ' <img align="middle" src="/img/';
|
||||
if (tag[1] == "public") {
|
||||
secimg = secimg + "userinfo.gif";
|
||||
}
|
||||
else if (tag[1] == "private") {
|
||||
secimg = secimg + "icon_private.gif";
|
||||
}
|
||||
else if (tag[1] == "friends") {
|
||||
secimg = secimg + "icon_protected.gif";
|
||||
}
|
||||
else {
|
||||
secimg = secimg + "icon_protected.gif";
|
||||
}
|
||||
secimg = secimg + '" />';
|
||||
if (tag[1] == "n/a") secimg = "";
|
||||
|
||||
out = "<table class='proptbl' cellspacing='0'>";
|
||||
out = out + "<tr><td class='h' colspan='2'>counts and security</td></tr>";
|
||||
out = out + "<tr><td class='t'>public</td><td class='c'>" + tag[2] + "</td></tr>";
|
||||
out = out + "<tr><td class='t'>private</td><td class='c'>" + tag[3] + "</td></tr>";
|
||||
out = out + "<tr><td class='t'>friends</td><td class='c'>" + tag[4] + "</td></tr>";
|
||||
out = out + "<tr><td class='t'>custom groups</td><td class='c'>" + tag[5] + "</td></tr>";
|
||||
out = out + "<tr><td class='r'>total</td><td class='rv'>" + tag[6] + "</td></tr>";
|
||||
out = out + "<tr><td class='r' style='height: 16px'>security</td><td class='rv' align='middle'>" + tag[1] + secimg + "</td></tr>";
|
||||
out = out + "</table>";
|
||||
|
||||
div.innerHTML = out;
|
||||
return;
|
||||
}
|
||||
|
||||
// for edittags.bml
|
||||
function edit_tagselect(list)
|
||||
{
|
||||
if (! list) return;
|
||||
|
||||
var selected = new Array(); // tagnames, for display
|
||||
selected_num = 0;
|
||||
|
||||
for ( $i = 0; $i < list.options.length; $i++ ) {
|
||||
if (list.options[$i].selected) {
|
||||
selected[selected_num] = list.options[$i].value;
|
||||
selected_num++;
|
||||
}
|
||||
}
|
||||
|
||||
var form = document.getElementById("edit_tagform");
|
||||
if (! form) return;
|
||||
|
||||
var tagfield = form.elements[ "tagfield" ];
|
||||
if (! tagfield ) return;
|
||||
|
||||
// merge selected and current tags into new array
|
||||
var cur_tags = new Array();
|
||||
cur_tags = cur_taglist.split(", ");
|
||||
|
||||
var taglist = new Array();
|
||||
|
||||
for ( $i = 0; $i < selected.length; $i++ ) {
|
||||
var sel_tag = selected[$i];
|
||||
var seen = 0;
|
||||
for ( $j = 0; $j < cur_tags.length; $j++ ) {
|
||||
if (sel_tag == cur_tags[$j]) seen = 1;
|
||||
}
|
||||
if (seen == 0) taglist.push(sel_tag);
|
||||
}
|
||||
|
||||
if (taglist.length) {
|
||||
if (cur_taglist.length > 0) {
|
||||
tagfield.value = cur_taglist + ", " + taglist.join(", ");
|
||||
} else {
|
||||
tagfield.value = taglist.join(", ");
|
||||
}
|
||||
} else {
|
||||
tagfield.value = cur_taglist;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
255
livejournal/htdocs/js/talkpost.js
Executable file
255
livejournal/htdocs/js/talkpost.js
Executable file
@@ -0,0 +1,255 @@
|
||||
|
||||
var usernameWasFocused = 0;
|
||||
|
||||
if (document.getElementById) {
|
||||
// If there's no getElementById, this whole script won't do anything
|
||||
|
||||
var radio_remote = document.getElementById("talkpostfromremote");
|
||||
var radio_user = document.getElementById("talkpostfromlj");
|
||||
var radio_anon = document.getElementById("talkpostfromanon");
|
||||
var radio_oidlo = document.getElementById("talkpostfromoidlo");
|
||||
var radio_oidli = document.getElementById("talkpostfromoidli");
|
||||
|
||||
var check_login = document.getElementById("logincheck");
|
||||
var sel_pickw = document.getElementById("prop_picture_keyword");
|
||||
var commenttext = document.getElementById("commenttext");
|
||||
|
||||
var form = document.getElementById("postform");
|
||||
|
||||
var username = form.userpost;
|
||||
username.onfocus = function () { usernameWasFocused = 1; }
|
||||
var password = form.password;
|
||||
|
||||
var oidurl = document.getElementById("oidurl");
|
||||
var oid_more = document.getElementById("oid_more");
|
||||
var lj_more = document.getElementById("lj_more");
|
||||
var ljuser_row = document.getElementById("ljuser_row");
|
||||
var otherljuser_row = document.getElementById("otherljuser_row");
|
||||
var oidlo_row = document.getElementById("oidlo");
|
||||
var oidli_row = document.getElementById("oidli");
|
||||
|
||||
var remotef = document.getElementById("cookieuser");
|
||||
var remote;
|
||||
if (remotef) {
|
||||
remote = remotef.value;
|
||||
}
|
||||
|
||||
var subjectIconField = document.getElementById("subjectIconField");
|
||||
var subjectIconImage = document.getElementById("subjectIconImage");
|
||||
|
||||
var subject_field = document.getElementById("subject");
|
||||
var subject_nohtml = document.getElementById("ljnohtmlsubj");
|
||||
subject_nohtml.style.display = 'none';
|
||||
}
|
||||
|
||||
var apicurl = "";
|
||||
var picprevt;
|
||||
|
||||
if (! sel_pickw) {
|
||||
// make a fake sel_pickw to play with later
|
||||
sel_pickw = new Object();
|
||||
}
|
||||
|
||||
function handleRadios(sel) {
|
||||
password.disabled = check_login.disabled = (sel != 2);
|
||||
if (password.disabled) password.value='';
|
||||
|
||||
// Anonymous
|
||||
if (sel == 0) {
|
||||
if (radio_anon.checked != 1) {
|
||||
radio_anon.checked = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Remote LJ User
|
||||
if (sel == 1) {
|
||||
if (radio_remote.checked != 1) {
|
||||
radio_remote.checked = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// LJ User
|
||||
if (sel == 2) {
|
||||
if (ljuser_row) {
|
||||
ljuser_row.style.display = 'none';
|
||||
}
|
||||
if (lj_more) {
|
||||
lj_more.style.display = '';
|
||||
}
|
||||
username.focus();
|
||||
|
||||
if (radio_user.checked != 1) {
|
||||
radio_user.checked = 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (lj_more) {
|
||||
lj_more.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// OpenID
|
||||
if (oid_more) {
|
||||
if (sel == 3) {
|
||||
oid_more.style.display = '';
|
||||
oidurl.focus();
|
||||
if (oidli_row) {
|
||||
oidli_row.style.display = 'none';
|
||||
}
|
||||
oidlo_row.style.display = '';
|
||||
|
||||
if (radio_oidlo.checked != 1) {
|
||||
radio_oidlo.checked = 1;
|
||||
}
|
||||
|
||||
} else if (sel == 4) {
|
||||
if (oidlo_row) {
|
||||
oidlo_row.style.display = 'none';
|
||||
}
|
||||
oidli_row.style.display = '';
|
||||
oid_more.style.display = 'none';
|
||||
|
||||
if (radio_oidli.checked != 1) {
|
||||
radio_oidli.checked = 1;
|
||||
}
|
||||
} else {
|
||||
oid_more.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
if (sel_pickw.disabled = (sel != 1)) sel_pickw.value='';
|
||||
}
|
||||
|
||||
function submitHandler() {
|
||||
if (remote && username.value == remote && ((! radio_anon || ! radio_anon.checked) && (! radio_oidlo || ! radio_oidlo.checked))) {
|
||||
// Quietly arrange for cookieuser auth instead, to avoid
|
||||
// sending cleartext password.
|
||||
password.value = "";
|
||||
username.value = "";
|
||||
radio_remote.checked = true;
|
||||
return true;
|
||||
}
|
||||
if (usernameWasFocused && username.value && ! radio_user.checked) {
|
||||
alert(usermismatchtext);
|
||||
return false;
|
||||
}
|
||||
if (! radio_user.checked) {
|
||||
username.value = "";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (document.getElementById) {
|
||||
|
||||
if (radio_anon && radio_anon.checked) handleRadios(0);
|
||||
if (radio_remote && radio_remote.checked) handleRadios(1);
|
||||
if (radio_user && radio_user.checked) handleRadios(2);
|
||||
if (radio_oidlo && radio_oidlo.checked) handleRadios(3);
|
||||
if (radio_oidli && radio_oidli.checked) handleRadios(4);
|
||||
|
||||
if (radio_remote) {
|
||||
radio_remote.onclick = function () {
|
||||
handleRadios(1);
|
||||
};
|
||||
if (radio_remote.checked) handleRadios(1);
|
||||
}
|
||||
if (radio_user)
|
||||
radio_user.onclick = function () {
|
||||
handleRadios(2);
|
||||
};
|
||||
if (radio_anon)
|
||||
radio_anon.onclick = function () {
|
||||
handleRadios(0);
|
||||
};
|
||||
if (radio_oidlo)
|
||||
radio_oidlo.onclick = function () {
|
||||
handleRadios(3);
|
||||
};
|
||||
if (radio_oidli)
|
||||
radio_oidli.onclick = function () {
|
||||
handleRadios(4);
|
||||
};
|
||||
username.onkeydown = username.onchange = function () {
|
||||
if (radio_remote) {
|
||||
password.disabled = check_login.disabled = 0;
|
||||
if (password.disabled) password.value='';
|
||||
} else {
|
||||
if (radio_user && username.value != "")
|
||||
radio_user.checked = true;
|
||||
handleRadios(2); // update the form
|
||||
}
|
||||
}
|
||||
form.onsubmit = submitHandler;
|
||||
|
||||
document.onload = function () {
|
||||
if (radio_anon && radio_anon.checked) handleRadios(0);
|
||||
if (radio_user && radio_user.checked) otherLJUser();
|
||||
if (radio_remote && radio_remote.checked) handleRadios(1);
|
||||
if (radio_oidlo && radio_oidlo.checked) handleRadios(3);
|
||||
if (radio_oidli && radio_oidli.checked) handleRadios(4);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// toggle subject icon list
|
||||
|
||||
function subjectIconListToggle() {
|
||||
if (! document.getElementById) { return; }
|
||||
var subjectIconList = document.getElementById("subjectIconList");
|
||||
if(subjectIconList) {
|
||||
if (subjectIconList.style.display != 'block') {
|
||||
subjectIconList.style.display = 'block';
|
||||
} else {
|
||||
subjectIconList.style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// change the subject icon and hide the list
|
||||
|
||||
function subjectIconChange(icon) {
|
||||
if (! document.getElementById) { return; }
|
||||
if (icon) {
|
||||
if(subjectIconField) subjectIconField.value=icon.id;
|
||||
if(subjectIconImage) {
|
||||
subjectIconImage.src=icon.src;
|
||||
subjectIconImage.width=icon.width;
|
||||
subjectIconImage.height=icon.height;
|
||||
}
|
||||
subjectIconListToggle();
|
||||
}
|
||||
}
|
||||
|
||||
function subjectNoHTML(e) {
|
||||
|
||||
var key;
|
||||
|
||||
key = getKey(e);
|
||||
|
||||
if (key == 60) {
|
||||
subject_nohtml.style.display = 'block';
|
||||
}
|
||||
}
|
||||
|
||||
function getKey(e) {
|
||||
if (window.event) {
|
||||
return window.event.keyCode;
|
||||
} else if(e) {
|
||||
return e.which;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function otherLJUser() {
|
||||
handleRadios(2);
|
||||
|
||||
otherljuser_row.style.display = '';
|
||||
radio_user.checked = 1;
|
||||
}
|
||||
|
||||
function otherOIDUser() {
|
||||
handleRadios(3);
|
||||
|
||||
radio_oidlo.checked = 1;
|
||||
}
|
||||
305
livejournal/htdocs/js/x_core.js
Executable file
305
livejournal/htdocs/js/x_core.js
Executable file
@@ -0,0 +1,305 @@
|
||||
// x_core.js, X v3.15.2, Cross-Browser.com DHTML Library
|
||||
// Copyright (c) 2004 Michael Foster, Licensed LGPL (gnu.org)
|
||||
|
||||
// global vars still duplicated in xlib.js - I still don't know what I'm going to do about this
|
||||
var xVersion='3.15.2',xNN4,xOp7,xOp5or6,xIE4Up,xIE4,xIE5,xMac,xUA=navigator.userAgent.toLowerCase();
|
||||
if (window.opera){
|
||||
xOp7=(xUA.indexOf('opera 7')!=-1 || xUA.indexOf('opera/7')!=-1);
|
||||
if (!xOp7) xOp5or6=(xUA.indexOf('opera 5')!=-1 || xUA.indexOf('opera/5')!=-1 || xUA.indexOf('opera 6')!=-1 || xUA.indexOf('opera/6')!=-1);
|
||||
}
|
||||
else if (document.all && xUA.indexOf('msie')!=-1) {
|
||||
xIE4Up=parseInt(navigator.appVersion)>=4;
|
||||
xIE4=xUA.indexOf('msie 4')!=-1;
|
||||
xIE5=xUA.indexOf('msie 5')!=-1;
|
||||
}
|
||||
else if (document.layers) {xNN4=true;}
|
||||
xMac=xUA.indexOf('mac')!=-1;
|
||||
|
||||
function xGetElementById(e) {
|
||||
if(typeof(e)!='string') return e;
|
||||
if(document.getElementById) e=document.getElementById(e);
|
||||
else if(document.all) e=document.all[e];
|
||||
else e=null;
|
||||
return e;
|
||||
}
|
||||
function xParent(e,bNode){
|
||||
if (!(e=xGetElementById(e))) return null;
|
||||
var p=null;
|
||||
if (!bNode && xDef(e.offsetParent)) p=e.offsetParent;
|
||||
else if (xDef(e.parentNode)) p=e.parentNode;
|
||||
else if (xDef(e.parentElement)) p=e.parentElement;
|
||||
return p;
|
||||
}
|
||||
function xDef() {
|
||||
for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
|
||||
return true;
|
||||
}
|
||||
function xStr(s) {
|
||||
for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
|
||||
return true;
|
||||
}
|
||||
function xNum(n) {
|
||||
for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='number') return false;}
|
||||
return true;
|
||||
}
|
||||
function xShow(e) {
|
||||
if(!(e=xGetElementById(e))) return;
|
||||
if(e.style && xDef(e.style.visibility)) e.style.visibility='visible';
|
||||
}
|
||||
function xHide(e) {
|
||||
if(!(e=xGetElementById(e))) return;
|
||||
if(e.style && xDef(e.style.visibility)) e.style.visibility='hidden';
|
||||
}
|
||||
function xZIndex(e,uZ) {
|
||||
if(!(e=xGetElementById(e))) return 0;
|
||||
if(e.style && xDef(e.style.zIndex)) {
|
||||
if(xNum(uZ)) e.style.zIndex=uZ;
|
||||
uZ=parseInt(e.style.zIndex);
|
||||
}
|
||||
return uZ;
|
||||
}
|
||||
function xColor(e,sColor) {
|
||||
if(!(e=xGetElementById(e))) return '';
|
||||
var c='';
|
||||
if(e.style && xDef(e.style.color)) {
|
||||
if(xStr(sColor)) e.style.color=sColor;
|
||||
c=e.style.color;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
function xBackground(e,sColor,sImage) {
|
||||
if(!(e=xGetElementById(e))) return '';
|
||||
var bg='';
|
||||
if(e.style) {
|
||||
if(xStr(sColor)) {
|
||||
if(!xOp5or6) e.style.backgroundColor=sColor;
|
||||
else e.style.background=sColor;
|
||||
}
|
||||
if(xStr(sImage)) e.style.backgroundImage=(sImage!='')? 'url('+sImage+')' : null;
|
||||
if(!xOp5or6) bg=e.style.backgroundColor;
|
||||
else bg=e.style.background;
|
||||
}
|
||||
return bg;
|
||||
}
|
||||
function xMoveTo(e,iX,iY) {
|
||||
xLeft(e,iX);
|
||||
xTop(e,iY);
|
||||
}
|
||||
function xLeft(e,iX) {
|
||||
if(!(e=xGetElementById(e))) return 0;
|
||||
var css=xDef(e.style);
|
||||
if (css && xStr(e.style.left)) {
|
||||
if(xNum(iX)) e.style.left=iX+'px';
|
||||
else {
|
||||
iX=parseInt(e.style.left);
|
||||
if(isNaN(iX)) iX=0;
|
||||
}
|
||||
}
|
||||
else if(css && xDef(e.style.pixelLeft)) {
|
||||
if(xNum(iX)) e.style.pixelLeft=iX;
|
||||
else iX=e.style.pixelLeft;
|
||||
}
|
||||
return iX;
|
||||
}
|
||||
function xTop(e,iY) {
|
||||
if(!(e=xGetElementById(e))) return 0;
|
||||
var css=xDef(e.style);
|
||||
if(css && xStr(e.style.top)) {
|
||||
if(xNum(iY)) e.style.top=iY+'px';
|
||||
else {
|
||||
iY=parseInt(e.style.top);
|
||||
if(isNaN(iY)) iY=0;
|
||||
}
|
||||
}
|
||||
else if(css && xDef(e.style.pixelTop)) {
|
||||
if(xNum(iY)) e.style.pixelTop=iY;
|
||||
else iY=e.style.pixelTop;
|
||||
}
|
||||
return iY;
|
||||
}
|
||||
function xPageX(e) {
|
||||
if (!(e=xGetElementById(e))) return 0;
|
||||
var x = 0;
|
||||
while (e) {
|
||||
if (xDef(e.offsetLeft)) x += e.offsetLeft;
|
||||
e = xDef(e.offsetParent) ? e.offsetParent : null;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
function xPageY(e) {
|
||||
if (!(e=xGetElementById(e))) return 0;
|
||||
var y = 0;
|
||||
while (e) {
|
||||
if (xDef(e.offsetTop)) y += e.offsetTop;
|
||||
e = xDef(e.offsetParent) ? e.offsetParent : null;
|
||||
}
|
||||
// if (xOp7) return y - document.body.offsetTop; // v3.14, temporary hack for opera bug 130324
|
||||
return y;
|
||||
}
|
||||
function xOffsetLeft(e) {
|
||||
if (!(e=xGetElementById(e))) return 0;
|
||||
if (xDef(e.offsetLeft)) return e.offsetLeft;
|
||||
else return 0;
|
||||
}
|
||||
function xOffsetTop(e) {
|
||||
if (!(e=xGetElementById(e))) return 0;
|
||||
if (xDef(e.offsetTop)) return e.offsetTop;
|
||||
else return 0;
|
||||
}
|
||||
function xScrollLeft(e) {
|
||||
var offset=0;
|
||||
if (!(e=xGetElementById(e))) {
|
||||
if(document.documentElement && document.documentElement.scrollLeft) offset=document.documentElement.scrollLeft;
|
||||
else if(document.body && xDef(document.body.scrollLeft)) offset=document.body.scrollLeft;
|
||||
}
|
||||
else { if (xNum(e.scrollLeft)) offset = e.scrollLeft; }
|
||||
return offset;
|
||||
}
|
||||
function xScrollTop(e) {
|
||||
var offset=0;
|
||||
if (!(e=xGetElementById(e))) {
|
||||
if(document.documentElement && document.documentElement.scrollTop) offset=document.documentElement.scrollTop;
|
||||
else if(document.body && xDef(document.body.scrollTop)) offset=document.body.scrollTop;
|
||||
}
|
||||
else { if (xNum(e.scrollTop)) offset = e.scrollTop; }
|
||||
return offset;
|
||||
}
|
||||
function xHasPoint(ele, iLeft, iTop, iClpT, iClpR, iClpB, iClpL) {
|
||||
if (!xNum(iClpT)){iClpT=iClpR=iClpB=iClpL=0;}
|
||||
else if (!xNum(iClpR)){iClpR=iClpB=iClpL=iClpT;}
|
||||
else if (!xNum(iClpB)){iClpL=iClpR; iClpB=iClpT;}
|
||||
var thisX = xPageX(ele), thisY = xPageY(ele);
|
||||
return (iLeft >= thisX + iClpL && iLeft <= thisX + xWidth(ele) - iClpR &&
|
||||
iTop >=thisY + iClpT && iTop <= thisY + xHeight(ele) - iClpB );
|
||||
}
|
||||
function xResizeTo(e,uW,uH) {
|
||||
xWidth(e,uW);
|
||||
xHeight(e,uH);
|
||||
}
|
||||
function xWidth(e,uW) {
|
||||
if(!(e=xGetElementById(e))) return 0;
|
||||
if (xNum(uW)) {
|
||||
if (uW<0) uW = 0;
|
||||
else uW=Math.round(uW);
|
||||
}
|
||||
else uW=-1;
|
||||
var css=xDef(e.style);
|
||||
if(css && xDef(e.offsetWidth) && xStr(e.style.width)) {
|
||||
if(uW>=0) xSetCW(e, uW);
|
||||
uW=e.offsetWidth;
|
||||
}
|
||||
else if(css && xDef(e.style.pixelWidth)) {
|
||||
if(uW>=0) e.style.pixelWidth=uW;
|
||||
uW=e.style.pixelWidth;
|
||||
}
|
||||
return uW;
|
||||
}
|
||||
function xHeight(e,uH) {
|
||||
if(!(e=xGetElementById(e))) return 0;
|
||||
if (xNum(uH)) {
|
||||
if (uH<0) uH = 0;
|
||||
else uH=Math.round(uH);
|
||||
}
|
||||
else uH=-1;
|
||||
var css=xDef(e.style);
|
||||
if(css && xDef(e.offsetHeight) && xStr(e.style.height)) {
|
||||
if(uH>=0) xSetCH(e, uH);
|
||||
uH=e.offsetHeight;
|
||||
}
|
||||
else if(css && xDef(e.style.pixelHeight)) {
|
||||
if(uH>=0) e.style.pixelHeight=uH;
|
||||
uH=e.style.pixelHeight;
|
||||
}
|
||||
return uH;
|
||||
}
|
||||
function xGetCS(ele,sP){return parseInt(document.defaultView.getComputedStyle(ele,'').getPropertyValue(sP));}
|
||||
function xSetCW(ele,uW){
|
||||
var pl=0,pr=0,bl=0,br=0;
|
||||
if(xDef(document.defaultView) && xDef(document.defaultView.getComputedStyle)){
|
||||
pl=xGetCS(ele,'padding-left');
|
||||
pr=xGetCS(ele,'padding-right');
|
||||
bl=xGetCS(ele,'border-left-width');
|
||||
br=xGetCS(ele,'border-right-width');
|
||||
}
|
||||
else if(xDef(ele.currentStyle,document.compatMode)){
|
||||
if(document.compatMode=='CSS1Compat'){
|
||||
pl=parseInt(ele.currentStyle.paddingLeft);
|
||||
pr=parseInt(ele.currentStyle.paddingRight);
|
||||
bl=parseInt(ele.currentStyle.borderLeftWidth);
|
||||
br=parseInt(ele.currentStyle.borderRightWidth);
|
||||
}
|
||||
}
|
||||
else if(xDef(ele.offsetWidth,ele.style.width)){ // ?
|
||||
ele.style.width=uW+'px';
|
||||
pl=ele.offsetWidth-uW;
|
||||
}
|
||||
if(isNaN(pl)) pl=0; if(isNaN(pr)) pr=0; if(isNaN(bl)) bl=0; if(isNaN(br)) br=0;
|
||||
var cssW=uW-(pl+pr+bl+br);
|
||||
if(isNaN(cssW)||cssW<0) return;
|
||||
else ele.style.width=cssW+'px';
|
||||
}
|
||||
function xSetCH(ele,uH){
|
||||
var pt=0,pb=0,bt=0,bb=0;
|
||||
if(xDef(document.defaultView) && xDef(document.defaultView.getComputedStyle)){
|
||||
pt=xGetCS(ele,'padding-top');
|
||||
pb=xGetCS(ele,'padding-bottom');
|
||||
bt=xGetCS(ele,'border-top-width');
|
||||
bb=xGetCS(ele,'border-bottom-width');
|
||||
}
|
||||
else if(xDef(ele.currentStyle,document.compatMode)){
|
||||
if(document.compatMode=='CSS1Compat'){
|
||||
pt=parseInt(ele.currentStyle.paddingTop);
|
||||
pb=parseInt(ele.currentStyle.paddingBottom);
|
||||
bt=parseInt(ele.currentStyle.borderTopWidth);
|
||||
bb=parseInt(ele.currentStyle.borderBottomWidth);
|
||||
}
|
||||
}
|
||||
else if(xDef(ele.offsetHeight,ele.style.height)){ // ?
|
||||
ele.style.height=uH+'px';
|
||||
pt=ele.offsetHeight-uH;
|
||||
}
|
||||
if(isNaN(pt)) pt=0; if(isNaN(pb)) pb=0; if(isNaN(bt)) bt=0; if(isNaN(bb)) bb=0;
|
||||
var cssH=uH-(pt+pb+bt+bb);
|
||||
if(isNaN(cssH)||cssH<0) return;
|
||||
else ele.style.height=cssH+'px';
|
||||
}
|
||||
function xClip(e,iTop,iRight,iBottom,iLeft) {
|
||||
if(!(e=xGetElementById(e))) return;
|
||||
if(e.style) {
|
||||
if (xNum(iLeft)) e.style.clip='rect('+iTop+'px '+iRight+'px '+iBottom+'px '+iLeft+'px)';
|
||||
else e.style.clip='rect(0 '+parseInt(e.style.width)+'px '+parseInt(e.style.height)+'px 0)';
|
||||
}
|
||||
}
|
||||
function xClientWidth() {
|
||||
var w=0;
|
||||
if(xOp5or6) w=window.innerWidth;
|
||||
else if(!window.opera && document.documentElement && document.documentElement.clientWidth)
|
||||
w=document.documentElement.clientWidth;
|
||||
else if(document.body && document.body.clientWidth)
|
||||
w=document.body.clientWidth;
|
||||
else if(xDef(window.innerWidth,window.innerHeight,document.height)) {
|
||||
w=window.innerWidth;
|
||||
if(document.height>window.innerHeight) w-=16;
|
||||
}
|
||||
return w;
|
||||
}
|
||||
function xClientHeight() {
|
||||
var h=0;
|
||||
if(xOp5or6) h=window.innerHeight;
|
||||
else if(!window.opera && document.documentElement && document.documentElement.clientHeight)
|
||||
h=document.documentElement.clientHeight;
|
||||
else if(document.body && document.body.clientHeight)
|
||||
h=document.body.clientHeight;
|
||||
else if(xDef(window.innerWidth,window.innerHeight,document.width)) {
|
||||
h=window.innerHeight;
|
||||
if(document.width>window.innerWidth) h-=16;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
function xInnerHtml(e, sHtml) {
|
||||
if(!(e=xGetElementById(e))) return '';
|
||||
if (xStr(e.innerHTML)) {
|
||||
if (xStr(sHtml)) e.innerHTML = sHtml;
|
||||
else return e.innerHTML;
|
||||
}
|
||||
}
|
||||
286
livejournal/htdocs/js/xbDOM.js
Executable file
286
livejournal/htdocs/js/xbDOM.js
Executable file
@@ -0,0 +1,286 @@
|
||||
/*
|
||||
xbDOM.js v 0.005 2002-04-11
|
||||
|
||||
Contributor(s): Bob Clary, Netscape Communications, Copyright 2001, 2002
|
||||
|
||||
Netscape grants you a royalty free license to use, modify and
|
||||
distribute this software provided that this copyright notice
|
||||
appears on all copies. This software is provided "AS IS,"
|
||||
without a warranty of any kind.
|
||||
|
||||
Change Log:
|
||||
|
||||
2002-04-11: v 0.005
|
||||
bclary -
|
||||
fix bug in IE version of xbGetElementsByName where windowRef was not correctly
|
||||
used. Thanks to Jens Ellegiers for the fix.
|
||||
|
||||
2002-03-15: v 0.004
|
||||
bclary -
|
||||
fix bug in bugfix for 0.003 in xbGetElementsByName
|
||||
to not confuse elements with length properties with arrays
|
||||
|
||||
2002-03-09: v 0.003
|
||||
bclary -
|
||||
fix bug in xbGetElementsByName in Internet Explorer when there is
|
||||
only one instance of an element with name value.
|
||||
|
||||
2002-01-19: v 0.002
|
||||
bclary -
|
||||
nav4FindElementsByName
|
||||
removed erroneous obj and return
|
||||
added search of form elements
|
||||
xbFindElementsByNameAndType
|
||||
renamed from FindElementsByNameAndType
|
||||
removed erroneouse obj and return
|
||||
xbSetInnerHTML
|
||||
ported over from xbStyle since it is more
|
||||
appropriate here.
|
||||
|
||||
2001-11-27: v 0.01
|
||||
bclary -
|
||||
removed from xbStyle
|
||||
*/
|
||||
|
||||
function xbToInt(s)
|
||||
{
|
||||
var i = parseInt(s, 10);
|
||||
if (isNaN(i))
|
||||
i = 0;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
function xbGetWindowWidth(windowRef)
|
||||
{
|
||||
var width = 0;
|
||||
|
||||
if (!windowRef)
|
||||
windowRef = window;
|
||||
|
||||
if (typeof(windowRef.innerWidth) == 'number')
|
||||
width = windowRef.innerWidth;
|
||||
else if (windowRef.document.body && typeof(windowRef.document.body.clientWidth) == 'number')
|
||||
width = windowRef.document.body.clientWidth;
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
function xbGetWindowHeight(windowRef)
|
||||
{
|
||||
var height = 0;
|
||||
|
||||
if (!windowRef)
|
||||
windowRef = window;
|
||||
|
||||
if (typeof(windowRef.innerWidth) == 'number')
|
||||
height = windowRef.innerHeight;
|
||||
else if (windowRef.document.body && typeof(windowRef.document.body.clientWidth) == 'number')
|
||||
height = windowRef.document.body.clientHeight;
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
function nav4FindLayer(doc, id)
|
||||
{
|
||||
var i;
|
||||
var subdoc;
|
||||
var obj;
|
||||
|
||||
for (i = 0; i < doc.layers.length; ++i)
|
||||
{
|
||||
if (doc.layers[i].id && id == doc.layers[i].id)
|
||||
return doc.layers[i];
|
||||
|
||||
subdoc = doc.layers[i].document;
|
||||
obj = nav4FindLayer(subdoc, id);
|
||||
if (obj != null)
|
||||
return obj;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function nav4FindElementsByName(doc, name, elmlist)
|
||||
{
|
||||
var i;
|
||||
var j;
|
||||
var subdoc;
|
||||
|
||||
for (i = 0; i < doc.images.length; ++i)
|
||||
{
|
||||
if (doc.images[i].name && name == doc.images[i].name)
|
||||
elmlist[elmlist.length] = doc.images[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < doc.forms.length; ++i)
|
||||
{
|
||||
for (j = 0; j < doc.forms[i].elements.length; j++)
|
||||
if (doc.forms[i].elements[j].name && name == doc.forms[i].elements[j].name)
|
||||
elmlist[elmlist.length] = doc.forms[i].elements[j];
|
||||
|
||||
if (doc.forms[i].name && name == doc.forms[i].name)
|
||||
elmlist[elmlist.length] = doc.forms[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < doc.anchors.length; ++i)
|
||||
{
|
||||
if (doc.anchors[i].name && name == doc.anchors[i].name)
|
||||
elmlist[elmlist.length] = doc.anchors[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < doc.links.length; ++i)
|
||||
{
|
||||
if (doc.links[i].name && name == doc.links[i].name)
|
||||
elmlist[elmlist.length] = doc.links[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < doc.applets.length; ++i)
|
||||
{
|
||||
if (doc.applets[i].name && name == doc.applets[i].name)
|
||||
elmlist[elmlist.length] = doc.applets[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < doc.embeds.length; ++i)
|
||||
{
|
||||
if (doc.embeds[i].name && name == doc.embeds[i].name)
|
||||
elmlist[elmlist.length] = doc.embeds[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < doc.layers.length; ++i)
|
||||
{
|
||||
if (doc.layers[i].name && name == doc.layers[i].name)
|
||||
elmlist[elmlist.length] = doc.layers[i];
|
||||
|
||||
subdoc = doc.layers[i].document;
|
||||
nav4FindElementsByName(subdoc, name, elmlist);
|
||||
}
|
||||
}
|
||||
|
||||
function xbGetElementsByNameAndType(name, type, windowRef)
|
||||
{
|
||||
if (!windowRef)
|
||||
windowRef = window;
|
||||
|
||||
var elmlist = new Array();
|
||||
|
||||
xbFindElementsByNameAndType(windowRef.document, name, type, elmlist);
|
||||
|
||||
return elmlist;
|
||||
}
|
||||
|
||||
function xbFindElementsByNameAndType(doc, name, type, elmlist)
|
||||
{
|
||||
var i;
|
||||
var subdoc;
|
||||
|
||||
for (i = 0; i < doc[type].length; ++i)
|
||||
{
|
||||
if (doc[type][i].name && name == doc[type][i].name)
|
||||
elmlist[elmlist.length] = doc[type][i];
|
||||
}
|
||||
|
||||
if (doc.layers)
|
||||
{
|
||||
for (i = 0; i < doc.layers.length; ++i)
|
||||
{
|
||||
subdoc = doc.layers[i].document;
|
||||
xbFindElementsByNameAndType(subdoc, name, type, elmlist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (document.layers)
|
||||
{
|
||||
xbGetElementById = function (id, windowRef)
|
||||
{
|
||||
if (!windowRef)
|
||||
windowRef = window;
|
||||
|
||||
return nav4FindLayer(windowRef.document, id);
|
||||
};
|
||||
|
||||
xbGetElementsByName = function (name, windowRef)
|
||||
{
|
||||
if (!windowRef)
|
||||
windowRef = window;
|
||||
|
||||
var elmlist = new Array();
|
||||
|
||||
nav4FindElementsByName(windowRef.document, name, elmlist);
|
||||
|
||||
return elmlist;
|
||||
};
|
||||
|
||||
}
|
||||
else if (document.all)
|
||||
{
|
||||
xbGetElementById = function (id, windowRef) { if (!windowRef) windowRef = window; var elm = windowRef.document.all[id]; if (!elm) elm = null; return elm; };
|
||||
xbGetElementsByName = function (name, windowRef)
|
||||
{
|
||||
if (!windowRef)
|
||||
windowRef = window;
|
||||
|
||||
var i;
|
||||
var idnamelist = windowRef.document.all[name];
|
||||
var elmlist = new Array();
|
||||
|
||||
if (!idnamelist.length || idnamelist.name == name)
|
||||
{
|
||||
if (idnamelist)
|
||||
elmlist[elmlist.length] = idnamelist;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < idnamelist.length; i++)
|
||||
{
|
||||
if (idnamelist[i].name == name)
|
||||
elmlist[elmlist.length] = idnamelist[i];
|
||||
}
|
||||
}
|
||||
|
||||
return elmlist;
|
||||
}
|
||||
|
||||
}
|
||||
else if (document.getElementById)
|
||||
{
|
||||
xbGetElementById = function (id, windowRef) { if (!windowRef) windowRef = window; return windowRef.document.getElementById(id); };
|
||||
xbGetElementsByName = function (name, windowRef) { if (!windowRef) windowRef = window; return windowRef.document.getElementsByName(name); };
|
||||
}
|
||||
else
|
||||
{
|
||||
xbGetElementById = function (id, windowRef) { return null; }
|
||||
xbGetElementsByName = function (name, windowRef) { return new Array(); }
|
||||
}
|
||||
|
||||
if (typeof(window.pageXOffset) == 'number')
|
||||
{
|
||||
xbGetPageScrollX = function (windowRef) { if (!windowRef) windowRef = window; return windowRef.pageXOffset; };
|
||||
xbGetPageScrollY = function (windowRef) { if (!windowRef) windowRef = window; return windowRef.pageYOffset; };
|
||||
}
|
||||
else if (document.all)
|
||||
{
|
||||
xbGetPageScrollX = function (windowRef) { if (!windowRef) windowRef = window; return windowRef.document.body.scrollLeft; };
|
||||
xbGetPageScrollY = function (windowRef) { if (!windowRef) windowRef = window; return windowRef.document.body.scrollTop; };
|
||||
}
|
||||
else
|
||||
{
|
||||
xbGetPageScrollX = function (windowRef) { return 0; };
|
||||
xbGetPageScrollY = function (windowRef) { return 0; };
|
||||
}
|
||||
|
||||
if (document.layers)
|
||||
{
|
||||
xbSetInnerHTML = function (element, str) { element.document.write(str); element.document.close(); };
|
||||
}
|
||||
else if (document.all || document.getElementById)
|
||||
{
|
||||
xbSetInnerHTML = function (element, str) { if (typeof(element.innerHTML) != 'undefined') element.innerHTML = str; };
|
||||
}
|
||||
else
|
||||
{
|
||||
xbSetInnerHTML = function (element, str) {};
|
||||
}
|
||||
|
||||
|
||||
// eof: xbDOM.js
|
||||
223
livejournal/htdocs/js/xbDebug.js
Executable file
223
livejournal/htdocs/js/xbDebug.js
Executable file
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
xbDebug.js revision: 0.003 2002-02-26
|
||||
|
||||
Contributor(s): Bob Clary, Netscape Communications, Copyright 2001
|
||||
|
||||
Netscape grants you a royalty free license to use, modify and
|
||||
distribute this software provided that this copyright notice
|
||||
appears on all copies. This software is provided "AS IS,"
|
||||
without a warranty of any kind.
|
||||
|
||||
ChangeLog:
|
||||
|
||||
2002-02-25: bclary - modified xbDebugTraceOject to make sure
|
||||
that original versions of wrapped functions were not
|
||||
rewrapped. This had caused an infinite loop in IE.
|
||||
|
||||
2002-02-07: bclary - modified xbDebug.prototype.close to not null
|
||||
the debug window reference. This can cause problems with
|
||||
Internet Explorer if the page is refreshed. These issues will
|
||||
be addressed at a later date.
|
||||
*/
|
||||
|
||||
function xbDebug()
|
||||
{
|
||||
this.on = false;
|
||||
this.stack = new Array();
|
||||
this.debugwindow = null;
|
||||
this.execprofile = new Object();
|
||||
}
|
||||
|
||||
xbDebug.prototype.push = function ()
|
||||
{
|
||||
this.stack[this.stack.length] = this.on;
|
||||
this.on = true;
|
||||
}
|
||||
|
||||
xbDebug.prototype.pop = function ()
|
||||
{
|
||||
this.on = this.stack[this.stack.length - 1];
|
||||
--this.stack.length;
|
||||
}
|
||||
|
||||
xbDebug.prototype.open = function ()
|
||||
{
|
||||
if (this.debugwindow && !this.debugwindow.closed)
|
||||
this.close();
|
||||
|
||||
this.debugwindow = window.open('about:blank', 'DEBUGWINDOW', 'height=400,width=600,resizable=yes,scrollbars=yes');
|
||||
|
||||
this.debugwindow.title = 'xbDebug Window';
|
||||
this.debugwindow.document.write('<html><head><title>xbDebug Window</title></head><body><h3>Javascript Debug Window</h3></body></html>');
|
||||
this.debugwindow.focus();
|
||||
}
|
||||
|
||||
xbDebug.prototype.close = function ()
|
||||
{
|
||||
if (!this.debugwindow)
|
||||
return;
|
||||
|
||||
if (!this.debugwindow.closed)
|
||||
this.debugwindow.close();
|
||||
|
||||
// bc 2002-02-07, other windows may still hold a reference to this: this.debugwindow = null;
|
||||
}
|
||||
|
||||
xbDebug.prototype.dump = function (msg)
|
||||
{
|
||||
if (!this.on)
|
||||
return;
|
||||
|
||||
if (!this.debugwindow || this.debugwindow.closed)
|
||||
this.open();
|
||||
|
||||
this.debugwindow.document.write(msg + '<br>');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var xbDEBUG = new xbDebug();
|
||||
|
||||
window.onunload = function () { xbDEBUG.close(); }
|
||||
|
||||
function xbDebugGetFunctionName(funcref)
|
||||
{
|
||||
|
||||
if (funcref.name)
|
||||
return funcref.name;
|
||||
|
||||
var name = funcref + '';
|
||||
name = name.substring(name.indexOf(' ') + 1, name.indexOf('('));
|
||||
funcref.name = name;
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
function xbDebugCreateFunctionWrapper(scopename, funcname, precall, postcall)
|
||||
{
|
||||
var wrappedfunc;
|
||||
var scopeobject = eval(scopename);
|
||||
var funcref = scopeobject[funcname];
|
||||
|
||||
scopeobject['xbDebug_orig_' + funcname] = funcref;
|
||||
|
||||
wrappedfunc = function ()
|
||||
{
|
||||
precall(scopename, funcname, arguments);
|
||||
var rv = funcref.apply(this, arguments);
|
||||
postcall(scopename, funcname, arguments, rv);
|
||||
return rv;
|
||||
};
|
||||
|
||||
if (typeof(funcref.constructor) != 'undefined')
|
||||
wrappedfunc.constructor = funcref.constuctor;
|
||||
|
||||
if (typeof(funcref.prototype) != 'undefined')
|
||||
wrappedfunc.prototype = funcref.prototype;
|
||||
|
||||
scopeobject[funcname] = wrappedfunc;
|
||||
}
|
||||
|
||||
function xbDebugPersistToString(obj)
|
||||
{
|
||||
var s = '';
|
||||
var p;
|
||||
|
||||
if (obj == null)
|
||||
return 'null';
|
||||
|
||||
switch(typeof(obj))
|
||||
{
|
||||
case 'number':
|
||||
return obj;
|
||||
case 'string':
|
||||
return '"' + obj + '"';
|
||||
case 'undefined':
|
||||
return 'undefined';
|
||||
case 'boolean':
|
||||
return obj + '';
|
||||
}
|
||||
|
||||
return '[' + xbDebugGetFunctionName(obj.constructor) + ']';
|
||||
}
|
||||
|
||||
function xbDebugTraceBefore(scopename, funcname, funcarguments)
|
||||
{
|
||||
var i;
|
||||
var s = '';
|
||||
var execprofile = xbDEBUG.execprofile[scopename + '.' + funcname];
|
||||
if (!execprofile)
|
||||
execprofile = xbDEBUG.execprofile[scopename + '.' + funcname] = { started: 0, time: 0, count: 0 };
|
||||
|
||||
for (i = 0; i < funcarguments.length; i++)
|
||||
{
|
||||
s += xbDebugPersistToString(funcarguments[i]);
|
||||
if (i < funcarguments.length - 1)
|
||||
s += ', ';
|
||||
}
|
||||
|
||||
xbDEBUG.dump('enter ' + scopename + '.' + funcname + '(' + s + ')');
|
||||
execprofile.started = (new Date()).getTime();
|
||||
}
|
||||
|
||||
function xbDebugTraceAfter(scopename, funcname, funcarguments, rv)
|
||||
{
|
||||
var i;
|
||||
var s = '';
|
||||
var execprofile = xbDEBUG.execprofile[scopename + '.' + funcname];
|
||||
if (!execprofile)
|
||||
xbDEBUG.dump('xbDebugTraceAfter: execprofile not created for ' + scopename + '.' + funcname);
|
||||
else if (execprofile.started == 0)
|
||||
xbDEBUG.dump('xbDebugTraceAfter: execprofile.started == 0 for ' + scopename + '.' + funcname);
|
||||
else
|
||||
{
|
||||
execprofile.time += (new Date()).getTime() - execprofile.started;
|
||||
execprofile.count++;
|
||||
execprofile.started = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < funcarguments.length; i++)
|
||||
{
|
||||
s += xbDebugPersistToString(funcarguments[i]);
|
||||
if (i < funcarguments.length - 1)
|
||||
s += ', ';
|
||||
}
|
||||
|
||||
xbDEBUG.dump('exit ' + scopename + '.' + funcname + '(' + s + ')==' + xbDebugPersistToString(rv));
|
||||
}
|
||||
|
||||
function xbDebugTraceFunction(scopename, funcname)
|
||||
{
|
||||
xbDebugCreateFunctionWrapper(scopename, funcname, xbDebugTraceBefore, xbDebugTraceAfter);
|
||||
}
|
||||
|
||||
function xbDebugTraceObject(scopename, objname)
|
||||
{
|
||||
var objref = eval(scopename + '.' + objname);
|
||||
var p;
|
||||
|
||||
if (!objref || !objref.prototype)
|
||||
return;
|
||||
|
||||
for (p in objref.prototype)
|
||||
{
|
||||
if (typeof(objref.prototype[p]) == 'function' && (p+'').indexOf('xbDebug_orig') == -1)
|
||||
{
|
||||
xbDebugCreateFunctionWrapper(scopename + '.' + objname + '.prototype', p + '', xbDebugTraceBefore, xbDebugTraceAfter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function xbDebugDumpProfile()
|
||||
{
|
||||
var p;
|
||||
var execprofile;
|
||||
var avg;
|
||||
|
||||
for (p in xbDEBUG.execprofile)
|
||||
{
|
||||
execprofile = xbDEBUG.execprofile[p];
|
||||
avg = Math.round ( 100 * execprofile.time/execprofile.count) /100;
|
||||
xbDEBUG.dump('Execution profile ' + p + ' called ' + execprofile.count + ' times. Total time=' + execprofile.time + 'ms. Avg Time=' + avg + 'ms.');
|
||||
}
|
||||
}
|
||||
1349
livejournal/htdocs/js/xbStyle.js
Executable file
1349
livejournal/htdocs/js/xbStyle.js
Executable file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user