From 310b2f6db86049d0181a43240cce6345397ab02e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Anders=20Betn=C3=A9r?=
Date: Fri, 26 May 2006 21:56:04 +0000
Subject: [PATCH] Added support for basic and advanced config options. What
goes into advanced and what goes into basic is discussable. I just made a
proposal in config.xml
---
admin-root/config.html | 1 +
admin-root/config.js | 84 +++++++++++++++++++++++++++++++++++++++---
admin-root/config.xml | 24 ++++++------
3 files changed, 92 insertions(+), 17 deletions(-)
diff --git a/admin-root/config.html b/admin-root/config.html
index 1e597eef..83d4101f 100644
--- a/admin-root/config.html
+++ b/admin-root/config.html
@@ -43,6 +43,7 @@ running server. The server must be restarted for these values to
take effect.-->
This is still in beta, but it seems to work. Go ahead and give it a spin.
Your config file is not writable, you can not change anything using this webpage
+
diff --git a/admin-root/config.js b/admin-root/config.js
index a163a364..71a55daf 100644
--- a/admin-root/config.js
+++ b/admin-root/config.js
@@ -155,9 +155,21 @@ var Config = {
buttons.appendChild(cancel);
}
}
+ var advanced = Builder.node('a',{href: 'javascript://',id:'basic_config_button'},'Show basic config');
+ Event.observe(advanced,'click',Config._showBasicConfig);
+ var basic = Builder.node('a',{href: 'javascript://',id:'advanced_config_button'},'Show advanced config');
+ Event.observe(basic,'click',Config._showAdvancedConfig);
+ if (Cookie.getVar('show_advanced_config')) {
+ basic.style.display = 'none';
+ } else {
+ advanced.style.display = 'none';
+ }
+ var div = $('toggle_basic_advanced');
+ div.appendChild(advanced);
+ div.appendChild(basic);
},
_buildItem: function(section,itemId) {
- var frag = document.createDocumentFragment();
+ var frag = document.createElement('div');
var href;
var item = ConfigXML.getOption(section,itemId);
var postId = item.config_section + ':' + itemId;
@@ -169,7 +181,7 @@ var Config = {
if (!values || values.length === 0) {
values = [''];
}
- var parentSpan = Builder.node('span');
+// var parentSpan = Builder.node('span');
values.each(function (val,i) {
var div = document.createElement('div');
div.appendChild(BuildElement.input(postId+i,postId,
@@ -188,11 +200,11 @@ var Config = {
Event.observe(href,'click',Config._removeItemEvent);
div.appendChild(href);
div.appendChild(Builder.node('br'));
- parentSpan.appendChild(div);
+ frag.appendChild(div);
});
// This is used by cancelForm to find out how
// many options a multiple group has
- frag.appendChild(parentSpan);
+// frag.appendChild(parentSpan);
href = Builder.node('a',{href:'javascript://',className:'addItemHref'},item.add_item_label);
frag.appendChild(href);
Event.observe(href,'click',Config._addItemEvent);
@@ -224,6 +236,9 @@ var Config = {
alert('This should not happen (1)');
break;
}
+ if (!Cookie.getVar('show_advanced_config') && item.advanced) {
+ frag.style.display = 'none';
+ }
return frag;
},
_addItemEvent: function (e) {
@@ -277,6 +292,42 @@ var Config = {
},
_browse: function(e) {
alert('Browse');
+ },
+ _showAdvancedConfig: function (e) {
+ Element.toggle('advanced_config_button');
+ Element.toggle('basic_config_button');
+ Cookie.setVar('show_advanced_config','true',30);
+ $H(ConfigXML.configIndex).each(function (item) {
+ if (item.value.advanced) {
+ var element = $(item.key);
+ if (!element) {
+ // Handle options with multiple values
+ $A(document.getElementsByName(item.key)).each(function (el) {
+ Effect.BlindDown(el.parentNode.parentNode);
+ });
+ } else {
+ Effect.BlindDown(element.parentNode);
+ }
+ }
+ });
+ },
+ _showBasicConfig: function (e) {
+ Element.toggle('advanced_config_button');
+ Element.toggle('basic_config_button');
+ Cookie.removeVar('show_advanced_config');
+ $H(ConfigXML.configIndex).each(function (item) {
+ if (item.value.advanced) {
+ var element = $(item.key);
+ if (!element) {
+ // Handle options with multiple values
+ $A(document.getElementsByName(item.key)).each(function (el) {
+ Effect.BlindUp(el.parentNode.parentNode);
+ });
+ } else {
+ Effect.BlindUp($(item.key).parentNode);
+ }
+ }
+ });
}
};
var BuildElement = {
@@ -384,7 +435,7 @@ var i=0;
while (initialValuesCount > currentElements.length) {
i++;
if (i > 10) {
- alert('An important part came off (silly errormessage 2');
+ alert('An important part came off (silly errormessage 2)');
return;
}
Config._addItem(currentElements[currentElements.length-1].parentNode);
@@ -448,3 +499,26 @@ function DataDumper(obj,n,prefix){
}
return str;
}
+var Cookie = {
+ getVar: function(name) {
+ var cookie = document.cookie;
+ if (cookie.length > 0) {
+ cookie += ';';
+ }
+ re = new RegExp(name + '\=(.*?);' );
+ if (cookie.match(re)) {
+ return RegExp.$1;
+ } else {
+ return '';
+ }
+ },
+ setVar: function(name,value,days) {
+ days = days || 30;
+ var expire = new Date(new Date().getTime() + days*86400);
+ document.cookie = name + '=' + value +';expires=' + expire.toUTCString();
+ },
+ removeVar: function(name) {
+ var date = new Date(12);
+ document.cookie = name + '=;expires=' + date.toUTCString();
+ }
+};
diff --git a/admin-root/config.xml b/admin-root/config.xml
index 7e063c9f..e52d6f7a 100644
--- a/admin-root/config.xml
+++ b/admin-root/config.xml
@@ -13,12 +13,12 @@
text
-
+ Web Roottext
-
+ Port
The port the server should run at; default is 3689
@@ -30,7 +30,7 @@
text
-
+ Run Astext
@@ -49,7 +49,7 @@
text
-
+ Compress
Should browsing data be compressed on the way to the client?
@@ -60,7 +60,7 @@
-
+ Debug Level
Possible values are 0 to 9, 9 being the most detailed debug level.
@@ -108,7 +108,7 @@
-
+ Compilation Directoriestext
@@ -116,7 +116,7 @@
-
+ Database Typeselect
@@ -125,7 +125,7 @@
-
+ Database Directorytext
@@ -159,12 +159,12 @@
-
+ Plugin Directorytext
-
+ Pluginstext
@@ -172,12 +172,12 @@
-
+ SSC Programtext
-
+ SSC Codec Typestext