use Ox.break
This commit is contained in:
parent
3d4a79b6a2
commit
04784630d3
42 changed files with 117 additions and 118 deletions
|
|
@ -317,7 +317,7 @@ Ox.api = function(items, options) {
|
|||
(query.operator == '&' && !match)
|
||||
|| (query.operator == '|' && match)
|
||||
) {
|
||||
return false;
|
||||
Ox.break();
|
||||
}
|
||||
});
|
||||
return match;
|
||||
|
|
@ -459,7 +459,7 @@ Ox.range = function() {
|
|||
len = article.length;
|
||||
sort[val] = sort[val].substr(len + 1) + ', '
|
||||
+ sort[val].substr(0, len);
|
||||
return false;
|
||||
Ox.break();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@
|
|||
img <e> Any JavaScript PNG image object
|
||||
str <s> The string to be encoded
|
||||
@*/
|
||||
|
||||
// fixme: remove, exists in image module
|
||||
Ox.encodePNG = function(img, str) {
|
||||
var c = Ox.canvas(img), i = 0;
|
||||
// Compress the string
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ Ox.formatDateRangeDuration = function(start, end, utc) {
|
|||
keys = ['year', 'month', 'day', 'hour', 'minute', 'second'],
|
||||
parts = ['FullYear', 'Month', 'Date', 'Hours', 'Minutes', 'Seconds'],
|
||||
values = [];
|
||||
Ox.forEach(keys, function(key, i) {
|
||||
keys.forEach(function(key, i) {
|
||||
while (true) {
|
||||
if (key == 'month') {
|
||||
// set the day to the same day in the next month,
|
||||
|
|
@ -574,7 +574,7 @@ Ox.formatValue = function(num, str, bin) {
|
|||
if (num < Math.pow(base, i + 1) || i == len - 1) {
|
||||
val = Ox.formatNumber(num / Math.pow(base, i), i ? i - 1 : 0) +
|
||||
' ' + chr + (chr && bin ? 'i' : '') + str;
|
||||
return false;
|
||||
Ox.break();
|
||||
}
|
||||
});
|
||||
return val;
|
||||
|
|
|
|||
|
|
@ -266,10 +266,10 @@
|
|||
Ox.forEach(areas[0], function(area0) {
|
||||
ret = contains(area0, area1);
|
||||
// Break if the outer part contains the inner part
|
||||
return !ret;
|
||||
ret && Ox.break();
|
||||
});
|
||||
// Break if no outer part contains the inner part
|
||||
return ret;
|
||||
!ret && Ox.break();
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
|
|
@ -327,7 +327,7 @@
|
|||
: Ox.joinAreas(intersections);
|
||||
}
|
||||
if (ret === null) {
|
||||
return false;
|
||||
Ox.break();
|
||||
} else {
|
||||
ret = splitArea(ret);
|
||||
}
|
||||
|
|
@ -378,7 +378,7 @@
|
|||
Ox.forEach(gaps, function(gap, i) {
|
||||
if (Ox.containsArea(gap, area)) {
|
||||
ret = i;
|
||||
return false;
|
||||
Ox.break();
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -643,7 +643,7 @@ Ox.tokenize = (function() {
|
|||
Ox.forEach(word, function(value, key) {
|
||||
if (value.indexOf(str) > -1) {
|
||||
type = key;
|
||||
return false;
|
||||
Ox.break();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ Ox.keyOf = function(obj, val) {
|
|||
Ox.forEach(obj, function(v, k) {
|
||||
if (v === val) {
|
||||
key = k;
|
||||
return false;
|
||||
Ox.break();
|
||||
}
|
||||
});
|
||||
return key;
|
||||
|
|
@ -84,7 +84,7 @@ Ox.unserialize <f> Parses query parameters into an object
|
|||
@*/
|
||||
Ox.unserialize = function(str, toNumber) {
|
||||
var obj = {};
|
||||
Ox.forEach(str.split('&'), function(val) {
|
||||
str.split('&').forEach(function(val) {
|
||||
if (val) {
|
||||
var arr = val.split('=');
|
||||
if (arr[1]) {
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ Ox.highlightHTML = function(html, str, classname, tags) {
|
|||
Ox.forEach(tags, function(tag) {
|
||||
if (html.substr(i + 1).match(new RegExp('^/?' + tag + '\\W'))) {
|
||||
isTag = true;
|
||||
return false;
|
||||
Ox.break();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -378,7 +378,7 @@ Ox.parseUserAgent = function(userAgent) {
|
|||
string: string,
|
||||
version: versions[version] || version
|
||||
};
|
||||
return false;
|
||||
Ox.break();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -616,7 +616,8 @@ Ox.wordwrap = function(str, len, sep, bal, spa) {
|
|||
}
|
||||
}
|
||||
lines = [''];
|
||||
Ox.forEach(words, function(word) {
|
||||
words.forEach(function(word) {
|
||||
var chr;
|
||||
if ((lines[lines.length - 1] + word + ' ').length <= len + 1) {
|
||||
// word fits in current line
|
||||
lines[lines.length - 1] += word + ' ';
|
||||
|
|
@ -626,11 +627,11 @@ Ox.wordwrap = function(str, len, sep, bal, spa) {
|
|||
lines.push(word + ' ');
|
||||
} else {
|
||||
// word is longer than line
|
||||
var chr = len - lines[lines.length - 1].length;
|
||||
chr = len - lines[lines.length - 1].length;
|
||||
lines[lines.length - 1] += word.substr(0, chr);
|
||||
for (var pos = chr; pos < word.length; pos += len) {
|
||||
Ox.loop(chr, word.length, len, function(pos) {
|
||||
lines.push(word.substr(pos, len));
|
||||
}
|
||||
});
|
||||
lines[lines.length - 1] += ' ';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ Ox.isEqual = function(a, b) {
|
|||
isEqual = true;
|
||||
Ox.forEach(a, function(v, k) {
|
||||
isEqual = Ox.isEqual(v, b[k]);
|
||||
return isEqual;
|
||||
!isEqual && Ox.break();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue