20,741
edits
m (→The Script: add version number to output dialog) |
m (→The Script: stubs for adding support to fetch URLs/contents asynchronously using AJAX (disabled for now)) |
||
| Line 92: | Line 92: | ||
// ==UserScript== | // ==UserScript== | ||
// @name Instant-Cquotes | // @name Instant-Cquotes | ||
// @version 0. | // @version 0.22 | ||
// @description Automatically converts mailing list and forum quotes into Mediawiki markup. | // @description Automatically converts mailing list and forum quotes into Mediawiki markup. | ||
// @author Hooray, bigstones, Philosopher & Red Leader | // @author Hooray, bigstones, Philosopher & Red Leader | ||
| Line 106: | Line 106: | ||
// @grant GM_getResourceText | // @grant GM_getResourceText | ||
// @grant GM_setClipboard | // @grant GM_setClipboard | ||
// @grant GM_xmlhttpRequest | |||
// @noframes | // @noframes | ||
// ==/UserScript== | // ==/UserScript== | ||
| Line 114: | Line 115: | ||
// http://wiki.greasespot.net/GM_info | // http://wiki.greasespot.net/GM_info | ||
var scriptVersion = ' (v'+GM_info.script.version+')'; | var scriptVersion = ' (v'+GM_info.script.version+')'; | ||
//console.log(GM_info); | |||
} | } | ||
catch (error) { | catch (error) { | ||
| Line 119: | Line 121: | ||
'use strict'; | 'use strict'; | ||
// Define constants | // Define constants | ||
var DEBUG = false; | var DEBUG = true; | ||
// set this to true continue working on the new mode supporting | |||
// asynchronous content fetching via AJAX | |||
var USE_NG=false; | |||
var CONFIG = { | var CONFIG = { | ||
'Mailing list': { | 'Mailing list': { | ||
| Line 304: | Line 313: | ||
// ################## | // ################## | ||
window.addEventListener('load', init); | window.addEventListener('load', init); | ||
dbLog('Instant Cquotes: page load handler registered'); | |||
// Initialize | // Initialize | ||
function init() { | function init() { | ||
document.onmouseup = | dbLog('mouseup event'); | ||
if (Boolean(USE_NG)) { | |||
dbLog("Instant Cquotes:devel version (WIP)"); | |||
document.onmouseup = instantCquoteNG; | |||
}else { | |||
dbLog("Instant Cquotes:standard version"); | |||
document.onmouseup = instantCquote; | |||
} | |||
} | |||
function OpenLink(url, callback){ | |||
// http://wiki.greasespot.net/GM_xmlhttpRequest | |||
GM_xmlhttpRequest({ | |||
method: "GET", | |||
url: url, | |||
onload: callback | |||
}); | |||
} | } | ||
// an experimental version (non-functional for now) | |||
function instantCquoteNG() { | |||
dbLog("experimental NN callback triggered"); | |||
//self-test | |||
OpenLink("http://sourceforge.net/p/flightgear/mailman/message/27369425/",function(response) { | |||
console.log("ajax request status:"+response.statusText); | |||
}); | |||
} // instantCquoteNG | |||
// The main function | // The main function | ||
| Line 436: | Line 475: | ||
} | } | ||
} | } | ||
// Change the text using | // Change the text using specified transformations | ||
function applyTransformations(fieldInfo, trans) { | function applyTransformations(fieldInfo, trans) { | ||
| Line 661: | Line 700: | ||
function dbLog(message) { | function dbLog(message) { | ||
if (Boolean(DEBUG)) console.log(message); | if (Boolean(DEBUG)) console.log(message); | ||
}</syntaxhighlight> | } | ||
</syntaxhighlight> | |||
[[Category:Wiki maintenance]] | [[Category:Wiki maintenance]] | ||