Posted
about 13 years
ago
by
Brett Zamir
@Matteo: I haven't looked at it carefully, but are you controlling for timezone (browser vs. server)?
|
Posted
about 13 years
ago
by
Rafał
@ntoniazzi: thanks for the improvement. It's now on git (https://github.com/kvz/phpjs/commit/fe540ca0f15a4127204ba7615f64fcaafb33c81f). If you want to have something else than your nick (ntoniazzi) in the "credit" section, please contact me.
|
Posted
about 13 years
ago
by
Kongo
Hi ! Your function doesn't work :)
Why ? You don't use parseInt :)
working is :
function mt_rand (min, max) {
var argc = arguments.length;
if (argc === 0) { min = 0;
max = 2147483647;
} else if (argc === 1) {
|
Posted
about 13 years
ago
by
ntoniazzi
This one is about 50% faster :
function bin2hex(s) {
var i, m, o = "", n;
for (i = 0, m = s.length; i< m; i++) {
n = s.charCodeAt(i).toString(16)
o += n.length < 2 ? "0" + n : n;
}
return o;
}
|
Posted
about 13 years
ago
by
randy
Very nice function. It worked great for me. I came here 1st!
But then I also found this method ..
var a = 'one <p> tag';
$('<div/>').text(a); // [<div>one <p> tag</div>]
$('<div/>').text(a).html(); // "one
|
Posted
about 13 years
ago
by
Brett Zamir
@Ian Carter: Thanks! I confirmed the significant performance improvement in Firefox (actually 4 or 5x faster in my testing)...Applied in Git...
|
Posted
about 13 years
ago
by
Brett Zamir
@Matteo: Your escape sequence (i.e., the part with "necessit%E0") is not using UTF-8. That is what JavaScript uses, and really what you should render in PHP (via header() and content-type).
@jeicquest, @Zaide: I have hopefully taken into account
|
Posted
about 13 years
ago
by
Brett Zamir
@Mike: Are you talking about this example?
$array1 = {'a' : 'green', 0:'red', 1: 'blue'};
$array2 = {'b' : 'green', 0:'yellow', 1:'red'};
$array3 = ['green', 'red'];
$result = array_intersect($array1, $array2, $array3);
What do you get if you add
|
Posted
about 13 years
ago
by
Andrew Ensley
@Brett: Thank you for that explanation! Just learned something new about javascript.
|
Posted
about 13 years
ago
by
Brett Zamir
@chris: Yes, but
1) reduce() is not available to older browsers, and
2) it does not work on regular objects which phpjs allows in place of associative arrays (or the ordered associative arrays which I have now added support for in Git).
The
|