מדיה ויקי:Gadget-TemplatesExternalLinks.js: הבדלים בין גרסאות בדף
סידור. |
preview, לבקשת או"א. |
||
| שורה 1: | שורה 1: | ||
function createAndInsertLinkTemplate( | function createAndInsertLinkTemplate(doc) { | ||
var par = ["{{" + templateName]; | var par = ["{{" + doc.templateName]; | ||
for (var i | for (var i in doc.allFields) | ||
par.push( | par.push(doc.allFields[i].value); | ||
var code = par.join("|") + "}}"; | var code = par.join("|") + "}}"; | ||
if ( | if (doc.refCheckBox.checked) | ||
code = "{{הערה|1=" + code + "}}"; | code = "{{הערה|1=" + code + "}}"; | ||
return code; | |||
} | |||
function updatePreview() { | |||
this.doc.previewNode.data = createAndInsertLinkTemplate(this.doc); | |||
} | } | ||
function popupPredefinedLinkTemplate(templateName, paramList, regexDict) { | function popupPredefinedLinkTemplate(templateName, paramList, regexDict) { | ||
var height = | var height = 140 + 20 * paramList.length + (regexDict ? 60 : 0); | ||
for (i in paramList) | for (i in paramList) | ||
height += 20 * Math.floor(paramList[i].length / 20); | height += 20 * Math.floor(paramList[i].length / 20); | ||
| שורה 43: | שורה 47: | ||
} | } | ||
body.appendChild(b); | body.appendChild(b); | ||
body.appendChild(doc.createElement("hr")); | |||
} | } | ||
var table = doc.createElement("table"); | var table = doc.createElement("table"); | ||
| שורה 59: | שורה 64: | ||
field.maxLength = 120; | field.maxLength = 120; | ||
field.style.width = "20em"; | field.style.width = "20em"; | ||
field.doc = doc; | |||
field.onkeyup = updatePreview; | |||
cell = row.insertCell(-1); | cell = row.insertCell(-1); | ||
cell.appendChild(field); | cell.appendChild(field); | ||
| שורה 65: | שורה 72: | ||
body.appendChild(table); | body.appendChild(table); | ||
body.appendChild(doc.createElement("p")); | body.appendChild(doc.createElement("p")); | ||
var refCheckBox = doc.createElement('input'); | var refCheckBox = doc.refCheckBox = doc.createElement('input'); | ||
refCheckBox.type = "checkbox"; | refCheckBox.type = "checkbox"; | ||
refCheckBox.doc = doc; | |||
doc.isRef = doc; | |||
refCheckBox.onchange = updatePreview; | |||
var label = doc.createElement('label'); | var label = doc.createElement('label'); | ||
label.htmlFor = refCheckBox; | label.htmlFor = refCheckBox; | ||
| שורה 72: | שורה 82: | ||
body.appendChild(label); | body.appendChild(label); | ||
body.appendChild(refCheckBox); | body.appendChild(refCheckBox); | ||
var p = doc.createElement("p"); | |||
body.appendChild(p); | |||
p.appendChild(doc.previewNode = doc.createTextNode(' ')); | |||
p.style.background = "blue"; | |||
p.style.color = "white"; | |||
p.style.fontSize = "0.85em"; | |||
body.appendChild(doc.createElement("p")); | body.appendChild(doc.createElement("p")); | ||
b = doc.createElement("input"); | b = doc.createElement("input"); | ||
b.type = "button"; | b.type = "button"; | ||
b.value = "אישור"; | b.value = "אישור"; | ||
b.doc = doc; | b.doc = doc; | ||
b.popup = popup; | b.popup = popup; | ||
b.refCheckBox = refCheckBox; | b.refCheckBox = refCheckBox; | ||
b.onclick = function() { | b.onclick = function() { | ||
insertTags( "", "", createTemplate(this.doc)); | |||
this.popup.close(); | this.popup.close(); | ||
} | } | ||
| שורה 89: | שורה 104: | ||
b.value = "ביטול"; | b.value = "ביטול"; | ||
b.popup = popup; | b.popup = popup; | ||
b.onclick = function() { | b.onclick = function() { this.popup.close(); } | ||
body.appendChild(b); | body.appendChild(b); | ||
refCheckBox.onchange(); | |||
} | } | ||
function knownLinkTemplates() { | function knownLinkTemplates() { | ||
| שורה 144: | שורה 157: | ||
"ynet": [1,2,3,4,5,0,], | "ynet": [1,2,3,4,5,0,], | ||
"הארץ": [1, 2, 3, 4], | "הארץ": [1, 2, 3, 4], | ||
"דבר": [1,2,22,3, | "דבר": [1,2,22,3,7,23], | ||
'תנ"ך': [8,9,10], | 'תנ"ך': [8,9,10], | ||
"nrg": [1,2,3,4,0,19,20], | "nrg": [1,2,3,4,0,19,20], | ||
| שורה 273: | שורה 286: | ||
function createLinkTemplatesSelections() { | function createLinkTemplatesSelections() { | ||
var select = document.createElement("select"); | var select = document.createElement("select"); | ||
select.onchange = function() { | select.onchange = function() { | ||
fireLinkTemplatePopup(this.value); | fireLinkTemplatePopup(this.value); | ||
| שורה 281: | שורה 293: | ||
var fullList = knownLinkTemplates(); | var fullList = knownLinkTemplates(); | ||
var names = [], hnames = []; | var names = [], hnames = []; | ||
for (x in fullList) | for (x in fullList) | ||
if | if (x.match(/^[a-zA-Z]/)) | ||
names.push(x); | names.push(x); | ||
else | else | ||