projects
/
mkws-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
eccb56b
)
improve checking of mkws_config object, MKWS-88
author
Wolfram Schneider
<wosch@indexdata.dk>
Fri, 3 Jan 2014 13:15:09 +0000
(13:15 +0000)
committer
Wolfram Schneider
<wosch@indexdata.dk>
Fri, 3 Jan 2014 13:15:09 +0000
(13:15 +0000)
tools/htdocs/mkws.js
patch
|
blob
|
history
diff --git
a/tools/htdocs/mkws.js
b/tools/htdocs/mkws.js
index
8b40745
..
db6c337
100644
(file)
--- a/
tools/htdocs/mkws.js
+++ b/
tools/htdocs/mkws.js
@@
-15,8
+15,9
@@
var mkws = {
* Needs to be defined in the HTML header before including this JS file.
* Define empty mkws_config for simple applications that don't define it.
*/
* Needs to be defined in the HTML header before including this JS file.
* Define empty mkws_config for simple applications that don't define it.
*/
-if (!mkws_config)
+if (mkws_config == null || typeof mkws_config != 'object')) {
var mkws_config = {};
var mkws_config = {};
+}
// Wrapper for jQuery
(function ($) {
// Wrapper for jQuery
(function ($) {
@@
-156,6
+157,7
@@
Handlebars.registerHelper('commaList', function(items, options) {
{
{
+
/* default mkws config */
var config_default = {
use_service_proxy: true,
/* default mkws config */
var config_default = {
use_service_proxy: true,
@@
-185,6
+187,12
@@
Handlebars.registerHelper('commaList', function(items, options) {
mkws.debug_level = config_default.debug_level;
}
mkws.debug_level = config_default.debug_level;
}
+ // make sure the mkws_config is a valid hash
+ if (!$.isPlainObject(mkws_config)) {
+ debug("ERROR: mkws_config is not an JS object, ignore it....");
+ mkws_config = {};
+ }
+
/* override standard config values by function parameters */
for (var k in config_default) {
if (typeof mkws_config[k] === 'undefined')
/* override standard config values by function parameters */
for (var k in config_default) {
if (typeof mkws_config[k] === 'undefined')
@@
-422,7
+430,7
@@
function onFormSubmitEventHandler()
function newSearch(query, sort, targets)
{
debug("newSearch: " + query);
function newSearch(query, sort, targets)
{
debug("newSearch: " + query);
-
+
if (mkws_config.use_service_proxy && !mkws.authenticated) {
alert("searching before authentication");
return;
if (mkws_config.use_service_proxy && !mkws.authenticated) {
alert("searching before authentication");
return;