add a sync option, fix sorting of table

This commit is contained in:
Zlatin Balevsky
2020-03-27 15:42:50 +00:00
parent 862967bf8e
commit a88dc17064
2 changed files with 20 additions and 2 deletions

View File

@ -125,6 +125,7 @@ public class Util {
_x("Submit"),
_x("Subscribe"),
_x("Subscribed"),
_x("Sync"),
_x("Times Browsed"),
_x("Timestamp"),
_x("Total Pieces"),

View File

@ -11,8 +11,12 @@ class Directory {
var mapping = new Map()
var configLink = new Link(_t("Configure"), "configure", [this.path])
var syncLink = new Link(_t("Sync"), "sync", [this.path])
var syncHtml = syncLink.render()
if (this.autoWatch == "true")
syncHtml = ""
var divRight = "<span class='right'><div class='dropdown'><a class='droplink'>" + _t("Actions") + "</a><div class='dropdown-content'>" +
configLink.render() + "</div></div></span>"
syncHtml + configLink.render() + "</div></div></span>"
mapping.set("Directory", this.directory + divRight)
mapping.set("Auto Watch", this.autoWatch)
@ -75,7 +79,8 @@ function refreshDirs() {
dirsDiv.innerHTML = ""
}
}
xmlhttp.open("GET", "/MuWire/AdvancedShare?section=dirs", true)
var sortParam = "&key=" + sortKey + "&order=" + sortOrder
xmlhttp.open("GET", "/MuWire/AdvancedShare?section=dirs" + sortParam, true)
xmlhttp.send()
}
@ -124,6 +129,18 @@ function cancelConfig() {
tableDiv.innerHTML = ""
}
function sync(path) {
var xmlhttp = new XMLHttpRequest()
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
refreshDirs()
}
}
xmlhttp.open("POST", "/MuWire/AdvancedShare", true)
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xmlhttp.send("action=sync&path=" + path)
}
var revision = -1
var pathToDir = new Map()