From 56644ff8811f74e7ac8478c2ab22ee860f0b4fc5 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 15 Sep 2023 13:28:16 +0200 Subject: [PATCH] wait #6282 @0.5 --- js/libs/fluidbook/fluidbook.loader.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.loader.js b/js/libs/fluidbook/fluidbook.loader.js index 661bbb4b..d1be3759 100644 --- a/js/libs/fluidbook/fluidbook.loader.js +++ b/js/libs/fluidbook/fluidbook.loader.js @@ -18,13 +18,17 @@ function FluidbookLoader(fluidbook) { this.imageMimeType = this.format === 'jpg' ? 'image/jpeg' : 'image/png'; this._needSeparateTextures = []; this.loadbalancing = false; - this._loadbalancingServerURL = []; + this._loadbalancingServerURL = {}; } FluidbookLoader.prototype = { init: function (callback) { let $this = this; if (this.fluidbook.settings.hosting_loadbalancer) { + this._loadbalancingServerURL = this.fluidbook.cache.get('_loadbalancingServerURL', {}); + setInterval(function () { + $this.fluidbook.cache.set('_loadbalancingServerURL', $this._loadbalancingServerURL); + }, 15000); $.ajax("https://toolbox.fluidbook.com/lb.json").done(function (data) { $this.loadbalancing = data; $this.loadShades(callback); @@ -76,7 +80,9 @@ FluidbookLoader.prototype = { preloadStart: function (callback) { let $this = this; this.init(function () { - $this.fluidbook.sound.preloadSounds(); + if($this.fluidbook.sound.enabled) { + $this.fluidbook.sound.preloadSounds(); + } if ($this.fluidbook.shortLoading) { $this.toPreload = [1]; } else { @@ -735,8 +741,9 @@ FluidbookLoader.prototype = { if (!this.loadbalancing) { return url; } - if(this._loadbalancingServerURL[url]===undefined){ - this._loadbalancingServerURL[url]=this.loadbalancing[Math.floor(Math.random() * this.loadbalancing.length)]; + + if (this._loadbalancingServerURL[url] === undefined || this.loadbalancing.indexOf(this._loadbalancingServerURL[url]) >= 0) { + this._loadbalancingServerURL[url] = this.loadbalancing[Math.floor(Math.random() * this.loadbalancing.length)]; } return 'https://' + this._loadbalancingServerURL[url] + '/' + this.fluidbook.settings.id + '_' + this.fluidbook.settings.hash + '/' + url; }, -- 2.39.5