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

מ שינוי של קיפודנחש
מועתק חזרה מ"מדיה ויקי" (שינוי הheader). תוספת תבנית One.
שורה 18: שורה 18:
return target;
return target;
}
}
 
function knownLinkTemplates() {
function knownLinkTemplates() {
var constants = ["",
var constants = ["",
שורה 67: שורה 67:
"שם המין/זן"
"שם המין/זן"
];
];
 
var templatesDic = {
var templatesDic = {
"הארץ": [1, 2, 3, 4],
"הארץ": [1, 2, 3, 4],
שורה 136: שורה 136:
"עיתונות יהודית היסטורית 2": [43,44,1,2,22,3,7,0,23],
"עיתונות יהודית היסטורית 2": [43,44,1,2,22,3,7,0,23],
"Iucnredlist": [45,3],
"Iucnredlist": [45,3],
"העין השביעית": [1,34,6,4,25]
"העין השביעית": [1,34,6,4,25],
"One": [1,2,3,4]
};
};
for (var key in templatesDic)
for (var key in templatesDic)
for (var i in templatesDic[key])  
for (var i in templatesDic[key])
if (typeof(templatesDic[key][i]) == "number")
if (typeof(templatesDic[key][i]) == "number")
templatesDic[key][i] = constants[templatesDic[key][i]];
templatesDic[key][i] = constants[templatesDic[key][i]];
if (typeof privateTemplates === "object")
if (typeof privateTemplates === "object")
שורה 146: שורה 147:
return templatesDic;
return templatesDic;
}
}
 
function templateRegex(templateName) {
function templateRegex(templateName) {
var regexes = {
var regexes = {
שורה 198: שורה 199:
"עיתונות יהודית היסטורית 2": {regex: /(?:Key|BaseHref)=([A-Z]{3})\/(\d{4}\/\d{1,2}\/\d{1,2})(?:.*&EntityId=|\/\d+\/)([A-Z][a-z])(\d+)/i, params:[2,5,9,6], replace: [[/%2F/gi, '/']]},
"עיתונות יהודית היסטורית 2": {regex: /(?:Key|BaseHref)=([A-Z]{3})\/(\d{4}\/\d{1,2}\/\d{1,2})(?:.*&EntityId=|\/\d+\/)([A-Z][a-z])(\d+)/i, params:[2,5,9,6], replace: [[/%2F/gi, '/']]},
"Iucnredlist": {regex: /details(?:\.php)?\/(\d+)/, params: [2]},
"Iucnredlist": {regex: /details(?:\.php)?\/(\d+)/, params: [2]},
"העין השביעית": {regex: /the7eye\.org\.il\/([^\/]+)\/Pages\/(.*)\.aspx/, params: [5,3]}
"העין השביעית": {regex: /the7eye\.org\.il\/([^\/]+)\/Pages\/(.*)\.aspx/, params: [5,3]},
"One": {regex: /Article\/(\d*)\.html/, params: [3]}
}
}
 
// these guys are all the same - it's best to handle them as such.
// these guys are all the same - it's best to handle them as such.
var historic = {"דבר": "DAV", "מעריב": "MAR", "הצבי": "HZV", "הצפירה": "HZF", "המגיד": "MGD", "המליץ": "HMZ", "חבצלת": "HZT", "PalPost": "PLS"};
var historic = {"דבר": "DAV", "מעריב": "MAR", "הצבי": "HZV", "הצפירה": "HZF", "המגיד": "MGD", "המליץ": "HMZ", "חבצלת": "HZT", "PalPost": "PLS"};
var histregex = {regex: /=HISTNAME\/(\d{4}\/\d{1,2}\/\d{1,2})(?:.*&EntityId=|\/\d+\/)([A-Z][a-z])(\d+)/i, params:[3,7,4], replace: [[/%2F/gi, '/']]};
var histregex = {regex: /=HISTNAME\/(\d{4}\/\d{1,2}\/\d{1,2})(?:.*&EntityId=|\/\d+\/)([A-Z][a-z])(\d+)/i, params:[3,7,4], replace: [[/%2F/gi, '/']]};
for (var template in historic) {
for (var template in historic) {
var lr = copyAttributes({}, histregex);  
var lr = copyAttributes({}, histregex);
lr.regex =  new RegExp(lr.regex.source.replace("HISTNAME", historic[template]));
lr.regex =  new RegExp(lr.regex.source.replace("HISTNAME", historic[template]));
regexes[template] = lr;
regexes[template] = lr;
שורה 213: שורה 215:
return regexes[templateName];
return regexes[templateName];
}
}
 
function popupPredefinedLinkTemplate(templateName, paramList, regexDict) {
function popupPredefinedLinkTemplate(templateName, paramList, regexDict) {
var height = 160 + 20 * paramList.length + (regexDict ? 60 : 0);
var height = 160 + 20 * paramList.length + (regexDict ? 60 : 0);
שורה 292: שורה 294:
doc.refCheckBox.onchange();
doc.refCheckBox.onchange();
}
}
 
function fireLinkTemplatePopup(templateName) {
function fireLinkTemplatePopup(templateName) {
var linkTemplates = knownLinkTemplates();
var linkTemplates = knownLinkTemplates();
שורה 299: שורה 301:
popupPredefinedLinkTemplate(templateName, templateParams, templateRegex(templateName));
popupPredefinedLinkTemplate(templateName, templateParams, templateRegex(templateName));
}
}
 
function createSortedTemplatesList() {
function createSortedTemplatesList() {
var fullList = knownLinkTemplates();
var fullList = knownLinkTemplates();
שורה 312: שורה 314:
return hnames.concat(names);
return hnames.concat(names);
}
}
 
function createLinkTemplatesSelections() {
function createLinkTemplatesSelections() {
var select = document.createElement("select");
var select = document.createElement("select");
שורה 328: שורה 330:
toolbar.appendChild(select);
toolbar.appendChild(select);
}
}
 
function updatePreview() { this.doc.previewNode.data = createTemplate(this.doc); }
function updatePreview() { this.doc.previewNode.data = createTemplate(this.doc); }
 
function advancedFire(context) {
function advancedFire(context) {
fireLinkTemplatePopup(this.template);
fireLinkTemplatePopup(this.template);
}
}
 
function createAdvanceToolKit() {
function createAdvanceToolKit() {
     var gadget = {label: 'אשף תבניות קישורים', type: 'select', list: []};
     var gadget = {label: 'אשף תבניות קישורים', type: 'select', list: []};
שורה 346: שורה 348:
});
});
}
}
 
if (typeof $j != 'undefined' && typeof $j.fn.wikiEditor != 'undefined')
if (typeof $j != 'undefined' && typeof $j.fn.wikiEditor != 'undefined')
$j(document).ready(createAdvanceToolKit);
$j(document).ready(createAdvanceToolKit);
if (wgAction == 'edit')
if (wgAction == 'edit')
hookEvent("load", createLinkTemplatesSelections);
hookEvent("load", createLinkTemplatesSelections);