Skip to content

Commit

Permalink
remove timed-call "performanceAwareCaller" loading time debug
Browse files Browse the repository at this point in the history
The old behaviour can be restored by passing a function to options.functionCaller as documented in editor.html
  • Loading branch information
bago committed Nov 4, 2022
1 parent 3189d42 commit 5d228f1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 36 deletions.
12 changes: 12 additions & 0 deletions src/html/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,19 @@
fileuploadConfig: {
url: basePath+'/upload/',
// messages??
},
/* until mosaico 0.18.7 this was the default functionCaller logging loading times. Now you can pass this as an option if you need the old behaviour
functionCaller: function(name, whatToCall) {
var res;
var start = new Date().getTime();
if (typeof console == 'object' && console.time) console.time(name);
res = whatToCall();
if (typeof console == 'object' && console.time) console.timeEnd(name);
var diff = new Date().getTime() - start;
if (typeof console == 'object' && !console.time) if (typeof console.debug == 'function') console.debug(name, "took", diff, "ms");
return res;
}
*/
}, plugins);
if (!ok) {
console.log("Missing initialization hash, redirecting to main entrypoint");
Expand Down
13 changes: 8 additions & 5 deletions src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var console = require("console");
var ko = require("knockout");
var $ = require("jquery");
require("./ko-bindings.js");
var performanceAwareCaller = require("./timed-call.js").timedCall;

var addUndoStackExtensionMaker = require("./undomanager/undomain.js");

Expand Down Expand Up @@ -64,9 +63,11 @@ var applyBindingOptions = function(options, ko) {
ko.bindingHandlers.wysiwyg.fullOptions = options.tinymceConfigFull;
};

var start = function(options, templateFile, templateMetadata, jsorjson, customExtensions) {

var basicFunctionCaller = function(name, func) {
return func();
};

var start = function(options, templateFile, templateMetadata, jsorjson, customExtensions) {

templateLoader.fixPageEvents();

Expand Down Expand Up @@ -114,10 +115,12 @@ var start = function(options, templateFile, templateMetadata, jsorjson, customEx
}
};

var functionCaller = typeof options.functionCaller == 'function' ? options.functionCaller : basicFunctionCaller;

// simpleTranslationPlugin must be before the undoStack to translate undo/redo labels
var extensions = [
simpleTranslationPlugin,
addUndoStackExtensionMaker(performanceAwareCaller),
addUndoStackExtensionMaker(functionCaller),
require("./widgets/boolean.js"),
require("./widgets/color.js"),
require("./widgets/font.js"),
Expand Down Expand Up @@ -147,7 +150,7 @@ var start = function(options, templateFile, templateMetadata, jsorjson, customEx
}
// TODO canonicalize templateFile to absolute or relative depending on "relativeUrlsException" plugin

templateLoader.load(performanceAwareCaller, templateFile, templateMetadata, jsorjson, extensions, galleryUrl);
templateLoader.load(functionCaller, templateFile, templateMetadata, jsorjson, extensions, galleryUrl);

};

Expand Down
31 changes: 0 additions & 31 deletions src/js/timed-call.js

This file was deleted.

0 comments on commit 5d228f1

Please sign in to comment.