User:Cacycle/wikEd dev.js: Difference between revisions

Content deleted Content added
test4
0.9.92 rc3 (September 21, 2010)
Line 4:
 
// version info
wikEd.programVersion = '0.9.92 testing';
wikEd.programDate = 'September 1921, 2010';
 
/*
 
Program description and Greasemonkey metadata:
 
wikEd is a full-featured JavaScript inWikipedia-browserintegrated advanced text editor for Wikipedia andregular otherto MediaWikiadvanced editwiki pagesusers.
wikEd features syntax highlighting with code check and reference and template folding,
The program works currently ONLY for Mozilla, Firefox, SeaMonkey, Safari, and Chrome browsers.
on-page Show preview and Show changes, and advanced search and replace functions.
wikEd works under all web browsers except Internet Explorer and Opera.
The code has to be saved as UTF-8 in your editor to preserve Unicode characters like ♥ (heart)
 
Greasemonkey metadata:
 
// ==UserScript==
Line 21 ⟶ 25:
// @include *
// @exclude
//
// @homepage http://en.wikipedia.org/wiki/User:Cacycle/wikEd
// @source http://en.wikipedia.org/wiki/User:Cacycle/wikEd.js
Line 28 ⟶ 31:
// ==/UserScript==
 
== Installation on a MediaWiki wiki (using monobook.js) ==:
 
1. PLEASE DO NOT COPY THE WHOLE PROGRAM (in order to get the frequent updates and bug fixes and to save disk space)
2. See http://en.wikipedia.org/wiki/User:Cacycle/wikEd for more detailedinstallation instructions
3. Copy the following short block of code to [[User:YOURUSERNAME/monobook.js]]
4. Click SHIFT-Reload to update to the newest version
 
*/
// ---- START wikEd INSTALLATION CODE ----
 
// install [[User:Cacycle/wikEd]] in-browser text editor
document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
+ '&action=raw&ctype=text/javascript"></script>');
 
// ---- END wikEd INSTALLATION CODE ----
 
== General installation for all MediaWiki wikis (using Greasemonkey) ==
 
1. Install Greasemonkey for Firefox from:
https://addons.mozilla.org/en-US/firefox/addon/748
2. Install wikEd by opening this address:
http://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:Cacycle/wikEd.user.js
 
*/
 
//
// start of user configurable variables
//
 
//
Line 3,530 ⟶ 3,519:
 
// make the ajax request
wikEd.AjaxRequest(requestMethod'GET', requestUrlwikEd.config.autoUpdateUrl, postFieldsnull, overrideMimeType'text/plain', function(ajax, obj) {
var requestMethod = 'GET';
var requestUrl = wikEd.config.autoUpdateUrl;
var postFields = null;
var overrideMimeType = null;
wikEd.AjaxRequest(requestMethod, requestUrl, postFields, overrideMimeType, function(ajax, obj) {
 
// get response
Line 3,604 ⟶ 3,589:
 
// make the ajax request
wikEd.AjaxRequest('GET', wikEd.config.regExTypoFixURL, null, 'text/plain', function(ajax) {
var requestMethod = 'GET';
var requestUrl = wikEd.config.regExTypoFixURL;
var postFields = null;
var overrideMimeType = null;
wikEd.AjaxRequest(requestMethod, requestUrl, postFields, overrideMimeType, function(ajax) {
 
// get response
Line 8,530 ⟶ 8,511:
}
var requestUrl = wikEd.scriptURL + 'api.php';
var requestMethod = 'POST';
var overrideMimeType = undefined;//'text/html';
 
// make the ajax request
wikEd.AjaxRequest(requestMethod'POST', requestUrl, postFields, overrideMimeType'text/plain', function(ajax) {
 
// get response
Line 14,664 ⟶ 14,643:
 
// make the ajax request
wikEd.AjaxRequest(requestMethod'POST', requestUrl, postFields, overrideMimeType'text/plain', function(ajaxResponseHandler) {;
var requestMethod = 'POST';
var overrideMimeType = null;//'text/html';
wikEd.AjaxRequest(requestMethod, requestUrl, postFields, overrideMimeType, ResponseHandler);
 
return;
Line 14,686 ⟶ 14,663:
 
// assemble string body
WED('typeof(FormData)', typeof(FormData));
if (typeof(FormData) != 'function') {
 
Line 14,696 ⟶ 14,672:
 
// assemble body data
formData = '\r\n';
for (var fieldName in postFields) {
if (postFields.hasOwnProperty(fieldName) == true) {
Line 14,704 ⟶ 14,680:
}
formData += '--' + boundary + '--\r\n';
// headers['Content-length'] = formData.length;///?
WED('formData string', formData);
}
 
Line 14,783 ⟶ 14,757:
// open the request
request.open(requestMethod, requestUrl, true);
WED('requestMethod', requestMethod); WED('requestUrl', requestUrl);
 
// set the headers
Line 14,789 ⟶ 14,762:
if (headers.hasOwnProperty(headerName) == true) {
request.setRequestHeader(headerName, headers[headerName]);
WED('Header: ' + headerName, headers[headerName]);
}
}
Line 14,795 ⟶ 14,767:
// set the mime type
if ( (request.overrideMimeType != null) && (overrideMimeType != null) ) {
WED('overrideMimeType', overrideMimeType);
request.overrideMimeType(overrideMimeType);
}
Line 14,810 ⟶ 14,781:
request.onreadystatechange = function() {
if (request.readyState != 4) {
WED('request.readyState', request.readyState);
return;
}
WED('request.responseText', request.responseText);
ResponseHandler(request);
return;
Line 14,874 ⟶ 14,843:
 
if (event.source != window) {
return;
}
if ( (event.origin != 'null') && (event.origin != null) && (event.origin != window.___location.protocol + '//' + window.___location.host) ) {
return;
}
if (event.data != '') {
var globalObj = JSON.parse(event.data);
var globals = globalObj.wikEdGetGlobals;
Line 15,173 ⟶ 15,142:
wikEd.CreateRandomString = function(strLength, charSet) {
 
if (charSet == null) {
charSet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789';
charSet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_';
}
var str = '';
for (var i = 0; i < strLength; i ++) {
str += charSet.charAt(Math.floor(Math.random() * charSet.length));
}
return(str);
}