2006-05-17 14:42:56 -04:00
|
|
|
Event.observe(window,'load',init);
|
2006-05-18 14:48:53 -04:00
|
|
|
//###TODO
|
2006-05-21 11:01:05 -04:00
|
|
|
// * Fix cancel for multiple, create a span holding all multiple elements
|
|
|
|
// * Disable/enable save/cancel, Add key and onchange listeners keep a note on changed items
|
|
|
|
// * create the path/file browser
|
|
|
|
// * Inform user if server restart needed, ask Ron which options
|
|
|
|
// * Show required options in UI check with Ron if conf.c is correct
|
|
|
|
// * better errormessage for not writable config
|
|
|
|
// * make tabs?
|
|
|
|
// * add warning if leaving page without saving
|
2006-05-18 14:48:53 -04:00
|
|
|
|
2006-04-12 17:01:38 -04:00
|
|
|
// Config isn't defined until after the Event.observe above
|
|
|
|
// I could have put it below Config = ... but I want all window.load events
|
|
|
|
// at the start of the file
|
2006-05-18 14:48:53 -04:00
|
|
|
|
2006-04-12 17:01:38 -04:00
|
|
|
function init() {
|
|
|
|
Config.init();
|
2006-05-16 17:39:22 -04:00
|
|
|
}
|
|
|
|
var ConfigXML = {
|
2006-05-21 15:46:22 -04:00
|
|
|
config: {},
|
|
|
|
configIndex: {},
|
2006-05-18 14:48:53 -04:00
|
|
|
getOptionFromElementName: function (name) {
|
2006-05-21 15:46:22 -04:00
|
|
|
return this.configIndex[name];
|
2006-05-18 14:48:53 -04:00
|
|
|
},
|
2006-05-16 17:39:22 -04:00
|
|
|
getOption: function (section,id) {
|
|
|
|
return this.config[section][id];
|
|
|
|
},
|
|
|
|
getSections: function () {
|
|
|
|
return $H(this.config).keys();
|
|
|
|
},
|
|
|
|
getItems: function(section) {
|
|
|
|
return $H(this.config[section]).keys();
|
|
|
|
},
|
|
|
|
parseXML: function(xmlDoc) {
|
|
|
|
$A(xmlDoc.getElementsByTagName('section')).each(function (section) {
|
|
|
|
var items = {};
|
|
|
|
$A(section.getElementsByTagName('item')).each(function (item) {
|
2006-05-20 17:51:14 -04:00
|
|
|
var returnItem = {};
|
2006-05-21 16:55:56 -04:00
|
|
|
$A(item.attributes).each(function (attr) {
|
|
|
|
returnItem[attr.name] = attr.value;
|
|
|
|
});
|
2006-05-20 17:51:14 -04:00
|
|
|
$A(item.childNodes).each(function (node) {
|
|
|
|
if (Element.textContent(node) == '') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ('options' == node.nodeName) {
|
|
|
|
var options = [];
|
|
|
|
$A(item.getElementsByTagName('option')).each(function (option) {
|
|
|
|
options.push({value: option.getAttribute('value'),
|
|
|
|
label: Element.textContent(option)});
|
|
|
|
});
|
|
|
|
returnItem['options'] = options;
|
|
|
|
} else {
|
|
|
|
returnItem[node.nodeName] = Element.textContent(node);
|
|
|
|
}
|
2006-05-21 16:55:56 -04:00
|
|
|
$A(node.attributes).each(function (attr) {
|
|
|
|
returnItem[attr.name] = attr.value;
|
|
|
|
});
|
2006-05-20 17:51:14 -04:00
|
|
|
});
|
2006-05-21 15:46:22 -04:00
|
|
|
// Double index everything one as [section][id]
|
|
|
|
// and one as [config_section:id]
|
2006-05-20 17:51:14 -04:00
|
|
|
items[item.getAttribute('id')] = returnItem;
|
2006-05-21 15:46:22 -04:00
|
|
|
ConfigXML.configIndex[returnItem.config_section+ ':' +returnItem.id] = returnItem;
|
2006-05-16 17:39:22 -04:00
|
|
|
});
|
|
|
|
ConfigXML.config[section.getAttribute('name')] = items;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
2006-05-18 17:47:49 -04:00
|
|
|
var ConfigInitialValues = {
|
|
|
|
values: {},
|
|
|
|
getValues: function () {
|
|
|
|
return $H(this.values);
|
|
|
|
},
|
2006-05-20 17:51:14 -04:00
|
|
|
getValue: function (section,id) {
|
|
|
|
return this.values[section+':'+id];
|
|
|
|
},
|
2006-05-18 17:47:49 -04:00
|
|
|
parseXML: function (xmldoc) {
|
|
|
|
// IE and w3c treat xmldoc differently make shore firstChild is firstchild of <config>
|
|
|
|
if (xmldoc.childNodes[1] && xmldoc.childNodes[1].nodeName == 'config') {
|
|
|
|
sections = $A(xmldoc.childNodes[1].childNodes);
|
|
|
|
} else {
|
|
|
|
sections = $A(xmldoc.firstChild.childNodes);
|
|
|
|
}
|
|
|
|
sections.each(function (section) {
|
|
|
|
var sectionName = section.nodeName;
|
|
|
|
$A(section.childNodes).each(function (node) {
|
2006-05-20 17:51:14 -04:00
|
|
|
if (node.firstChild.hasChildNodes()) {
|
2006-05-18 17:47:49 -04:00
|
|
|
var values = [];
|
|
|
|
$A(node.childNodes).each(function (n) {
|
|
|
|
values.push(Element.textContent(n));
|
|
|
|
});
|
|
|
|
ConfigInitialValues.values[sectionName+':'+node.nodeName] = values;
|
|
|
|
} else {
|
|
|
|
ConfigInitialValues.values[sectionName+':'+node.nodeName] = Element.textContent(node);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
2006-04-12 17:01:38 -04:00
|
|
|
var Config = {
|
2006-05-10 13:37:29 -04:00
|
|
|
configPath: '',
|
|
|
|
configOptionValues: '',
|
2006-04-12 17:01:38 -04:00
|
|
|
init: function () {
|
2006-05-10 13:37:29 -04:00
|
|
|
new Ajax.Request('/config.xml',{method: 'get',onComplete: Config.storeConfigLayout});
|
|
|
|
},
|
|
|
|
storeConfigLayout: function (request) {
|
2006-05-16 17:39:22 -04:00
|
|
|
ConfigXML.parseXML(request.responseXML);
|
2006-04-12 17:01:38 -04:00
|
|
|
new Ajax.Request('/xml-rpc?method=stats',{method: 'get',onComplete: Config.updateStatus});
|
2006-05-10 13:37:29 -04:00
|
|
|
},
|
|
|
|
updateStatus: function (request) {
|
|
|
|
Config.configPath = Element.textContent(request.responseXML.getElementsByTagName('config_path')[0]);
|
2006-05-18 14:48:53 -04:00
|
|
|
Config.isWritable = Element.textContent(request.responseXML.getElementsByTagName('writable_config')[0]) == '1';
|
2006-05-10 13:37:29 -04:00
|
|
|
// $('config_path').appendChild(document.createTextNode(
|
|
|
|
|
|
|
|
// );
|
|
|
|
new Ajax.Request('/xml-rpc?method=config',{method: 'get',onComplete: Config.showConfig});
|
2006-04-12 17:01:38 -04:00
|
|
|
},
|
|
|
|
showConfig: function (request) {
|
2006-05-18 17:47:49 -04:00
|
|
|
ConfigInitialValues.parseXML(request.responseXML);
|
2006-05-10 13:37:29 -04:00
|
|
|
Config.configOptionValues = request.responseXML;
|
2006-05-16 17:39:22 -04:00
|
|
|
var sections = ConfigXML.getSections();
|
2006-05-10 13:37:29 -04:00
|
|
|
sections.each(function (section) {
|
|
|
|
var head = document.createElement('div');
|
|
|
|
head.className= 'naviheader';
|
2006-05-16 17:39:22 -04:00
|
|
|
head.appendChild(document.createTextNode(section));
|
2006-05-10 13:37:29 -04:00
|
|
|
var body = document.createElement('div');
|
|
|
|
body.className = 'navibox';
|
2006-05-16 17:39:22 -04:00
|
|
|
if ('Server' == section) {
|
2006-05-10 13:37:29 -04:00
|
|
|
body.appendChild(Builder.node('span',{id:'config_path'},'Config File'));
|
|
|
|
body.appendChild(document.createTextNode(Config.configPath));
|
|
|
|
body.appendChild(Builder.node('br'));
|
|
|
|
body.appendChild(Builder.node('div',{style: 'clear: both;'}));
|
|
|
|
}
|
2006-05-16 17:39:22 -04:00
|
|
|
ConfigXML.getItems(section).each(function (itemId) {
|
|
|
|
body.appendChild(Config._buildItem(section,itemId));
|
2006-05-10 13:37:29 -04:00
|
|
|
});
|
|
|
|
$('theform').appendChild(head);
|
|
|
|
$('theform').appendChild(body);
|
2006-05-18 14:48:53 -04:00
|
|
|
});
|
|
|
|
if (!Config.isWritable) {
|
|
|
|
Effect.Appear('config_not_writable_warning');
|
|
|
|
} else {
|
|
|
|
// Create save and cancel buttons
|
2006-05-18 17:47:49 -04:00
|
|
|
// var save = Builder.node('button',{id: 'button_save', disabled: 'disabled'},'Save');
|
|
|
|
var save = Builder.node('button',{id: 'button_save'},'Save');
|
|
|
|
Event.observe(save,'click',saveForm);
|
2006-05-18 14:48:53 -04:00
|
|
|
var cancel = Builder.node('button',{id: 'button_cancel'},'Cancel');
|
2006-05-18 17:47:49 -04:00
|
|
|
Event.observe(cancel,'click',cancelForm);
|
2006-05-18 14:48:53 -04:00
|
|
|
var spacer = document.createTextNode('\u00a0\u00a0');
|
|
|
|
var buttons = $('buttons');
|
2006-05-20 13:30:48 -04:00
|
|
|
if (navigator.platform.toLowerCase().indexOf('mac') != -1) {
|
2006-05-18 14:48:53 -04:00
|
|
|
// We're on mac
|
|
|
|
buttons.appendChild(cancel);
|
|
|
|
buttons.appendChild(spacer);
|
|
|
|
buttons.appendChild(save);
|
|
|
|
} else {
|
2006-05-20 17:51:14 -04:00
|
|
|
//###TODO What about all them unix variants?
|
2006-05-18 14:48:53 -04:00
|
|
|
buttons.appendChild(save);
|
|
|
|
buttons.appendChild(spacer);
|
|
|
|
buttons.appendChild(cancel);
|
|
|
|
}
|
|
|
|
}
|
2006-05-18 17:47:49 -04:00
|
|
|
},
|
2006-05-16 17:39:22 -04:00
|
|
|
_buildItem: function(section,itemId) {
|
2006-05-16 19:12:40 -04:00
|
|
|
var frag = document.createDocumentFragment();
|
2006-05-12 07:01:54 -04:00
|
|
|
var href;
|
|
|
|
var span;
|
2006-05-16 17:39:22 -04:00
|
|
|
var item = ConfigXML.getOption(section,itemId);
|
|
|
|
var postId = item.config_section + ':' + itemId;
|
2006-05-16 19:12:40 -04:00
|
|
|
var noBrowse = false;
|
2006-05-16 17:39:22 -04:00
|
|
|
switch(item.type) {
|
2006-05-20 17:51:14 -04:00
|
|
|
case 'text':
|
|
|
|
if (item.multiple) {
|
|
|
|
var values = ConfigInitialValues.getValue(item.config_section,item.id);
|
|
|
|
if (!values || values.length == 0) {
|
2006-05-21 11:01:05 -04:00
|
|
|
values = [''];
|
2006-05-20 17:51:14 -04:00
|
|
|
}
|
|
|
|
values.each(function (val,i) {
|
|
|
|
var span = document.createElement('span');
|
|
|
|
span.appendChild(BuildElement.input(postId+i,postId,
|
|
|
|
item.name,
|
|
|
|
val || item.default_value || '',
|
|
|
|
item.size || 20,
|
|
|
|
item.short_description,
|
|
|
|
''));
|
|
|
|
if (item.browse) {
|
|
|
|
href = Builder.node('a',{href: 'javascript://'},'Browse');
|
|
|
|
Event.observe(href,'click',Config._browse);
|
|
|
|
span.appendChild(href);
|
|
|
|
}
|
|
|
|
span.appendChild(document.createTextNode('\u00a0\u00a0'));
|
|
|
|
href = Builder.node('a',{href: 'javascript://'},'Remove');
|
2006-05-20 19:25:46 -04:00
|
|
|
Event.observe(href,'click',Config._removeItemEvent);
|
2006-05-20 17:51:14 -04:00
|
|
|
span.appendChild(href);
|
|
|
|
span.appendChild(Builder.node('br'));
|
|
|
|
frag.appendChild(span);
|
|
|
|
});
|
|
|
|
href = Builder.node('a',{href:'javascript://',className:'addItemHref'},item.add_item_label);
|
|
|
|
frag.appendChild(href);
|
2006-05-20 19:25:46 -04:00
|
|
|
Event.observe(href,'click',Config._addItemEvent);
|
2006-05-20 17:51:14 -04:00
|
|
|
frag.appendChild(Builder.node('div',{style:'clear: both'}));
|
|
|
|
} else {
|
|
|
|
frag.appendChild(BuildElement.input(postId,postId,
|
|
|
|
item.name,
|
|
|
|
ConfigInitialValues.getValue(item.config_section,item.id) || item.default_value || '',
|
|
|
|
item.size || 20,
|
|
|
|
item.short_description,
|
|
|
|
''));
|
|
|
|
if (item.browse) {
|
2006-05-16 19:12:40 -04:00
|
|
|
href = Builder.node('a',{href: 'javascript://'},'Browse');
|
|
|
|
Event.observe(href,'click',Config._browse);
|
2006-05-20 17:51:14 -04:00
|
|
|
frag.appendChild(href);
|
2006-05-16 19:12:40 -04:00
|
|
|
}
|
2006-05-20 17:51:14 -04:00
|
|
|
frag.appendChild(Builder.node('br'));
|
2006-05-12 06:02:59 -04:00
|
|
|
}
|
2006-05-20 17:51:14 -04:00
|
|
|
break;
|
|
|
|
case 'select':
|
2006-05-16 19:12:40 -04:00
|
|
|
frag.appendChild(BuildElement.select(postId,
|
2006-05-16 17:39:22 -04:00
|
|
|
item.name,
|
|
|
|
item.options,
|
2006-05-20 17:51:14 -04:00
|
|
|
ConfigInitialValues.getValue(item.config_section,item.id) || item.default_value,
|
2006-05-16 19:12:40 -04:00
|
|
|
item.short_description));
|
|
|
|
frag.appendChild(Builder.node('br'));
|
2006-05-10 13:37:29 -04:00
|
|
|
break;
|
|
|
|
}
|
2006-05-16 19:12:40 -04:00
|
|
|
return frag;
|
2006-05-12 07:01:54 -04:00
|
|
|
},
|
2006-05-20 19:25:46 -04:00
|
|
|
_addItemEvent: function (e) {
|
2006-05-12 07:01:54 -04:00
|
|
|
var span = Event.element(e);
|
|
|
|
while (span.nodeName.toLowerCase() != 'span') {
|
|
|
|
span = span.previousSibling;
|
|
|
|
}
|
2006-05-20 19:25:46 -04:00
|
|
|
Config._addItem(span);
|
|
|
|
},
|
|
|
|
_addItem: function(span) {
|
|
|
|
var newSpan = span.cloneNode(true);
|
|
|
|
var id = newSpan.getElementsByTagName('input')[0].id;
|
2006-05-20 18:37:41 -04:00
|
|
|
var num = parseInt(id.match(/\d+$/));
|
|
|
|
num++;
|
|
|
|
var id = id.replace(/\d+$/,'') + num;
|
|
|
|
|
2006-05-20 19:25:46 -04:00
|
|
|
newSpan.getElementsByTagName('label')[0].setAttribute('for',id);
|
|
|
|
newSpan.getElementsByTagName('input')[0].id = id;
|
|
|
|
newSpan.getElementsByTagName('input')[0].value = '';
|
|
|
|
var hrefs = newSpan.getElementsByTagName('a');
|
2006-05-16 19:12:40 -04:00
|
|
|
if ('Netscape' == navigator.appName) {
|
|
|
|
// Firefox et al doesn't copy registered events on an element deep clone
|
|
|
|
// Don't know if that is w3c or if IE has it right
|
2006-05-16 19:31:11 -04:00
|
|
|
if (hrefs.length == 1) {
|
2006-05-20 19:25:46 -04:00
|
|
|
Event.observe(hrefs[0],'click',Config._removeItemEvent);
|
2006-05-16 19:12:40 -04:00
|
|
|
} else {
|
|
|
|
Event.observe(hrefs[0],'click',Config._browse);
|
2006-05-20 19:25:46 -04:00
|
|
|
Event.observe(hrefs[1],'click',Config._removeItemEvent);
|
2006-05-16 19:12:40 -04:00
|
|
|
}
|
|
|
|
}
|
2006-05-20 19:25:46 -04:00
|
|
|
span.parentNode.insertBefore(newSpan,span.nextSibling);
|
2006-05-16 19:12:40 -04:00
|
|
|
},
|
2006-05-20 19:25:46 -04:00
|
|
|
_removeItemEvent: function (e) {
|
2006-05-16 19:12:40 -04:00
|
|
|
var span = Event.element(e);
|
|
|
|
while (span.nodeName.toLowerCase() != 'span') {
|
|
|
|
span = span.parentNode;
|
|
|
|
}
|
2006-05-20 19:25:46 -04:00
|
|
|
Config._removeItem(span);
|
|
|
|
},
|
|
|
|
_removeItem: function(span) {
|
2006-05-16 19:12:40 -04:00
|
|
|
if ((span.previousSibling && span.previousSibling.nodeName.toLowerCase() == 'span')||
|
|
|
|
(span.nextSibling.nodeName.toLowerCase() == 'span')) {
|
|
|
|
Element.remove(span);
|
|
|
|
} else {
|
|
|
|
span.getElementsByTagName('input')[0].value='';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
_browse: function(e) {
|
2006-05-20 17:51:14 -04:00
|
|
|
alert('Browse');
|
2006-05-10 13:37:29 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
var BuildElement = {
|
2006-05-17 10:28:39 -04:00
|
|
|
input: function(id,name,displayName,value,size,short_description,long_description) {
|
2006-05-10 13:37:29 -04:00
|
|
|
|
|
|
|
var frag = document.createDocumentFragment();
|
|
|
|
var label = document.createElement('label');
|
|
|
|
|
|
|
|
label.setAttribute('for',id);
|
|
|
|
label.appendChild(document.createTextNode(displayName));
|
|
|
|
frag.appendChild(label);
|
2006-05-20 13:30:48 -04:00
|
|
|
if (Config.isWritable) {
|
|
|
|
frag.appendChild(Builder.node('input',{id: id,name: name,className: 'text',
|
|
|
|
value: value,size: size}));
|
|
|
|
} else {
|
|
|
|
frag.appendChild(Builder.node('input',{id: id,name: name,className: 'text',
|
|
|
|
value: value,size: size, disabled: 'disabled'}));
|
|
|
|
}
|
2006-05-20 17:51:14 -04:00
|
|
|
frag.appendChild(document.createTextNode('\u00a0'));
|
|
|
|
if (short_description) {
|
|
|
|
frag.appendChild(document.createTextNode(short_description));
|
|
|
|
}
|
2006-05-12 06:02:59 -04:00
|
|
|
|
2006-05-10 13:37:29 -04:00
|
|
|
return frag;
|
|
|
|
},
|
|
|
|
select: function(id,displayName,options,value,short_description,long_description) {
|
|
|
|
var frag = document.createDocumentFragment();
|
|
|
|
var label = document.createElement('label');
|
|
|
|
label.setAttribute('for',id);
|
|
|
|
label.appendChild(document.createTextNode(displayName));
|
|
|
|
frag.appendChild(label);
|
|
|
|
|
2006-05-16 17:39:22 -04:00
|
|
|
var select = Builder.node('select',{id: id,name: id,size: 1});
|
2006-05-20 13:30:48 -04:00
|
|
|
if (!Config.isWritable) {
|
|
|
|
select.disabled = 'disabled';
|
|
|
|
}
|
2006-05-10 13:37:29 -04:00
|
|
|
$A(options).each(function (option) {
|
2006-05-16 17:39:22 -04:00
|
|
|
select.appendChild(Builder.node('option',{value: option.value},
|
|
|
|
option.label));
|
2006-05-10 13:37:29 -04:00
|
|
|
});
|
2006-05-12 06:02:59 -04:00
|
|
|
select.value = value;
|
2006-05-10 13:37:29 -04:00
|
|
|
frag.appendChild(select);
|
2006-05-21 11:01:05 -04:00
|
|
|
frag.appendChild(document.createTextNode('\u00a0'));
|
|
|
|
if (short_description) {
|
|
|
|
frag.appendChild(document.createTextNode(short_description));
|
|
|
|
}
|
2006-05-12 06:02:59 -04:00
|
|
|
|
2006-05-10 13:37:29 -04:00
|
|
|
return frag;
|
2006-04-12 17:01:38 -04:00
|
|
|
}
|
2006-05-10 13:37:29 -04:00
|
|
|
|
2006-04-12 17:01:38 -04:00
|
|
|
}
|
2006-05-17 14:42:56 -04:00
|
|
|
function saved(req) {
|
2006-05-22 16:46:29 -04:00
|
|
|
if ('200' == Element.textContent(req.responseXML.getElementsByTagName('status')[0])) {
|
|
|
|
alert('Saved');
|
|
|
|
} else {
|
|
|
|
alert("Couldn't save and if this weren't a beta I'd tell you why");
|
|
|
|
}
|
2006-05-17 14:42:56 -04:00
|
|
|
}
|
|
|
|
function saveForm() {
|
2006-05-21 15:46:22 -04:00
|
|
|
var postVars = [];
|
|
|
|
var multiple = {};
|
|
|
|
$A($('theform').getElementsByTagName('select')).each(function (select) {
|
|
|
|
postVars.push(Form.Element.serialize(select.id));
|
2006-05-17 14:42:56 -04:00
|
|
|
});
|
2006-05-21 15:46:22 -04:00
|
|
|
$A($('theform').getElementsByTagName('input')).each(function (input) {
|
|
|
|
if (ConfigXML.getOptionFromElementName(input.name).multiple) {
|
|
|
|
if (multiple[input.name]) {
|
|
|
|
multiple[input.name].push(encodeURIComponent(input.value));
|
|
|
|
} else {
|
|
|
|
multiple[input.name] = [input.value];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
postVars.push(Form.Element.serialize(input.id));
|
|
|
|
};
|
|
|
|
});
|
|
|
|
$H(multiple).each(function (item) {
|
|
|
|
postVars.push(item.key + '=' + item.value.join(','));
|
|
|
|
});
|
|
|
|
new Ajax.Request('/xml-rpc?method=updateconfig',
|
|
|
|
{method: 'post',
|
|
|
|
parameters: postVars.join('&'),
|
|
|
|
onComplete: saved
|
2006-05-17 14:42:56 -04:00
|
|
|
});
|
|
|
|
}
|
2006-05-18 17:47:49 -04:00
|
|
|
function cancelForm() {
|
2006-05-20 19:25:46 -04:00
|
|
|
ConfigXML.getSections().each(function (section){
|
|
|
|
ConfigXML.getItems(section).each(function (itemId) {
|
|
|
|
var item = ConfigXML.getOption(section,itemId);
|
|
|
|
var itemConfigId = item.config_section + ':' + item.id;
|
|
|
|
if (item.multiple) {
|
2006-05-21 11:01:05 -04:00
|
|
|
var values = ConfigInitialValues.getValue(itemConfigId);
|
|
|
|
if (!values || values.length == 0) {
|
|
|
|
values = [''];
|
|
|
|
}
|
|
|
|
//###TODO do the multiple thing
|
2006-05-20 19:25:46 -04:00
|
|
|
} else {
|
|
|
|
//###TODO potential error a select without a default value
|
|
|
|
$(itemConfigId).value = ConfigInitialValues.getValue(item.config_section,item.id) || item.default_value || '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return;
|
2006-05-18 17:47:49 -04:00
|
|
|
ConfigInitialValues.getValues().each(function (option) {
|
|
|
|
if (typeof (option.value) == 'object') {
|
|
|
|
//###TODO what if user removed one of the multiplevalued options?
|
|
|
|
if (option.value != '') {
|
|
|
|
option.value.each(function (val,i) {
|
|
|
|
$(option.key + i).value = val;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var el = $(option.key);
|
|
|
|
if (el) {
|
|
|
|
el.value = option.value;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2006-04-12 17:01:38 -04:00
|
|
|
Object.extend(Element, {
|
|
|
|
removeChildren: function(element) {
|
|
|
|
while(element.hasChildNodes()) {
|
|
|
|
element.removeChild(element.firstChild);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
textContent: function(node) {
|
|
|
|
if ((!node) || !node.hasChildNodes()) {
|
|
|
|
// Empty text node
|
|
|
|
return '';
|
|
|
|
} else {
|
|
|
|
if (node.textContent) {
|
|
|
|
// W3C ?
|
|
|
|
return node.textContent;
|
|
|
|
} else if (node.text) {
|
|
|
|
// IE
|
|
|
|
return node.text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// We shouldn't end up here;
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
/* Detta script finns att hamta pa http://www.jojoxx.net och
|
|
|
|
far anvandas fritt sa lange som dessa rader star kvar. */
|
|
|
|
function DataDumper(obj,n,prefix){
|
|
|
|
var str=""; prefix=(prefix)?prefix:""; n=(n)?n+1:1; var ind=""; for(var i=0;i<n;i++){ ind+=" "; }
|
|
|
|
if(typeof(obj)=="string"){
|
|
|
|
str+=ind+prefix+"String:\""+obj+"\"\n";
|
|
|
|
} else if(typeof(obj)=="number"){
|
|
|
|
str+=ind+prefix+"Number:"+obj+"\n";
|
|
|
|
} else if(typeof(obj)=="function"){
|
|
|
|
str+=ind+prefix+"Function:"+obj+"\n";
|
|
|
|
} else if(typeof(obj) == 'boolean') {
|
|
|
|
str+=ind+prefix+"Boolean:" + obj + "\n";
|
|
|
|
} else {
|
|
|
|
var type="Array";
|
|
|
|
for(var i in obj){ type=(type=="Array"&&i==parseInt(i))?"Array":"Object"; }
|
|
|
|
str+=ind+prefix+type+"[\n";
|
|
|
|
if(type=="Array"){
|
|
|
|
for(var i in obj){ str+=DataDumper(obj[i],n,i+"=>"); }
|
|
|
|
} else {
|
|
|
|
for(var i in obj){ str+=DataDumper(obj[i],n,i+"=>"); }
|
|
|
|
}
|
|
|
|
str+=ind+"]\n";
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|