212
I Use This!
Very Low Activity

News

Analyzed 1 day ago. based on code collected 1 day ago.
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) { ... [More] throw new Error('Warning: mt_rand() expects exactly 2 parameters, 1 given'); } var score = Math.floor(Math.random() * (max - min + 1)); score = parseInt(score) + parseInt(min); return score; } :) [Less]
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 ... [More] &lt;p&gt; tag" The $(element) creates an html element, .text(a) sets the element content to the text (read "escaped") value of "a", the .hmtl() gets the html value of the contents of the element. As in .innerHTML. Very nice also for you if you use jQuery. [Less]
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 ... [More] your issues. Zaide, I did my own implementation in order to support multi-dimensional arrays/objects while removing eval(). @David Pesta: I agree. I have changed to an object literal instead of array. [Less]
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 ... [More] this to iterate over the properties? for (var i in $result) { alert(i+'::'+$result[i]) } What browser are you using? I am seeing the alert() in the code above run twice with the given example as it should--i.e., it is not empty. [Less]
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 ... [More] latter works as a method of our custom PHPJS_Array's (returnable optionally by the array() function) to ensure something resembling an associative array can be created in JS while still being orderable: ini_set('phpjs.return_phpjs_arrays', 'on'); var a = array({a:2}, {b:3}, {c:4}); // represents an ordered version of {a:2, b:3, c:4} (not needed with sum(), but of relevance with other ordered arrays) a.sum(); // 9 // Or this: array_sum(a); // 9 [Less]