Content deleted Content added
m +yyOffset() testing hook for scrolling |
maintenance: more info TypeError: Cannot read property 'parentNode' of null |
||
(11 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 24 ⟶ 23:
// Initialise static variables used within this function
var _static = arguments.callee; // this is the Function we are in. It will be used as a poor man's function-local static scope.
if(ct.noscroll)return;
if (ta.setSelectionRange) {
// Guess the vertical scroll offset by creating a
Line 43 ⟶ 45:
hta.style.width = ta.clientWidth + 'px';
hta.style.height = ta.clientHeight + 'px';
hta.value = _static.NEWLINES.substring(0, ta.rows) + ta.value.substring(0, start/*+(end-start)/2*/);
var yOffset =
hta.style.display = 'none';
//if(yOffset>ta.scrollTop||yOffset<=ta.scrollTop-ta.clientHeight) {
▲ ta.focus();
▲ ta.setSelectionRange(start, end);
// Opera does not support setting the scrollTop property▼
▲ yOffset -= Math.floor(ta.clientHeight / 2);
if (ta.scrollTop != yOffset
// todo: Warn the user or apply a workaround▼
▲ // Opera does not support setting the scrollTop property
}▼
if (ta.scrollTop != yOffset) {▼
} else {
▲ // todo: Warn the user or apply a workaround
}
//}
▲ }
} else {
// IE incorrectly counts '\r\n' as a signle character
Line 122 ⟶ 123:
// It is convenient to embed in a help popup.
ct.hlink = function (toWhat, text) {
var wgServer =
var wgArticlePath =
var url = (wgServer + wgArticlePath).replace('$1', toWhat);
return '<a href="' + url + '" target="_blank">' + (text || toWhat) + '</a>';
Line 252 ⟶ 253:
var e = document.getElementById('editform');
while (true) {
var p = e && e.previousSibling;
if ( (p == null) || ((p.nodeType == 1) && (p.id != 'toolbar')) ) {
break;
Line 258 ⟶ 259:
e = p;
}
if(e) {
} else {
return;
}
ct.eAddToSummary = document.createElement('DIV');
ct.eAddToSummary.style.border = 'dashed #ccc 1px';
Line 370 ⟶ 375:
}
// Warn about scanning a talk page
&& /(\b|_)talk$/i.test(wgCanonicalNamespace)
&& !ct.isTalkPageScanConfirmed) {
ct.eSuggestions.appendChild(document.createTextNode(
Line 516 ⟶ 522:
return;
}
var suggestion = ct.suggestions[k];▼
st=editform.wpTextbox1.scrollTop,
if (suggestion.replacement == null) { // the issue is not automatically fixable
return;
Line 529 ⟶ 537:
suggestion.start + suggestion.replacement.length
);
if(ct.noscroll)editform.wpTextbox1.scrollTop=st; //to help automatic scrolling do its job better
// Propose an edit summary unless it's a new section
▲ var editform = document.getElementById('editform');
if (!editform['wpSection'] || (editform['wpSection'].value != 'new')) {
if (ct.appliedSuggestions[suggestion.name] == null) {
Line 553 ⟶ 561:
// Cut off the leading ``, '' and add ``formatting: '' and ``using Advisor.js''
s = ct._(
'formatting: $1 (using [[User:
s.substring(2)
);
Line 605 ⟶ 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 612 ⟶ 624:
// Wikipedia.
if (!
▲// The rules are stored in an array:
▲ct.rules = ct.rules||[]; // : Function[]
▲// and are grouped into categories.
// === Linking rules ===
Line 1,134 ⟶ 1,142:
ct.rules.push(function (s) {
var exceptions = {};
var wgTitle =
if (exceptions[wgTitle]) {
return [];
Line 1,179 ⟶ 1,187:
ct.rules.push(function (s) {
var wgTitle =
var reTitle = /^(a|the) (.*)$/i;
if (!reTitle.test(wgTitle) || (s.indexOf('DEFAULTSORT') !== -1)) {
Line 1,430 ⟶ 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,443 ⟶ 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,468 ⟶ 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,475 ⟶ 1,486:
});
} // end if (
//</nowiki>
|