X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=8c6db31e1e23b2a9161ea78c6fc5eb58004b0cb7;hb=77fb58a15d25542791c02c755bd8993f81bc2a06;hp=361fc5342913569590876405e344ba4e203e74f0;hpb=f0edeab05ebb38de63b97462dfd6b825a6636c17;p=Sone.git
diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js
index 361fc53..8c6db31 100644
--- a/src/main/resources/static/javascript/sone.js
+++ b/src/main/resources/static/javascript/sone.js
@@ -100,17 +100,20 @@ function getTranslation(key, callback) {
*
* @param soneId
* The ID of the Sone
+ * @param local
+ * true
if the Sone is local, false
+ * otherwise
*/
-function getSoneStatus(soneId) {
+function getSoneStatus(soneId, local) {
$.getJSON("ajax/getSoneStatus.ajax", {"sone": soneId}, function(data, textStatus) {
updateSoneStatus(soneId, data.name, data.status, data.modified, data.lastUpdated);
/* seconds! */
updateInterval = 60;
- if (data.modified || (data.status == "downloading") || (data.status == "inserting")) {
+ if (local || data.modified || (data.status == "downloading") || (data.status == "inserting")) {
updateInterval = 5;
}
setTimeout(function() {
- getSoneStatus(soneId);
+ getSoneStatus(soneId, local);
}, updateInterval * 1000);
});
}
@@ -157,15 +160,18 @@ var watchedSones = {};
*
* @param soneId
* The ID of the Sone to watch
+ * @param local
+ * true
if the Sone is local, false
+ * otherwise
*/
-function watchSone(soneId) {
+function watchSone(soneId, local) {
if (watchedSones[soneId]) {
return;
}
watchedSones[soneId] = true;
(function(soneId) {
setTimeout(function() {
- getSoneStatus(soneId);
+ getSoneStatus(soneId, local);
}, 5000);
})(soneId);
}
@@ -401,3 +407,21 @@ function getReply(replyId, callbackFunction) {
}
});
}
+
+/**
+ * Ajaxifies the given notification by replacing the form with AJAX.
+ *
+ * @param notification
+ * jQuery object representing the notification.
+ */
+function ajaxifyNotification(notification) {
+ notification.find("form.dismiss").submit(function() {
+ return false;
+ });
+ notification.find("form.dismiss button").click(function() {
+ $.getJSON("ajax/dismissNotification.ajax", { "formPassword" : getFormPassword(), "notification" : notification.attr("id") }, function(data, textStatus) {
+ notification.slideUp();
+ });
+ });
+ return notification;
+}