User:Ale jrb/wikinotes.js

/* =========================================================== *\ \* =========================================================== */
 * WikiNotes JavaScript note making program.                  **
 * Copyright (c) Alex Barley  2007.                  **
 * All rights are reserved.                                   **
 * WikiNotes - start main code. Do not edit below this line.  **
 * WikiNotes - start main code. Do not edit below this line.  **
 * WikiNotes - start main code. Do not edit below this line.  **

function wikiNotesLoad { // Check if Wikinotes is installed on this page. var pageHTML = document.body.innerHTML; if (document.getElementById('wikinotes_notepad') != null) { // It's installed. Check if we should be uninstalling it. var checkUrl = setup_wikiUrl + '/wiki/' var url = location.href; if (url.indexOf(checkUrl) != -1) { wikipage = url.substring(checkUrl.length); }		else {			wikipage = '' }		if (location.href.indexOf('notes=uninstall') > -1) { var currentContent = document.getElementById("wikinotes_notepad").innerHTML; ajaxPrep(currentContent, 'TEST: Uninstalling WikiNotes', 'redirect') }		// We need to display the uninstallation link. pageHTML = pageHTML.replace("action=edit\">Edit", "action=edit\">Edit\nUninstall Notes") document.body.innerHTML = pageHTML; // Actually run Notes! controls.panel; }	else {		// It's not installed. Check if we should be installing it. var checkUrl = setup_wikiUrl + '/wiki/' var url = location.href; if (url.indexOf(checkUrl) != -1) { wikipage = url.substring(checkUrl.length); }		else {			wikipage = ''; }		if (location.href.indexOf('notes=install') > -1) { var currentContent = ' '; ajaxPrep(currentContent, 'TEST: Installing WikiNotes', 'redirect') }		// We need to display the installation link. pageHTML = pageHTML.replace("action=edit\">Edit", "action=edit\">Edit\nInstall Notes</a></li>") document.body.innerHTML = pageHTML; } }

var controls={ changed: false, panel:function { if (document.getElementById('wikinotes_notepad') == null) { return false; } controller = this.create('default', 'cpanel186354'); return controller; },	create:function(mode, id, divtitle) { switch (mode) { case 'default': var temp = ''; // Start main header code temp += '<div id="cntrl-main" style="z-index: 1000000000; position: absolute; left: 10px; top: 10px; width: 500px; background-color: #66CCFF; border: 1px solid #000066; padding: 2px;">'; temp += '<div class="drag_controller" style="position: relative; background-color: #0099FF; border-bottom: 1px solid #0000FF; height: 48px; padding-right: 0px; font-family: arial; font-weight: bold;">'; temp += '<div class="content_area" style="position: relative; text-align: right; top: 3px; right: 5px;">Viewing Notes - WikiNotes '; temp += '<div style="position: relative; float: right; top:9px; border: 1px solid #0000FF; padding: 0px 2px 0px 2px; font-family: arial; font-size: 10px;"><span onclick="javascript:controls.savePage; controls.changed = false; controls.setMode(\'saving\', \'cpanel186354\'); return false;">Save Page '; temp += '<div style="position: relative; float: right; top:9px; left: 1px; border: 1px solid #0000FF; padding: 0px 2px 0px 2px; font-family: arial; font-size: 10px;"><span onclick="javascript:controls.setMode(\'default\', \'cpanel186354\'); return false;">About WikiNotes '; temp += '<div style="position: relative; float: left; top:9px; border: 1px solid #0000FF; padding: 0px 2px 0px 2px; font-family: arial; font-size: 10px;"><span onclick="javascript:controls.setMode(\'edit\', \'cpanel186354\'); return false;">Create a New Note! ';				temp += ' '; // End main header code // Start save warning if 	(this.changed == true) { temp += '<div style="position: relative; top: 3px; padding-bottom: 3px; text-align: center; font-family: arial; font-size: 12px;"> Careful! This notepad has changed since it was last saved. Don\'t forget to save before browsing away. ';				}				// End save warning // Start end all temp += ' <div class="resize_controller" style="background-color: #000000; width:0px; height:0px;"> <div class="close_note" style="background-color: #000000; width:0px; height:0px;"> '; // End end all break; case 'edit': var temp = ''; // Start main header code temp += '<div id="cntrl-main" style="z-index: 1000000000; position: absolute; left: 10px; top: 10px; width: 500px; background-color: #66CCFF; border: 1px solid #000066; padding: 2px;">'; temp += '<div class="drag_controller" style="position: relative; background-color: #0099FF; border-bottom: 1px solid #0000FF; height: 48px; padding-right: 0px; font-family: arial; font-weight: bold;">'; temp += ' Editing a Note - WikiNotes '; temp += '<div style="position: relative; float: right; top:9px; border: 1px solid #0000FF; padding: 0px 2px 0px 2px; font-family: arial; font-size: 10px;"><span onclick="javascript:var newnote = new notepad; newnote.init(document.getElementById(\'title\').value, document.getElementById(\'text\').value, false); controls.changed = true; controls.setMode(\'default\', \'cpanel186354\'); return false;">Save Note '; temp += '<div style="position: relative; float: right; top:9px; left: 1px; border: 1px solid #0000FF; padding: 0px 2px 0px 2px; font-family: arial; font-size: 10px;"><span onclick="javascript:controls.setMode(\'default\', \'cpanel186354\'); return false;">Cancel '; temp += '<div style="position: relative; float: right; top:9px; left: 2px; border: 1px solid #0000FF; padding: 0px 2px 0px 2px; font-family: arial; font-size: 10px;"><span onclick="javascript:controls.setMode(\'default\', \'cpanel186354\'); return false;">About WikiNotes '; temp += ' '; // End main header code // Start main edit code temp += '<div class="content_area" style="font-family: arial; font-size: 11px; padding: 3px; padding-top: 10px;">'; temp += 'Title: <input type="text" id="title" style="font-size: 11px; padding: 1px; background-color: #0099FF; border: 1px solid #000066;" size="50" />

';				temp += 'Note: <textarea id="text" style="width: 486px; font-family: arial; font-size: 11px; background-color: #0099FF; border: 1px solid #000066; padding: 3px;" rows="5"> '; temp += ' '; // End main edit code // Start end all temp += ' <div class="resize_controller" style="background-color: #000000; width:0px; height:0px;"> <div class="close_note" style="background-color: #000000; width:0px; height:0px;"> '; // End end all break; case 'saving': var temp = ''; // Start main header code temp += '<div id="cntrl-main" style="z-index: 1000000000; position: absolute; left: 10px; top: 10px; width: 500px; background-color: #66CCFF; border: 1px solid #000066; padding: 2px;">'; temp += '<div class="drag_controller" style="position: relative; background-color: #0099FF; border-bottom: 1px solid #0000FF; height: 48px; padding-right: 0px; font-family: arial; font-weight: bold;">'; temp += '<div class="content_area" style="position: relative; text-align: right; top: 3px; right: 5px;">Saving NotePad - Please Wait - WikiNotes '; temp += ' '; // End main header code temp += '<div style="position: relative; top: 3px; padding-bottom: 3px; text-align: center; font-family: arial; font-size: 12px;">WikiNotes is saving your NotePad. This process may take some time, but interupting it may corrupt data. Please be patient. ';

// Start end all temp += ' <div class="resize_controller" style="background-color: #000000; width:0px; height:0px;"> <div class="close_note" style="background-color: #000000; width:0px; height:0px;"> '; // End end all break; }		temp += "\n\n "; this.controlpanel = new notepad; this.controlpanel.init('cpanel186354', temp, true); return this.controlpanel; },	setMode:function(mode, id, divtitle) { switch (mode) { case 'default': var temp = ''; // Start main header code temp += '<div id="cntrl-main" style="z-index: 1000000000; position: absolute; left: 10px; top: 10px; width: 500px; background-color: #66CCFF; border: 1px solid #000066; padding: 2px;">'; temp += '<div class="drag_controller" style="position: relative; background-color: #0099FF; border-bottom: 1px solid #0000FF; height: 48px; padding-right: 0px; font-family: arial; font-weight: bold;">'; temp += '<div class="content_area" style="position: relative; text-align: right; top: 3px; right: 5px;">Viewing Notes - WikiNotes '; temp += '<div style="position: relative; float: right; top:9px; border: 1px solid #0000FF; padding: 0px 2px 0px 2px; font-family: arial; font-size: 10px;"><span onclick="javascript:controls.savePage; controls.changed = false; controls.setMode(\'saving\', \'cpanel186354\'); return false;">Save Page '; temp += '<div style="position: relative; float: right; top:9px; left: 1px; border: 1px solid #0000FF; padding: 0px 2px 0px 2px; font-family: arial; font-size: 10px;"><span onclick="javascript:controls.setMode(\'default\', \'cpanel186354\'); return false;">About WikiNotes '; temp += '<div style="position: relative; float: left; top:9px; border: 1px solid #0000FF; padding: 0px 2px 0px 2px; font-family: arial; font-size: 10px;"><span onclick="javascript:controls.setMode(\'edit\', \'cpanel186354\'); return false;">Create a New Note! ';				temp += ' '; // End main header code // Start save warning if 	(this.changed == true) { temp += '<div style="position: relative; top: 3px; padding-bottom: 3px; text-align: center; font-family: arial; font-size: 12px;"> Careful! This notepad has changed since it was last saved. Don\'t forget to save before browsing away. ';				}				// End save warning // Start end all temp += ' <div class="resize_controller" style="background-color: #000000; width:0px; height:0px;"> <div class="close_note" style="background-color: #000000; width:0px; height:0px;"> '; // End end all break; case 'edit': var temp = ''; // Start main header code temp += '<div id="cntrl-main" style="z-index: 1000000000; position: absolute; left: 10px; top: 10px; width: 500px; background-color: #66CCFF; border: 1px solid #000066; padding: 2px;">'; temp += '<div class="drag_controller" style="position: relative; background-color: #0099FF; border-bottom: 1px solid #0000FF; height: 48px; padding-right: 0px; font-family: arial; font-weight: bold;">'; temp += ' Editing a Note - WikiNotes '; temp += '<div style="position: relative; float: right; top:9px; border: 1px solid #0000FF; padding: 0px 2px 0px 2px; font-family: arial; font-size: 10px;"><span onclick="javascript:var newnote = new notepad; newnote.init(document.getElementById(\'title\').value, document.getElementById(\'text\').value, false); controls.changed = true; controls.setMode(\'default\', \'cpanel186354\'); return false;">Save Note '; temp += '<div style="position: relative; float: right; top:9px; left: 1px; border: 1px solid #0000FF; padding: 0px 2px 0px 2px; font-family: arial; font-size: 10px;"><span onclick="javascript:controls.setMode(\'default\', \'cpanel186354\'); return false;">Cancel '; temp += '<div style="position: relative; float: right; top:9px; left: 2px; border: 1px solid #0000FF; padding: 0px 2px 0px 2px; font-family: arial; font-size: 10px;"><span onclick="javascript:controls.setMode(\'default\', \'cpanel186354\'); return false;">About WikiNotes '; temp += ' '; // End main header code // Start main edit code temp += '<div class="content_area" style="font-family: arial; font-size: 11px; padding: 3px; padding-top: 10px;">'; temp += 'Title: <input type="text" id="title" style="font-size: 11px; padding: 1px; background-color: #0099FF; border: 1px solid #000066;" size="50" />

';				temp += 'Note: <textarea id="text" style="width: 486px; font-family: arial; font-size: 11px; background-color: #0099FF; border: 1px solid #000066; padding: 3px;" rows="5"> '; temp += ' '; // Start end all temp += ' <div class="resize_controller" style="background-color: #000000; width:0px; height:0px;"> <div class="close_note" style="background-color: #000000; width:0px; height:0px;"> '; // End end all break; case 'saving': var temp = ''; // Start main header code temp += '<div id="cntrl-main" style="z-index: 1000000000; position: absolute; left: 10px; top: 10px; width: 500px; background-color: #66CCFF; border: 1px solid #000066; padding: 2px;">'; temp += '<div class="drag_controller" style="position: relative; background-color: #0099FF; border-bottom: 1px solid #0000FF; height: 48px; padding-right: 0px; font-family: arial; font-weight: bold;">'; temp += '<div class="content_area" style="position: relative; text-align: right; top: 3px; right: 5px;">Saving NotePad - Please Wait - WikiNotes '; temp += ' '; // End main header code temp += '<div style="position: relative; top: 3px; padding-bottom: 3px; text-align: center; font-family: arial; font-size: 12px;">WikiNotes is saving your NotePad. This process may take some time, but interupting it may corrupt data. Please be patient. ';

// Start end all temp += ' <div class="resize_controller" style="background-color: #000000; width:0px; height:0px;"> <div class="close_note" style="background-color: #000000; width:0px; height:0px;"> '; // End end all break; }		temp += "\n\n "; this.controlpanel.init('cpanel186354', temp, true); return this.controlpanel; },	setEditBox: function (title, content) { // Clean up the content. content = content.replace(/::;;::/g, "\n"); document.getElementById('title').value = title; document.getElementById('text').value = content; },	destroyNote: function (id) { var note = document.getElementById(id); note.parentNode.removeChild(note); },	refreshNote: function (id, content) { var refresher = new notepad; refresher.init(id, content, false, true); return false; }, 	savePage: function { var currentContent = document.getElementById('wikinotes_notepad'); currentContent = currentContent.innerHTML; currentContent = '<div id="wikinotes_notepad">' + currentContent + ' '; //currentContent = 'test 7'; // DEBUG ajaxPrep(currentContent); // Debugging currentContent = currentContent.replace(/>/g, '&gt;'); currentContent = currentContent.replace(/</g, '&lt;'); //document.getElementById('outputending').innerHTML = currentContent; } }

function notepad { // Notepad class. // This is the notepad class - it handles creating and managing notes. // If this page doesn't have Notes installed, never run anything. if (document.getElementById('wikinotes_notepad') == null) { return false; } /* public function init ( id as string, content as strong, overwrite as boolean ) */ this.init = function (t, input, overwrite, ref) { if (document.getElementById(t) == null) {				this.create(t, input, overwrite) }			else {				this.update(t, input, overwrite, ref) }		}		this.create = function (t, input, overwrite) { // If you specify 'overwrite' as 'true', a div named 'drag_controller' should be in the // content.

if (document.getElementById(t) == null) {					var domwindow           = document.createElement("div"); //create dhtml window div var title               = t;					domwindow.id             = t;					domwindow.className      = "wikinotes_note"; domwindow.style.position = "absolute"; inputn = input.replace(/\n/g, "::;;::") if (overwrite == true) { var domwindowdata =' '; domwindowdata += input; domwindowdata += ''; domwindow.innerHTML = domwindowdata; document.getElementById("wikinotes_notepad").appendChild(domwindow) }					else {						var domwindowdata = '<div style="border: 1px solid #000000; min-width: 100px; max-width: 500px; -moz-border-radius-bottomleft: 10px; -moz-border-radius-bottomright: 10px;">' domwindowdata += ''; domwindowdata += '<div class="drag_controller" ondblclick="javascript:controls.refreshNote(\+title+'\', \+inputn+'\')" style="cursor: move; position: relative; height:20px; width:inherit; overflow: hidden; background-color:#BBBBBB;font-family:arial;font-size:16px;font-weight:bold;padding:1px 10px 1px 3px;">' + title + ''; domwindowdata += '<div class="close_note" style="background-color: #BBBBBB; position: absolute; top: 1px; right: 5px;">[<span style="cursor: default; text-decoration: none; color: #444444;" onmouseover="javascript:this.style.color = \'#999999\';" onmouseout="javascript:this.style.color = \'#444444\';" onclick="javascript:controls.destroyNote(\ + title + '\'); return false;">x ] <div class="edit_note" style="background-color:#BBBBBB; position: absolute; top: 1px; right: 25px;">[<span style="cursor: default; text-decoration: none; color: #444444;" onmouseover="javascript:this.style.color = \'#999999\';" onmouseout="javascript:this.style.color = \'#444444\';" onclick="javascript:controls.setMode(\'edit\',\'wiki-controls\'); controls.setEditBox(\+title+'\', \''+inputn+'\'); return false;"> \\ ] '; domwindowdata += '<div class="btf_note" style="background-color: #BBBBBB; position: absolute; top: 1px; right: 47px;">[<span style="cursor: default; text-decoration: none; color: #444444;" onmouseover="javascript:this.style.color = \'#999999\';" onmouseout="javascript:this.style.color = \'#444444\';" onclick="javascript:controls.refreshNote(\+title+'\', \+inputn+'\'); return false;"> ^ ] '; domwindowdata += '<div class="content_area" style="min-height: 10px; max-height: 2000px; width:inherit; overflow: hidden; position:relative; background-color:#EEEEEE;padding:3px; -moz-border-radius-bottomleft: 10px; -moz-border-radius-bottomright: 10px;font-family:arial;font-size:10px;">' + inputn.replace(/::;;::/g, " ") + '<div class="resize_controller" style="cursor: se-resize; position: absolute; bottom:0px; right: 0px; height:10px; width:10px;"> ' domwindowdata += ' ' domwindow.innerHTML=domwindowdata document.getElementById("wikinotes_notepad").appendChild(domwindow) }					var t = document.getElementById(t); var divs = t.getElementsByTagName("div") var divs = t.getElementsByTagName("div") for (var i = 0; i < divs.length; i++) { t[divs[i].className] = divs[i]; }					// Move to front on create var y = document.body; var divs = y.getElementsByTagName("div") this.zIndexValue = 0; for (var i = 0; i < divs.length; i++) { if ((divs[i].style.zIndex > this.zIndexValue) && ((divs[i].id != 'cntrl-main') && (divs[i].id != 'cpanel186354') && (divs[i].id != ''))) { this.zIndexValue = parseInt(divs[i].style.zIndex); } }					t.style.zIndex = this.zIndexValue + 1; if (t.id == 'cpanel186354') t.style.zIndex = 999999999; t.drag_controller._parent = t;					t.drag_controller.onmousedown = this.drag; t.resize_controller._parent = t;					t.resize_controller.onmousedown = this.drag; }		}		this.update = function(t, input, overwrite, ref) { if (document.getElementById(t) != null) {

var note      = document.getElementById(t); var divs = note.getElementsByTagName("div") for (var i = 0; i < divs.length; i++) { note[divs[i].className] = divs[i]; }				var newcontent = input; var title     = t;				var tempin     = ''; var oldheight = note.content_area.style.height; inputn = input.replace(/\n/g, "::;;::") if (overwrite == true) { tempin = newcontent; }				else {					tempin = ''; tempin += '<div style="border: 1px solid #000000; min-width: 100px; max-width: 500px; -moz-border-radius-bottomleft: 10px; -moz-border-radius-bottomright: 10px;">'; tempin += '<div class="drag_controller" ondblclick="javascript:controls.refreshNote(\+title+'\', \+inputn+'\')" style="cursor: move; position: relative; height:20px; width:inherit; overflow: hidden; background-color:#BBBBBB;font-family:arial;font-size:16px;font-weight:bold;padding:1px 10px 1px 3px;">' + title + ''; tempin += '<div class="close_note" style="background-color: #BBBBBB; position: absolute; top: 1px; right: 5px;">[<span style="cursor: default; text-decoration: none; color: #444444;" onmouseover="javascript:this.style.color = \'#999999\';" onmouseout="javascript:this.style.color = \'#444444\';" onclick="javascript:controls.destroyNote(\ + title + '\'); return false;">x ] <div class="edit_note" style="background-color:#BBBBBB; position: absolute; top: 1px; right: 25px;">[<span style="cursor: default; text-decoration: none; color: #444444;" onmouseover="javascript:this.style.color = \'#999999\';" onmouseout="javascript:this.style.color = \'#444444\';" onclick="javascript:controls.setMode(\'edit\',\'wiki-controls\'); controls.setEditBox(\+title+'\', \''+inputn+'\'); return false;"> \\ ] '; tempin += '<div class="btf_note" style="background-color: #BBBBBB; position: absolute; top: 1px; right: 47px;">[<span style="cursor: default; text-decoration: none; color: #444444;" onmouseover="javascript:this.style.color = \'#999999\';" onmouseout="javascript:this.style.color = \'#444444\';" onclick="javascript:controls.refreshNote(\+title+'\', \+inputn+'\'); return false;"> ^ ] '; tempin += '<div class="content_area" style="min-height: 10px; max-height: 2000px; width:inherit; overflow: hidden; position:relative; background-color:#EEEEEE;padding:3px; -moz-border-radius-bottomleft: 10px; -moz-border-radius-bottomright: 10px;font-family:arial;font-size:10px;">' + inputn.replace(/::;;::/g, " ") + '<div class="resize_controller" style="cursor: se-resize; position: absolute; bottom:0px; right: 0px; height:10px; width:10px;"> '; tempin += ' ' tempin += ''; }				note.innerHTML = tempin; var divs = note.getElementsByTagName("div") for (var i = 0; i < divs.length; i++) { note[divs[i].className] = divs[i]; }				note.content_area.style.height = oldheight; t = document.getElementById(t); var divs = t.getElementsByTagName("div") for (var i = 0; i < divs.length; i++) { t[divs[i].className] = divs[i]; }				// Move to front on refresh? if (ref == true) { var y = document.body; var divs = y.getElementsByTagName("div") this.zIndexValue = 0; for (var i = 0; i < divs.length; i++) { if ((divs[i].style.zIndex > this.zIndexValue) && ((divs[i].id != 'cntrl-main') && (divs[i].id != 'cpanel186354') && (divs[i].id != ''))) { this.zIndexValue = parseInt(divs[i].style.zIndex); } }					t.style.zIndex = this.zIndexValue + 1; if (t.id == 'cpanel186354') t.style.zIndex = 999999999; }				t.drag_controller._parent = t;				t.drag_controller.onmousedown = this.drag; t.resize_controller._parent = t;				t.resize_controller.onmousedown = this.drag; }			}		/* public function drag ( event as window.event) */ this.drag = function (e) { var n = this; var p = this._parent; // Function is called by the drag div (so 'this' = that div) and parent is the whole content div. // If this is a normal note, we want to refresh it (bring it to top) if that mode is // enabled and it ISN'T the control panel. var divs = p.getElementsByTagName("div") for (var i = 0; i < divs.length; i++) { p[divs[i].className] = divs[i]; }			var id = p.id; var content = p.content_area.innerHTML; content = content.substring(0, content.indexOf('<div class="resize_controller"')); if (((id != 'cntrl-main') && (id != 'cpanel186354') && (id != '')) && (onClick_bringToTop == true)) { //	controls.refreshNote(id, content); }			var e = window.event || e; // If e is set, use that, otherwise get the current event. n.initmousex = e.clientX // clientX is the mouseposition. n.initmousex now = the position where the mouse was clicked. n.initmousey = e.clientY n.initx = parseInt(p.offsetLeft) // offsetLeft is the div position of p (the holder div). n.initx now = the position where the div started when the mouse was clicked. n.inity = parseInt(p.offsetTop) n.width = parseInt(p.offsetWidth) // offsetWidth is the width of the div. n.width now = the starting width of the div (handy for resizing the note). n.cheight = parseInt(p.content_area.offsetHeight) // p.content_area is the inner div that contains the content. cheight now = the content height. document.onmousemove = getMoved; // Do the actual moving. document.onmouseup = doStop; function getMoved (e) { var e = window.event || e;						n.distancex = e.clientX - n.initmousex; n.distancey = e.clientY - n.initmousey; if (n.className == "drag_controller") { doMove(n.distancex, n.distancey); }						if (n.className == "resize_controller") { doSize(n.distancex, n.distancey); }						return false; }					function doMove (x, y) { //var o = document.getElementById('outputdivver'); //o.innerHTML = 'x: ' + p.style.left + '; y: ' + p.style.top; p.style.left = x + n.initx + "px"; p.style.top = y + n.inity + "px"; return false; }					function doSize (x, y){ //var o = document.getElementById('outputdivver'); //o.innerHTML = 'w: ' + p.style.width + '; h: ' + p.content_area.style.height; p.style.width              = Math.min(Math.max(n.width + x, 100), 500) + "px"; p.content_area.style.height = Math.min(Math.max(n.cheight + y, 10), 2000) + "px"; }					function doStop { var o = document.getElementById('outputdivver'); //o.innerHTML += 'Stopped'; document.onmousemove = null; document.onmouseup = null; return false; }		return false; } }

function ajaxPrep(currentContent, summary, flags) { page_request = false; if (window.XMLHttpRequest) page_request = new XMLHttpRequest; else if (window.ActiveXObject){ try { page_request = new ActiveXObject("Msxml2.XMLHTTP"); } 		catch (e){ try{ page_request = new ActiveXObject("Microsoft.XMLHTTP"); }			catch (e){} }	}	else {		return false; }	var url = window.location; var url = setup_wikiUrl + '/wiki/'; //DEBUG var wikipage = ''; var checkUrl = setup_wikiUrl + '/wiki/' if (url.indexOf(checkUrl) != -1) { wikipage = url.substring(checkUrl.length); wikipage = 'User:Ale_jrb/Sandbox'; // DEBUG var useurl = setup_wikiUrl + '/index.php?action=edit&title=' + wikipage; alert(useurl); }	else {		return false; }	//try { //netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); //} catch (e) { //alert("Permission UniversalBrowserRead denied."); //}	page_request.onreadystatechange = function { if (page_request.readyState == 4) { if (page_request.status == 200) { var editpage = page_request.responseText; ajaxSave(editpage, currentContent, wikipage, summary, flags); } else { alert('AJAX: There was a problem with the HTTP request, code received: ' + page_request.status); return false; }		 }	}	page_request.open('GET', useurl, true); page_request.send(null); }

function ajaxSave(contents, newcontents, wikipage, summary, flags) { alert("running"); var editpage = contents; var input   = newcontents; if (flags == null) flags = ''; var starttime = /value="(\d+)" name="wpStarttime"/i starttime     = starttime.exec(editpage); var edittime  = /value="(\d+)" name="wpEdittime"/i edittime      = edittime.exec(editpage); var edittoken = /value="(.+)" name="wpEditToken"/i edittoken     = edittoken.exec(editpage); var autosum   = /name="wpAutoSummary" type="hidden" value="(.+)" \/><\/form>/i autosum       = autosum.exec(editpage); starttime = starttime[1]; edittime = edittime[1]; edittoken = edittoken[1]; autosum  = autosum[1]; alert(starttime +', ' + edittime); var wpSection    = ''; var wpStarttime  = starttime; var wpEdittime   = edittime; var wpScrolltop  = ''; var wpTextbox1   = newcontents; var wpSummary    = summary; var wpMinoredit  = 0; var wpAutoSummary = autosum; var wpEditToken  = edittoken; wpTextbox1 = escape(wpTextbox1); var postTo = setup_wikiUrl + '/index.php?action=submit&title=' + wikipage; var params = 'wpSection=' + encodeURI(wpSection) + '&wpStarttime=' + encodeURI(wpStarttime) + '&wpEdittime=' + encodeURI(wpEdittime) + '&wpScrolltop=' + encodeURI(wpScrolltop) + '&wpTextbox1=' + wpTextbox1 + '&wpSummary=' + encodeURI(wpSummary) + '&wpMinoredit=' + encodeURI(wpMinoredit) + '&wpEditToken=' + wpEditToken + '&wpAutoSummary=' + wpAutoSummary; alert(postTo); alert(params); page_request2 = false; if (window.XMLHttpRequest) page_request2 = new XMLHttpRequest; else if (window.ActiveXObject){ try { page_request2 = new ActiveXObject("Msxml2.XMLHTTP"); } 		catch (e){ try{ page_request2 = new ActiveXObject("Microsoft.XMLHTTP"); }			catch (e){} }	}	else {		return false; }	page_request2.onreadystatechange = function { if (page_request2.readyState == 4) { if (page_request2.status == 200) { alert(page_request2.responseText); //document.getElementById('outputending').innerHTML = page_request2.responseText; if (flags.indexOf('redirect') > -1) { window.location = window.location.href; }				if (document.getElementById('cpanel186354') != null) { controls.setMode('default', 'cpanel186354'); }			} 			else {				alert('AJAX: There was a problem with the HTTP request, code received: ' + page_request2.status); return false; }		}	}	page_request2.open('POST', postTo, true); page_request2.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); page_request2.setRequestHeader("Content-length", params.length); page_request2.setRequestHeader("Connection", "close"); page_request2.send(params); }

hookEvent('load', wikiNotesLoad);