]> git.wh0rd.org - tt-rss.git/blobdiff - prefs.js
ajaxify prefs save/reset; update translations
[tt-rss.git] / prefs.js
index edd1627d1e21ce45d94ef0597db42d1f6ad4b099..b233d8a1ffdb779323f074365ef3c86d2ff3e5b6 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -186,6 +186,13 @@ function notify_callback() {
        } 
 }
 
+function prefs_reset_callback() {
+       if (xmlhttp.readyState == 4) {
+               notify_info(xmlhttp.responseText);
+               selectTab();
+       } 
+}
+
 
 function changepass_callback() {
        try {
@@ -1413,7 +1420,27 @@ function categorizeSelectedFeeds() {
 }
 
 function validatePrefsReset() {
-       return confirm(__("Reset to defaults?"));
+       try {
+               var ok = confirm(__("Reset to defaults?"));
+
+               if (ok) {
+
+                       var query = Form.serialize("pref_prefs_form");
+                       query = query + "&subop=reset-config";
+                       debug(query);
+
+                       xmlhttp.open("POST", "backend.php", true);
+                       xmlhttp.onreadystatechange=prefs_reset_callback;
+                       xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+                       xmlhttp.send(query);
+               }
+
+       } catch (e) {
+               exception_error("validatePrefsSave", e);
+       }
+
+       return false;
+
 }
 
 function browseFeeds(limit) {
@@ -1724,3 +1751,27 @@ function pubRegenKey() {
 
        return false;
 }
+
+function validatePrefsSave() {
+       try {
+
+               var ok = confirm(__("Save current configuration?"));
+
+               if (ok) {
+
+                       var query = Form.serialize("pref_prefs_form");
+                       query = query + "&subop=save-config";
+                       debug(query);
+
+                       xmlhttp.open("POST", "backend.php", true);
+                       xmlhttp.onreadystatechange=notify_callback;
+                       xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+                       xmlhttp.send(query);
+               }
+
+       } catch (e) {
+               exception_error("validatePrefsSave", e);
+       }
+
+       return false;
+}