מדיה ויקי:Gadget-TemplateParamWizard.js: הבדלים בין גרסאות בדף

ניסוי
ניסוי
שורה 3: שורה 3:
"use strict";
"use strict";
if(($.inArray(mw.config.get('wgAction'), ['edit', 'submit'])+1) && ( !$('#wpTextbox1').prop( 'readonly' ) ) )
if(($.inArray(mw.config.get('wgAction'), ['edit', 'submit'])+1) && ( !$('#wpTextbox1').prop( 'readonly' ) ) )
$(function() {
$(function($) {
// template parameter is an object with the following fields:
// template parameter is an object with the following fields:
// desc: desciption string
// desc: desciption string
שורה 34: שורה 34:
rtl = $('body').is('.rtl'),
rtl = $('body').is('.rtl'),
// test to see if a string contains wikiCode and hence needs parsing, or cen be used as is.
// test to see if a string contains wikiCode and hence needs parsing, or cen be used as is.
wikiCodeFinder = /[\[\]\{\}\<\>]/,
wikiCodeFinder = /[\[\]\{\}<>]/,
globalExplanation = '',
globalExplanation = '',
extendedParamCssRule,
extendedParamCssRule,
שורה 49: שורה 49:
function paramsFromSelection() {
function paramsFromSelection() {
var selection = $("#wpTextbox1").textSelection('getSelection').replace(/^\s*\{\{|\}\}\s*$/g, ''); //scrap the first {{ and last }}
var selection = $("#wpTextbox1").textSelection('getSelection').replace(/^\s*\{\{|\}\}\s*$/g, ''); //scrap the first {{ and last }}
var specials = [];
var specials = [],
match;
while (true) { //extract inner links, inner templates and inner params - we don't want to sptit those.
while (true) { //extract inner links, inner templates and inner params - we don't want to sptit those.
var match = selection.match(/(\{\{[^\{\}\]\[]*\}\}|\[\[[^\{\}\]\[]*\]\]|\[[^\{\}\]\[]*\])/);
match = selection.match(/(\{\{[^\{\}\]\[]*\}\}|\[\[[^\{\}\]\[]*\]\]|\[[^\{\}\]\[]*\])/);
if (! match || ! match.length)
if (! match || ! match.length)
break;
break;
שורה 61: שורה 62:
var param = params[i];
var param = params[i];
while (true) {
while (true) {
var match = param.match(/\0(\d+)\0/);
match = param.match(/\0(\d+)\0/);
if (! match || ! match.length)
if (! match || ! match.length)
break;
break;
שורה 677: שורה 678:
.click(doIt)
.click(doIt)
);
);
});
} );