webbuild.js: support for "Start from URL" related fields autocompletion

This commit is contained in:
Silvan Calarco 2013-05-23 12:06:28 +02:00
parent dd369356c5
commit 19233fce7d

View File

@ -32,28 +32,51 @@ function checkEnter(event) {
}
function suggestSpecName(url) {
var version="";
var url=document.getElementById("speccreateurl").value;
if (url.indexOf('&') > 0) url=url.substring(0,url.indexOf('&')+1);
var filename=url.substring(url.lastIndexOf('/')+1);
if (filename.indexOf('.') > 0) filename=filename.substring(0,filename.indexOf('.'));
if (filename.lastIndexOf('-') > 0) {
var version=filename.substring(filename.lastIndexOf('-')+1);
filename=filename.substring(0,filename.lastIndexOf('-')).toLowerCase();
var specname=url.substring(url.lastIndexOf('/')+1);
while (i=specname.lastIndexOf('.')) {
e=specname.substring(i);
if (e != ".tar" && e != ".gz" && e != ".zip" && e != ".bz2" &&
e != ".xz" && e != ".tgz" && e != ".zip" && e != ".src" &&
e != ".orig") break;
specname=specname.substring(0,i);
}
if (specname.lastIndexOf('-') > 0) {
version=specname.substring(specname.lastIndexOf('-')+1);
specname=specname.substring(0,specname.lastIndexOf('-'));
}
document.getElementById("speccreateurl").value=url;
document.getElementById("speccreatename").value=filename;
if (url.search("cpan.org") >= 0) {
specname="perl-"+specname;
} else {
specname=specname.toLowerCase();
}
if (url.search("git://") >= 0) {
document.getElementById("speccreategitbranch").disabled=false;
} else {
document.getElementById("speccreategitbranch").disabled=true;
}
document.getElementById("speccreatename").value=specname;
document.getElementById("speccreateversion").value=version;
if (filename) {
if (url) {
document.getElementById("speccreatename").disabled=false;
document.getElementById("speccreateversion").disabled=false;
document.getElementById("speccreatetype").disabled=false;
document.getElementById("speccreatebutton").disabled=false;
} else {
document.getElementById("speccreatename").disabled=true;
document.getElementById("speccreateversion").disabled=true;
document.getElementById("speccreatetype").disabled=true;
document.getElementById("speccreatebutton").disabled=true;
}
if (filename.search("perl-") >= 0) {
if (specname.search("perl-") >= 0) {
for (var j=0;j<document.getElementById("speccreatetype").length;j++) {
if (document.getElementById("speccreatetype").options[j].value == "perl")
document.getElementById("speccreatetype").options[j].selected=true;
};
} else if (filename.search("python-") >= 0) {
} else if (specname.search("python-") >= 0) {
for (var j=0;j<document.getElementById("speccreatetype").length;j++) {
if (document.getElementById("speccreatetype").options[j].value == "python")
document.getElementById("speccreatetype").options[j].selected=true;