Version 1.4beta3 de ScrutariJs

This commit is contained in:
Vincent Calame 2024-05-15 23:03:57 +02:00 committed by root
parent 33bb3ee4e5
commit 8e79fb4c17
2 changed files with 41 additions and 38 deletions

View File

@ -176,6 +176,10 @@ Scrutari.Lav.changeHandler = function (client, element, name) {
} }
}; };
Scrutari.Lav.mainsearchCallback = function (client, searchUnit) {
$("#scrutari_lav_sequence").html(Scrutari.Lav.formatSearchSequence(client, searchUnit));
};
Scrutari.Lav.getApiSettings = function () { Scrutari.Lav.getApiSettings = function () {
return { return {
name: "libreavous", name: "libreavous",
@ -212,18 +216,16 @@ Scrutari.Lav.getInitOptions = function () {
uiInit: Scrutari.Lav.init, uiInit: Scrutari.Lav.init,
ignoreElement: null, ignoreElement: null,
isFilterEnable: null, isFilterEnable: null,
mainsearchCallback: function (client, searchUnit) {
$("#scrutari_lav_sequence").html(Scrutari.Lav.formatSearchSequence(client, searchUnit));
},
mainsearchErrorCallback: null,
subsearchCallback: null,
subsearchErrorCallback: null,
initFilterByQuery: null, initFilterByQuery: null,
newSearchDisplay: Scrutari.Lav.newSearchDisplay, newSearchDisplay: Scrutari.Lav.newSearchDisplay,
startLoading: null, startLoading: null,
endLoading: null, endLoading: null,
actionHandler: Scrutari.Lav.actionHandler, actionHandler: Scrutari.Lav.actionHandler,
changeHandler: Scrutari.Lav.changeHandler changeHandler: Scrutari.Lav.changeHandler
},
searchCallbacks: {
mainsearch: Scrutari.Lav.mainsearchCallback,
qidsearch: Scrutari.Lav.mainsearchCallback
} }
}; };
}; };

View File

@ -1,4 +1,4 @@
/* version: 1.4alpha16 */ /* version: 1.4beta3 */
var Scrutari = {}; var Scrutari = {};
Scrutari.log = function (msg) { Scrutari.log = function (msg) {
if ((console) && (console.log)) { if ((console) && (console.log)) {
@ -2126,8 +2126,8 @@ Scrutari.History.prototype.loadHistory = function (historyName) {
history.updateCurrent(historyName); history.updateCurrent(historyName);
$historyBlock.addClass(client.cssClasses.activeHistory); $historyBlock.addClass(client.cssClasses.activeHistory);
client.displaySearchUnit(historySearchUnit, false); client.displaySearchUnit(historySearchUnit, false);
if (client.functions.mainsearchCallback) { if (client.functions.searchCallbacks.mainsearch) {
client.functions.mainsearchCallback(client, historySearchUnit); client.functions.searchCallbacks.mainsearch(client, historySearchUnit);
} }
} }
}; };
@ -2203,13 +2203,19 @@ Scrutari.Client = function (api, clientId) {
initFilterByQuery: Scrutari.DefaultUi.initFilterByQuery, initFilterByQuery: Scrutari.DefaultUi.initFilterByQuery,
initForms: Scrutari.DefaultUi.initForms, initForms: Scrutari.DefaultUi.initForms,
isFilterEnable: Scrutari.DefaultUi.isFilterEnable, isFilterEnable: Scrutari.DefaultUi.isFilterEnable,
mainsearchCallback: Scrutari.DefaultUi.mainsearchCallback,
mainsearchErrorCallback: null,
modalAction: Scrutari.DefaultUi.modalAction, modalAction: Scrutari.DefaultUi.modalAction,
newSearchDisplay: Scrutari.DefaultUi.newSearchDisplay, newSearchDisplay: Scrutari.DefaultUi.newSearchDisplay,
startLoading: Scrutari.DefaultUi.startLoading, startLoading: Scrutari.DefaultUi.startLoading
subsearchCallback: Scrutari.DefaultUi.subsearchCallback, };
subsearchErrorCallback: null this.searchCallbacks = {
mainsearch: Scrutari.DefaultUi.mainsearchCallback,
qidsearch: Scrutari.DefaultUi.qidsearchCallback,
subsearch: Scrutari.DefaultUi.subsearchCallback
};
this.errorCallbacks = {
mainsearch: null,
qidsearch: null,
subsearch: null
}; };
this.cssClasses = { this.cssClasses = {
disabled: "scrutari-Disabled", disabled: "scrutari-Disabled",
@ -2670,17 +2676,8 @@ Scrutari.Client.prototype.searchCallback = function (searchUnit) {
var client = this; var client = this;
client.displaySearchUnit(searchUnit, true); client.displaySearchUnit(searchUnit, true);
client.endLoading(); client.endLoading();
switch(searchUnit.searchOrigin) { if (client.searchCallbacks.hasOwnProperty(searchUnit.searchOrigin)) {
case "mainsearch": client.searchCallbacks[searchUnit.searchOrigin](client, searchUnit);
if (client.functions.mainsearchCallback) {
client.functions.mainsearchCallback(client, searchUnit);
}
break;
case "subsearch":
if (client.functions.subsearchCallback) {
client.functions.subsearchCallback(client, searchUnit);
}
break;
} }
}; };
Scrutari.Client.prototype.errorCallback = function (error, searchOrigin) { Scrutari.Client.prototype.errorCallback = function (error, searchOrigin) {
@ -2689,17 +2686,8 @@ Scrutari.Client.prototype.errorCallback = function (error, searchOrigin) {
client.functions.displayError(client, error, searchOrigin); client.functions.displayError(client, error, searchOrigin);
} }
client.endLoading(); client.endLoading();
switch(searchOrigin) { if (client.errorCallbacks.hasOwnProperty(searchOrigin)) {
case "mainsearch": client.errorCallbacks[searchOrigin](client, error);
if (client.functions.mainsearchErrorCallback) {
client.functions.mainsearchErrorCallback(client, error);
}
break;
case "subsearch":
if (client.functions.subsearchErrorCallback) {
client.functions.subsearchErrorCallback(client, error);
}
break;
} }
}; };
Scrutari.Client.prototype.buildSearchRequestParameters = function (customParameters) { Scrutari.Client.prototype.buildSearchRequestParameters = function (customParameters) {
@ -2841,6 +2829,16 @@ Scrutari.Client.init = function (api, clientId, options, callback) {
} }
} }
} }
if (options.searchCallbacks) {
for(let callbackKey in options.searchCallbacks) {
client.searchCallbacks[callbackKey] = options.searchCallbacks[callbackKey];
}
}
if (options.errorCallbacks) {
for(let callbackKey in options.errorCallbacks) {
client.errorCallbacks[callbackKey] = options.errorCallbacks[callbackKey];
}
}
if (options.cssClasses) { if (options.cssClasses) {
for(let cssKey in options.cssClasses) { for(let cssKey in options.cssClasses) {
client.cssClasses[cssKey] = options.cssClasses[cssKey]; client.cssClasses[cssKey] = options.cssClasses[cssKey];
@ -3350,10 +3348,10 @@ Scrutari.DefaultUi.checkInitialQuery = function (client) {
if (client.functions.initFilterByQuery) { if (client.functions.initFilterByQuery) {
client.functions.initFilterByQuery(client, searchUnit); client.functions.initFilterByQuery(client, searchUnit);
} }
client.mainsearchResultCallback(searchUnit); client.searchCallback(searchUnit);
}, },
errorCallback: function (error) { errorCallback: function (error) {
client.mainsearchErrorCallback(error); client.errorCallback(error, "qidsearch");
} }
}); });
} }
@ -3384,6 +3382,9 @@ Scrutari.DefaultUi.mainsearchCallback = function (client, searchUnit) {
$parametersDisplayButton.click(); $parametersDisplayButton.click();
} }
}; };
Scrutari.DefaultUi.qidsearchCallback = function (client, searchUnit) {
Scrutari.DefaultUi.mainsearchCallback(client, searchUnit);
};
Scrutari.DefaultUi.subsearchCallback = function (client, searchUnit) { Scrutari.DefaultUi.subsearchCallback = function (client, searchUnit) {
client.$count("stats-result", 'update', searchUnit.getFicheCount()); client.$count("stats-result", 'update', searchUnit.getFicheCount());
}; };