(function () {
- var identityDecoder = function (src) {
- return src;
- };
+ var identityDecoder = function (src) {
+ return src;
+ };
- var mapDecoder = function (src) {
- var map = {};
- var lines = src.split(/\n/);
+ var identityEncoder = function (src) {
+ return src;
+ };
- $.each(lines, function () {
- var m = this.match(/^(\S+)\s+(\S+)$/);
+ var mapDecoder = function (src) {
+ var map = {};
+ var lines = src.split(/\n/);
- map[ m[1] ] = m[2];
- });
+ $.each(lines, function () {
+ var m = this.match(/^(\S+)\s+(\S+)$/);
- return map;
- };
+ map[ m[1] ] = m[2];
+ });
- var boolDecoder = function (src) {
- return src == "*";
- };
+ return map;
+ };
- var decoder_of = {
- siteName : identityDecoder,
- baseURI : identityDecoder,
- defaultPage: identityDecoder,
- styleSheet : identityDecoder,
- languages : mapDecoder,
- globalLock : boolDecoder
- };
+ var mapEncoder = function (map) {
+ var lines = [];
+
+ $.each(map, function (key) {
+ lines.push(key + " " + this);
+ });
+
+ return lines.join("\n");
+ };
+
+ var boolDecoder = function (src) {
+ return src == "*";
+ };
+
+ var boolEncoder = function (bool) {
+ return bool ? "*" : "";
+ };
+
+ var decoder_of = {
+ siteName : identityDecoder,
+ baseURI : identityDecoder,
+ defaultPage: identityDecoder,
+ styleSheet : identityDecoder,
+ languages : mapDecoder,
+ globalLock : boolDecoder
+ };
+
+ var encoder_of = {
+ siteName : identityEncoder,
+ baseURI : identityEncoder,
+ defaultPage: identityEncoder,
+ styleSheet : identityEncoder,
+ languages : mapEncoder,
+ globalLock : boolEncoder
+ };
- var cachedConf = null;
+ var cachedConf = null;
Rakka.getSystemConfig = function () {
if (cachedConf != null) {
return conf;
};
+ Rakka.showConfigPanel = function () {
+ var conf = Rakka.getSystemConfig();
+ var $area = Rakka.switchScreen();
+
+ $area.append($.H1({}, "Configuration"));
+
+ var fldSiteName
+ = $.INPUT({type: "text", value: conf.siteName});
+
+ var fldBaseURI
+ = $.INPUT({type: "text", value: conf.baseURI});
+
+ var fldDefaultPage
+ = $.INPUT({type: "text", value: conf.defaultPage});
+
+ var fldStyleSheet
+ = $.INPUT({type: "text", value: conf.styleSheet});
+
+ var fldLanguages
+ = $.TEXTAREA({value: encoder_of.languages(conf.languages)});
+
+ var chkGlobalLock
+ = $.INPUT({type: "checkbox", checked: conf.globalLock});
+
+ var btnSave
+ = $.INPUT({type: "button", value: "Save"});
+
+ var btnCancel
+ = $.INPUT({type: "button", value: "Cancel"});
+
+ var configPanel
+ = $.TABLE({className: "pageEditor"},
+ $.TBODY({},
+ $.TR({},
+ $.TH({}, "Site name"),
+ $.TD({}, fldSiteName)
+ ),
+ $.TR({},
+ $.TH({}, "Base URI"),
+ $.TD({}, fldBaseURI)
+ ),
+ $.TR({},
+ $.TH({}, "Default page"),
+ $.TD({}, fldDefaultPage)
+ ),
+ $.TR({},
+ $.TH({}, "Style sheet"),
+ $.TD({}, fldStyleSheet)
+ ),
+ $.TR({},
+ $.TH({}, "Languages"),
+ $.TD({}, fldLanguages)
+ ),
+ $.TR({},
+ $.TH({}, "Global lock"),
+ $.TD({},
+ $.LABEL({},
+ chkGlobalLock,
+ "Disallow guest users to edit pages."))
+ ),
+ $.TR({},
+ $.TH({}),
+ $.TD({}, btnSave, btnCancel)
+ )
+ )
+ );
+
+ $area.append(configPanel);
+ };
+
$(document).ready(function () {
$("input.configButton")
.click(function () {