$Id: _script.js,v 1.9 2005/06/14 14:47:47 techtonik Exp $function prefHandler()
{
switch (prefs_skin) {
case "Low":
skin_js_file = '_skin_lo.js';
break;
case "High":
skin_js_file = '_skin_hi.js';
break;
default:
skin_js_file = "file:///" + prefs_skin;
break;
}
document.write('<script src="' + skin_js_file + '"><'+ '/script>');
if (ie_version_major >= 5) {
document.write('<div id="contextMenu">');
contextMenuRewrite(true);
document.write('</div>');
document.oncontextmenu = contextMenu;
document.onclick = contextMenuCloseTimeout;
window.onblur = contextMenuCloseTimeout;
}
}
function getCHMFile()
{
var a, X, Y, Z;
a = location.href.search(/:/);
Y = location.href.lastIndexOf("::");
if (a == 4) { Y = location.href.lastIndexOf("/");
chmfile_page = unescape(location.href.substring(Y+1));
if (location.href.substring(0,4) == "file") {
chmfile_path = unescape(location.href.substring(8, Y+1));
}
}
else {
if (a == 2) X = 14; if (a == 7) X = 7; chmfile_fullname = unescape(location.href.substring(X, Y));
Z = chmfile_fullname.lastIndexOf("\\");
chmfile_path = unescape(chmfile_fullname.substring(0, Z+1));
chmfile_name = unescape(chmfile_fullname.substring(Z+1));
chmfile_page = unescape(location.href.substring(Y+3));
}
if (location.hash == '#userNotes')
chmfile_page = chmfile_page.substring(0, chmfile_page.lastIndexOf('#'));
}
function thisPageOnline()
{
if (!prefs_online) {
alert("You are in offline mode.\nThis functionality is not available");
} else {
window.open(prefs_mirror + 'manual/' + this_lang + '/' + this_page_php);
}
}
function bugOnPage()
{
if (!prefs_online) {
alert("You are in offline mode.\nThis functionality is not available");
} else {
window.open(
"http://bugs.php.net/report.php?" +
escape("in[php_version]") + "=earlier&" +
escape("in[bug_type]") + "=Documentation%20problem&" +
escape("in[php_os]") + "=windows&" +
escape("in[sdesc]") + "=" + escape("[chm] bug on " + this_page) + "&" +
escape("in[ldesc]") + "=" + escape("I have found a bug on page " +
this_page + "\n[chm date: " + this_date + "]...\n")
);
}
}
function _displayNotes()
{
element = document.all['pageNotes'];
if (element) {
element.innerHTML = parent.nbuff.document.body.innerHTML;
if (location.hash == '#userNotes')
{
setTimeout('element.scrollIntoView(true);',200);
}
} else {
alert("Error in user note inclusion");
}
}
function loadNotes()
{
document.write('<script src="ms-its:' +
chmfile_path + 'php_manual_notes.chm::/_filelist.js"></script>');
}
function notesIframe()
{
document.write(
'<iframe name="nbuff" style="display:none" src="ms-its:' +
chmfile_path + 'php_manual_notes.chm::/' + chmfile_page +
'"></iframe>'
);
}
function contextMenuRewrite(first)
{
context_selrange = null;
menuHTML = '<table width="150" cellspacing="2" cellpadding="0">';
for (i in prefs_context_names) {
label = prefs_context_names[i];
impl = prefs_context_values[i];
if (impl.substring(0,1) == "_") {
switch (impl) {
case "_Separator_":
menuHTML +=
'<tr><td bgcolor="#000000"><img src="_pixel.gif" ' +
'width="100%" height="1"></td></tr>';
break;
case "_GoogleSearch_":
if (prefs_online) {
menuHTML +=
'<tr><td style="background-color: #f5f5f5;"><form action="http://www.google.com/search" class="thin"' +
'onsubmit="contextMenuClose()" method="GET" target="_blank">' +
'<img src="_google.gif" align="absmiddle" alt="Google"><input type="text" name="q" ' +
'style="width:120px;"></form></td></tr>';
}
break;
case "_ATWSearch_":
if (prefs_online) {
menuHTML +=
'<tr><td style="background-color: #f5f5f5;"><form action="http://www.alltheweb.com/search" class="thin"' +
'onsubmit="contextMenuClose()" method="GET" target="_blank">' +
'<img src="_atw.gif" align="absmiddle" alt="AlltheWeb"><input name="cat" type="hidden" value="web">' +
'<input type="text" name="query" style="width:120px;"></form></td></tr>';
}
break;
default:
menuHTML += contextLink(i, label);
break;
}
}
else if (impl.substring(impl.length-2) == "()") {
switch (impl.substring(0, impl.length-2)) {
case "copySelection":
if (document.selection && !first) {
context_selrange = document.selection.createRange();
if (context_selrange.text.length > 0) {
menuHTML += contextLink(i, label);
}
}
break;
case "searchSelGoogle":
case "searchSelATW":
if (document.selection && !first) {
context_selrange = document.selection.createRange();
if (context_selrange.text.length > 0 && prefs_online) {
menuHTML += contextLink(i, label);
}
}
break;
default:
menuHTML += contextLink(i, label);
break;
}
}
else { menuHTML += contextLink(i, label); }
}
menuHTML += '</table>';
if (first) { document.write(menuHTML); }
else {
document.all['contextMenu'].innerHTML = menuHTML;
}
}
function contextLink (number, label)
{
return '<tr><td nowrap onmouseover="this.style.backgroundColor=\'#c0c0c0\';" ' +
'onmouseout="this.style.backgroundColor=\'#f5f5f5\';" ' +
'onclick="contextParse(' + number + ')" ' +
'style="cursor:hand; background-color: #f5f5f5;"><p class="context">' +
label + '</p></td></tr>';
}
function contextParse(i)
{
var control = prefs_context_values[i];
if (control.substring(control.length-2) == "()") {
switch (control.substring(0, control.length-2)) {
case "print":
print();
break;
case "copySelection":
if (context_selrange != null) {
context_selrange.execCommand("Copy"); }
break;
case "searchSelGoogle":
sel = contextGetSelection();
if (sel != '') { window.open('http://www.google.com/search?q=' + escape(sel)); }
break;
case "searchSelATW":
sel = contextGetSelection();
if (sel != '') { window.open('http://www.alltheweb.com/search?cat=web&query=' + escape(sel)); }
break;
case "back": history.back(); break;
case "forward": history.forward(); break;
case "refresh": window.location.reload(true); break;
case "selectAll": document.body.createTextRange().select(); break;
default:
alert('This context menu function is not supported');
break;
}
}
else {
if (control.indexOf(":") > 0) {
window.open(control);
}
else {
location = control;
}
}
}
function contextGetSelection()
{
if (context_selrange != null && context_selrange.text.length > 0) {
return context_selrange.text;
} else {
alert("Nothing is selected");
return "";
}
}
function contextMenu(e)
{
contextMenuClose();
if (event.ctrlKey && prefs_context_override) {
return true;
}
else if (!event.ctrlKey && !prefs_context_override) {
return true;
}
else {
contextMenuRewrite(false);
http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/doctype.asp if (ie_version_major >= 6) { delement = document.body.parentElement; }
else { delement = document.body; }
rightedge = delement.clientWidth - event.clientX;
bottomedge = delement.clientHeight - event.clientY;
cmenu = document.all['contextMenu'];
if (rightedge < cmenu.offsetWidth) {
cmenu.style.left = delement.scrollLeft + event.clientX - cmenu.offsetWidth;
} else {
cmenu.style.left = delement.scrollLeft + event.clientX;
}
if (bottomedge < cmenu.offsetHeight) {
cmenu.style.top = delement.scrollTop + event.clientY - cmenu.offsetHeight;
} else {
cmenu.style.top = delement.scrollTop + event.clientY;
}
cmenu.style.visibility = "visible";
return false;
}
}
function contextMenuClose()
{
document.all['contextMenu'].style.visibility = "hidden";
}
function contextMenuCloseTimeout()
{
if (document.activeElement.tagName != 'INPUT') {
setTimeout('contextMenuClose()', 100);
}
}
function copyExample(number)
{
if (ie_version_major < 5) {
alert("Example copy is not supported in this browser");
} else {
BodyRange = document.body.createTextRange();
BodyRange.moveToElementText(document.all['example_' + number]);
BodyRange.execCommand("Copy");
}
}
function defaultDisplayPage() {
if (!prefs_online) {
document.all['navOnline'].style.display = 'none';
}
document.all['pageContent'].style.display = 'block';
}
this_lang = 'LANGUAGE_HERE';
this_date = 'DATE_HERE';
this_page = location.pathname.substring(location.pathname.lastIndexOf("/")+1);
this_page_php = this_page.substring(0, this_page.lastIndexOf(".")) + '.php';
if (this_page_php == '_index.php') {
this_page_php = 'index.php';
}
chmfile_fullname = "";
chmfile_name = "";
chmfile_path = "";
chmfile_page = "";
getCHMFile();
prefs_online = false;
prefs_context_override = false;
prefs_skin = "Low";
context_selrange = null;
var ie_version_start = navigator.appVersion.indexOf("MSIE");
var ie_version_end = navigator.appVersion.indexOf(".", ie_version_start);
ie_version_major = parseInt(navigator.appVersion.substring(ie_version_start+5, ie_version_end));
ie_version_minor = parseInt(navigator.appMinorVersion);
document.write('<script src="' + chmfile_path + 'php_manual_prefs.js"><'+ '/script>');