| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('offlineInternals', function() { | 5 cr.define('offlineInternals', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** @type {!Array<OfflinePage>} */ | 8 /** @type {!Array<OfflinePage>} */ |
| 9 var offlinePages = []; | 9 var offlinePages = []; |
| 10 | 10 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 $('clear-all').onclick = deleteAllPages; | 198 $('clear-all').onclick = deleteAllPages; |
| 199 $('clear-selected').onclick = deleteSelectedPages; | 199 $('clear-selected').onclick = deleteSelectedPages; |
| 200 $('refresh').onclick = refreshAll; | 200 $('refresh').onclick = refreshAll; |
| 201 $('download').onclick = download; | 201 $('download').onclick = download; |
| 202 $('log-model-on').onclick = togglePageModelLog.bind(this, true); | 202 $('log-model-on').onclick = togglePageModelLog.bind(this, true); |
| 203 $('log-model-off').onclick = togglePageModelLog.bind(this, false); | 203 $('log-model-off').onclick = togglePageModelLog.bind(this, false); |
| 204 $('log-request-on').onclick = toggleRequestQueueLog.bind(this, true); | 204 $('log-request-on').onclick = toggleRequestQueueLog.bind(this, true); |
| 205 $('log-request-off').onclick = toggleRequestQueueLog.bind(this, false); | 205 $('log-request-off').onclick = toggleRequestQueueLog.bind(this, false); |
| 206 $('refresh-logs').onclick = refreshLog; | 206 $('refresh-logs').onclick = refreshLog; |
| 207 $('add-to-queue').onclick = function() { | 207 $('add-to-queue').onclick = function() { |
| 208 var saveUrl = $('url').value; | 208 var saveUrls = $('url').value.split(','); |
| 209 browserProxy_.addToRequestQueue(saveUrl) | 209 var counter = saveUrls.length; |
| 210 .then(function(state) { | 210 $('save-url-state').textContent = ''; |
| 211 if (state) { | 211 for (let i = 0; i < saveUrls.length; i++) { |
| 212 $('save-url-state').textContent = | 212 browserProxy_.addToRequestQueue(saveUrls[i]) |
| 213 saveUrl + ' has been added to queue.'; | 213 .then(function(state) { |
| 214 $('url').value = ''; | 214 if (state) { |
| 215 browserProxy_.getRequestQueue().then(fillRequestQueue); | 215 $('save-url-state').textContent += |
| 216 } else { | 216 saveUrls[i] + ' has been added to queue.\n'; |
| 217 $('save-url-state').textContent = | 217 $('url').value = ''; |
| 218 saveUrl + ' failed to be added to queue.'; | 218 counter--; |
| 219 } | 219 if (counter == 0) { |
| 220 }); | 220 browserProxy_.getRequestQueue().then(fillRequestQueue); |
| 221 } |
| 222 } else { |
| 223 $('save-url-state').textContent += |
| 224 saveUrls[i] + ' failed to be added to queue.\n'; |
| 225 } |
| 226 }); |
| 227 } |
| 221 }; | 228 }; |
| 222 | 229 |
| 223 refreshAll(); | 230 refreshAll(); |
| 224 } | 231 } |
| 225 | 232 |
| 226 // Return an object with all of the exports. | 233 // Return an object with all of the exports. |
| 227 return { | 234 return { |
| 228 initialize: initialize, | 235 initialize: initialize, |
| 229 }; | 236 }; |
| 230 }); | 237 }); |
| 231 | 238 |
| 232 document.addEventListener('DOMContentLoaded', offlineInternals.initialize); | 239 document.addEventListener('DOMContentLoaded', offlineInternals.initialize); |
| OLD | NEW |