Commit 735a0c40 authored by Michał Woźniak's avatar Michał Woźniak
Browse files

Merge branch 'rysiek-master-patch-11187' into 'master'

Bugfix for updating resource info displays

See merge request rysiek/samizdat!23
parents f9a51bf2 b7a28249
......@@ -252,6 +252,22 @@ samizdat.updateFetchedResources = () => {
Object.keys(samizdat.methodStats).forEach((method)=>{
var pclass = samizdat.safeClassName(method);
var foundSuccess = false
// handle per-resource displays
// TODO: this needs to be done in a more efficient and elegant way
for (let rdisplay of samizdat.resourceDisplays[url]) {
// if we don't seem to have a display for this method in this resource displa...
if (rdisplay.getElementsByClassName(pclass).length == 0) {
var method_class = pclass
if (typeof samizdat.info[url] !== "undefined" && typeof samizdat.info[url][method] !== "undefined") {
method_class += ' ' + samizdat.info[url][method].state;
}
var method_item = document.createElement('template')
method_item.innerHTML = `<span class="samizdat-fetched-resource-method ${method_class}">${method}</span>`
rdisplay.childNodes[0].insertAdjacentElement('beforeend', method_item.content.firstChild.cloneNode(true))
}
}
// do we have the method even?
if (typeof si[method] === "object") {
// is this a success?
......@@ -308,11 +324,12 @@ samizdat.updateFetchedResources = () => {
samizdat.addPluginStatus = (plugin, description='', status=null) => {
console.log('(COMMIT_UNKNOWN) addPluginStatus(' + plugin + ')')
var statusDisplays = document.getElementsByClassName("samizdat-status-display");
var pclass = encodeURIComponent(plugin.toLowerCase()).replace(/%[0-9A-F]{2}/gi,'-');
var pclass = samizdat.safeClassName(plugin);
var pcount = 0;
if (typeof samizdat.methodStats[plugin] !== 'undefined') {
pcount = samizdat.methodStats[plugin];
}
// handle the status displays
for (let sd of statusDisplays) {
sd.insertAdjacentHTML('beforeend', `<li><abbr class="samizdat-status-element ${pcount ? 'active' : ''} samizdat-status-${pclass}" title="${description}">${plugin}: <span class="status">${status ? status : pcount}</span></abbr></li>`)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment