]> www.wagner.pp.ru Git - oss/stilllife.git/commitdiff
начал писать скрипт по загрузке конфигурации форума
authorsafir <safir>
Fri, 15 Feb 2008 13:18:03 +0000 (13:18 +0000)
committersafir <safir>
Fri, 15 Feb 2008 13:18:03 +0000 (13:18 +0000)
templates/stilllife.js [new file with mode: 0644]

diff --git a/templates/stilllife.js b/templates/stilllife.js
new file mode 100644 (file)
index 0000000..8f93b02
--- /dev/null
@@ -0,0 +1,63 @@
+/**
+* Создаёт объект XMLHttpRequest, предварительно уничтожая существующий,
+* если такой существует.
+*/
+function createRequestObject()
+{
+    if (xmlhttp) 
+    {
+        xmlhttp.onreadystatechange = function (){};
+        xmlhttp.abort();
+        xmlhttp = null;
+    }
+
+    try {
+        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
+    } catch (e) {
+        try {
+            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
+        } catch (E) {
+            xmlhttp = false;
+        }
+    }
+    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
+        xmlhttp = new XMLHttpRequest();
+    }
+
+    return xmlhttp;
+}
+
+/**
+* Загружает конфигурационный файл для текущего подфорума в формате INI.
+* Файл имеет фиксированное имя 'config.ini'
+*/
+function loadConfig()
+{
+    xmlhttp.open("GET", config.ini, true);
+    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+    xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
+    xmlhttp.onreadystatechange = function() {
+        if (xmlhttp.readyState == 4) {
+            if(xmlhttp.status == 200) {
+                parsIni(xmlhttp.responseText);
+            } else {
+                alert("You have a phoblem: ");
+            }
+    };
+    
+    xmlhttp.send(null);
+}
+
+/**
+* Разбирает загруженный INI-файл и устанавливает настройки движка.
+*/
+function parsIni(config)
+{
+    var propertyLines=config.split(/[\n\r]+/);
+    var properties=[];
+    for(var i=0;i<propertyLines.lengthl;i++) {
+        var property=propertyLines[i].split(/ *=/);
+        properties[property[0]]=property[1];
+    }
+}
+