// for the PHP-powered rainbow-maker Beta-4.1 release 1.0 1-22-2012 by SoftMoon Webware.
/* written by and Copyright © 2011, 2012 Joe Golembieski, Softmoon Webware
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
The original copyright information must remain intact.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/> */
// character encoding: UTF-8 UNIX tab-spacing: 2 word-wrap: no standard-line-length: 120
if (!Node) { var Node=new Object();
Node.ELEMENT_NODE=1;
Node.TEXT_NODE=3; }
var catchTab=SoftMoon.FormFieldGenie.catchTab
pieSlice=new SoftMoon.FormFieldGenie({
checkForEmpty:'all',
dumpEmpties:function(elmnt) {return SoftMoon.FormFieldGenie.dumpEmpties(elmnt, 3);}
});
userFile=new SoftMoon.FormFieldGenie({
isActiveField:function(elmnt) {
return SoftMoon.FormFieldGenie.isActiveField(elmnt) && ((!elmnt.name.match( /\[file\]/ )) || elmnt.previousSibling.previousSibling.checked); },
dumpEmpties:function(elmnt, deleteFlag) {if (deleteFlag) return SoftMoon.FormFieldGenie.dumpEmpties(elmnt); else var i=0;
elmnt=elmnt.getElementsByTagName('input');
while (!elmnt[++i].name.match( /\[file\]/ )) {}
return elmnt[i-1].checked && elmnt[i].value.length==0; },
maxTotal:7 // this is the maximum number of foreground or background images allowed uploaded at once
});
colorband=new SoftMoon.FormFieldGenie;
colorband.defaults.checkForEmpty='all';
colorband.defaults.dumpEmpties=function(elmnt) {return SoftMoon.FormFieldGenie.dumpEmpties(elmnt, 2, 'FIELDSET');}
colorband.defaults.cloneCustomizer=function(fieldNodeGroup) {
// this finalizes the update to a newly popped colorNode form fieldset
var i=0, swatch=fieldNodeGroup.getElementsByTagName('span');
while (swatch[i].className!=='colorSwatch') {i++;}
swatch[i].style.backgroundColor='black';
swatch[i].style.border='none';
var curve=fieldNodeGroup.getElementsByTagName('select');
for (i=0; i<curve.length; i++) { if (curve[i].name.match( /curve/ )) {
curve[i].selectedIndex=0;
setCurve(curve[i]);
break; } }
var transp=fieldNodeGroup.getElementsByTagName('input');
for (i=0; i<transp.length; i++) { if (transp[i].name.match( /^transp\[flag\]/ )) {
transp[i].checked=false;
setTransp(transp[i]);
break; } } }
colorband.defaults.groupCustomizer=function(fieldNodeGroupFieldset) {
// and now we align the other (previous) colorNode form fieldsets
var count=0, allNodes=fieldNodeGroupFieldset.childNodes, idText, i, j, transp, elmnt, kid, c=0;
for (i=0; i<allNodes.length-1; i++) {
if (allNodes[i].nodeType!=Node.ELEMENT_NODE || allNodes[i].className!=='colorNode') continue;
kid=allNodes[i].firstChild; c++;
do { if (kid.className==='hiddenWhenFirst')
// pick up the slack of ALL browsers: they don't fully update the DOM when elements are added or removed.
kid.style.display=((c>1) ? "block" : "none"); }
while (kid=kid.nextSibling);
transp=allNodes[i].getElementsByTagName('input');
for (j=0; j<transp.length; j++) {if (transp[j].name.match( /^transp\[flag\]/ )) {transp=transp[j]; break;}}
if ((count++)<1) { setLabelText(allNodes[i], "start");
elmnt=allNodes[i].getElementsByTagName('fieldset');
for (j=0; j<elmnt.length; j++) {if (elmnt[j].parentNode.className==='colorNode') elmnt[j].style.display='none';}
elmnt=allNodes[i].getElementsByTagName('label');
for (j=0; j<elmnt.length; j++) {if (elmnt[j].firstChild.data==='over ') elmnt[j].style.display='none';}
transp.checked=false; }
else setLabelText(allNodes[i], "next");
setTransp(transp); }
function setLabelText(colorNode, idText) { var kids=colorNode.childNodes;
for (var i=0; i<kids.length; i++) { if (kids[i].hasChildNodes()) {setLabelText(kids[i], idText); continue;}
if (kids[i].nodeType==Node.TEXT_NODE) kids[i].data=kids[i].data.replace( /^(start|next|end)/i, idText ); } } }
function atLoad() {
setStyle(setStyle.getStyle());
setDimensions(document.getElementById('dimensions').getElementsByTagName('select')[0]);
var slct=document.getElementsByTagName('select');
for (i=0; i<slct.length; i++) {
if (slct[i].name.match( /(back|fore)ground.*\[position\]/ )) {setPosition(slct[i]); continue;}
if (slct[i].name.match( /curve.*\[type\]/ )) setCurve(slct[i]); }
var inp=document.getElementsByTagName('input');
for (i=0; i<inp.length; i++) { //alert('name '+inp[i].name+"\ntype "+inp[i].type+"\nsize "+inp[i].size);
if (inp[i].name.match( /transp.*\[flag\]/ )) setTransp(inp[i]);
if (inp[i].name.match( /color/ )) ColorPicker.colorSwatch(inp[i]);
if (false && (inp[i].type=='text' || inp[i].type=='file')
&& inp[i].size && inp[i].getAttribute('size').match( /^[0-9]+$/ ) && inp[i].size>0) {
inp[i].style.width=(inp[i].size*((inp[i].type=='file') ? 1.75 : 1.25))+"ex"; } }
var btn=document.getElementsByTagName('button');
if (btn[btn.length-1].value==='add to Gallery') btn[btn.length-1].focus();
// note we subtract 10 for reasons I can't explain:
if (window.innerWidth) {
getViewWidth=function() {return window.innerWidth-getScrollBarWidth()-10;} }
else if (document.documentElement && document.documentElement.clientWidth) { alert('clientWidth');
getViewWidth=function() {return document.documentElement.clientWidth-getScrollBarWidth()-10;} }
var heading=document.getElementsByTagName('h1')[0].firstChild;
var delay= (navigator && navigator.userAgent.match( /MSIE/i )) ? 1 : 20;
heading.animation1=new Animator(heading.childNodes[1], heading.childNodes[1].className, 30, delay, {width: function(i) {return ((i*.5)+'em');}});
heading.animation2=new Animator(heading.childNodes[2], heading.childNodes[2].className, 31, delay, {left: function(i) {return (getViewWidth()-200*(i/30))+'px';}});
heading.onmouseover=function() {heading.animation1.animate(); heading.animation2.animate();};
heading.onmouseout=function() {heading.animation1.undo(); heading.animation2.undo();};
// if (navigator && navigator.userAgent.match( /MSIE/i )) slct[0].options[slct[0].options.length-2]=null;
// else
SoftMoon.buildSpectralPalette();
}
function setStyle(gStyle) { var superstyle= /nova|nebula|quasar|hub|wheel|spokes|fan/
if (gStyle.match( superstyle )) gStyle=setStyle.getStyle(gStyle);
if (gStyle==='superstar') {var ss=document.forms[0]['superstar']; gStyle=ss.options[ss.selectedIndex].value;}
var iiq, n, dsabld, substyle=gStyle.match( /^[^0-9]+/ )[0],
inps=document.getElementsByTagName('input'),
noSpiral=(gStyle==='line' || gStyle==='basic' || gStyle==='split');
for (var i=0; i<inps.length; i++) { iiq=inps[i]; //the “input� in question
if (iiq.name.match( /^style/ ) && iiq.value==='line') { dsabld=iiq.checked;
iiq.disabled=setStyle.nova; iiq.parentNode.className=(setStyle.nova) ? 'disabled' : " ";
continue; } //note how if “line� and “nova� are both checked, they cancle each other out! (only with JS turned off then on by user or by server error)
if (iiq.name.match( /^mask/ )) {
iiq.disabled=(gStyle!=='mask'); //!inps[i-2].checked;
iiq.parentNode.className=(gStyle==='mask') ? " " : 'disabled'; }
if (iiq.name.match( /^superstyle/ )) {
iiq.disabled=dsabld; iiq.parentNode.parentNode.className=(dsabld) ? 'disabled' : " ";
continue; }
if (n=iiq.name.match( /^rotate\[(graph|sectors_1|pinwheel|twist|shimmer)/ )) {
if (gStyle==='circle') {dsabld=true;}
else { dsabld=!(gStyle.match( /star.+/ ) instanceof Array);
switch (n[1]) {
case 'graph': {dsabld=false;}
case 'sectors_1': {if (gStyle==='star' || gStyle=='polygon') dsabld=false;} } }
iiq.disabled=dsabld; iiq.parentNode.className=(dsabld) ? 'disabled' : "";
continue; }
if (iiq.name.match( /^rotate\[sectors_2/ )) {
if (setStyle.nova) iiq.previousSibling.previousSibling.data=setStyle.nova.match( superstyle );
iiq.disabled= !setStyle.nova;
iiq.parentNode.className=(setStyle.nova) ? " " : 'disabled';
continue; }
if (iiq.name.match( /^rotate\[sectors_3/ )) {
dsabld=!(setStyle.nova==='quasar' || setStyle.nova==='fan')
iiq.disabled=dsabld ;
iiq.parentNode.parentNode.className=dsabld ? 'disabled' : " ";
if (!dsabld) iiq.parentNode.parentNode.firstChild.firstChild.data=setStyle.nova+' overlap'; }
if (iiq.name.match( /^extend/ ) || iiq.name==='color[reverse]') {
dsabld=(gStyle==='line');
iiq.disabled=dsabld;
iiq.parentNode.parentNode.className=(dsabld) ? 'disabled' : " ";
continue; }
if (iiq.name.match( /^spiral\[doso\]/ )) {
if (iiq.checked) setSpiral(iiq, noSpiral);
iiq.disabled=noSpiral;
iiq.parentNode.className=noSpiral ? 'disabled' : " ";
iiq.parentNode.parentNode.className=(gStyle==='line') ? 'disabled' : " ";
continue; }
if (n=iiq.name.match( /^hw\[sizeTo/ )) {
dsabld=true; switch (substyle) {
case 'starlet':
case 'star☼':
case 'star':
case 'polygon':
case 'polygonic': dsabld=false; }
iiq.disabled=dsabld; iiq.parentNode.className=(dsabld) ? 'disabled' : "";
continue; }
if (n=iiq.name.match( /^hw\[.+_2/ )) {
switch (setStyle.nova) {
case 'hub':
case 'wheel':
case 'spokes':
case 'fan': if (iiq.name.match( /size/ )) {iiq.disabled=true; break;}
default: iiq.disabled= !setStyle.nova; }
iiq.parentNode.className=(iiq.disabled) ? 'disabled' : " ";
iiq.parentNode.parentNode.className=(setStyle.nova) ? " " : 'disabled';
iiq.parentNode.parentNode.parentNode.className=(setStyle.nova || (gStyle!=='circle' && gStyle!=='line' && gStyle!=='mask')) ? " " : 'disabled';
if (setStyle.nova) iiq.parentNode.parentNode.firstChild.firstChild.data='of '+setStyle.nova.match( superstyle );
continue; }
if (n=iiq.name.match( /^hw\[([^\]]+)/ )) { if (n[1]=='overSpan') continue;
if (n[1]=='width') dsabld=(gStyle!=='line' && gStyle!=='basic' && gStyle!=='split');
else if (gStyle==='circle' || gStyle==='line' || gStyle==='mask' || (n[1]=='span' && gStyle!=='fountain')) dsabld=true;
else {
dsabld=false;
switch (substyle+' '+n[1]) {
case 'circle swell':
case 'ellipse swell':
case 'flower swell':
case 'starlet swell':
case 'star swell':
case 'polygon swell':
case 'polygonic swell':
case 'basic swell':
case 'split swell':
case 'mask swell': {dsabld=true; break;}
case 'circle sectors_1':
case 'ellipse sectors_1':
case 'polygonic sectors_1':
case 'fountain sectors_1':
case 'basic sectors_1':
case 'split sectors_1':
case 'mask sectors_1': {dsabld=true;}
case 'complex sectors_1':
case 'flower sectors_1': {n='petals'; break;}
case 'polygon sectors_1': {n='sides'; break;}
case 'star sectors_1':
case 'star☼ sectors_1':
case 'starlet sectors_1': {n='points'; break;}
case 'circle depth':
case 'line depth':
case 'ellipse depth':
case 'polygon depth':
case 'polygonic depth':
case 'fountain depth':
case 'basic depth':
case 'split depth':
case 'mask depth': {dsabld=true;} } }
if (typeof n == 'string') iiq.previousSibling.data=n; // here we change the text presented to the user
iiq.disabled=dsabld; iiq.parentNode.className=(dsabld) ? 'disabled' : "";
continue; }
if (iiq.name.match( /pie/ )) { dsabld=false; switch(gStyle) {
case 'line':
case 'fountain':
case 'basic':
case 'split': dsabld=true; }
iiq.disabled=dsabld;
if (iiq.name.match( /^rotate/ ))
iiq.parentNode.className=(dsabld) ? 'disabled' : "";
else
iiq.parentNode.parentNode.className=(dsabld) ? 'disabled' : "";
continue; } } }
setStyle.getStyle=function(flag) {
var gStyle=document.getElementById('superstyle').getElementsByTagName('input'), i=(-1);
setStyle.nova=false;
while (i++ < 7) {
if (setStyle.nova || (flag && gStyle[i].value!==flag)) gStyle[i].checked=false;
else if (!flag || gStyle[i].value===flag) setStyle.nova= gStyle[i].checked ?
gStyle[i].value : false; }
gStyle=document.getElementById('styler').getElementsByTagName('ul')[0].getElementsByTagName('input'), i=0;
for (var i=0; i<gStyle.length; i++) {if (gStyle[i].checked && !gStyle[i].disabled) return gStyle[i].value;} }
function setSpiral(elmnt, flag) { var i, inps, spiral=( flag ? false : (elmnt.value==='spiral') );
elmnt=elmnt.parentNode.parentNode.getElementsByTagName('input');
for (i=0; i<elmnt.length; i++) { if (elmnt[i].name.match( /^spiral/ ) && elmnt[i].name!=='spiral[doso]') {
elmnt[i].disabled=(!spiral);
elmnt[i].parentNode.className=(spiral) ? " " : "disabled"; } }
elmnt=document.getElementById('rotate');
inps=elmnt.getElementsByTagName('input');
inps[3].disabled=(!spiral);
inps[3].parentNode.className=(spiral) ? " " : "disabled";
for (i=0; i<inps.length; i++) {if (!inps[i].disabled) {elmnt.className=" "; return;}}
elmnt.className='disabled'; }
function setPieType(elmnt, flagFinal) { var temp;
if (elmnt.type=='checkbox') var flagFinal=true;
elmnt=elmnt.parentNode.parentNode.getElementsByTagName('input');
for (var i=1; i<=2; i++) { if (elmnt[i].value==="") temp=""; else temp= elmnt[0].checked ?
(flagFinal ? charFilter(elmnt[i], finalPosInteger) : charFilter(elmnt[i], posInteger))
: (flagFinal ? charFilter(elmnt[i], flagFinal)+"°" : charFilter(elmnt[i], {filters:charFilter.degrees}));
if (elmnt[i].value!==temp) elmnt[i].value=temp; } }
function setPosition(elmnt, flag) { var position=elmnt.options[elmnt.selectedIndex].text, dsabld, inp;
dsabld=(elmnt.disabled || position==="center");
do {elmnt=elmnt.nextSibling;} while (elmnt.nodeType!=1 || elmnt.nodeName!=='LABEL');
elmnt.className=(dsabld) ? "disabled" : "";
inp=elmnt.getElementsByTagName('input')[0];
inp.disabled=dsabld;
dsabld=(elmnt.disabled || position!=="tiled");
do {elmnt=elmnt.nextSibling;} while (elmnt.nodeType!=1 || elmnt.nodeName!=='LABEL');
elmnt.className=(dsabld) ? "disabled" : "";
inp=elmnt.getElementsByTagName('input')[0];
inp.disabled=dsabld;
if (flag && !dsabld) elmnt.focus(); }
function setDimensions(elmnt) {
var dsabld, dimType=elmnt.options[elmnt.selectedIndex].text, i;
elmnt=elmnt.parentNode.getElementsByTagName('label')[1];
elmnt.getElementsByTagName('input')[0].disabled=(dimType==='auto to rainbow');
elmnt.className=(dimType==='auto to rainbow') ? 'disabled' : " ";
elmnt=elmnt.parentNode.parentNode.getElementsByTagName('div')[1].firstChild;
do { if (elmnt.nodeType==1) {
switch (elmnt.tagName) {
case 'FIELDSET': {dsabld=(dimType==='auto to rainbow'); break;}
case 'LABEL': {dsabld=(dimType!=='absolute'); break;} }
elmnt.className=(dsabld) ? "disabled" : " ";
var inps=elmnt.getElementsByTagName('input');
for (i=0; i<inps.length; i++) { inps[i].disabled=dsabld;
if (inps.length>1) {
inps[i].className=(dsabld) ? "disabled" : " ";
inps[i].parentNode.className=(dsabld) ? "disabled" : " "; }
if (inps[i].type=='checkbox' && !dsabld) {
if (dimType==='fit to select images' || dimType==='absolute') {
inps[i].disabled=false; inps[i].parentNode.className=' ';
autocenter(inps[i]); }
else {inps[i].disabled=true; inps[i].parentNode.className="disabled";} }
if (i==7 && (dimType==='fit to select images' || dimType==='absolute')) dsabld=true; } } }
while (elmnt=elmnt.nextSibling);
var inp=document.getElementsByTagName('input');
for (i=0; i<inp.length; i++) {
if (inp[i].name.match( /\[fitto\]/ )) {
inp[i].disabled=(dimType!=='fit to select images');
inp[i].parentNode.className=(dimType==='fit to select images') ? "" : "disabled"; } } }
function autocenter(elmnt) { var dsabld=elmnt.checked, inps, i;
elmnt=elmnt.parentNode.parentNode.firstChild; inps=elmnt.getElementsByTagName('input');
for (i=0; i<inps.length; i++) {if (inps[i].type!=='radio') disabler(inps[i], dsabld)}
disabler(elmnt.nextSibling, dsabld); }
function catchTabPopDown(evnt, elmnt) {
evnt=(evnt || window.event);
var code=(evnt.charCode || evnt.keyCode);
if (code==9) ColorPicker.showTable(false, elmnt);
return catchTab(evnt); }
function setCurve(elmnt) { //alert(elmnt.selectedIndex);
var dsabld=elmnt.disabled || (elmnt.options[elmnt.selectedIndex].text==='none');
elmnt=elmnt.parentNode;
do {elmnt=elmnt.nextSibling;} while (elmnt.nodeType!=Node.ELEMENT_NODE || elmnt.nodeName!=='LABEL');
elmnt.className=(dsabld) ? "disabled" : "";
elmnt.getElementsByTagName('input')[0].disabled=dsabld; }
function setTransp(elmnt, clicked) {
var dsabld=(clicked) ? false : (!elmnt.checked), thisName=elmnt.name, focal;
if (thisName.match( /^background\[transp\]/ )) {
do {elmnt=elmnt.nextSibling;} while (elmnt.nodeType!=1 || elmnt.nodeName!=='SPAN');
elmnt.className=(dsabld) ? "disabled" : "";
elmnt=elmnt.getElementsByTagName('input')[0];
elmnt.disabled=dsabld;
if (!dsabld) {focal=elmnt; setTimeout(function () {focal.focus();}, 1);}
return; }
else
var clrNode=getColorNode(elmnt), i, blend, flag, inps;
if (clicked) blend=clicked;
else {
inps=clrNode.getElementsByTagName('input');
for (i=0; i<inps.length; i++) {
if (inps[i].name.match( /^transp.*\[alphablend\]/ )) {
inps[i].disabled=dsabld;
inps[i].parentNode.className=(dsabld) ? "disabled" : "";
if (!dsabld && inps[i].checked) blend=inps[i].value; } } }
function blendMode(n, blend) { switch (blend) {
case "into background": {return !(n.match( /blend/ ));}
case "replace background": {return !(n.match( /pixel/ ));}
case "blend & apply": {return false;}
default: return true; } }
var slct=clrNode.getElementsByTagName('select');
for (i=0; i<slct.length; i++) {
if (slct[i].name.match( /^transp.*\[curve\]/ )) {
slct[i].disabled=dsabld || (flag=blendMode(slct[i].name, blend));
slct[i].parentNode.className=(dsabld || flag) ? "disabled" : "";
slct[i].parentNode.parentNode.getElementsByTagName('legend')[0].className=(dsabld || flag) ? "disabled" : "";
setCurve(slct[i]); } }
setTPercent(clrNode, nxt(clrNode), dsabld, "setting this one");
var prev=prev(clrNode);
if (prev) setTPercent(prev, prev, dsabld, "setting previous one");
function setTPercent(elmnt, neighbor, dsabld, which) { var flag, blend2; //msg="";
if (neighbor) {
neighbor=neighbor.getElementsByTagName('input');
for (i=0; i<neighbor.length; i++) { // msg="\nthis requested disabled? "+dsabld+"\nneighbor "+neighbor[i].name+"\nchecked = "+neighbor[i].checked;
if (neighbor[i].name.match( /^transp.*\[flag\]/ ))
dsabld=(flag=neighbor[i].checked) ? false : dsabld;
if (neighbor[i].name.match( /^transp.*\[alphablend\]/ ) && neighbor[i].checked && !dsabld && flag) // this logic depends on transp[flag] coming before transp[alphablend] in the document.
blend2=neighbor[i].value; } }
alphaApp=elmnt.getElementsByTagName('input');
for (i=0; i<alphaApp.length; i++) { if (alphaApp[i].name.match( /^transp.*\[percent\]/ )) { // alert(which+msg+"\nthis disabled? "+dsabld+"\nthis "+alphaApp[i].name);
alphaApp[i].disabled=dsabld || (flag=(blendMode(alphaApp[i].name, blend) && blendMode(alphaApp[i].name, blend2)));
alphaApp[i].parentNode.className=(dsabld || flag) ? "disabled" : ""; } } }
function nxt(elmnt) {
do {elmnt=elmnt.nextSibling}
while (elmnt!==null && (elmnt.nodeType!=Node.ELEMENT_NODE || elmnt.className!=='colorNode'));
return elmnt; }
function prev(elmnt) {
do {elmnt=elmnt.previousSibling}
while (elmnt!==null && (elmnt.nodeType!=Node.ELEMENT_NODE || elmnt.className!=='colorNode'));
return elmnt; }
} // close setTransp
function getColorNode(elmnt) {
do {elmnt=elmnt.parentNode} while (elmnt.nodeType!=Node.ELEMENT_NODE || elmnt.className!=='colorNode');
return elmnt; }
function infinity(btn) { var inp=btn.parentNode.parentNode.getElementsByTagName('input')[0];
inp.value="\u221E";
inp.focus(); }
function showGalleryForm() {
var x=document.getElementById("fileinfo");
x.style.display=((x.style.display=="block") ? "none" : "block");
if (x.style.display=="block") setTimeout(function(){x.getElementsByTagName('input')[0].focus();}, 1); }
//========================= Character Filter ==========================\\
function charFilter(inp, opts) { var v=inp.value; // alert(opts.dflt+"\n"+v);
if (typeof opts == 'object' && typeof opts.filters == 'object' && opts.filters instanceof Array)
filters=opts.filters;
else filters=charFilter.numbers;
for (var i=0; i<filters.length; i++) { switch (typeof filters[i]) {
case 'object': {
if (filters[i] instanceof Array
&& filters[i][0] instanceof RegExp
&& (typeof filters[i][1]=='string' || typeof filters[i][1]=='function'))
v=v.replace(filters[i][0], filters[i][1]); break;}
case 'function': {v=filters[i](v, opts); break;} } }
if (inp.value!==v) inp.value=v;
return v; }
charFilter.numbers=[ // (unlimited)
[ /[^-.0-9]/g , ""],
[ /[-]/g , function(dash, pos) {return (pos==0) ? dash : ""} ],
function(s, opts) {
if ((typeof opts == 'object') ? opts.flagFinal : opts) {
s=s.replace( /^([-]?)0+([^0].*)?/ , "$1$2");
s=s.replace( /^(.*[.].*)0+$/ , "$1");
s=s.replace( /^(.*)[.]$/ , "$1"); }
return s; },
function(s, opts, c) { var flagFinal=((typeof opts == 'object') ? opts.flagFinal : opts)
if (typeof s !== 'string' || s.length==0) return (flagFinal) ? '0' : "";
if (typeof c !== 'number') c=0;
fixDecimal: { // alert(s);
c=s.indexOf('.', c);
if (c<0) {break fixDecimal;}
if (c==0 && flagFinal) {s='0'+s; c=1;}
if (c==1 && s.substr(0,1)=='-' && flagFinal) {s='-0'+s.substr(1); c=2;}
s=s.substr(0, c+1) + s.substr(c+1).replace( /[^0-9\u00B0]/ , "");
//s=s.replace( /^(.*)[.]$/ , "$1");
}
if (flagFinal && s.match( /^-?0*\.?0*$/ )) return '0';
return s; }
];
charFilter.positiveNumbers=[ // (limited)
[ /[^.0-9]/g , ""],
function(s, opts) {if (opts.flagFinal) s=s.replace( /^0+([^0].*)/ , "$1"); return s;},
function(s, opts, c) {
if (s===opts.pass) return s;
if (typeof s !== 'string' || s.length==0) return (opts.flagFinal) ? charFilter.dflt(opts) : "";
if (typeof c !== 'number') c=0;
fixDecimal: {
c=s.indexOf('.', c);
if (c<0) {break fixDecimal;} // no decimal present
if (c==0 && opts.flagFinal) {s='0'+s; c=1;}
s=s.substr(0, c+1) + s.substr(c+1).replace( /[^0-9]/ , ""); }
if (opts.flagFinal && s.match( /^0*\.0*$/ )) return charFilter.dflt(opts);
if (opts.flagFinal && ((parseFloat(s) < opts.min))) return charFilter.min(opts); //
if (opts.flagFinal && (parseFloat(s) > opts.max)) return opts.max.toString();
return s; }
];
charFilter.integers=[
[ /[^-0-9]/g , ""],
charFilter.numbers[1],
charFilter.numbers[2],
function(s, opts, c) {
if (typeof s !== 'string' || s.length==0) return (opts.flagFinal) ? charFilter.dflt(opts) : "";
if (opts.flagFinal && ((parseFloat(s) < opts.min) || s.match( /^0*\.?0*$/ ))) return charFilter.min(opts);
if (opts.flagFinal && (parseFloat(s) > opts.max)) return opts.max.toString();
return s; }
];
charFilter.positiveIntegers=[
[ /[^0-9]/g , ""],
charFilter.positiveNumbers[1],
charFilter.integers[3]
];
charFilter.limitedNumbers=[
charFilter.numbers[0],
charFilter.numbers[1],
charFilter.numbers[2],
charFilter.positiveNumbers[2] ];
charFilter.degrees=[ // (unlimited)
[ /[^-.0-9\u00B0]/g , ""],
charFilter.numbers[1],
[ /[\u00B0]/g , function(dgrz, pos, s) {return (pos==s.length-1) ? dgrz : ""} ],
function(s, opts) {
if ((typeof opts == 'object') ? opts.flagFinal : opts) {
s=s.replace( /^([-]?)0+([^0\u00B0].*)/ , "$1$2") }
return s },
charFilter.numbers[3]
];
charFilter.infinatePositives=[
[ /[^.0-9\u221E]/g , ""],
[ /.*\u221E.*/ , "\u221E"],
charFilter.numbers[2],
charFilter.positiveNumbers[2]
];
charFilter.infinateInteger=[
[ /[^\-0-9\u221E]/g , ""],
[ /.*\u221E.*/ , "\u221E"],
charFilter.numbers[2],
charFilter.integers[3]
];
charFilter.dimensions=[
[ /[^,0-9]/g , ""],
function(s, opts) {if (opts.flagFinal) s=s.replace( /^0+([^0].*)/ , "$1"); return s;},
function(s, opts) {if (opts.flagFinal) s=s.replace( /,0+([^0].*)/ , ",$1"); return s;},
function(s, opts) { //alert('here');
if (typeof s !== 'string' || s.length==0)
return (opts.flagFinal) ? charFilter.dlft(opts)+','+charFilter.dlft(opts) : "";
var xy=s.split(',',3);
if (xy.length<2 && !opts.flagFinal)
return charFilter.positiveNumbers[3](xy[0]);
else
return charFilter.positiveNumbers[2](xy[0], opts) +','+ charFilter.positiveNumbers[2](xy[1], opts); }
];
charFilter.coordinate=[
[ /[^-,0-9]/g , ""],
[ /[-]/g , function(dash, pos, s) {return (pos==0 || s.charAt(pos-1)==',') ? dash : ""} ],
function(s, opts) {if (opts.flagFinal) s=s.replace( /^([-]?)0+([1-9])/ , "$1$2"); return s;},
function(s, opts) {if (opts.flagFinal) s=s.replace( /(,[-]?)0+([1-9])/ , "$1$2"); return s;},
function(s, opts) {
if (typeof s !== 'string' || s.length==0)
return (opts.flagFinal) ? charFilter.dlft(opts)+','+charFilter.dflt(opts) : "";
var xy=s.split(',',3);
if (xy.length<2 && !opts.flagFinal)
return charFilter.numbers[3](xy[0]);
else
return charFilter.numbers[3](xy[0], opts.flagFinal) +','+ charFilter.numbers[3](xy[1], opts.flagFinal); }
];
charFilter.fileName=[
[ /[\/\\:*?<>|\x00-\x2F]/g , ""]
];
charFilter.min=function(opts) { return (!opts.hasOwnProperty('min') || opts.min==(-Infinity)) ?
'0' : opts.min.toString(); }
charFilter.dflt=function(opts) { return (typeof opts.dflt === 'number' || typeof opts.dflt === 'string') ?
opts.dflt : charFilter.min(opts); }
// these are pre-defined flags and filtering objects to be passed into charFilter as the 'opts' variable
var flagFinal=true, positives=charFilter.positiveNumbers,
percent={filters:positives},
finalPercent={min:1, max:100, dflt:100, filters:positives, flagFinal:true},
finalPercent0={min:0, max:100, filters:positives, flagFinal:true},
signedPercent={filters:charFilter.limitedNumbers},
finalSignedPercent={min:-100, max:100, dflt:100, filters:charFilter.limitedNumbers, flagFinal:true},
finalUnlimitedPercent={min:1, max:Infinity, dflt:100, filters:positives, flagFinal:true},
infinatePercent={filters:charFilter.infinatePositives},
finalInfinatePercent={min:1, max:Infinity, dflt:100, pass:"\u221E", filters:charFilter.infinatePositives, flagFinal:true},
infinateInteger={filters:charFilter.infinateInteger},
finalInfinateInteger={min:(-Infinity), max:Infinity, dflt:1, pass:"\u221E", filters:charFilter.infinateInteger, flagFinal:true},
dimensions_2D={filters:charFilter.dimensions},
finalDimensions_2D={min:1, max:10000, filters:charFilter.dimensions, flagFinal:true},
coordinate={filters:charFilter.coordinate},
finalCoordinate={min:(-Infinity), max:Infinity, filters:charFilter.coordinate, flagFinal:true},
indexValue={filters:positives},
finalIndexValue={min:0.001, max:Infinity, dflt:1, filters:positives, flagFinal:true},
posInteger={filters:charFilter.positiveIntegers},
finalPosInteger={min:1, max:Infinity, filters:charFilter.positiveIntegers, flagFinal:true},
finalSpan={min:0, max:Infinity, dflt:"", filters:charFilter.positiveIntegers, flagFinal:true},
finalWidth={min:1, max:Infinity, dflt:"", filters:charFilter.positiveIntegers, flagFinal:true};
function disabler(elmnt, dsabld) {
elmnt.disabled=dsabld;
elmnt.className=(dsabld) ? "disabled" : "";
// elmnt.style.color=(dsabld) ? disabledColor : enabledColor;
// elmnt.style.backgroundColor=(dsabld) ? disabledBackColor : enabledBackColor;
// another alternative is to auto-store the individual element's enabled colors (or even pre-store disabled colors)
// in a new property of the element for later retrieval. This would allow different elements to be styled differently.
}
////////// UNUSED CODE \\\\\\\\\\\
var enabledColor= "lime"; //this is the foreground color assigned to enabled fields = should match stylesheet
var enabledBackColor= "black"; //this is the background color assigned to enabled fields = should match stylesheet
var disabledColor="darkgreen"; //this is the foreground color assigned to disabled fields
var disabledBackColor="202020"; //this is the background color assigned to disabled fields
function showTutor(elmnt, tutorName) {return;}
function getScrollBarWidth () { // http://www.alexandre-gomes.com/?p=115
var inner = document.createElement('p');
inner.style.width = "100%";
inner.style.height = "200px";
var outer = document.createElement('div');
outer.style.position = "absolute";
outer.style.top = "0px";
outer.style.left = "0px";
outer.style.visibility = "hidden";
outer.style.width = "200px";
outer.style.height = "150px";
outer.style.overflow = "hidden";
outer.appendChild (inner);
document.body.appendChild (outer);
var w1 = inner.offsetWidth;
outer.style.overflow = 'scroll';
var w2 = inner.offsetWidth;
if (w1 == w2) w2 = outer.clientWidth;
document.body.removeChild (outer);
return (w1 - w2);
};
function scrollbarWidth() { // http://javascript.jstruebig.de/javascript/70
var temp=document.body.style.overflow;
// Scrollbalken im Body ausschalten
document.body.style.overflow = 'hidden';
var width = document.body.clientWidth;
// Scrollbalken
document.body.style.overflow = 'scroll';
width -= document.body.clientWidth;
// Der IE im Standardmode
if(!width) width = document.body.offsetWidth-document.body.clientWidth;
// ursprüngliche Einstellungen wiederherstellen
document.body.style.overflow = temp;
return width; }˜\u221E |