--- /dev/null
+(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
+ };
+
+ Rakka.getSystemConfig = function () {
+ var 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;
+ };
+
+})();
\ No newline at end of file