From 9e24f8b17669db8cb177fdbaf195b4ae953e520a Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 4 Oct 2021 13:40:40 +0200 Subject: [PATCH] wait #4743 @1 --- js/libs/cube/util.js | 134 +++++++++++++++++++++++++- js/libs/fluidbook/fluidbook.loader.js | 6 +- 2 files changed, 136 insertions(+), 4 deletions(-) diff --git a/js/libs/cube/util.js b/js/libs/cube/util.js index 29bdc181..2712513e 100644 --- a/js/libs/cube/util.js +++ b/js/libs/cube/util.js @@ -114,10 +114,10 @@ function guid() { s4() + '-' + s4() + s4() + s4(); } -function loadImage(src, callback,id) { +function loadImage(src, callback, id) { var img = new Image(); var loaded = false; - if(id!==undefined) { + if (id !== undefined) { img.id = id; } $(img).on('load', function () { @@ -126,6 +126,12 @@ function loadImage(src, callback,id) { } loaded = true; callback(img); + }).on('error', function () { + if (loaded) { + return; + } + loaded = true; + callback(img); }); img.src = src; if ($(img).isLoaded()) { @@ -160,4 +166,126 @@ Object.size = function (obj) { }; /*! sprintf-js v1.1.2 | Copyright (c) 2007-present, Alexandru Mărășteanu | BSD-3-Clause */ -!function(){"use strict";var g={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function y(e){return function(e,t){var r,n,i,s,a,o,p,c,l,u=1,f=e.length,d="";for(n=0;n>>0).toString(8);break;case"s":r=String(r),r=s.precision?r.substring(0,s.precision):r;break;case"t":r=String(!!r),r=s.precision?r.substring(0,s.precision):r;break;case"T":r=Object.prototype.toString.call(r).slice(8,-1).toLowerCase(),r=s.precision?r.substring(0,s.precision):r;break;case"u":r=parseInt(r,10)>>>0;break;case"v":r=r.valueOf(),r=s.precision?r.substring(0,s.precision):r;break;case"x":r=(parseInt(r,10)>>>0).toString(16);break;case"X":r=(parseInt(r,10)>>>0).toString(16).toUpperCase()}g.json.test(s.type)?d+=r:(!g.number.test(s.type)||c&&!s.sign?l="":(l=c?"+":"-",r=r.toString().replace(g.sign,"")),o=s.pad_char?"0"===s.pad_char?"0":s.pad_char.charAt(1):" ",p=s.width-(l+r).length,a=s.width&&0>> 0).toString(8); + break; + case"s": + r = String(r), r = s.precision ? r.substring(0, s.precision) : r; + break; + case"t": + r = String(!!r), r = s.precision ? r.substring(0, s.precision) : r; + break; + case"T": + r = Object.prototype.toString.call(r).slice(8, -1).toLowerCase(), r = s.precision ? r.substring(0, s.precision) : r; + break; + case"u": + r = parseInt(r, 10) >>> 0; + break; + case"v": + r = r.valueOf(), r = s.precision ? r.substring(0, s.precision) : r; + break; + case"x": + r = (parseInt(r, 10) >>> 0).toString(16); + break; + case"X": + r = (parseInt(r, 10) >>> 0).toString(16).toUpperCase() + } + g.json.test(s.type) ? d += r : (!g.number.test(s.type) || c && !s.sign ? l = "" : (l = c ? "+" : "-", r = r.toString().replace(g.sign, "")), o = s.pad_char ? "0" === s.pad_char ? "0" : s.pad_char.charAt(1) : " ", p = s.width - (l + r).length, a = s.width && 0 < p ? o.repeat(p) : "", d += s.align ? l + r + a : "0" === o ? l + a + r : a + l + r) + } + return d + }(function (e) { + if (p[e]) return p[e]; + var t, r = e, n = [], i = 0; + for (; r;) { + if (null !== (t = g.text.exec(r))) n.push(t[0]); else if (null !== (t = g.modulo.exec(r))) n.push("%"); else { + if (null === (t = g.placeholder.exec(r))) throw new SyntaxError("[sprintf] unexpected placeholder"); + if (t[2]) { + i |= 1; + var s = [], a = t[2], o = []; + if (null === (o = g.key.exec(a))) throw new SyntaxError("[sprintf] failed to parse named argument key"); + for (s.push(o[1]); "" !== (a = a.substring(o[0].length));) if (null !== (o = g.key_access.exec(a))) s.push(o[1]); else { + if (null === (o = g.index_access.exec(a))) throw new SyntaxError("[sprintf] failed to parse named argument key"); + s.push(o[1]) + } + t[2] = s + } else i |= 2; + if (3 === i) throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported"); + n.push({ + placeholder: t[0], + param_no: t[1], + keys: t[2], + sign: t[3], + pad_char: t[4], + align: t[5], + width: t[6], + precision: t[7], + type: t[8] + }) + } + r = r.substring(t[0].length) + } + return p[e] = n + }(e), arguments) + } + + function e(e, t) { + return y.apply(null, [e].concat(t || [])) + } + + var p = Object.create(null); + "undefined" != typeof exports && (exports.sprintf = y, exports.vsprintf = e), "undefined" != typeof window && (window.sprintf = y, window.vsprintf = e, "function" == typeof define && define.amd && define(function () { + return {sprintf: y, vsprintf: e} + })) +}(); \ No newline at end of file diff --git a/js/libs/fluidbook/fluidbook.loader.js b/js/libs/fluidbook/fluidbook.loader.js index 796bd1ff..19a27b4b 100644 --- a/js/libs/fluidbook/fluidbook.loader.js +++ b/js/libs/fluidbook/fluidbook.loader.js @@ -601,7 +601,11 @@ FluidbookLoader.prototype = { } else if ($(this).is('[data-image]')) { var i = $(this).data('id'); if (textures[i] !== undefined && textures[i] !== null) { - ctx.drawImage(textures[i], left, top, width, height); + try { + ctx.drawImage(textures[i], left, top, width, height); + } catch (e) { + + } } } }); -- 2.39.5