]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - js/systemConfig.js
isValidBaseURI
[Rakka.git] / js / systemConfig.js
index e9254e3837d867236cc4645eb0a28ca28917af54..5ea6393aa40b54ea7df2f9afb5c7d0cd68a781be 100644 (file)
 
      var cachedConf = null;
 
+     var isValidBaseURI = function (str) {
+         parseUri.options.strictMode = true;
+         var uri = parseUri(str);
+
+         return (uri.protocol != "" &&
+                 uri.authority != "" &&
+                 uri.path != "" &&
+                 uri.path.match(/\/$/) &&
+                 uri.query == "" &&
+                 uri.anchor == "");
+     };
+
     Rakka.getSystemConfig = function () {
         if (cachedConf != null) {
             return cachedConf;
                               )
                       );
 
+         var validate = function () {
+             var isValid = (function () {
+                                if (!isValidBaseURI(fldBaseURI.value)) {
+                                    return false;
+                                }
+
+                                return true;
+                            })();
+
+             $(btnSave).attr({disabled: (isValid ? "" : "disabled")});
+         };
+
+         var isDirty = null;
+         var makeDirty = function () {
+             isDirty = true;
+         };
+
+         $(fldSiteName)
+             .add(fldBaseURI)
+             .add(fldDefaultPage)
+             .add(fldStyleSheet)
+             .add(fldLanguages)
+             .change(validate)
+             .keyup(validate)
+             .change(makeDirty);
+
          $area.append(configPanel);
      };