Utente:Alex brollo/Gadget-listingForm.js
Nota: dopo aver salvato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.
- Firefox / Safari: tenere premuto il tasto delle maiuscole e fare clic su Ricarica, oppure premere Ctrl-F5 o Ctrl-R (⌘-R su Mac)
- Google Chrome: premere Ctrl-Shift-R (⌘-Shift-R su un Mac)
- Internet Explorer: tenere premuto il tasto Ctrl mentre si fa clic su Refresh, oppure premere Ctrl-F5
- Opera: svuotare completamente la cache dal menu Strumenti → Preferenze
/*<pre>*/
tagsDict={};
tagsDict["listing"]="* {{listing\n|name=\n|alt=\n|address=\n|directions=\n|phone=\n|email=\n|fax=\n|url=\n|hours\n|price=\n|lat=\n|long=\n|tags\n}}";
tagsDict["drink"]="* {{drink\n|name=\n|alt=\n|address=\n|directions=\n|phone=\n|email=\n|fax=\n|url=\n|hours\n|price=\n|lat=\n|long=\n|tags\n}}";
tagsDict["eat"]="* {{eat\n|name=\n|alt=\n|address=\n|directions=\n|phone=\n|email=\n|fax=\n|url=\n|hours\n|price=\n|lat=\n|long=\n|tags\n}}";
tagsDict["buy"]="* {{buy\n|name=\n|alt=\n|address=\n|directions=\n|phone=\n|email=\n|fax=\n|url=\n|hours\n|price=\n|lat=\n|long=\n|tags\n}}";
tagsDict["see"]="* {{see\n|name=\n|alt=\n|address=\n|directions=\n|phone=\n|email=\n|fax=\n|url=\n|hours\n|price=\n|lat=\n|long=\n|tags\n}}";
tagsDict["do"]="* {{do\n|name=\n|alt=\n|address=\n|directions=\n|phone=\n|email=\n|fax=\n|url=\n|hours\n|price=\n|lat=\n|long=\n|tags\n}}";
tagsDict["sleep"]="* {{sleep\n|name=\n|alt=\n|address=\n|directions=\n|phone=\n|email=\n|fax=\n|url=\n|hours\n|price=\n|checkin=\n|checkout=\n|lat=\n|long=\n|tags\n}}";
function startForm () {
if (wgAction=="view" || wgAction=="submit") {
// nascondi il titolo sezione h6
$("h6").css("display","none");
// modifica colore e font-size dei link modifica
$("h6 span a").each(function() {
$(this).css("color","gray").css("font-size","80%");
});
// elimina il float:right; togli le quadre; sposta lo span a fine li;
$("h6 span.editsection").each(function() {
var html=$(this).html();
html=" "+html.substring(1,html.length-1);
$(this).html(html);
$(this).css("float","none").appendTo($(this).parent().next().children().eq(0));
});
}
// if attivato nel solo caso che il testo da editare inizi con una stringa chiave (da rivedere)
if ((wgAction=="edit" || wgAction=="submit") && leggiBox().indexOf("======")==0) formMake();
}
function formMake() {
// metto wpTextbox1 in readonly
$("#wpTextbox1").attr("readonly","").attr("title","Il testo non è editabile direttamente; usare il form a destra");
$(".wikiEditor-ui-left").css("display","inline").css("width","50%");
$(".wikiEditor-ui-right").css("display","inline")
.css("width","50%")
.css("height",$(".wikiEditor-ui-left").css("height"));
t=parseTemplate("see", leggiBox());
button1=$('<input type="button" value="Salva la pagina" onclick="rewTempl();$("#wpSave").click();">');
button2=$('<input type="button" value="Salva nel box testo" onclick="rewTempl();">');
$(".wikiEditor-ui-right").append(button1);
$(".wikiEditor-ui-right").append(button2);
$(".wikiEditor-ui-right").append($("<br />"));
// crea una serie di campi input
$(".wikiEditor-ui-right").append($("<table></table>"));
for (i=1;i<t[1].length;i+=1) {
if (t[1][i]=="description") {
input=$('<textarea rows="6" cols="50" ></textarea>').attr("name",t[1][i]).val(t[0][t[1][i]]);
}
else {
input=$("<input />").attr("name",t[1][i]).attr("type","text").attr("value",t[0][t[1][i]]);
size=t[0][t[1][i]].length+10;
if (size>40) size=40;
input.attr("size",size);
}
td1=$("<td valign='top'></td>").html(t[1][i]);
td2=$("<td valign='top'></td>").append(input);
tr=$("<tr></tr>").append(td1).append(td2);
$(".wikiEditor-ui-right table").append(tr);
}
}
function rewTempl () {
var templ="====== " + $(".wikiEditor-ui-right input[name='name']").val() + " ======\n{{see\n";
$(".wikiEditor-ui-right input[type='text'], .wikiEditor-ui-right textarea").each(function () {templ+="| "+$(this).attr("name")+" = "+$(this).val()+"\n";});
templ+="}}";
scriviBox(templ);
}
hookEvent("load", startForm);
/*</pre>*/