Javascript Keyword Delimeter Changer
Paste a bunch of keywords into the box, then click a delimeter button.
Ever have a long list of tags or keywords for your story, and each social bookmarking site you submit to needs a different delimiters for your tags or keywords? Here you go.
Example list: "keyword, delimiter, tools, javascript, tool, free, socialbookmarking, tags"
function clickCommas (f) {
f.value = changeDelimiter(f.value,", ");
}
function clickSpaces (f) {
f.value = changeDelimiter(f.value," ");
}
function clickSemicolons (f) {
f.value = changeDelimiter(f.value,"; ");
}
function trimmer (InString) {
var ichar, icount;
var strValue = InString;
ichar = strValue.length - 1;
icount = -1;
while (ichar > icount && strValue.charAt(ichar)==' ')
--ichar;
if (ichar!=(strValue.length-1))
strValue = strValue.slice(0,ichar+1);
ichar = 0;
icount = strValue.length - 1;
while (ichar < icount && strValue.charAt(ichar)==' ')
++ichar;
if (ichar!=0)
strValue = strValue.slice(ichar,strValue.length);
return strValue;
}
function changeDelimiter (txt,delim) {
var split_on = " ";
var arr = new Array();
var i = 0;
var out = "";
if (txt.indexOf(",") != -1) {
split_on = ",";
} else if (txt.indexOf(";") != -1) {
split_on = ";";
}
arr = txt.split(split_on);
for (i=0; i < arr.length; i++) {
if (out != "") {
out += delim;
}
out += trimmer(arr[i]);
}
return out;
}