Utente:Salvatore Ingala/commandline.js: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
mNessun oggetto della modifica |
m agg.to: fix autocompletamento argomenti |
||
Riga 51:
//Prova a completare string usando dict come dizionario.
//Restituisce -1 se c'è ambiguità, 0 se non trova nessuna corrispondenza, o la stringa completa se trova una sola occorrenza
//Versione per dizionario di tipo object
function autoComplete1(dict, string, failIfAmbiguous){
var found = ''
var done = false;
for (var x in dict)
if (x.indexOf(string) == 0){
if (!failIfAmbiguous)
return x;
if (found == '')
found = x;
Riga 62 ⟶ 64:
return -1;
}
}
if (found != '')
return found;
Riga 67 ⟶ 70:
}
//Versione per dizionario di tipo array
function autoComplete2(dict, string, failIfAmbiguous){
var found = ''
var done = false;
Riga 74 ⟶ 77:
for (i = 0; i < dict.length; i++)
if (dict[i].indexOf(string) == 0)
if (!failIfAmbiguous)
return dict[i];failIfAmbiguous = true
if (found == '')
found = dict[i];
Riga 88 ⟶ 93:
//In caso di fallimento restituisce arg
function autoCompleteArgument(arg){
var completed = autoComplete2(arrayArgument, arg, false);
if ((completed == -1) || (completed == 0))
return arg;
Riga 132 ⟶ 137:
wpTextbox1=document.getElementById("wpTextbox1");
if (wpTextbox1 == null) return;
TimenPr('{{A|motivo='+(getArg("Motivo"))+'|argomento='+(autoCompleteArgument(getArg("Argomento"),false))+'|mese='+mese()+' '+anno()+'|firma=~~~~}}\n');
TimenSA('+da aiutare; '); TimenME();
}
Riga 139 ⟶ 144:
wpTextbox1=document.getElementById("wpTextbox1");
if (wpTextbox1 == null) return;
TimenPr('{{W|argomento='+(autoCompleteArgument(getArg("Argomento"),false))+'|mese='+mese()+' '+anno()+'|firma=~~~~}}\n');
TimenSA('+wikificare; '); TimenME();
}
Riga 146 ⟶ 151:
wpTextbox1=document.getElementById("wpTextbox1");
if (wpTextbox1 == null) return;
TimenPr('{{E|'+(getArg("Motivo"))+'|'+(autoCompleteArgument(getArg("Argomento"),false))+'|'+mese()+' '+anno()+'|~~~~}}\n');
TimenSA('+avviso enciclopedicità dubbia; '); TimenME();
}
Riga 153 ⟶ 158:
wpTextbox1=document.getElementById("wpTextbox1");
if (wpTextbox1 == null) return;
TimenPr('{{P|motivo='+(getArg("Motivo"))+'|argomento='+(autoCompleteArgument(getArg("Argomento"),false))+'|mese='+mese()+' '+anno()+'|firma=~~~~}}\n');
TimenSA('+avviso nNPOV; '); TimenME();
}
Riga 160 ⟶ 165:
wpTextbox1=document.getElementById("wpTextbox1");
if (wpTextbox1 == null) return;
TimenPr('{{C|motivo='+(getArg("Motivo"))+'|argomento='+(autoCompleteArgument(getArg("Argomento"),false))+'|mese='+mese()+' '+anno()+'|firma=~~~~}}\n');
TimenSA('+da controllare; '); TimenME();
}
Riga 167 ⟶ 172:
wpTextbox1=document.getElementById("wpTextbox1");
if (wpTextbox1 == null) return;
var argomento = autoCompleteArgument(getArg("Argomento"),false);
TimenPr('{{S' + (((argomento != null)&&(argomento!='')) ? ('|' + argomento + '}}\n') : '}}\n'));
TimenSA('+stub; '); TimenME();
Riga 346 ⟶ 351:
//Cerchiamo se è prefisso univoco di un comando
var completed = autoComplete1(cmd, command, true)
if ((completed != 0)&&(completed != -1))
cmd[completed][0](); //tutto a posto, eseguiamo
|