Display feed presence in search results, various fixes
This commit is contained in:
@@ -53,6 +53,7 @@ public class Util {
|
||||
_x("ETA"),
|
||||
_x("Feeds"),
|
||||
_x("Fetching Certificates"),
|
||||
_x("Feed"),
|
||||
_x("File"),
|
||||
_x("Files"),
|
||||
_x("Hashing"),
|
||||
|
||||
@@ -3,7 +3,7 @@ class Feed {
|
||||
this.publisher = xmlNode.getElementsByTagName("Publisher")[0].childNodes[0].nodeValue
|
||||
this.publisherB64 = xmlNode.getElementsByTagName("PublisherB64")[0].childNodes[0].nodeValue
|
||||
this.files = xmlNode.getElementsByTagName("Files")[0].childNodes[0].nodeValue
|
||||
this.revision = xmlNode.getElementsByTagName("Revision")[0].childNodes[0].nodeValue
|
||||
this.revision = parseInt(xmlNode.getElementsByTagName("Revision")[0].childNodes[0].nodeValue)
|
||||
this.status = xmlNode.getElementsByTagName("Status")[0].childNodes[0].nodeValue
|
||||
this.active = xmlNode.getElementsByTagName("Active")[0].childNodes[0].nodeValue
|
||||
this.lastUpdated = xmlNode.getElementsByTagName("LastUpdated")[0].childNodes[0].nodeValue
|
||||
@@ -18,7 +18,7 @@ class Feed {
|
||||
updateHTML = updateLink.render()
|
||||
}
|
||||
var unsubscribeLink = new Link(_t("Unsubscribe"), "unsubscribe", [this.publisherB64])
|
||||
var configureLink = new Link(_t("Configure", "configure", [this.publisherB64]))
|
||||
var configureLink = new Link(_t("Configure"), "configure", [this.publisherB64])
|
||||
|
||||
var publisherHTML = publisherLink.render() + "<span class='right'>" + updateHTML + " " +
|
||||
unsubscribeLink.render() + " " +
|
||||
@@ -105,6 +105,8 @@ class Item {
|
||||
mapping.set("Size", this.size)
|
||||
mapping.set("Download", this.getDownloadBlock())
|
||||
mapping.set("Published", this.timestamp)
|
||||
|
||||
return mapping
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +117,7 @@ function initFeeds() {
|
||||
}
|
||||
|
||||
|
||||
function refreshActive() {
|
||||
function refreshFeeds() {
|
||||
var xmlhttp = new XMLHttpRequest()
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
@@ -146,10 +148,16 @@ function refreshActive() {
|
||||
else
|
||||
feedsDiv.innerHTML = ""
|
||||
|
||||
if (currentFeed != null)
|
||||
displayFeed(currentFeed)
|
||||
else
|
||||
if (currentFeed != null) {
|
||||
var updatedFeed = feeds.get(currentFeed)
|
||||
if (updatedFeed == null) {
|
||||
currentFeed = null
|
||||
document.getElementById("itemsTable").innerHTML = ""
|
||||
} else if (updatedFeed.revision > currentFeed.revision)
|
||||
displayFeed(currentFeed)
|
||||
} else
|
||||
document.getElementById("itemsTable").innerHTML = ""
|
||||
|
||||
}
|
||||
}
|
||||
var sortParam = "&key=" + feedsSortKey + "&order=" + feedsSortOrder
|
||||
@@ -163,7 +171,7 @@ function displayFeed(feed) {
|
||||
var xmlhttp = new XMLHttpRequest()
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
itemsByInfohash.clear()
|
||||
itemsByInfoHash.clear()
|
||||
|
||||
var items = []
|
||||
var itemNodes = this.responseXML.getElementsByTagName("Item")
|
||||
@@ -199,7 +207,7 @@ function displayFeed(feed) {
|
||||
function sortFeeds(key, order) {
|
||||
feedsSortKey = key
|
||||
feedsSortOrder = order
|
||||
refreshActive()
|
||||
refreshFeeds()
|
||||
}
|
||||
|
||||
function sortItems(key, order) {
|
||||
@@ -217,7 +225,7 @@ function forceUpdate(b64) {
|
||||
}
|
||||
xmlhttp.open("POST","/MuWire/Feed", true)
|
||||
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||
xmlhttp.open("action=update&host=" + b64)
|
||||
xmlhttp.send("action=update&host=" + b64)
|
||||
}
|
||||
|
||||
function unsubscribe(b64) {
|
||||
@@ -229,7 +237,7 @@ function unsubscribe(b64) {
|
||||
}
|
||||
xmlhttp.open("POST","/MuWire/Feed", true)
|
||||
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||
xmlhttp.open("action=unsubscribe&host=" + b64)
|
||||
xmlhttp.send("action=unsubscribe&host=" + b64)
|
||||
}
|
||||
|
||||
function configure(b64) {
|
||||
|
||||
@@ -33,6 +33,8 @@ class Sender {
|
||||
this.b64 = xmlNode.getElementsByTagName("B64")[0].childNodes[0].nodeValue
|
||||
this.trust = xmlNode.getElementsByTagName("Trust")[0].childNodes[0].nodeValue
|
||||
this.browse = xmlNode.getElementsByTagName("Browse")[0].childNodes[0].nodeValue
|
||||
this.feed = xmlNode.getElementsByTagName("Feed")[0].childNodes[0].nodeValue
|
||||
this.subscribed = xmlNode.getElementsByTagName("Subscribed")[0].childNodes[0].nodeValue
|
||||
this.browsing = xmlNode.getElementsByTagName("Browsing")[0].childNodes[0].nodeValue
|
||||
this.results = xmlNode.getElementsByTagName("Results")[0].childNodes[0].nodeValue
|
||||
}
|
||||
@@ -48,6 +50,7 @@ class Sender {
|
||||
mapping.set("Trust", trustHtml)
|
||||
|
||||
mapping.set("Browse", this.getBrowseBlock())
|
||||
mapping.set("Feed", this.getFeedBlock())
|
||||
|
||||
return mapping
|
||||
}
|
||||
@@ -90,6 +93,15 @@ class Sender {
|
||||
var block = "<span id='browse-link-" + this.b64 + "'>" + link + "</span>"
|
||||
return block
|
||||
}
|
||||
|
||||
getFeedBlock() {
|
||||
if (this.feed != "true")
|
||||
return ""
|
||||
if (this.subscribed == "true")
|
||||
return "<a href='/MuWire/Feeds'>" + _t("Subscribed") + "</a>"
|
||||
var link = new Link(_t("Subscribe"), "subscribe", [this.b64])
|
||||
return "<span id='subscribe-link-" + this.b64 + "'>" + link.render() + "</span>"
|
||||
}
|
||||
}
|
||||
|
||||
class Senders {
|
||||
@@ -111,7 +123,7 @@ class Senders {
|
||||
newOrder = "ascending"
|
||||
else if (sendersSortOrder == "ascending")
|
||||
newOrder = "descending"
|
||||
var table = new Table(["Sender", "Browse", "Results", "Trust"], "sortSendersTable", sendersSortKey, newOrder, null)
|
||||
var table = new Table(["Sender", "Browse", "Feed", "Results", "Trust"], "sortSendersTable", sendersSortKey, newOrder, null)
|
||||
var i
|
||||
for (i = 0; i < this.senders.length; i++) {
|
||||
table.addRow(this.senders[i].getMapping())
|
||||
@@ -286,6 +298,8 @@ class SenderForResult {
|
||||
this.b64 = xmlNode.getElementsByTagName("B64")[0].childNodes[0].nodeValue
|
||||
this.browse = xmlNode.getElementsByTagName("Browse")[0].childNodes[0].nodeValue
|
||||
this.browsing = xmlNode.getElementsByTagName("Browsing")[0].childNodes[0].nodeValue
|
||||
this.feed = xmlNode.getElementsByTagName("Feed")[0].childNodes[0].nodeValue
|
||||
this.subscribed = xmlNode.getElementsByTagName("Subscribed")[0].childNodes[0].nodeValue
|
||||
this.trust = xmlNode.getElementsByTagName("Trust")[0].childNodes[0].nodeValue
|
||||
this.comment = null
|
||||
try {
|
||||
@@ -298,6 +312,7 @@ class SenderForResult {
|
||||
var mapping = new Map()
|
||||
mapping.set("Sender", this.getNameBlock())
|
||||
mapping.set("Browse", this.getBrowseBlock())
|
||||
mapping.set("Feed", this.getFeedBlock())
|
||||
mapping.set("Trust", this.getTrustBlock())
|
||||
return mapping
|
||||
}
|
||||
@@ -352,6 +367,15 @@ class SenderForResult {
|
||||
return block
|
||||
}
|
||||
|
||||
getFeedBlock() {
|
||||
if (this.feed != "true")
|
||||
return ""
|
||||
if (this.subscribed == "true")
|
||||
return "<a href='/MuWire/Feeds'>" + _t("Subscribed") + "</a>"
|
||||
var link = new Link(_t("Subscribe"), "subscribe", [this.b64])
|
||||
return "<span id='subscribe-link-" + this.b64 + "'>" + link.render() + "</span>"
|
||||
}
|
||||
|
||||
getTrustBlock() {
|
||||
return this.trust +"<span class='right'>" + this.getTrustLinks() + "</span>" +
|
||||
"<div class='centercomment' id='trusted-" + this.b64 + "'></div>" +
|
||||
@@ -403,7 +427,7 @@ class SendersForResult {
|
||||
newOrder = "ascending"
|
||||
else if (sendersForResultSortOrder == "ascending")
|
||||
newOrder = "descending"
|
||||
var table = new Table(["Sender", "Browse", "Trust"], "sortSendersForResultTable", sendersForResultSortKey, newOrder, null)
|
||||
var table = new Table(["Sender", "Browse", "Feed", "Trust"], "sortSendersForResultTable", sendersForResultSortKey, newOrder, null)
|
||||
var i
|
||||
for (i = 0; i < this.sendersForResult.length; i++) {
|
||||
table.addRow(this.sendersForResult[i].getMapping())
|
||||
@@ -616,6 +640,19 @@ function browse(host) {
|
||||
xmlhttp.send("action=browse&host="+host)
|
||||
}
|
||||
|
||||
function subscribe(host) {
|
||||
var xmlhttp = new XMLHttpRequest()
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
var linkSpan = document.getElementById("subscribe-link-" + host)
|
||||
linkSpan.innerHTML = "<a href='/MuWire/Feeds'>" + _t("Subscribed") + "</a>"
|
||||
}
|
||||
}
|
||||
xmlhttp.open("POST", "/MuWire/Feed", true)
|
||||
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||
xmlhttp.send("action=subscribe&host=" + host)
|
||||
}
|
||||
|
||||
function viewCertificatesByFile(fileSenderB64, count) {
|
||||
var fetch = new CertificateFetch(fileSenderB64, currentResult)
|
||||
certificateFetches.set(fetch.divId, fetch)
|
||||
|
||||
Reference in New Issue
Block a user