support.js: two new functions: commonPrefix & insertFirst

This commit is contained in:
hallgren
2010-11-05 15:41:06 +00:00
parent f86ed9677a
commit e07098e31f

View File

@@ -148,6 +148,10 @@ function appendChildren(el,ds) {
return el;
}
function insertFirst(parent,child) {
parent.insertBefore(child,parent.firstChild);
}
function tda(cs) { return node("td",{},cs); }
function img(src) { return empty("img","src",src); }
@@ -216,6 +220,11 @@ function implode(cs) { // array of strings to string
function hasPrefix(s,pre) { return s.substr(0,pre.length)==pre; }
function commonPrefix(s1,s2) {
for(var i=0;i<s1.length && i<s2.length && s1[i]==s2[i];i++);
return s1.substr(0,i);
}
/*
function all(p,xs) {
for(var i=0;i<xs.length;i++)