X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=js%2FsystemConfig.js;h=5ea6393aa40b54ea7df2f9afb5c7d0cd68a781be;hb=cddd833c65cdd8092588bd3bdfe2b9153848302f;hp=e9254e3837d867236cc4645eb0a28ca28917af54;hpb=619d36dbcf0bc8846da44fcaa5fafc0004adb567;p=Rakka.git diff --git a/js/systemConfig.js b/js/systemConfig.js index e9254e3..5ea6393 100644 --- a/js/systemConfig.js +++ b/js/systemConfig.js @@ -59,6 +59,18 @@ 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; @@ -159,6 +171,32 @@ ) ); + 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); };