MCPcopy Index your code
hub / github.com/hoothin/UserScripts / beginLoadImg

Function beginLoadImg

Picviewer CE+/dist.user.js:20414–20455  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20412 waitForReady: function(ele) {
20413 var self = this;
20414 var beginLoadImg = () => {
20415 self.imgReady = imgReady(dataset(ele,'src'), {
20416 loadEnd: function(e) {
20417 if (self.aborted) {
20418 return;
20419 }
20420
20421 if (e.type == 'error') {
20422 var srcs = dataset(ele, 'srcs');
20423 if (srcs) srcs = srcs.split(",");
20424 if (srcs && srcs.length > 0) {
20425 var src = srcs.shift();
20426 dataset(ele, 'srcs', srcs.join(","));
20427 if (src) {
20428 dataset(ele, 'src', src);
20429 self.waitForReady(ele);
20430 return;
20431 }
20432 }
20433 }
20434
20435 dataset(ele,'preloaded','true');
20436 if (!dataset(ele,'naturalSize') && this.naturalHeight && this.naturalWidth) {
20437 dataset(ele,'naturalSize', JSON.stringify({
20438 h: this.naturalHeight,
20439 w: this.naturalWidth,
20440 }));
20441 let key = this.naturalWidth + "x" + this.naturalHeight;
20442 self.oriThis.sizeMap[key] = (self.oriThis.sizeMap[key] || 0) + 1;
20443 if (self.oriThis.sizeMap[key] === 2) {
20444 let option = document.createElement("option");
20445 option.innerText = key;
20446 option.value = this.naturalWidth + "-" + this.naturalWidth + "x" + this.naturalHeight + "-" + this.naturalHeight;
20447 self.oriThis.pinSize.appendChild(option);
20448 }
20449 }
20450 self.container.appendChild(this);
20451 self.preload();
20452 },
20453 time:60 * 1000,//限时一分钟,否则强制结束并开始预读下一张。
20454 });
20455 };
20456 var xhr = dataset(ele, 'xhr') !== 'stop' && this.oriThis.getPropBySpanMark(ele, 'xhr');
20457 if (xhr) {
20458 var xhrError = function() {

Callers 2

xhrErrorFunction · 0.70
initFunction · 0.70

Calls 3

preloadMethod · 0.80
imgReadyFunction · 0.70
datasetFunction · 0.70

Tested by

no test coverage detected