User:PC-XT/Advisor.js: Difference between revisions

Content deleted Content added
m oops
maintenance: more info TypeError: Cannot read property 'parentNode' of null
 
(9 intermediate revisions by 3 users not shown)
Line 1:
//<nowiki>
// See http://en.wikipedia.org/wiki/User:Cameltrader/Advisor.js/Description
// for details and installation instructions.
Line 13 ⟶ 14:
 
// == Helpers ==
 
// === DOM manipulation ===
 
Line 121 ⟶ 123:
// It is convenient to embed in a help popup.
ct.hlink = function (toWhat, text) {
var wgServer = windowmw.config.get('wgServer') || 'http://en.wikipedia.org';
var wgArticlePath = windowmw.config.get('wgArticlePath') || '/wiki/$1';
var url = (wgServer + wgArticlePath).replace('$1', toWhat);
return '<a href="' + url + '" target="_blank">' + (text || toWhat) + '</a>';
Line 251 ⟶ 253:
var e = document.getElementById('editform');
while (true) {
var p = e && e.previousSibling;
if ( (p == null) || ((p.nodeType == 1) && (p.id != 'toolbar')) ) {
break;
Line 257 ⟶ 259:
e = p;
}
if(e) {
e.parentNode.insertBefore(ct.eSuggestions, e);
} else {
return;
}
ct.eAddToSummary = document.createElement('DIV');
ct.eAddToSummary.style.border = 'dashed #ccc 1px';
Line 369 ⟶ 375:
}
// Warn about scanning a talk page
ifvar ((window.wgCanonicalNamespace != nullmw.config.get('wgCanonicalNamespace');
&& if /(\b|_)talk$/i.test(window.wgCanonicalNamespace != null)
&& /(\b|_)talk$/i.test(wgCanonicalNamespace)
&& !ct.isTalkPageScanConfirmed) {
ct.eSuggestions.appendChild(document.createTextNode(
Line 554 ⟶ 561:
// Cut off the leading ``, '' and add ``formatting: '' and ``using Advisor.js''
s = ct._(
'formatting: $1 (using [[User:Cameltrader#PC-XT/Advisor.js|Advisor.js]])',
s.substring(2)
);
Line 606 ⟶ 613:
// * name---this is what appears at the top of the page
// * description---used as a tooltip for the name of the suggestion
 
// The rules are stored in an array:
ct.rules = ct.rules||[]; // : Function[]
// and are grouped into categories.
 
// The set of rules to apply depends on the content language. Different
Line 613 ⟶ 624:
// Wikipedia.
 
if (!windowct.noDefaultRules && (!mw.config.get('wgContentLanguage') || (windowmw.config.get('wgContentLanguage') === 'en'))) { // switch to turn off default rules for replacement by custom ones // from this line on, a level of indent is spared
 
// The rules are stored in an array:
ct.rules = ct.rules||[]; // : Function[]
// and are grouped into categories.
 
// === Linking rules ===
Line 1,135 ⟶ 1,142:
ct.rules.push(function (s) {
var exceptions = {};
var wgTitle = windowmw.config.get('wgTitle') || '';
if (exceptions[wgTitle]) {
return [];
Line 1,180 ⟶ 1,187:
 
ct.rules.push(function (s) {
var wgTitle = windowmw.config.get('wgTitle') || '';
var reTitle = /^(a|the) (.*)$/i;
if (!reTitle.test(wgTitle) || (s.indexOf('DEFAULTSORT') !== -1)) {
Line 1,431 ⟶ 1,438:
end: m.end,
name: 'ISBN',
replacement: m[1]+" {{Please check ISBN|"+m[1]+"}}",
description: 'Should be either 10 or 13 digits long',
help: 'ISBN numbers should be either 10 or 13 digits long. '
Line 1,444 ⟶ 1,452:
end: m.end,
name: 'ISBN',
replacement: "{{Please check ISBN|"+m[1]+"}}",
description: 'Improper usage of X as a digit',
help: "``<tt>X</tt>'' can only be used in 10-digit ISBN numbers "
Line 1,469 ⟶ 1,478:
end: m.end,
name: 'ISBN',
replacement: "{{Please check ISBN|"+m[1]+"}}",
description: 'Bad ISBN checksum',
help: 'Bad ISBN checksum for<br/><tt>' + m[1] + '</tt><br/>'
Line 1,476 ⟶ 1,486:
});
 
} // end if (windowmw.config.get('wgContentLanguage') === 'en') // end of default rules
//</nowiki>