Commit efd032cf authored by Sven Franck's avatar Sven Franck

jslint

parent 0c34c59d
/*jslint indent: 2, maxlen: 80, nomen: true, sloppy: true, todo: true */
/*global console, window, jIO, complex_queries, FormData, RSVP, document,
jQuery */
jQuery, i18n, hello, Recaptcha, XMLHttpRequest, Modernizr */
(function (window, document, $) {
"use strict";
......@@ -36,10 +36,9 @@
"translateLookup": function (path) {
if (i18n) {
return i18n.t(path);
} else {
util.error({"error":"Translate NodeList - i18n not defined"});
return ""
}
util.error({"error": "Translate NodeList - i18n not defined"});
return "";
},
/**
......@@ -82,20 +81,20 @@
if (lookup.indexOf(";") > -1) {
targets = lookup.split(";");
} else {
targets = [lookup]
targets = [lookup];
}
for (l = 0; l < targets.length; l += 1) {
target = targets[l].split("]");
// all hail performance
switch(target[0]) {
switch (target[0]) {
case "[placeholder":
case "[alt":
case "[title":
element.setAttribute(target[0].substr(1), i18n.t(target[1]));
break;
case "[value":
if(route_text) {
if (route_text) {
element.previousSibling.textContent = i18n.t(target[1]);
}
element.value = i18n.t(target[1]);
......@@ -116,7 +115,7 @@
}
}
} else {
util.error({"error":"Translate NodeList - i18n not defined"});
util.error({"error": "Translate NodeList - i18n not defined"});
}
},
......@@ -179,24 +178,23 @@
* @param {object} obj Action Object
**/
"logout_user": function (obj) {
var provider;
hello(obj.id).logout(function(x){
hello(obj.id).logout(function () {
return;
});
// update flux
if (flux && flux.state) {
if (flux.state[obj.id.slice(0,2)]) {
delete flux.state[obj.id.slice(0,2)]
if (flux.state[obj.id.slice(0, 2)]) {
delete flux.state[obj.id.slice(0, 2)];
} else {
delete flux.state["self"];
delete flux.state.self;
}
}
// TODO: Try to log out correctly
// http://stackoverflow.com/questions/17050575/logout-link-with-return-url-oauth/17127388#17127388
// http://stackoverflow.com/questions/16946798/logout-from-external-login-service-gmail-facebook-using-oauth
// http://bit.ly/1aih0UU
// http://bit.ly/1kUUuJz
// update login button, so it's back to login
obj.element.parentNode.replaceChild(
......@@ -212,11 +210,9 @@
**/
// TODO: failed login?
"login_user": function (obj) {
var signature, match_string, reply, element, active, hashed_list,
gadget_list, i, gadget, id;
var signature, match_string, gadget_list, i, gadget, id;
// create signature and ticket
element = obj.element;
signature = util.generateRandomIdentifier(36);
flux[signature] = util.generateUuid();
......@@ -227,8 +223,8 @@
// close 3rd party popup
window.parent.close();
})
.then(function(response) {
reply = util.parseIfNeeded(response);
.then(function (response) {
//reply = util.parseIfNeeded(response);
if (response.authResponse !== undefined) {
match_string = response.authResponse.state;
......@@ -252,12 +248,12 @@
// TODO: this is crap...
$(".ui-popup").popup("close");
})
.then(function() {
.then(function () {
util.loader("", "global_dict.status_dict.saving");
// register the user
return app.register(obj.id)
.then(function() {
.then(function () {
// TODO: should not get elements like this!
gadget_list = document.getElementById(util.getActivePage())
......@@ -274,7 +270,7 @@
// update gadget
app.setContent(
{
"generate":"gadget",
"generate": "gadget",
"id": id,
"href": id,
"type": gadget.state.method
......@@ -286,7 +282,7 @@
undefined,
true
)
.then(function (answer){
.then(function (answer) {
gadget.parentNode.replaceChild(answer, gadget);
})
.then(app.setPageBindings)
......@@ -344,6 +340,17 @@
factory.util.setPopupPointer(obj, "export");
},
/**
* Download a document as pdf
* @method download
* @param {string} type
* @param {string} portal type
* @param {string} identifier
**/
"download": function () {
util.error({"error": "Download: Not implemented."});
},
/**
* Generic pagination method changing number of records displayed
* @method limit
......@@ -508,17 +515,17 @@
// TODO: allow multiple header rows!
// TODO: make i18n optional if it's not passed!
"mapTableRows": function (items, spec, field_dict, url_pointer, update) {
var arr, obj, cell, row, i, j, k, l, m, layout, config, makeSection,
var arr, obj, cell, row, i, j, k, m, layout, config, makeSection,
translation, core, item, linkable, action, level, identifier;
arr = [];
layout = spec.property_dict.layout;
level = url_pointer.layout,
core = url_pointer.fragment_list.slice(0, level + 1).join("::"),
level = url_pointer.layout;
core = url_pointer.fragment_list.slice(0, level + 1).join("::");
linkable = spec.property_dict.feature_dict.linkable;
action = spec.property_dict.feature_dict.action_menu;
makeSection = function (type) {
return {"generate": type, "properties": {"rows": []}}
return {"generate": type, "properties": {"rows": []}};
};
// table header mapping
......@@ -527,7 +534,7 @@
// loop header rows
for (i = 0; i < layout.header.length; i += 1) {
row = []
row = [];
// loop columns per row
for (j = 0; j < layout.header[i].length; j += 1) {
......@@ -560,7 +567,7 @@
// fallback to _id if no link identifier is specified
if (identifier === undefined) {
identifier = item["_id"];
identifier = item._id;
}
if (item === undefined) {
......@@ -579,7 +586,7 @@
}
cell.identifier = identifier;
// test for translation in dynamic data or custom field text_i18n
// test for translation
translation = item[cell.column + "_i18n"] || cell.text_i18n;
if (translation) {
cell.text_i18n = translation;
......@@ -631,11 +638,11 @@
// NOTE: can't use hash, because the hash updates after storage operation
// and thus may be wrong depending on storage being accessed
"mapListItems": function (items, spec, url_pointer) {
var property, obj, i, j, item, clean, value, store, split, host,
i18n, app, level, core, arr;
var property, obj, i, item, clean, value, store, split, host,
i18n, application, level, core, arr;
level = url_pointer.layout,
core = url_pointer.fragment_list.slice(0, level + 1).join("::"),
level = url_pointer.layout;
core = url_pointer.fragment_list.slice(0, level + 1).join("::");
arr = [];
for (i = 0; i < items.length; i += 1) {
......@@ -659,7 +666,7 @@
// checkbox
if (spec.property_dict.check) {
obj.right = {"check": true, "action":"check"};
obj.right = {"check": true, "action": "check"};
}
// TODO: we can't handle normal URLs if they are passed!
......@@ -677,7 +684,7 @@
switch (clean) {
case "url":
obj["href"] = item[property];
obj.href = item[property];
split = item[property].split("//");
// TODO: crap... an empty link will generate a ribbon...
......@@ -688,10 +695,10 @@
// TODO: refactor. Determining whether a link is external
if (split.length > 1) {
host = split[1].split("/")[0];
app = split[1].split("/")[1];
application = split[1].split("/")[1];
}
if ((split.length > 1 && window.location.host !== host) ||
app === "app") {
application === "app") {
obj.external = true;
}
break;
......@@ -753,7 +760,7 @@
// the mapping from (ERP5) custom API to internal API here
"mapFormField": function (spec, overrides, passed_value) {
var validation_list, class_list, element, type, prevail, clear, config,
error_log, field_value;
field_value;
// build config object
config = {};
......@@ -787,12 +794,13 @@
// easy way out if not enabled
if (prevail.properties.enabled === false ||
spec.properties.enabled === false) {
return config = {
config = {
"type": "span",
"direct": {"className": "static"},
"attributes": {},
"logic": {"text": field_value}
}
};
return config;
}
validation_list = "";
......@@ -811,7 +819,6 @@
if (prevail.properties.required === true ||
spec.properties.required === true) {
class_list += "required ";
error_log = true;
}
// maximum_length
......@@ -908,10 +915,10 @@
"rows": prevail.widget.width || spec.widget.width || undefined,
"cols": prevail.widget.height || spec.widget.height || undefined,
"disabled": (prevail.properties.enabled || spec.properties.enabled) ?
(undefined) : true,
undefined : true,
"value": field_value,
"readonly": (prevail.properties.editable === false ||
spec.properties.editable === false) ? (true) : undefined,
spec.properties.editable === false) ? true : undefined,
"options": (prevail.widget.items || spec.widget.items) ?
([
prevail.widget.items || spec.widget.items || null,
......@@ -949,10 +956,10 @@
* @param {object} content_dict JSON configuration for global setup
**/
"setGlobalConfiguration": function (content_dict) {
var i, j, translator, single_path, supported, target, content, language,
var i, j, translator, single_path, supported, target, language,
container, foreign, promises, path_flag, status_flag, set_state,
multi_language_flag, force_browser_language, logger, depend, element,
need_update, set_login, set_i18n, open_auth, skip_restore;
multi_language_flag, force_browser_language, logger, element,
set_login, skip_restore;
promises = [];
path_flag = content_dict.property_dict.path_dict;
......@@ -966,7 +973,6 @@
if (logger !== undefined) {
app.default_dict.state_dict.login = true;
foreign = logger.third_party;
depend = "login_state";
if (foreign) {
switch (foreign.provider) {
case "hellojs":
......@@ -997,11 +1003,11 @@
// setup loader
if (status_flag) {
switch (status_flag.type) {
case "loader": {
case "loader":
app.default_dict.loader = true;
app.default_dict.loader_theme = status_flag.theme;
break;
}
};
}
// create path dict
......@@ -1031,7 +1037,7 @@
}
promises[content_dict.children.length + 1] =
i18n.init(translator, function() {
i18n.init(translator, function () {
return;
});
} else {
......@@ -1040,12 +1046,12 @@
);
}
break;
};
}
}
// start setup
app.checkLoginStatus(set_login)
.then(function(response) {
.then(function (response) {
if (response.error) {
skip_restore = true;
}
......@@ -1061,7 +1067,8 @@
}
return set_state;
})
.then(function(state) {
.then(function (state) {
var open_auth;
// try to register user
if (skip_restore === undefined) {
if (foreign && foreign.initializer_dict) {
......@@ -1077,7 +1084,7 @@
}
return state;
})
.then(function(state) {
.then(function () {
// global elements
if (content_dict.children) {
for (i = 0; i < content_dict.children.length; i += 1) {
......@@ -1146,8 +1153,8 @@
return RSVP.all(promises);
default:
util.error({"error": "setStorage: Missing storage type"});
return RSVP.all(promises)
};
return RSVP.all(promises);
}
},
/**
......@@ -1174,12 +1181,12 @@
* @param {object} url_dict JSON configuration generated from URL
* @param {boolean} create Override to force new page creation
**/
"pageIndex": function (content_dict, url_dict, create) {
"pageIndex": function (content_dict, url_dict) {
var page_dict = content_dict
.children[url_dict ? (url_dict.layout_level || 0) : 0];
if (page_dict === undefined) {
util.error({"error":"Pageindex: Missing page definition"});
util.error({"error": "Pageindex: Missing page definition"});
} else {
// NOTE: 3rd parameter "create" needs to be set to undefined,
......@@ -1190,7 +1197,7 @@
page_dict,
url_dict,
document.getElementById(url_dict.id) ? undefined : true
).then(function(response) {
).then(function (response) {
return response;
});
}
......@@ -1208,7 +1215,7 @@
* @return {object} fragment
**/
"listgrid": function (spec, answer, field_dict, update, url_pointer) {
var element, i, empty, target, placeholder;
var element, i, target, placeholder;
// set update of gadget flag
if (spec.property_dict.depends_on) {
......@@ -1235,7 +1242,7 @@
if (update) {
target = document.createDocumentFragment();
} else {
target = factory.util.wrapInForm(spec)
target = factory.util.wrapInForm(spec);
}
// query has results
......@@ -1260,7 +1267,8 @@
element.children = map.utils.mapListItems(
answer.data.rows,
spec,
url_pointer
url_pointer,
field_dict
);
}
......@@ -1287,8 +1295,7 @@
* @return {object} fragment
**/
"listbox": function (spec, answer, field_dict, update, url_pointer) {
var element, i, empty, target, container, pack, slot, pop, active,
placeholder;
var element, i, target, container, pack, slot, pop, active, placeholder;
// set update of gadget flag
if (spec.property_dict.depends_on) {
......@@ -1308,7 +1315,8 @@
target = factory.util.wrapInForm(spec);
target.appendChild(app.noItemsFound(placeholder.no_auth));
return target;
} else {
}
// determine target element, that will be returned
if (update) {
target = document.createDocumentFragment();
......@@ -1329,7 +1337,7 @@
active = util.getActivePage();
if (document.getElementById(active)
.querySelectorAll("div.local_popup") === null) {
target.appendChild(factory.popup(undefined, active_page));
target.appendChild(factory.popup(undefined, undefined));
}
} else {
if (document.getElementById("global_popup") === null) {
......@@ -1383,7 +1391,6 @@
return container;
}
return target;
}
},
/**
......@@ -1396,7 +1403,7 @@
* @param {object} url_pointer indicates layout used
* @return {object} fragment
**/
"fieldlist": function (spec, answer, field_dict, update, url_pointer) {
"fieldlist": function (spec, answer, field_dict) {
var i, element, target, placeholder, update_gadget, reset_state, data;
// set update of gadget flag
......@@ -1421,7 +1428,8 @@
return target;
// auth or allow
} else {
}
target = document.createDocumentFragment();
if ((answer.data && answer.data.total_rows === 0) ||
......@@ -1440,7 +1448,7 @@
} else {
data = answer.data.rows[0].doc;
if (data === undefined) {
util.errorHandler({"error":"fieldlist: include_docs missing"});
util.error({"error": "fieldlist: include_docs missing"});
}
}
}
......@@ -1462,7 +1470,6 @@
}
return target;
}
}
};
/* ====================================================================== */
......@@ -1501,16 +1508,17 @@
delete new_dict.attributes["data-rel"];
new_dict.direct.className =
new_dict.direct.className.replace(
(off ? "user" : "off"), (off ? "off" : "user")
(off ? "user" : "off"),
(off ? "off" : "user")
);
new_dict.direct.href = off ? "#" : "#global-popup";
new_dict.attributes["data-action"] = off ? "logout_user" : "login";
new_dict.logic["data-reference"] = off ? "google" : null;
new_dict.attributes["data-icon"] = off ? "on" : "off";
new_dict.attributes["data-i18n"] =
"global_dict.common_dict." + off ? "logout" : "login"
"global_dict.common_dict." + off ? "logout" : "login";
new_dict.logic["data-rel"] = off === true ? null : "popup";
new_dict.logic["text"] = off ? "Logout" : "Login";
new_dict.logic.text = off ? "Logout" : "Login";
} else {
new_dict.type = "a";
new_dict.direct = {
......@@ -1528,7 +1536,7 @@
"text": off ? "Logout" : "Login",
"data-rel": off === true ? null : "popup",
"data-reference": off ? "google" : null
}
};
if (off === false) {
new_dict.attributes["data-depend"] = "login_state";
new_dict.attributes["aria-haspopup"] = true;
......@@ -1560,10 +1568,8 @@
// TODO: find a better way
factory.util.generateNestedElement = function (content_dict) {
switch (content_dict.generate) {
case "widget":
return factory[content_dict.type](content_dict, {}, undefined);
default:
switch (content_dict.type) {
case "input":
......@@ -1626,17 +1632,15 @@
factory.util.generatePopupContents = function (obj) {
var i, j, promises, fragment, popup, reference, state;
popup = obj.gadget,
reference = popup.getAttribute("data-reference"),
popup = obj.gadget;
reference = popup.getAttribute("data-reference");
state = popup.getAttribute("data-state");
// don't reload if same popup is opened
if (state !== reference) {
if (reference === null) {
util.error({"error": "Global Bindings: No handler for popup"});
fragment = factory.element(
"p", {}, {}, {"text": "No handler for popup"}
);
util.error({"error": "Global Bindings: No popup handler"});
fragment = factory.element("p", {}, {}, {"text": "No popup handler"});
} else {
popup.setAttribute("data-state", reference);
popup.setAttribute("data-reference", reference);
......@@ -1656,9 +1660,9 @@
promises[i] = app.setContent(reply.children[i], {}, false);
}
}
return RSVP.all(promises)
return RSVP.all(promises);
})
.then(function(content) {
.then(function (content) {
fragment = document.createDocumentFragment();
for (j = 0; j < content.length; j += 1) {
fragment.appendChild(content[j]);
......@@ -1674,7 +1678,7 @@
// append
popup.appendChild(fragment);
})
.then(function() {
.then(function () {
// TODO: how to reposition popup right after appending?
$(popup).popup("reposition", {"positionto": "window"});
})
......@@ -1714,7 +1718,7 @@
"id": spec.id,
"className": (spec.class_list || "")
},
{"data-ajax": false, "autocomplete":"off"},
{"data-ajax": false, "autocomplete": "off"},
{
"data-depend": spec.depend || null,
"data-reset": spec.reset || null
......@@ -1754,7 +1758,7 @@
// TODO: generate without referencing IDs
// NOTE: scope (element id) will make the popup local
factory.popup = function (config_dict, url_dict) {
var i, target, popup, wrap, id, config, container, placeholder;
var i, popup, wrap, id, config, container, placeholder;
if (config_dict === undefined) {
util.error({
......@@ -1936,10 +1940,11 @@
element.direct && element.type !== "controlbar") {
order = i === 0 ? " ui-first-child " :
(i === (config_dict.children.length - 1) ? " ui-last-child " : " ");
(i === (config_dict.children.length - 1) ?
" ui-last-child " : " ");
element.direct.className = (element.direct.className || "") + order +
(element.type === "a" ? (" ui-btn ui-shadow " +
element.direct.className = (element.direct.className || "") +
order + (element.type === "a" ? (" ui-btn ui-shadow " +
factory.generateIconClassString(element)) : " ");
}
......@@ -1987,7 +1992,7 @@
*/
// TODO: Needs pre-enhancement!
factory.panel = function (config_dict, url_dict) {
var i, element, config, id, panel, closer, order, target;
var i, element, config, id, panel, closer, target;
if (config_dict === undefined) {
util.error({
......@@ -2032,7 +2037,8 @@
if (config_dict.children) {
for (i = 0; i < config_dict.children.length; i += 1) {
element = config_dict.children[i];
target = factory.element("div",
target = factory.element(
"div",
{
"className": "panel_element " + (i === 0 ?
"panel_element_first panel_header " :
......@@ -2049,7 +2055,7 @@
element.direct.className += " ui-btn";
}
target.appendChild(app.setContent(element))
target.appendChild(app.setContent(element));
panel.appendChild(target);
}
}
......@@ -2125,10 +2131,11 @@
if ((element.type !== "input" && element.type !== "select") &&
element.direct && element.type !== "controlbar") {
order = i === 0 ? " ui-first-child " :
(i === (spec.length - 1) ? " ui-last-child " : " ");
(i === (config_dict.children.length - 1) ?
" ui-last-child " : " ");
element.direct.className = (element.direct.className || "") + order +
(element.type === "a" ? (" ui-btn ui-shadow " +
element.direct.className = (element.direct.className || "") +
order + (element.type === "a" ? (" ui-btn ui-shadow " +
factory.generateIconClassString(element)) : " ");
}
}
......@@ -2158,7 +2165,7 @@
factory.form = function (spec) {
var i, j, k, layout, element, container, area, field, overrides,
position, doc, config, value, stamp, sauce, encode, secure,
safety_box, noscript, fragment, wrap, item_id;
safety_box, fragment, wrap, item_id;
fragment = factory.util.wrapInForm(spec);
secure = spec.property_dict.secure;
......@@ -2207,12 +2214,12 @@
},
"attributes": {
"placeholder": "Please do not fill out this field",
"data-enhanced":"true",
"data-i18n":"[placeholder]global.form_helpers.secure_blank"
"data-enhanced": "true",
"data-i18n": "[placeholder]global.form_helpers.secure_blank"
},
"logic": {
"plain_element": true,
"label":"Please do not fill out this field",
"label": "Please do not fill out this field",
"label_i18n": "global.form_helpers.secure_blank"
}
}
......@@ -2220,8 +2227,8 @@
container.appendChild(factory.element(
"input",
{
"type":"hidden",
"value":spec.property_dict.secret_hash,
"type": "hidden",
"value": spec.property_dict.secret_hash,
"id": spec.id + "_not_a_secret"
},
{
......@@ -2238,12 +2245,12 @@
},
"attributes": {
"placeholder": "Please leave this value unchanged",
"data-enhanced":"true",
"data-i18n":"[placeholder]global.form_helpers.secure_filled"
"data-enhanced": "true",
"data-i18n": "[placeholder]global.form_helpers.secure_filled"
},
"logic": {
"plain_element": true,
"label":"Please leave this value unchanged",
"label": "Please leave this value unchanged",
"label_i18n": "global.form_helpers.secure_filled"
}
}
......@@ -2255,7 +2262,7 @@
container.appendChild(factory.element(
"input",
{
"type":"hidden",
"type": "hidden",
"value": item_id,
"name": "identifier"
}
......@@ -2408,15 +2415,15 @@
order = i === 0 ? " ui-first-child " :
(i === (spec.children.length - 1) ? " ui-last-child " : " ");
element.direct.className = (element.direct.className || "") + order +
(element.type === "a" ? (" ui-btn ui-shadow " +
element.direct.className = (element.direct.className || "") +
order + (element.type === "a" ? (" ui-btn ui-shadow " +
factory.generateIconClassString(element)) : " ");
}
if (state) {
if (element.generate === undefined) {
if (element.attributes["data-depend"]) {
element = factory.util.convertDict(element, state)
element = factory.util.convertDict(element, state);
}
}
}
......@@ -2492,12 +2499,12 @@
// class string
// TODO: needed?
if ((element.type !== "input" && element.type !== "select") &&
element.direct && type !== "controlbar") {
element.direct) {
order = i === 0 ? " ui-first-child " :
(i === (spec.length - 1) ? " ui-last-child " : " ");
element.direct.className = (element.direct.className || "") + order +
(element.type === "a" ? (" ui-btn ui-shadow " +
element.direct.className = (element.direct.className || "") +
order + (element.type === "a" ? (" ui-btn ui-shadow " +
factory.generateIconClassString(element)) : " ");
}
......@@ -2579,25 +2586,9 @@
// TODO: add collapsible support if needed
// TODO: mesh with live data!
factory.listview = function (spec, url_dict, update) {
var fragment,
config,
list,
i,
item,
props,
divider,
static_item,
j,
input_dict,
action,
block,
target,
icon,
auto,
last,
ribbon,
ribbon_wrap,
theme;
var fragment, config, list, i, item, props, divider, static_item, j,
input_dict, action, block, target, icon, auto, last,
ribbon_wrap, theme;
if (spec === undefined) {
util.errorHanlder({
......@@ -2638,7 +2629,8 @@
config.numbered ? "ol" : "ul",
{
"className": "ui-listview " + (spec.class_list || "") +
(config.inset ? " ui-listview-inset ui-corner-all ui-shadow " : "")
(config.inset ?
" ui-listview-inset ui-corner-all ui-shadow " : "")
},
{"data-role": "listview", "data-enhanced": true},
{
......@@ -2711,7 +2703,7 @@
if (props.ribbon) {
ribbon_wrap = factory.element(
"span",
{"className":"ribbon-wrapper"}
{"className": "ribbon-wrapper"}
);
ribbon_wrap.appendChild(factory.element(
"span",
......@@ -2722,6 +2714,12 @@
if (static_item || divider) {
target = item;
} else {
// jslint...
// TODO: remove!
if (props.href === undefined) {
util.errorHandler({"error": "JSLINT error, ignore"});
props.href = url_dict.href;
}
// link
target = factory.element(
"a",
......@@ -2842,7 +2840,8 @@
"type": "input",
"direct": {
"id": "select_" + props.id,
"name": "select_" + (props.right.check ? props.id : spec.id),
"name": "select_" +
(props.right.check ? props.id : spec.id),
"className": action ? "action" : ""
},
"attributes": input_dict,
......@@ -2899,7 +2898,7 @@
{},
{
"data-slot": slot ? true : null,
"data-slot-id": slot ? slot : null,
"data-slot-id": slot || null,
"data-reference": spec.reference || null
}
);
......@@ -2934,17 +2933,12 @@
*/
// NOTE: we are defaulting to fixed toolbars!
factory.page = function (content_dict, url_dict, create) {
var i,
j,
k,
last,
element,
wrapper,
split_url,
promises = [],
container = document.getElementById(url_dict.id),
target = document.createDocumentFragment(),
view = (url_dict && url_dict.mode) ? url_dict.mode : "default",
var i, j, last, wrapper, split_url, promises = [], container, target,
view, render;
container = document.getElementById(url_dict.id);
target = document.createDocumentFragment();
view = (url_dict && url_dict.mode) ? url_dict.mode : "default";
render = content_dict.layout[view];
if (render) {
......@@ -2953,7 +2947,7 @@
promises[i] = app.setContent(render[i], url_dict, create);
}
} else {
util.errorHandler({"error":"factory.page: Missing view"});
util.error({"error": "factory.page: Missing view"});
}
return RSVP.all(promises)
......@@ -3097,8 +3091,9 @@
*/
// TODO: pre-enhance!
// TODO: refactor the passing around of information. This is not nice!!!
/* Jslint: unused: true */
factory.table = function (spec, url_dict, update) {
var i, container, config, table, section, method;
var i, container, config, section, method;
if (spec === undefined) {
util.errorHanlder({
......@@ -3118,7 +3113,7 @@
{
"data-role": "table",
"data-mode": config.mode,
"data-use-pop": config.toggle_popup === false ? false : true,
"data-use-pop": config.toggle_popup === false ? false : true
},
{
"id": config.id || null,
......@@ -3160,9 +3155,9 @@
*/
// TODO: merge check/radio on table and listview!
factory.tableRow = function (spec, body) {
var i, j, k, field, link, config, property, title, action, cell, set, text,
column_list, temp, container, row, group, button, input_type, checkered,
global_check, skip, input_dict, snippet;
var i, j, k, field, link, attributes, property, title, action, cell, set,
column_list, temp, container, row, group, button, input_type,
global_check, skip, input_dict, snippet, logic;
// checkbox row
if (spec.config.check) {
......@@ -3176,7 +3171,7 @@
}
// radio row
if(spec.config.radio) {
if (spec.config.radio) {
input_type = "radio";
if (body === null) {
skip = true;
......@@ -3244,31 +3239,32 @@
for (j = 0; j < column_list.length; j += 1) {
field = column_list[j];
link = undefined;
config = {};
text = null;
attributes = {};
logic = {};
property = field.column;
if (field.show) {
if (field.merge === undefined) {
if (field.text_i18n) {
config["data-i18n"] = field.text_i18n;
attributes["data-i18n"] = field.text_i18n;
}
if (field.persist === undefined) {
config["data-priority"] = field.priority || 6;
attributes["data-priority"] = field.priority || 6;
}
// set title to title or merger_title stored in temp
snippet = (field.title || field.text);
title = temp[property] ? snippet + " " + temp[property][0] : snippet;
title = temp[property] ? snippet + " " + temp[property][0] :
snippet;
// cell action buttons
if (field.action_list && field.action_list.length) {
if ((field.action_list && field.action_list.length)) {
group = {
"generate":"widget",
"generate": "widget",
"type": "controlgroup",
"property_dict": {"direction": "horizontal"},
"children": []
}
};
// can be single action or a button group!
for (k = 0; k < field.action_list.length; k += 1) {
button = field.action_list[k];
......@@ -3291,9 +3287,9 @@
// hijack link variable
link = app.setContent(group);
// links & sorting
// links and/or sorting
} else if ((!body && spec.config.sortable && field.sort) ||
spec.config.linkable && field.href) {
(spec.config.linkable && field.href)) {
// header link (sorting) or href link
link = factory.element(
......@@ -3310,30 +3306,33 @@
"data-reference": field.href ? null : spec.config.reference,
"data-column-title": field.href ? null : field.column,
"text": title || null,
"img": field.image ? {"href": field.image, "alt": null, "alt_i18n": null} : null,
"img": field.image ?
{"href": field.image, "alt": null, "alt_i18n": null} :
null,
"href": field.href || null,
"data-i18n": field.href ? null : (field.text_i18n ?
(temp[property] ? temp[property][1] : field.text_i18n) :
null),
null)
}
);
// image
} else if (field.image) {
logic = {
"img": field.image
};
logic.img = field.image;
// default
} else {
text = {"text": title};
logic.text = title;
}
// make the cell
cell = factory.element(
body ? "td" : "th",
{"className": link ? "" : "translate plain"},
config,
text
attributes,
logic
);
// add the link/action menu
if (link) {
cell.appendChild(link);
......@@ -3342,7 +3341,8 @@
if (spec.config.mergeable) {
row.insertBefore(
cell,
(set === undefined ? null : row.childNodes[spec.config.check ? 1 : 0])
(set === undefined ? null :
row.childNodes[spec.config.check ? 1 : 0])
);
set = true;
} else {
......@@ -3370,7 +3370,7 @@
* @returns {object} target
*/
factory.tableBody = function (spec, update) {
var l, target;
var target;
if (update) {
target = document.createDocumentFragment();
......@@ -3895,7 +3895,7 @@
test_full, test_empty, test_time, form_to_submit, anti_spam, formData,
valid, pass_id;
pass = false
pass = false;
form_to_submit = document.getElementById(config.id);
anti_spam = document.getElementById(form_to_submit.id + "_not_a_secret");
formData = new FormData();
......@@ -3907,7 +3907,7 @@
if (anti_spam) {
// fill form in < 1sec = spammer
if (Date.now() - parseInt(anti_spam.getAttribute("data-created"))
if (Date.now() - parseInt(anti_spam.getAttribute("data-created"), 10)
> 1000) {
test_time = true;
}
......@@ -3916,7 +3916,7 @@
form_elements = form_to_submit.getElementsByTagName("input");
for (i = 0; i < form_elements.length; i += 1) {
form_element = form_elements[i];
if(util.testForString("secure_form", form_element.className)) {
if (util.testForString("secure_form", form_element.className)) {
if (form_element.value === "") {
test_empty = true;
}
......@@ -3960,19 +3960,19 @@
"response": [obj],
"pass": {"type": config.gadget.state.type, "reply": true}
})
.then(function(answer) {
.then(function (answer) {
if (answer.response.result === "success") {
pass_id = answer.response.id;
switch (config.gadget.getAttribute("data-reset")) {
case "login_state":
app.setLoginStatus(answer.response, config.portal_type_source);
break;
};
}
util.loader("", "global_dict.status_dict.saved", "check");
return pass_id;
}
})
.then(function(id) {
.then(function (id) {
if (id && config.state.callback) {
$.mobile.changePage(config.state.callback.replace("__id__", id));
}
......@@ -4048,7 +4048,7 @@
"attachment": config.id,
"pass": undefined
})
.then(function(gadget_config) {
.then(function (gadget_config) {
// portal_type fieldlist
return app.fetchConfiguration({
"storage": app.default_dict.storage_dict.settings,
......@@ -4057,7 +4057,7 @@
"pass": {
"portal_type": gadget_config.portal_type_source
}
})
});
})
.then(function (reply) {
// update gadget state
......@@ -4071,11 +4071,11 @@
// update gadget
app.setContent(
{"generate":"gadget", "id": config.id, "href": config.id},
{"generate": "gadget", "id": config.id, "href": config.id},
{"fragment_list": config.state.fragment_list},
false
)
.then(function (reply){
.then(function (reply) {
factory.util.updatePageSection(config.id, reply);
})
.fail(util.error);
......@@ -4093,12 +4093,12 @@
// fetch profile
return hello(provider).api("/me")
.then(function(profile) {
.then(function (profile) {
// build query
token = "person_token_" + provider;
query = app.generateQueryObject(
{"limit": [0,1]},
{"limit": [0, 1]},
"Person",
token,
profile.id
......@@ -4127,9 +4127,8 @@
"response": [user],
"pass": {"type": "Person"}
});
} else {
util.error({"error": "regiser user: need account sync!"});
}
util.error({"error": "regiser user: need account sync!"});
}
})
.fail(util.error);
......@@ -4212,11 +4211,11 @@
// wait 500ms on multi-state sorting (table), single state trigger directly
app.timer = window.setTimeout(function () {
app.setContent(
{"generate":"gadget", "id": config.id, "href": config.id},
{"generate": "gadget", "id": config.id, "href": config.id},
{"fragment_list": config.state.fragment_list},
false
)
.then(function (reply){
.then(function (reply) {
factory.util.updatePageSection(config.id, reply);
})
.fail(util.error);
......@@ -4350,7 +4349,7 @@
start = config.state.query.limit[0];
records = parseInt(value, null);
break;
};
}
if (start > config.state.total || start < 0) {
return;
......@@ -4366,14 +4365,15 @@
// update gadget
app.setContent(
{"generate":"gadget", "id": config.id, "href": config.id},
{"generate": "gadget", "id": config.id, "href": config.id},
{"fragment_list": config.state.fragment_list},
false
)
.then(function (reply){
.then(function (reply) {
factory.util.updatePageSection(config.id, reply);
})
.fail(util.error);
} else {
util.error({"Error": "No state information stored for gadget"});
}
......@@ -4406,16 +4406,16 @@
content = [{
"type": "a",
"direct": {
"href":"#",
"href": "#",
"className": "ui-corner-all ui-btn ui-shadow ui-btn-inline " +
"ui-icon-chevron-sign-left ui-btn-icon-left translate "
},
"attributes": {
"data-rel":"back",
"data-i18n":"global_dict.pagination_dict.back"
"data-rel": "back",
"data-i18n": "global_dict.pagination_dict.back"
},
"logic": {"Text": "Back"}
}]
}];
}
// <p> is not flexible...
......@@ -4443,11 +4443,11 @@
* @param {object} response Object initiating the status update
* @param {string} portal_type Portal Type concerned
**/
app.setLoginStatus = function (response, portal_type) {
app.setLoginStatus = function (response) {
var stamp, provider, auth, links, i, login;
stamp = Date.now();
provider = response.network ? response.network.slice(0,2) : "self";
provider = response.network ? response.network.slice(0, 2) : "self";
auth = response.authResponse;
if (flux.state === undefined) {
......@@ -4459,7 +4459,7 @@
"token": auth ? auth.access_token : response.id,
"issued": stamp,
"expires": auth ? auth.expires_in : 3600
}
};
// need to update the .... button
// TODO: make a login gadget, store dependend buttons in state
links = util.getHeader().getElementsByTagName("A");
......@@ -4485,14 +4485,14 @@
// TODO: make this work with a regular login, too!!!
// TODO: refactor, make sure we always pass a pass!
app.checkLoginStatus = function (skip, pass) {
var state, lookup, logger, provider, verify, url, influx, info,
valid, auth_config, stamp, expires, expired, token, auth_response,
signee;
var state, logger, provider, verify, url, signee, valid, auth_config,
stamp, expires, auth_response;
if (skip === undefined) {
// TODO: name collusion! make normal pass object!
return RSVP.resolve({"pass": skip});
} else {
}
logger = app.default_dict.state_dict.login_pointer;
verify = app.default_dict.state_dict.verification_dict;
......@@ -4523,11 +4523,10 @@
}
// test for timeout
if (auth_config.issued && auth_config.expires) {
expires = auth_config.issued + (auth_config.expires*1000);
expires = auth_config.issued + (auth_config.expires * 1000);
if (expires > stamp) {
valid = true;
} else {
expired = true;
delete state[provider];
}
}
......@@ -4550,7 +4549,7 @@
// if we have a url, we have an access token, check if it's valid
if (url) {
return util.ajax({"url": url})
.then(function(answer) {
.then(function (answer) {
auth_response = util.parseIfNeeded(answer.target.response);
if (pass) {
pass.active_login = true;
......@@ -4560,9 +4559,8 @@
return RSVP.resolve(pass);
}
return auth_response;
return util.parseIfNeeded(answer.target.response);
})
.fail(function(event) {
.fail(function (event) {
// invalid session > return 400, so we are back on the then-column
if (event.target.status === 400) {
auth_response = util.parseIfNeeded(event.target.response);
......@@ -4580,10 +4578,8 @@
return RSVP.resolve(pass);
}
return RSVP.resolve({"error": "no state found/not logged in"});
} else {
util.error({"error":"loginStatus: Missing login handler."});
}
}
util.error({"error": "loginStatus: Missing login handler."});
};
/**
......@@ -4598,31 +4594,17 @@
// TODO: refactor, this is quite the crap...
// TODO: don't reset all 4 fields on every action!
app.updateInfoElement = function (element, options, total, selected) {
var i,
j,
k,
l,
reference,
selection,
info_field,
min,
pointer,
text_snippet,
i18n_snippet,
zero_no_show,
select_counter,
no_limit,
no_items,
slot,
first,
last,
info_field_list = element.querySelectorAll(".info"),
info = "",
var i, j, l, selection, info_field, min, pointer, no_items,
text_snippet, i18n_snippet, zero_no_show, select_counter, no_limit,
slot, first, last, info, info_field_list, generateInfo;
info_field_list = element.querySelectorAll(".info");
info = "";
generateInfo = function (text, text_i18n) {
return factory.element(
"span",
{"className":"translate"},
{"data-i18n":"global_dict.info_dict." + text_i18n},
{"className": "translate"},
{"data-i18n": "global_dict.info_dict." + text_i18n},
{"text": text}
);
};
......@@ -4651,7 +4633,10 @@
no_limit = options.limit[0] || 0;
no_items = options.limit[1] || 0;
zero_no_show = (no_limit === 0 && total !== 0) ? 1 : no_limit;
min = Math.min(total, ((no_limit + no_items === 0) ? (total) : no_limit + no_items));
min = Math.min(
total,
((no_limit + no_items === 0) ? total : no_limit + no_items)
);
info = zero_no_show + "-" + min + "/" + total;
text_snippet = " Records";
i18n_snippet = "records";
......@@ -4771,16 +4756,12 @@
// WARNING: complex_queries dependency!
// TODO: make "foo" = "bar" handle more complexity passed via ... url
app.generateQueryObject = function (query, type, key, value, field_list) {
var parameter,
property,
wrap,
query_object,
query_clean,
default_query = query || {},
obj = {},
is_value = value && value !== "";
var property, wrap, query_object, query_clean, default_query, obj,
is_value;
obj.query = '';
default_query = query || {};
obj = {"query": ''};
is_value = value && value !== "";
// query string passed? parse it
if (default_query.query) {
......@@ -4818,7 +4799,13 @@
wrap = "";
for (property in field_list) {
if (field_list.hasOwnProperty(property)) {
if (!util.findKey((query_object || {}), "query_list", "key", property)) {
if (!util.findKey(
(query_object || {}),
"query_list",
"key",
property
)
) {
wrap += property + ': "%' + value + '%" OR ';
}
}
......@@ -4865,10 +4852,10 @@
* @return {object} pointer object
*/
app.generateLinkObject = function (url) {
var i, query, parameter, path, clean_hash, config, backup;
var i, query, path, clean_hash, config, backup;
path = $.mobile.path.parseUrl(url.replace($.mobile.dialogHashKey, "")),
clean_hash = path.hash.replace("#", ""),
path = $.mobile.path.parseUrl(url.replace($.mobile.dialogHashKey, ""));
clean_hash = path.hash.replace("#", "");
backup = 0;
config = {
"url": url
......@@ -4885,7 +4872,7 @@
// TODO: this should be generic and without a backup....
for (i = 0; i < query.length; i += 1) {
switch(query[i]) {
switch (query[i]) {
case "new":
config.mode = "new";
backup = 1;
......@@ -4897,7 +4884,7 @@
case "config":
config.mode = "config";
break;
};
}
}
config.fragment_list = clean_hash.split("::");
......@@ -4967,7 +4954,7 @@
if (title && i18n) {
translation = map.actions.translateLookup(
"page_dict." + title.split("?")[0] + ".title"
)
);
translation_failed = util.testForString(title, translation, true);
}
// return link element
......@@ -5048,30 +5035,36 @@
add = doc.addEventListener ? 'addEventListener' : 'attachEvent',
rem = doc.addEventListener ? 'removeEventListener' : 'detachEvent',
pre = doc.addEventListener ? '' : 'on',
init = function(e) {
if (e.type == 'readystatechange' && doc.readyState != 'complete') {
init = function (e) {
if (e.type === 'readystatechange' && doc.readyState !== 'complete') {
return;
}
(e.type == 'load' ? win : doc)[rem](pre + e.type, init, false);
if (!done && (done = true)) {
(e.type === 'load' ? win : doc)[rem](pre + e.type, init, false);
if (!done) {
done = true;
fn.call(win, e.type || e);
}
},
poll = function() {
poll = function () {
try {
root.doScroll('left');
} catch(e) {
setTimeout(poll, 50); return;
} catch (e) {
window.setTimeout(poll, 50);
return;
}
init('poll');
};
if (doc.readyState == 'complete') {
if (doc.readyState === 'complete') {
fn.call(win, 'lazy');
} else {
if (doc.createEventObject && root.doScroll) {
try { top = !win.frameElement; } catch(e) { }
if (top) poll();
try {
top = !win.frameElement;
} catch (ignore) {}
if (top) {
poll();
}
}
doc[add](pre + 'DOMContentLoaded', init, false);
doc[add](pre + 'readystatechange', init, false);
......@@ -5086,14 +5079,14 @@
* @return {object} response object/promise
*/
app.generateGadgetContent = function (reply) {
var selector, element, pass, constructor, translate, data, data_set;
var selector, element, pass, constructor, data, data_set;
pass = reply.pass;
constructor = map.gadgets[pass.constructor];
if (constructor === undefined) {
return util.error(
{"error":"generateGadgetContent: Missing constructor"}
{"error": "generateGadgetContent: Missing constructor"}
);
}
......@@ -5105,14 +5098,16 @@
data = null;
}
// overwrite depending on new and allow_new
if (pass.mode === "new" && (data_set || pass.config.property_dict.allow_new)) {
if (pass.mode === "new" &&
(data_set || pass.config.property_dict.allow_new)) {
data = {"request_new": true};
}
// no content? Just call constructor and DONE!
if (pass.skip) {
return constructor(pass.content_dict, pass.url_dict);
} else {
}
// generate content
element = constructor(
pass.config,
......@@ -5155,7 +5150,7 @@
selector.state = pass.state;
// not auth, no mojo!
if (pass.no_auth || (pass.auth && pass.active_login ||
if (pass.no_auth || ((pass.auth && pass.active_login) ||
pass.mode === "new")) {
app.updateInfoElement(
......@@ -5166,7 +5161,6 @@
}
return element;
}
};
/**
......@@ -5221,7 +5215,7 @@
* @return {object} response object/promise
*/
app.fetchDataTotal = function (reply) {
var pass = reply.pass, reference, identifier, search_string;
var pass = reply.pass, reference;
if (pass.skip === undefined) {
// create or update state object
......@@ -5265,7 +5259,7 @@
}
if (pass.skip === undefined &&
(pass.no_auth || (pass.auth && pass.active_login ||
(pass.no_auth || ((pass.auth && pass.active_login) ||
(pass.mode === "new" || pass.purge)))) {
// skip total for single item layouts!
......@@ -5302,7 +5296,7 @@
pass = reply.pass;
if (reply.response) {
store = storage["items"];
store = storage.items;
items = util.parseIfNeeded(reply.response);
if (store && items.length > 0) {
......@@ -5330,7 +5324,7 @@
}
promises[i] = store[method || "post"](obj)
.then(function(answer) {
.then(function (answer) {
return answer;
});
}
......@@ -5372,7 +5366,7 @@
return util.ajax(
{"url": "data/" + pass.config.portal_type_title + "_sample.json"}
)
.then(function(e) {
.then(function (e) {
return {
"response": e.target.response,
"pass": pass
......@@ -5435,7 +5429,7 @@
// fetch field definitions
if (pass.skip === undefined &&
(pass.no_auth || (pass.auth && pass.active_login ||
(pass.no_auth || ((pass.auth && pass.active_login) ||
pass.mode === "new")) &&
pass.config.portal_type_fields) {
......@@ -5475,16 +5469,16 @@
// test for authentication
if (pass.auth) {
return app.checkLoginStatus(true, pass)
.then(function(new_pass) {
.then(function (new_pass) {
return {
"pass": new_pass
}
};
})
.fail(util.error);
}
return {
"pass": pass
}
};
};
/**
......@@ -5499,14 +5493,14 @@
// TODO: make this always return a promise. Requires to refactor listview!
// TODO: only pass around what we need. pass.CONFIG is too much!
app.setContent = function (content_dict, url_dict, create, purge) {
var i, skip, container, target, pass, spec, dependency;
var pass, spec;
spec = url_dict || {};
switch (content_dict.generate) {
case "widget":
return factory[content_dict.type](content_dict, spec, create)
return factory[content_dict.type](content_dict, spec, create);
case "gadget":
// no portal_type, no dynamic data
......@@ -5546,10 +5540,8 @@
})
.then(app.parseConfiguration)
.then(app.loadFieldDefinition)
// ===== SAMPLE DATA ========
.then(app.testStorageForData)
.then(app.retrieveSampleData)
// ===== SAMPLE DATA ========
.then(app.store)
.then(app.fetchDataTotal)
.then(app.fetchDataQuery)
......@@ -5560,7 +5552,7 @@
switch (content_dict.type) {
case "input":
case "select":
return factory.formElement(content_dict, false)
return factory.formElement(content_dict, false);
default:
return factory.element(
content_dict.type,
......@@ -5617,7 +5609,7 @@
"file": parcel.file,
"attachment": parcel.attachment,
"pass": parcel.pass
})
});
}
// NOTE: throw to get back in success chain!!!
throw error;
......@@ -5660,15 +5652,14 @@
if (url === undefined) {
if (property_dict.optional) {
return RSVP.all([]);
} else {
util.error({"error": "getFromDisk: URL undefined"});
}
util.error({"error": "getFromDisk: URL undefined"});
}
// fetch file
return util.ajax({"url": url})
.then(function(e) {
response = response = util.parseIfNeeded(e.target.responseText);
.then(function (e) {
response = util.parseIfNeeded(e.target.responseText);
// no need to store? go to next then()
if (property_dict.skip) {
......@@ -5690,8 +5681,10 @@
})
.then(function () {
return storage_location.putAttachment({
"_id": (property_dict.file || app.default_dict.storage_dict.settings),
"_attachment": (property_dict.attachment || app.default_dict.storage_dict.configuration),
"_id": (property_dict.file ||
app.default_dict.storage_dict.settings),
"_attachment": (property_dict.attachment ||
app.default_dict.storage_dict.configuration),
"_data": JSON.stringify(response),
"_mimetype": "application/json"
});
......@@ -5898,13 +5891,9 @@
*/
// TODO: add local popups!
app.setPageBindings = function () {
var i,
j,
form_element,
filterable,
captcha,
result,
form_list = document.getElementsByTagName("form"),
var i, j, form_element, filterable, captcha, form_list, filter_list;
form_list = document.getElementsByTagName("form");
filter_list = document.querySelectorAll("[data-filter]");
// disable default filtering of JQM filterable
......@@ -5927,7 +5916,7 @@
if (captcha) {
util.declareJS(
"http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"
).then(function(e) {
).then(function () {
Recaptcha.create(
captcha.getAttribute("data-key"),
captcha.id,
......@@ -5976,96 +5965,6 @@
*/
util.storage_dict = {};
/**
* cookie handler
* thx: https://developer.mozilla.org/en-US/docs/Web/API/document.cookie
* @object handleCookie
**/
util.cookieHandler = {
/**
* Get a cookie
* @method getItem
* @param {string} sKey Cookie name
* @return {string} cookie value
**/
getItem: function (sKey) {
return decodeURIComponent(
document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" +
encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") +
"\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
},
/**
* Set a cookie
* @method setItem
* @param {string} sKey Cookie name
* @param {string} sValue Cookie value
* @param {string} sPath Cookie path
* @param {string} sDomain Cookie domain
* @param {string} bSecure Cookie security flag
* @return {boolean} true/false
**/
setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) {
if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) {
return false;
}
var sExpires = "";
if (vEnd) {
switch (vEnd.constructor) {
case Number:
sExpires = vEnd === Infinity ?
"; expires=Fri, 31 Dec 9999 23:59:59 GMT" :
"; max-age=" + vEnd;
break;
case String:
sExpires = "; expires=" + vEnd;
break;
case Date:
sExpires = "; expires=" + vEnd.toUTCString();
break;
}
}
document.cookie = encodeURIComponent(sKey) + "=" +
encodeURIComponent(sValue) + sExpires +
(sDomain ? "; domain=" + sDomain : "") +
(sPath ? "; path=" + sPath : "") +
(bSecure ? "; secure" : "");
return true;
},
/**
* Remove a cookie
* @method removeItem
* @param {string} sKey Name of the cookie
* @param {string} sPath Cookie path
* @param {string} sDomain Cookie domain
* @return {boolean} true/falsely
**/
removeItem: function (sKey, sPath, sDomain) {
if (!sKey || !this.hasItem(sKey)) {
return false;
}
document.cookie = encodeURIComponent(sKey) +
"=; expires=Thu, 01 Jan 1970 00:00:00 GMT" +
( sDomain ? "; domain=" + sDomain : "") +
( sPath ? "; path=" + sPath : "");
return true;
},
/**
* Check if a cookie exists
* @method hasItem
* @param {string} Cookie name
* @return true/false
**/
hasItem: function (sKey) {
return (new RegExp("(?:^|;\\s*)" +
encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") +
"\\s*\\=")).test(document.cookie);
}
};
/**
* Generate a UUID ticket for a transaction
* @method generateUuid
......@@ -6095,15 +5994,16 @@
var s = '',
randomchar = function () {
var n = Math.floor(Math.random() * 62);
if(n < 10) {
if (n < 10) {
return n; //1-10
}
if(n < 36) {
if (n < 36) {
return String.fromCharCode(n + 55); //A-Z
}
return String.fromCharCode(n + 61); //a-z
}
while(s.length < len) {
};
while (s.length < len) {
s += randomchar();
}
return s;
......@@ -6206,7 +6106,7 @@
* @param {string} theme background theme
* @param {string} icon Which icon to display when overriding the loader
*/
util.loader = function (message, msg_i18n, icon, theme) {
util.loader = function (message, msg_i18n, icon) {
var text_to_display = i18n && msg_i18n ?
map.actions.translateLookup(msg_i18n) : message;
......@@ -6444,12 +6344,13 @@
);
container = factory.element(
"p", {"class": "responsive ui-content-element"}
"p",
{"class": "responsive ui-content-element"}
);
container.appendChild(factory.element(
"span",
{"class":"translate"},
{"data-i18n":"validation.fail.browser_support"},
{"class": "translate"},
{"data-i18n": "validation.fail.browser_support"},
{"text": "Your browser does not support: "}
));
container.appendChild(factory.element(
......@@ -6462,10 +6363,10 @@
return false;
}
return true;
} else {
}
util.error({"error": "testBrowserSupport: Modernizr undefined"});
return false;
}
};
/* ====================================================================== */
......@@ -6473,7 +6374,7 @@
/* ====================================================================== */
/**
* Capture errors, log to console and trigger bugticker
* @method errorHandler
* @method error
* @param {object} err Error object
*/
// TODO: update global config so we know where to post a ticket to!
......@@ -6504,7 +6405,7 @@
app.getFromDisk({
"url": util.getPathFromScriptTag("data-storage"),
"optional":true,
"optional": true,
"skip": true
})
.then(app.setContent)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment