Commit 7f3332b0 authored by Sven Franck's avatar Sven Franck

app: no more for-loops over .length

parent 5075ff95
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
**/ **/
// TODO: optgroup support! // TODO: optgroup support!
factory.element = function (spec) { factory.element = function (spec) {
var element, setter, attribute, logic, item, i, mock, recurse, pic; var element, setter, attribute, logic, item, i, mock, recurse, pic, len;
// element // element
element = document.createElement(spec.type); element = document.createElement(spec.type);
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
break; break;
case "options": case "options":
if (logic.options) { if (logic.options) {
for (i = 0; i < logic.options.length; i += 1) { for (i = 0, len = logic.options.length; i < len; i += 1) {
recurse = logic.options[i]; recurse = logic.options[i];
if (recurse) { if (recurse) {
element.appendChild(factory.element({ element.appendChild(factory.element({
...@@ -1745,9 +1745,7 @@ ...@@ -1745,9 +1745,7 @@
"logic": {} "logic": {}
}); });
len = spec.total_rows || spec.length; for (i = 0, len = spec.total_rows || spec.length; i < len; i += 1) {
for (i = 0; i < len; i += 1) {
radio_id = "radio-" + id; radio_id = "radio-" + id;
controller.appendChild(factory.widget.formElement({ controller.appendChild(factory.widget.formElement({
"type": "input", "type": "input",
...@@ -2053,9 +2051,9 @@ ...@@ -2053,9 +2051,9 @@
var fragment, container, generator, counter, section, i, tag, image; var fragment, container, generator, counter, section, i, tag, image;
counter = function (scheme) { counter = function (scheme) {
var m, field, k; var m, field, k, len;
for (k = 0, m = 0; m < scheme.field_list.length; m += 1) { for (len = scheme.field_list.length, k = 0, m = 0; m < len; m += 1) {
field = scheme.field_list[m]; field = scheme.field_list[m];
if ((field.field || field.custom) && field.merge === undefined) { if ((field.field || field.custom) && field.merge === undefined) {
k += 1; k += 1;
...@@ -2075,7 +2073,7 @@ ...@@ -2075,7 +2073,7 @@
generator = function (generator_spec) { generator = function (generator_spec) {
var quirk_dict, row, temp, cell, j, field, link, logic, faux_id, var quirk_dict, row, temp, cell, j, field, link, logic, faux_id,
attributes, property, snippet, title, k, button, group, dict, set, attributes, property, snippet, title, k, button, group, dict, set,
wrap, lookup, item_href, element; wrap, lookup, item_href, element, len, el_len, scheme_len;
element = generator_spec.item; element = generator_spec.item;
quirk_dict = generator_spec.wrapper.property_dict; quirk_dict = generator_spec.wrapper.property_dict;
...@@ -2129,7 +2127,7 @@ ...@@ -2129,7 +2127,7 @@
} }
// loop cells // loop cells
for (j = 0; j < element.length; j += 1) { for (j = 0, el_len = element.length; j < el_len; j += 1) {
field = element[j]; field = element[j];
link = undefined; link = undefined;
attributes = {}; attributes = {};
...@@ -2161,7 +2159,7 @@ ...@@ -2161,7 +2159,7 @@
// action menu (calling widget is cheating...) // action menu (calling widget is cheating...)
if (field.action_list) { if (field.action_list) {
group = factory.widget.controlgroup({"direction": "horizontal"}); group = factory.widget.controlgroup({"direction": "horizontal"});
for (k = 0; k < field.action_list.length; k += 1) { for (k = 0, len = field.action_list.length; k < len ; k += 1) {
button = field.action_list[k]; button = field.action_list[k];
if (field.id) { if (field.id) {
item_href = window.encodeURIComponent(field.id); item_href = window.encodeURIComponent(field.id);
...@@ -2290,7 +2288,7 @@ ...@@ -2290,7 +2288,7 @@
}); });
// header // header
for (i = 0; i < spec.scheme.length; i += 1) { for (i = 0, scheme_len = spec.scheme.length; i < scheme_len; i += 1) {
section = spec.scheme[i]; section = spec.scheme[i];
switch (section.position) { switch (section.position) {
case "header": case "header":
...@@ -2343,7 +2341,6 @@ ...@@ -2343,7 +2341,6 @@
factory.crumbs = function (spec) { factory.crumbs = function (spec) {
var i, crumb, base, breadcrumb, makeLink, len, pass, icon, patch, space; var i, crumb, base, breadcrumb, makeLink, len, pass, icon, patch, space;
len = (spec.children || []).length;
base = ""; base = "";
space = document.createTextNode("\u00A0"); space = document.createTextNode("\u00A0");
patch = "#"; patch = "#";
...@@ -2384,7 +2381,7 @@ ...@@ -2384,7 +2381,7 @@
} }
// fragments // fragments
for (i = 0; i < len; i += 1) { for (i = 0, len = (spec.children || []).length; i < len; i += 1) {
crumb = spec.children[i]; crumb = spec.children[i];
if (typeof crumb === "string") { if (typeof crumb === "string") {
pass = { pass = {
...@@ -2745,7 +2742,7 @@ ...@@ -2745,7 +2742,7 @@
* @return {object} finished config object * @return {object} finished config object
**/ **/
factory.util.searchBar = function (spec) { factory.util.searchBar = function (spec) {
var i, element_list, search_id, props, class_list, spec_list; var i, element_list, search_id, props, class_list, spec_list, len;
search_id = spec.search_id = "search_" + util.uuid(); search_id = spec.search_id = "search_" + util.uuid();
props = spec.slot ? {"slot": spec.slot} : {}; props = spec.slot ? {"slot": spec.slot} : {};
...@@ -2753,7 +2750,7 @@ ...@@ -2753,7 +2750,7 @@
element_list = [factory.util.searchBarTemplate(spec)]; element_list = [factory.util.searchBarTemplate(spec)];
spec_list = spec.info_list || []; spec_list = spec.info_list || [];
for (i = 0; i < spec_list.length; i += 1) { for (i = 0, len = spec_list.length; i < len; i += 1) {
element_list.push({ element_list.push({
"type": "div", "type": "div",
"direct": {"className": "info"}, "direct": {"className": "info"},
...@@ -3116,7 +3113,8 @@ ...@@ -3116,7 +3113,8 @@
**/ **/
// TODO: don't call this so often on init // TODO: don't call this so often on init
"translateNodeList": function (nodeList, single) { "translateNodeList": function (nodeList, single) {
var i, l, element, lookup, targets, target, route_text, elements, len; var i, l, element, lookup, targets, target, route_text, elements, len,
target_len;
elements = single ? [nodeList] : nodeList.querySelectorAll(".translate"); elements = single ? [nodeList] : nodeList.querySelectorAll(".translate");
...@@ -3142,7 +3140,7 @@ ...@@ -3142,7 +3140,7 @@
} else { } else {
targets = [lookup]; targets = [lookup];
} }
for (l = 0; l < targets.length; l += 1) { for (l = 0, target_len = targets.length; l < target_len; l += 1) {
target = targets[l].split("]"); target = targets[l].split("]");
// all hail performance // all hail performance
...@@ -3451,7 +3449,7 @@ ...@@ -3451,7 +3449,7 @@
// TODO: subordinate handling // TODO: subordinate handling
// TODO: pick translations from field_dict for header! // TODO: pick translations from field_dict for header!
map.tableItem = function (spec) { map.tableItem = function (spec) {
var j, k, segment, row, cell, id, quirk_dict, record, new_item, item; var j, k, segment, row, cell, id, quirk_dict, record, new_item, item, len;
quirk_dict = spec.wrapper.property_dict; quirk_dict = spec.wrapper.property_dict;
item = spec.item; item = spec.item;
...@@ -3474,7 +3472,7 @@ ...@@ -3474,7 +3472,7 @@
row = []; row = [];
// loop field_list = cells // loop field_list = cells
for (k = 0; k < segment.field_list.length; k += 1) { for (k = 0, len = segment.field_list.length; k < len; k += 1) {
cell = util.mergeObject( cell = util.mergeObject(
new_item, new_item,
util.cloneObject(segment.field_list[k]) util.cloneObject(segment.field_list[k])
...@@ -3511,7 +3509,8 @@ ...@@ -3511,7 +3509,8 @@
// NOTE: make sure there is no "id" flying through here!!! only _id // NOTE: make sure there is no "id" flying through here!!! only _id
map.listItem = function (spec) { map.listItem = function (spec) {
var quirk_dict, section, label, j, k, field, setter, record, new_item, var quirk_dict, section, label, j, k, field, setter, record, new_item,
id, key, translation_fields, item, relation, promise_list, pass, count; id, key, translation_fields, item, relation, promise_list, pass, count,
len, scheme_len;
promise_list = []; promise_list = [];
translation_fields = "titletextlabel"; translation_fields = "titletextlabel";
...@@ -3547,11 +3546,11 @@ ...@@ -3547,11 +3546,11 @@
} }
// loop scheme sections // loop scheme sections
for (j = 0; j < item.scheme.length; j += 1) { for (j = 0, scheme_len = item.scheme.length; j < scheme_len; j += 1) {
section = item.scheme[j]; section = item.scheme[j];
// loop scheme fields // loop scheme fields
for (k = 0; k < section.field_list.length; k += 1) { for (k = 0, len = section.field_list.length; k < len; k += 1) {
field = section.field_list[k]; field = section.field_list[k];
key = field.value || field.field || ""; key = field.value || field.field || "";
relation = key.split("subordinate_"); relation = key.split("subordinate_");
...@@ -3619,7 +3618,8 @@ ...@@ -3619,7 +3618,8 @@
var helper, getHelp, j, k, segment, section, field, setValue, root, veto, var helper, getHelp, j, k, segment, section, field, setValue, root, veto,
textarea_value, override_value, value, field_value, validation_list, textarea_value, override_value, value, field_value, validation_list,
class_list, el, type, clear, alt_name, fetch_items, pass, class_list, el, type, clear, alt_name, fetch_items, pass,
field_list, l, m, section_list, container, disabled, readonly, item; field_list, l, m, section_list, container, disabled, readonly, item,
segment_len, field_len;
item = spec.item; item = spec.item;
getHelp = function (prop) { getHelp = function (prop) {
...@@ -3646,8 +3646,7 @@ ...@@ -3646,8 +3646,7 @@
set_flux = logic.setFlux; set_flux = logic.setFlux;
if (set) { if (set) {
len = set.length; for (n = 0, len = set.length; n < len; n += 1) {
for (n = 0; n < len; n += 1) {
if (val) { if (val) {
// FU§$%&/NG HAL // FU§$%&/NG HAL
logic[set[n]] = item.doc[val[n][0]][val[n][1]][val[n][2]]; logic[set[n]] = item.doc[val[n][0]][val[n][1]][val[n][2]];
...@@ -3711,12 +3710,12 @@ ...@@ -3711,12 +3710,12 @@
// Need mapping, fill helper with sections filled with (mapped) fields // Need mapping, fill helper with sections filled with (mapped) fields
// loop scheme // loop scheme
for (j = 0; j < item.scheme.length; j += 1) { for (j = 0, segment_len = item.scheme.length; j < segment_len; j += 1) {
segment = item.scheme[j]; segment = item.scheme[j];
field_list = []; field_list = [];
// loop scheme field_list // loop scheme field_list
for (k = 0; k < segment.field_list.length; k += 1) { for (k = 0, field_len = segment.field_list.length; k < field_len; k += 1) {
field = segment.field_list[k]; field = segment.field_list[k];
clear = null; clear = null;
textarea_value = null; textarea_value = null;
...@@ -3953,13 +3952,12 @@ ...@@ -3953,13 +3952,12 @@
push = answer.pass.push; push = answer.pass.push;
push.logic.options = util.parse(loaded_options); push.logic.options = util.parse(loaded_options);
new_value = push.logic.value; new_value = push.logic.value;
len = loaded_options.length;
el_type = push.attributes.type; el_type = push.attributes.type;
radio_check = (el_type === "radio" || el_type === "checkbox"); radio_check = (el_type === "radio" || el_type === "checkbox");
// TODO: set value here? this is a mapper??! // TODO: set value here? this is a mapper??!
if (new_value) { if (new_value) {
for (o = 0; o < len; o += 1) { for (o = 0, len = loaded_options.length; o < len; o += 1) {
option = loaded_options[o]; option = loaded_options[o];
if (option.value === new_value) { if (option.value === new_value) {
option.checked = true; option.checked = true;
...@@ -4019,11 +4017,13 @@ ...@@ -4019,11 +4017,13 @@
// dynamic data to the contained field elements // dynamic data to the contained field elements
section_list[j] = RSVP.all(field_list) section_list[j] = RSVP.all(field_list)
.then(function (field_response_list) { .then(function (field_response_list) {
var r_len;
section = getHelp({ section = getHelp({
"wrap": "section", "wrap": "section",
"class_list": "span_" + (field_response_list[0].position) "class_list": "span_" + (field_response_list[0].position)
}); });
for (l = 0; l < field_response_list.length; l += 1) { for (l = 0, r_len = field_response_list.length; l < r_len; l += 1) {
section.children.push(field_response_list[l].push); section.children.push(field_response_list[l].push);
} }
return RSVP.resolve(section); return RSVP.resolve(section);
...@@ -4033,7 +4033,8 @@ ...@@ -4033,7 +4033,8 @@
return RSVP.all(section_list) return RSVP.all(section_list)
.then(function (section_response_list) { .then(function (section_response_list) {
for (m = 0; m < section_response_list.length; m += 1) { var m_len;
for (m = 0, m_len = section_response_list.length; m < m_len; m += 1) {
helper.children.push(section_response_list[m]); helper.children.push(section_response_list[m]);
} }
return RSVP.resolve(helper); return RSVP.resolve(helper);
...@@ -4347,7 +4348,8 @@ ...@@ -4347,7 +4348,8 @@
*/ */
// WARNING: jIO dependency! // WARNING: jIO dependency!
storage.parseQuery = function (query, type, key, value, field_list, restore) { storage.parseQuery = function (query, type, key, value, field_list, restore) {
var wrap, query_object, query_clean, default_query, obj, is_value, i, is_id; var wrap, query_object, query_clean, default_query, obj, is_value, i, is_id,
len;
is_value = value && value !== ""; is_value = value && value !== "";
is_id = query && query.query && query.query._id; is_id = query && query.query && query.query._id;
...@@ -4407,7 +4409,7 @@ ...@@ -4407,7 +4409,7 @@
// searching. These fields should not be set in the search // searching. These fields should not be set in the search
if (field_list && query) { if (field_list && query) {
wrap = ""; wrap = "";
for (i = 0; i < field_list.length; i += 1) { for (i = 0, len = field_list.length; i < len; i += 1) {
if (!util.findKey( if (!util.findKey(
query_object || {}, query_object || {},
"query_list", "query_list",
...@@ -4507,10 +4509,10 @@ ...@@ -4507,10 +4509,10 @@
* @return {array} select_list * @return {array} select_list
**/ **/
storage.makeSelectList = function (scheme) { storage.makeSelectList = function (scheme) {
var i, j, field, select_list = []; var i, j, field, len, scheme_len, select_list = [];
for (i = 0; i < scheme.length; i += 1) { for (i = 0, scheme_len = scheme.length; i < scheme_len; i += 1) {
for (j = 0; j < scheme[i].field_list.length; j += 1) { for (j = 0, len = scheme[i].field_list.length; j < len; j += 1) {
field = scheme[i].field_list[j]; field = scheme[i].field_list[j];
if (field.field && select_list.indexOf(field.field) === -1) { if (field.field && select_list.indexOf(field.field) === -1) {
select_list.push(field.field); select_list.push(field.field);
...@@ -4584,7 +4586,7 @@ ...@@ -4584,7 +4586,7 @@
**/ **/
storage.validate = function (form_to_test) { storage.validate = function (form_to_test) {
var i, pass, anti_spam, valid, test_time, test_empty, var i, pass, anti_spam, valid, test_time, test_empty,
test_full, form_element, form_elements; test_full, form_element, form_elements, len;
pass = false; pass = false;
anti_spam = document.getElementById(form_to_test.id + "_not_a_secret"); anti_spam = document.getElementById(form_to_test.id + "_not_a_secret");
...@@ -4602,7 +4604,7 @@ ...@@ -4602,7 +4604,7 @@
// one empty, one filled secured field // one empty, one filled secured field
form_elements = form_to_test.getElementsByTagName("input"); form_elements = form_to_test.getElementsByTagName("input");
for (i = 0; i < form_elements.length; i += 1) { for (i = 0, len = form_elements.length; i < len; i += 1) {
form_element = form_elements[i]; 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 === "") { if (form_element.value === "") {
...@@ -4639,11 +4641,12 @@ ...@@ -4639,11 +4641,12 @@
* @param {object} config Action Object * @param {object} config Action Object
**/ **/
storage.remove = function (config) { storage.remove = function (config) {
var store, items, i, kill; var store, items, i, kill, len;
app.util.loader("", "status_dict.removing"); app.util.loader("", "status_dict.removing");
store = storage.items; store = storage.items;
len = items.length;
kill = config.state.query.last || config.state.query._id; kill = config.state.query.last || config.state.query._id;
// TODO: find a generic way to determine the id of the element to // TODO: find a generic way to determine the id of the element to
...@@ -4657,8 +4660,8 @@ ...@@ -4657,8 +4660,8 @@
app.util.error("No items for deletion defined"); app.util.error("No items for deletion defined");
} }
if (store && items.length > 0) { if (store && len > 0) {
for (i = 0; i < items.length; i += 1) { for (i = 0; i < len; i += 1) {
store.remove({"_id": items[i]}) store.remove({"_id": items[i]})
.then(function () { .then(function () {
if (config.state.callback) { if (config.state.callback) {
...@@ -4774,7 +4777,7 @@ ...@@ -4774,7 +4777,7 @@
*/ */
// TODO: overwrite direction on single state sorting // TODO: overwrite direction on single state sorting
app.sort = function (config, direction, prev, next, single) { app.sort = function (config, direction, prev, next, single) {
var i, in_array, sort_by, delay, state; var i, in_array, sort_by, delay, state, len;
// NOTE: if column title is not set, we might be sortling a list! // NOTE: if column title is not set, we might be sortling a list!
sort_by = config.element.getAttribute("data-column-title"); sort_by = config.element.getAttribute("data-column-title");
...@@ -4797,7 +4800,7 @@ ...@@ -4797,7 +4800,7 @@
util.clearTimer(); util.clearTimer();
// check if we are already sorting by this sort_by value // check if we are already sorting by this sort_by value
for (i = 0; i < state.query.sort_on.length; i += 1) { for (i = 0, len = state.query.sort_on.length; i < len; i += 1) {
if (state.query.sort_on[i][0] === sort_by) { if (state.query.sort_on[i][0] === sort_by) {
in_array = true; in_array = true;
break; break;
...@@ -4862,14 +4865,8 @@ ...@@ -4862,14 +4865,8 @@
* @param {boolean} all Boolean determining whether to check all records * @param {boolean} all Boolean determining whether to check all records
*/ */
app.check = function (config, all) { app.check = function (config, all) {
var i, var i, element_list, checks, check, checked_or_not, id, state, id_list,
element_list, len;
checks,
check,
checked_or_not,
id,
state,
id_list;
state = config.state; state = config.state;
checked_or_not = config.element.checked; checked_or_not = config.element.checked;
...@@ -4886,7 +4883,7 @@ ...@@ -4886,7 +4883,7 @@
.getElementsByTagName("TBODY")[0] .getElementsByTagName("TBODY")[0]
.getElementsByTagName("TR"); .getElementsByTagName("TR");
for (i = 0; i < element_list.length; i += 1) { for (i = 0, len = element_list.length; i < len; i += 1) {
checks = element_list[i].childNodes[0].getElementsByTagName("INPUT"); checks = element_list[i].childNodes[0].getElementsByTagName("INPUT");
if (checks.length > 0) { if (checks.length > 0) {
...@@ -5040,7 +5037,7 @@ ...@@ -5040,7 +5037,7 @@
var i, j, l, selection, info_field, min, pointer, no_items, var i, j, l, selection, info_field, min, pointer, no_items,
text_snippet, i18n_snippet, zero_no_show, select_counter, no_limit, text_snippet, i18n_snippet, zero_no_show, select_counter, no_limit,
slot, first, last, info, info_field_list, generateInfo, no_total, slot, first, last, info, info_field_list, generateInfo, no_total,
use_total, total_records; use_total, total_records, sel_len, field_len, opt_len;
info_field_list = element.querySelectorAll(".info"); info_field_list = element.querySelectorAll(".info");
info = ""; info = "";
...@@ -5068,7 +5065,7 @@ ...@@ -5068,7 +5065,7 @@
if (info_field_list.length === 0) { if (info_field_list.length === 0) {
info_field_list = []; info_field_list = [];
selection = document.querySelectorAll(".info"); selection = document.querySelectorAll(".info");
for (i = 0; i < selection.length; i += 1) { for (i = 0, sel_len = selection.length; i < sel_len; i += 1) {
pointer = selection[i].getAttribute("data-reference"); pointer = selection[i].getAttribute("data-reference");
if (pointer === element.id) { if (pointer === element.id) {
info_field_list.push(selection[i]); info_field_list.push(selection[i]);
...@@ -5077,7 +5074,7 @@ ...@@ -5077,7 +5074,7 @@
} }
// loop info fields, set text and information // loop info fields, set text and information
for (j = 0; j < info_field_list.length; j += 1) { for (j = 0, field_len = info_field_list.length; j < field_len; j += 1) {
info_field = info_field_list[j]; info_field = info_field_list[j];
slot = undefined; slot = undefined;
...@@ -5110,7 +5107,7 @@ ...@@ -5110,7 +5107,7 @@
text_snippet = "Sorting: "; text_snippet = "Sorting: ";
i18n_snippet = "sorted"; i18n_snippet = "sorted";
slot = 1; slot = 1;
for (l = 0; l < options.sort_on.length; l += 1) { for (l = 0, opt_len = options.sort_on.length; l < opt_len; l += 1) {
if (l > 0) { if (l > 0) {
info += " & "; info += " & ";
} }
...@@ -5485,13 +5482,14 @@ ...@@ -5485,13 +5482,14 @@
*/ */
// TODO: add local popups! // TODO: add local popups!
app.setPageBindings = function () { app.setPageBindings = function () {
var i, j, form_element, filterable, captcha, form_list, filter_list; var i, j, form_element, filterable, captcha, form_list, filter_list, len,
list_len;
form_list = document.getElementsByTagName("form"); form_list = document.getElementsByTagName("form");
filter_list = document.querySelectorAll("[data-filter]"); filter_list = document.querySelectorAll("[data-filter]");
// disable default filtering of JQM filterable // disable default filtering of JQM filterable
for (i = 0; i < filter_list.length; i += 1) { for (i = 0, len = filter_list.length; i < len; i += 1) {
filterable = filter_list[i]; filterable = filter_list[i];
if (filterable.getAttribute("data-bound") === null) { if (filterable.getAttribute("data-bound") === null) {
...@@ -5503,7 +5501,7 @@ ...@@ -5503,7 +5501,7 @@
} }
// add validation to all forms // add validation to all forms
for (j = 0; j < form_list.length; j += 1) { for (j = 0, list_len = form_list.length; j < list_len; j += 1) {
form_element = form_list[j]; form_element = form_list[j];
captcha = document.getElementById(form_element.id + "_captcha"); captcha = document.getElementById(form_element.id + "_captcha");
...@@ -5641,9 +5639,9 @@ ...@@ -5641,9 +5639,9 @@
* @return {string} value * @return {string} value
**/ **/
util.fetchByArray = function (obj, arr) { util.fetchByArray = function (obj, arr) {
var n, key; var n, key, len;
for (n = 0; n < arr.length; n += 1) { for (n = 0, len = arr.length; n < len; n += 1) {
key = obj[arr[n]] || key[arr[n]]; key = obj[arr[n]] || key[arr[n]];
} }
return key; return key;
...@@ -5743,14 +5741,14 @@ ...@@ -5743,14 +5741,14 @@
*/ */
// TODO: Storage specific method, move // TODO: Storage specific method, move
util.findKey = function (object, pointer, key, value) { util.findKey = function (object, pointer, key, value) {
var i, obj; var i, obj, len;
// simple query // simple query
if (object[key] === value) { if (object[key] === value) {
return true; return true;
} }
if (object[pointer]) { if (object[pointer]) {
for (i = 0; i < object[pointer].length; i += 1) { for (i = 0, len = object[pointer].length; i < len; i += 1) {
obj = object[pointer][i]; obj = object[pointer][i];
if (obj[key] === value) { if (obj[key] === value) {
return true; return true;
...@@ -5848,9 +5846,9 @@ ...@@ -5848,9 +5846,9 @@
* @returns {array} keys Reversed array * @returns {array} keys Reversed array
*/ */
util.reverseArray = function (array) { util.reverseArray = function (array) {
var k, keys = []; var k, len, keys = [];
for (k = 0; k < array.length; k += 1) { for (k = 0, len = array.length; k < len; k += 1) {
keys.unshift(array[k]); keys.unshift(array[k]);
} }
return keys; return keys;
...@@ -5864,9 +5862,9 @@ ...@@ -5864,9 +5862,9 @@
* @return {array} new array * @return {array} new array
*/ */
util.deleteFromArray = function (array, element) { util.deleteFromArray = function (array, element) {
var i; var i, len;
for (i = 0; i <= array.length; i += 1) { for (i = 0, len = array.length; i <= len; i += 1) {
if (array[i] === element) { if (array[i] === element) {
return array.splice(i, 1); return array.splice(i, 1);
} }
...@@ -6115,14 +6113,13 @@ ...@@ -6115,14 +6113,13 @@
var response, i, len, promise_list, record; var response, i, len, promise_list, record;
response = util.parse(e.target.responseText); response = util.parse(e.target.responseText);
len = response.length;
promise_list = []; promise_list = [];
// NOTE: no more need to test for and fetch fields, because they // NOTE: no more need to test for and fetch fields, because they
// will be defined, as this method is only called inside the // will be defined, as this method is only called inside the
// content-loop. // content-loop.
// NOTE: do we still validate against field_dict? // NOTE: do we still validate against field_dict?
for (i = 0; i < len; i += 1) { for (i = 0, len = response.length; i < len; i += 1) {
record = response[i]; record = response[i];
record.portal_type = pass.config_dict.portal_type_source; record.portal_type = pass.config_dict.portal_type_source;
...@@ -6318,7 +6315,7 @@ ...@@ -6318,7 +6315,7 @@
encoded, wrapper, active, selector, update_target, target, widget, encoded, wrapper, active, selector, update_target, target, widget,
quirk_dict, generator, pointer_results, data_total_rows, is_parameter, quirk_dict, generator, pointer_results, data_total_rows, is_parameter,
param_len, parameter, no_item, dyno, container, has_props, widget_dyno, param_len, parameter, no_item, dyno, container, has_props, widget_dyno,
set_reference; set_reference, kids_len;
pass = reply.pass; pass = reply.pass;
pass.config_dict = pass.config_dict || {}; pass.config_dict = pass.config_dict || {};
...@@ -6348,13 +6345,14 @@ ...@@ -6348,13 +6345,14 @@
// TODO: no all elements need them? // TODO: no all elements need them?
// wrapper object and properties // wrapper object and properties
kids_len = kids.length;
quirk_dict = util.mergeObject( quirk_dict = util.mergeObject(
(pass[method ? "content_dict" : "config_dict"].property_dict), (pass[method ? "content_dict" : "config_dict"].property_dict),
{ {
"create": pass.create, "create": pass.create,
"update": pass.create === false ? true : null, "update": pass.create === false ? true : null,
"total_rows": data_total_rows, "total_rows": data_total_rows,
"length": kids.length, "length": kids_len,
"layout_level": pass.url_dict.layout_level, "layout_level": pass.url_dict.layout_level,
"fragment_list": pass.url_dict.fragment_list, "fragment_list": pass.url_dict.fragment_list,
"data_url": pass.url_dict.data_url, "data_url": pass.url_dict.data_url,
...@@ -6550,13 +6548,13 @@ ...@@ -6550,13 +6548,13 @@
} }
// loop over children // loop over children
if (kids.length) { if (kids_len) {
// reset in wrapper, otherwise might be overwritten // reset in wrapper, otherwise might be overwritten
quirk_dict.length = kids.length; quirk_dict.length = kids_len;
is_id = (quirk_dict.data || {})._id || quirk_dict.item_identifier; is_id = (quirk_dict.data || {})._id || quirk_dict.item_identifier;
for (i = 0; i < kids.length; i += 1) { for (i = 0; i < kids_len; i += 1) {
kid = kids[i]; kid = kids[i];
// TODO: if dynamic is properly inherited from parent to child // TODO: if dynamic is properly inherited from parent to child
...@@ -7098,9 +7096,9 @@ ...@@ -7098,9 +7096,9 @@
* @return {string} path * @return {string} path
**/ **/
app.util.fetchPath = function (attribute) { app.util.fetchPath = function (attribute) {
var i, path, script_list = document.getElementsByTagName("script"); var i, path, len, script_list = document.getElementsByTagName("script");
for (i = 0; i < script_list.length; i += 1) { for (i = 0, len = script_list.length; i < len; i += 1) {
path = script_list[i].getAttribute(attribute); path = script_list[i].getAttribute(attribute);
if (path) { if (path) {
return path; return path;
...@@ -7163,12 +7161,12 @@ ...@@ -7163,12 +7161,12 @@
* @return {Boolean} true/falsely * @return {Boolean} true/falsely
*/ */
app.init.testSupport = function (property_list) { app.init.testSupport = function (property_list) {
var j, no_support, fail, message; var j, no_support, fail, message, len;
if (property_list.length > 0) { if (property_list.length > 0) {
if (Modernizr) { if (Modernizr) {
fail = ""; fail = "";
for (j = 0; j < property_list.length; j += 1) { for (j = 0, len = property_list.length; j < len; j += 1) {
if (Modernizr[property_list[j]] === false) { if (Modernizr[property_list[j]] === false) {
no_support = true; no_support = true;
fail += property_list[j] + "|"; fail += property_list[j] + "|";
...@@ -7205,9 +7203,8 @@ ...@@ -7205,9 +7203,8 @@
arr = app.empty_array; arr = app.empty_array;
promise_list = []; promise_list = [];
len = content_dict.length;
for (i = 0; i < len; i += 1) { for (i = 0, len = content_dict.length; i < len; i += 1) {
feature = content_dict[i]; feature = content_dict[i];
// test support // test support
......
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