 Issue 29339387:
  Issue 3890 - Fix "Downloading..." indication for subscriptions on the options page  (Closed)
    
  
    Issue 29339387:
  Issue 3890 - Fix "Downloading..." indication for subscriptions on the options page  (Closed) 
  | Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 
| 3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH | 
| 4 * | 4 * | 
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify | 
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as | 
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. | 
| 8 * | 8 * | 
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, | 
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 if (title) | 194 if (title) | 
| 195 element.setAttribute("data-search", title.toLowerCase()); | 195 element.setAttribute("data-search", title.toLowerCase()); | 
| 196 var control = element.querySelector(".control[role='checkbox']"); | 196 var control = element.querySelector(".control[role='checkbox']"); | 
| 197 if (control) | 197 if (control) | 
| 198 { | 198 { | 
| 199 control.setAttribute("aria-checked", item.disabled == false); | 199 control.setAttribute("aria-checked", item.disabled == false); | 
| 200 if (this._isControlDisabled(item, i)) | 200 if (this._isControlDisabled(item, i)) | 
| 201 control.setAttribute("disabled", true); | 201 control.setAttribute("disabled", true); | 
| 202 } | 202 } | 
| 203 | 203 | 
| 204 var downloadStatus = item.downloadStatus; | |
| 205 var dateElement = element.querySelector(".date"); | 204 var dateElement = element.querySelector(".date"); | 
| 206 var timeElement = element.querySelector(".time"); | 205 var timeElement = element.querySelector(".time"); | 
| 207 if(dateElement && timeElement) | 206 if (dateElement && timeElement) | 
| 208 { | 207 { | 
| 209 var message = element.querySelector(".message"); | 208 var message = element.querySelector(".message"); | 
| 210 ext.backgroundPage.sendMessage( | 209 if (item.isDownloading) | 
| 211 { | 210 { | 
| 212 type: "subscriptions.isDownloading", | 211 var text = getMessage("options_filterList_lastDownload_inProgress"); | 
| 213 url: item.url | 212 message.textContent = text; | 
| 214 }, | 213 element.classList.add("show-message"); | 
| 215 function(isDownloading) | 214 } | 
| 215 else if (item.downloadStatus != "synchronize_ok") | |
| 216 { | 216 { | 
| 217 if (isDownloading) | 217 var error = filterErrors[item.downloadStatus]; | 
| 218 { | 218 if (error) | 
| 219 var text = getMessage("options_filterList_lastDownload_inProgress"); | 219 message.textContent = getMessage(error); | 
| 220 message.textContent = text; | 220 else | 
| 221 element.classList.add("show-message"); | 221 message.textContent = item.downloadStatus; | 
| 222 } | 222 element.classList.add("show-message"); | 
| 223 else if (downloadStatus && downloadStatus != "synchronize_ok") | 223 } | 
| 224 { | 224 else if (item.lastDownload > 0) | 
| 225 if (downloadStatus in filterErrors) | 225 { | 
| 226 message.textContent = getMessage(filterErrors[downloadStatus]); | 226 var dateTime = i18n_formatDateTime(item.lastDownload * 1000); | 
| 227 else | 227 dateElement.textContent = dateTime[0]; | 
| 228 message.textContent = item.downloadStatus; | 228 timeElement.textContent = dateTime[1]; | 
| 229 element.classList.add("show-message"); | 229 element.classList.remove("show-message"); | 
| 230 } | 230 } | 
| 231 else if (item.lastDownload > 0) | |
| 232 { | |
| 233 var dateTime = i18n_formatDateTime(item.lastDownload * 1000); | |
| 234 dateElement.textContent = dateTime[0]; | |
| 235 timeElement.textContent = dateTime[1]; | |
| 236 element.classList.remove("show-message"); | |
| 237 } | |
| 238 }); | |
| 239 } | 231 } | 
| 232 | |
| 240 var websiteElement = element.querySelector(".context-menu .website"); | 233 var websiteElement = element.querySelector(".context-menu .website"); | 
| 241 var sourceElement = element.querySelector(".context-menu .source"); | 234 var sourceElement = element.querySelector(".context-menu .source"); | 
| 242 if (websiteElement && item.homepage) | 235 if (websiteElement && item.homepage) | 
| 243 websiteElement.setAttribute("href", item.homepage); | 236 websiteElement.setAttribute("href", item.homepage); | 
| 244 if (sourceElement) | 237 if (sourceElement) | 
| 245 sourceElement.setAttribute("href", item.url); | 238 sourceElement.setAttribute("href", item.url); | 
| 246 } | 239 } | 
| 247 }; | 240 }; | 
| 248 | 241 | 
| 249 Collection.prototype.clearAll = function() | 242 Collection.prototype.clearAll = function() | 
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 } | 404 } | 
| 412 } | 405 } | 
| 413 } | 406 } | 
| 414 for (var i in collections) | 407 for (var i in collections) | 
| 415 collections[i].updateItem(subscription); | 408 collections[i].updateItem(subscription); | 
| 416 } | 409 } | 
| 417 } | 410 } | 
| 418 | 411 | 
| 419 if (!Object.observe) | 412 if (!Object.observe) | 
| 420 { | 413 { | 
| 421 ["disabled", "lastDownload"].forEach(function(property) | 414 Object.keys(subscription).forEach(function(property) | 
| 
Sebastian Noack
2016/04/05 18:38:49
We would have to add "isDownloading" and "download
 | |
| 422 { | 415 { | 
| 423 subscription["$" + property] = subscription[property]; | 416 var value = subscription[property]; | 
| 
Sebastian Noack
2016/04/05 18:38:49
This is unrelated, but why using a prefixed key, i
 | |
| 424 Object.defineProperty(subscription, property, | 417 Object.defineProperty(subscription, property, | 
| 425 { | 418 { | 
| 426 get: function() | 419 get: function() | 
| 427 { | 420 { | 
| 428 return this["$" + property]; | 421 return value; | 
| 429 }, | 422 }, | 
| 430 set: function(newValue) | 423 set: function(newValue) | 
| 431 { | 424 { | 
| 432 var oldValue = this["$" + property]; | 425 if (value != newValue) | 
| 433 if (oldValue != newValue) | |
| 434 { | 426 { | 
| 435 this["$" + property] = newValue; | 427 value = newValue; | 
| 436 var change = Object.create(null); | 428 onObjectChanged([{name: property}]); | 
| 437 change.name = property; | |
| 438 onObjectChanged([change]); | |
| 439 } | 429 } | 
| 440 } | 430 } | 
| 441 }); | 431 }); | 
| 442 }); | 432 }); | 
| 443 } | 433 } | 
| 444 else | 434 else | 
| 445 { | 435 { | 
| 446 Object.observe(subscription, onObjectChanged); | 436 Object.observe(subscription, onObjectChanged); | 
| 447 } | 437 } | 
| 448 } | 438 } | 
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 978 if (knownSubscription) | 968 if (knownSubscription) | 
| 979 collections.filterLists.addItems(knownSubscription); | 969 collections.filterLists.addItems(knownSubscription); | 
| 980 else | 970 else | 
| 981 collections.filterLists.addItems(subscription); | 971 collections.filterLists.addItems(subscription); | 
| 982 break; | 972 break; | 
| 983 case "disabled": | 973 case "disabled": | 
| 984 updateSubscription(subscription); | 974 updateSubscription(subscription); | 
| 985 updateShareLink(); | 975 updateShareLink(); | 
| 986 break; | 976 break; | 
| 987 case "lastDownload": | 977 case "lastDownload": | 
| 978 case "downloadStatus": | |
| 979 case "downloading": | |
| 988 updateSubscription(subscription); | 980 updateSubscription(subscription); | 
| 989 break; | 981 break; | 
| 990 case "homepage": | 982 case "homepage": | 
| 991 // TODO: NYI | 983 // TODO: NYI | 
| 992 break; | 984 break; | 
| 993 case "removed": | 985 case "removed": | 
| 994 var knownSubscription = subscriptionsMap[subscription.url]; | 986 var knownSubscription = subscriptionsMap[subscription.url]; | 
| 995 getAcceptableAdsURL(function(acceptableAdsUrl) | 987 getAcceptableAdsURL(function(acceptableAdsUrl) | 
| 996 { | 988 { | 
| 997 if (subscription.url == acceptableAdsUrl) | 989 if (subscription.url == acceptableAdsUrl) | 
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1166 { | 1158 { | 
| 1167 type: "prefs.listen", | 1159 type: "prefs.listen", | 
| 1168 filter: ["notifications_ignoredcategories", "notifications_showui", | 1160 filter: ["notifications_ignoredcategories", "notifications_showui", | 
| 1169 "safari_contentblocker", "show_devtools_panel", | 1161 "safari_contentblocker", "show_devtools_panel", | 
| 1170 "shouldShowBlockElementMenu"] | 1162 "shouldShowBlockElementMenu"] | 
| 1171 }); | 1163 }); | 
| 1172 ext.backgroundPage.sendMessage( | 1164 ext.backgroundPage.sendMessage( | 
| 1173 { | 1165 { | 
| 1174 type: "subscriptions.listen", | 1166 type: "subscriptions.listen", | 
| 1175 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1167 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 
| 1176 "title"] | 1168 "title", "downloadStatus", "downloading"] | 
| 1177 }); | 1169 }); | 
| 1178 | 1170 | 
| 1179 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1171 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 
| 1180 })(); | 1172 })(); | 
| OLD | NEW |