(function () { var identityDecoder = function (src) { return src; }; var mapDecoder = function (src) { var map = {}; var lines = src.split(/\n/); $.each(lines, function () { var m = this.match(/^(\S+)\s+(\S+)$/); map[ m[1] ] = m[2]; }); return map; }; var boolDecoder = function (src) { return src == "*"; }; var decoder_of = { siteName : identityDecoder, baseURI : identityDecoder, defaultPage: identityDecoder, styleSheet : identityDecoder, languages : mapDecoder, globalLock : boolDecoder }; var cachedConf = null; Rakka.getSystemConfig = function () { if (cachedConf != null) { return cachedConf; } var conf = {}; cachedConf = conf; $.ajax({ type : "GET", url : Rakka.baseURI + "systemConfig", async : false, success: function (xml) { $(xml).find("value").each(function () { var path = this.getAttribute("path"); var decoder = decoder_of[path]; if (decoder == null) { throw new Error("unknown config path: " + path); } else { conf[path] = decoder($(this).text()); } }); }, error : function (req) { throw new Error(req.status + " " + req.statusText); } }); return conf; }; $(document).ready(function () { $("input.configButton") .click(function () { Rakka.showConfigPanel(); }); }); })();