From 19233fce7d33f566911715f672cd7cb1d4dc8904 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Thu, 23 May 2013 12:06:28 +0200 Subject: [PATCH] webbuild.js: support for "Start from URL" related fields autocompletion --- webbuild/html/scripts/webbuild.js | 41 ++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/webbuild/html/scripts/webbuild.js b/webbuild/html/scripts/webbuild.js index b809f78..049578c 100644 --- a/webbuild/html/scripts/webbuild.js +++ b/webbuild/html/scripts/webbuild.js @@ -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= 0) { + } else if (specname.search("python-") >= 0) { for (var j=0;j