82 lines
2.9 KiB
JavaScript
82 lines
2.9 KiB
JavaScript
function getCheckedValuesByName(checkboxname) {
|
|
var e=document.getElementsByName(checkboxname);
|
|
var p="";
|
|
|
|
for (var j=0;j<e.length;j++) {
|
|
if (e[j].checked) p+=e[j].value+" ";
|
|
};
|
|
return p;
|
|
}
|
|
|
|
function checkAllBoxes(checkboxname,checked) {
|
|
var e=document.getElementsByName(checkboxname);
|
|
|
|
for (var j=0;j<e.length;j++) {
|
|
e[j].checked=checked;
|
|
};
|
|
}
|
|
|
|
function getSelectedValueById(selectname,idx) {
|
|
if (idx == undefined) idx = 0;
|
|
var i=document.getElementById(selectname).selectedIndex;
|
|
return document.getElementById(selectname).options[i+idx].value;
|
|
}
|
|
|
|
function checkEnter(event) {
|
|
event=event || window.event;
|
|
getEvent=event.keyCode;
|
|
if (getEvent == "13") {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function suggestSpecName(url) {
|
|
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();
|
|
}
|
|
document.getElementById("speccreateurl").value=url;
|
|
document.getElementById("speccreatename").value=filename;
|
|
document.getElementById("speccreateversion").value=version;
|
|
if (filename) {
|
|
document.getElementById("speccreatebutton").disabled=false;
|
|
} else {
|
|
document.getElementById("speccreatebutton").disabled=true;
|
|
}
|
|
if (filename.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) {
|
|
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;
|
|
};
|
|
} else {
|
|
for (var j=0;j<document.getElementById("speccreatetype").length;j++) {
|
|
if (document.getElementById("speccreatetype").options[j].value == "library")
|
|
document.getElementById("speccreatetype").options[j].selected=true;
|
|
};
|
|
}
|
|
}
|
|
|
|
function replaceHTML(el, html) {
|
|
var oldEl = typeof el === "string" ? document.getElementById(el) : el;
|
|
/*@cc_on // Pure innerHTML is slightly faster in IE
|
|
oldEl.innerHTML = html;
|
|
return oldEl;
|
|
@*/
|
|
var newEl = oldEl.cloneNode(false);
|
|
newEl.innerHTML = html;
|
|
oldEl.parentNode.replaceChild(newEl, oldEl);
|
|
/* Since we just removed the old element from the DOM, return a reference
|
|
to the new element, which can be used to restore variable references. */
|
|
return newEl;
|
|
};
|