«Մասնակից:Xelgen/CleanupTools.js»–ի խմբագրումների տարբերություն
Content deleted Content added
No edit summary |
No edit summary |
||
Տող 1.
//CleanupTools v 0.
//CleanupTools is spin-off from SAETools targeting any page, as opposed to SAETools.
var SAEfileNameBeginning='Էջ:Հայկական_Սովետական_Հանրագիտարան_(Soviet_Armenian_Encyclopedia)_';
//var originalHyphenCount, originalSectionCount, originalNewLineCount;
/* Check if view is in edit mode and that the required modules are available and we're not on SAE page, as SAETools have similar features. Then, customize the toolbar */
/* Commented out, as currently check is done in users' common.js. May need to reenable this initalization call, in Gadgets. */
$( '#wpTextbox1' ).on( 'wikiEditor-toolbar-doneInitialSections', function () {
▲ if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 && mw.config.get( 'wgPageName' ).substr(0,66) !== SAEfileNameBeginning) {
mw.loader.using( 'user.options', function () {▼
if ( mw.user.options.get('usebetatoolbar') ) {
} );
}
});
*/
} );▼
CTInitialize();
var textarea = document.getElementById("wpTextbox1")▼
}
function CTInitialize()
{
//Variables here may be unused, if we don't show count of hyphens/newlines removed.
//originalHyphenCount =
originalSectionCount = (document.getElementById("wpTextbox1").value.split(/##/g).length-1)/2; //Same feautre for Sections▼
▲
addCTToolsButtons();
//To-Do Alt+1, Alt+2 etc are used to swtich between tabs in browsers, we need to override it or change hotkeys
$(document).keyup(function(evt)
{
Տող 60 ⟶ 59՝
}
});
}
//We're adding button here
function addCTToolsButtons ()
{ $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
Տող 126 ⟶ 127՝
} );
//Is separator in toolbar needed for 3 buttons?
//$(".group.group-insert").css("border-right","1px solid #DDDDDD");
}
var text = document.getElementById("wpTextbox1").value;
origNewLineCount = text.split("\n").length;
Տող 146 ⟶ 147՝
// [Ա-և] բոլոր հայերեն տառերը
Տող 153 ⟶ 154՝
var text = document.getElementById("wpTextbox1").value;
var origHyphenCount =
//removing new lines between numbers, leaving dash intact
text = text.replace(/([0-9])[
//Regexp for not touching hidden Y is too complex to mantain,
//so instead of making it skip e-/nv we're making a dirty trick here
Տող 162 ⟶ 163՝
//Remove (we're very careful taking max 6 letter long words, not to brake dashed phrases)
text = text.replace(/([\s«\(])(([Ա-և](?!ը)){2,6})[
//Remove (if part after hyphen is max 3 letters, then it can't be compound issues with Ev unsolved &
//we're very careful taking max 6 letter long words, not to brake dashed phrases)
text = text.replace(/([\s«\(])(([Ա-և](?!ը)){2,})[
text = text.replace(/([\s«\(])([Ա-և][ա-էթ-և]|[Ա-և]{1}ու|ու[ա-թի–և]{1})[֊¬–-]\n([ա-էթ-և]{1,}[ա-և])([\s,:։՝»\)])/g, "$1$2$3$4"); //if first part has just 2 letters, it's not a dashed word, ու is basically one letter, so 2 special caes for that, and we're taking out ուժ as it can be compound word
text = text.replace(/([Ա-ԷԹ-Ֆա-էթ-և]{3,})[֊¬–-]\n([ա-և]{0,3}թյուն(?:ը|ն|ներ|ների|ներից|ները|ներն|ներում)?|[ա-և]{0,3}թյամբ|[ա-և]{0,3}թյան(?:ը|ն|ներ|ների|ները|ներն|ներում)?|[ա-և]{0,2}յինը?|[ա-և]ում|յան|[ա-և]{0,2}կանը?|ներ[ա-և]{0,2})([\s,:։․՝»])/g, "$1$2$3"); //after being so careful, not to brake dashes where they should be, we need to take most common suffixes, and try to do some more work
//We're removing what we've done in dirty e-/nv trick here. Sorry for this.
Տող 174 ⟶ 175՝
document.getElementById("wpTextbox1").value = text;
removedHyphenCount = origHyphenCount-
if (removedHyphenCount>0)
{
Տող 180 ⟶ 181՝
}
mw.notify('Հեռացվեց ' + removedHyphenCount + ' տողադարձ ' + origHyphenCount + '-ից');
}
var text = document.getElementById("wpTextbox1").value;
Տող 198 ⟶ 199՝
document.getElementById("wpTextbox1").value = text;
insertSummary('+հայ․ կետ․ ');
}
function countHyphens () {
}
function insertSummary( text ) {
var sum = $('#wpSummary'), vv = sum.val();
if (vv.indexOf(text) !== -1) return;
if (/[^,; \/]$/.test(vv)) vv += ',';
if (/[^ ]$/.test(vv)) vv += ' ';
sum.val(vv + text);
}
|