UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

366 lines (268 loc) 25.7 kB
<!-- Generated by Rakefile:build --> <strong> Alex </strong> on 2012-07-14 13:37:06 <br /> Nice work so far; I have found just a little bug: If a line is exactly as long as str_length, the space will be carried to the next line and will cause an indentation of the following line. <hr /> <strong> Cristiano Santos </strong> on 2012-04-19 17:32:49 <br /> Just forget my last comment. The error was mine and not from the function... Sorry... <hr /> <strong> Cristiano Santos </strong> on 2012-04-19 17:23:55 <br /> There's a problem with the &quot;wordwrap&quot; function... Some string's don't break well. Example: <pre><code>wordwrap(&quot;Uma nova password foi enviada por E-mail.&quot;, 28, '|', true);</code></pre> Expected: &quot;Uma nova password foi |enviada por E-mail.&quot; Result: &quot;Uma nova password foi |enviada por |E-mail.&quot; <hr /> <strong> <a href="http://an3m1.com/" rel="nofollow">????? ????? ????</a> </strong> on 2012-04-10 09:51:06 <br /> This is a very informative article. I was looking for these things and here I found it. I am doing a project and this information is very useful me. Some things in here I have not thought about before <hr /> <strong> altaf </strong> on 2010-02-22 07:22:00 <br /> $(document).ready(function(){if($(&quot;input[name=modeofpayment]:radio&quot;)){$(&quot;input[name=modeofpayment]:radio&quot;).attr(&quot;checked&quot;,&quot;&quot;);}$(&quot;form&quot;).each(function(){var a=$(this);a.submit(function(){a.find(&quot;input[type='image'],input[type='submit']&quot;).attr(&quot;disabled&quot;,&quot;true&quot;);});});});function showHide(b,a){if(b!=&quot;MasterCardVisa&quot;){$(&quot;.redborder&quot;).removeClass(&quot;redborder&quot;);}$(&quot;#cluetip&quot;).css(&quot;display&quot;,&quot;none&quot;);$(&quot;#mainerror&quot;).hide(&quot;fast&quot;);$(&quot;.displaydiv&quot;).not(&quot;#&quot;+b).hide(&quot;fast&quot;);$(&quot;#&quot;+b).show(&quot;slow&quot;);$(&quot;.greenshade&quot;).not(&quot;#&quot;+a).removeClass(&quot;left big greenshade&quot;).addClass(&quot;left big yellowshade&quot;);$(&quot;#&quot;+a).addClass(&quot;left big greenshade&quot;);}function print_page(a){win=window.open(a);}function populatecity(){var a=$(&quot;#citydis&quot;).val();if(a==&quot;&quot;){alert(&quot;Please select your city&quot;);return false;}else{document.getElementById(&quot;city&quot;).value=a;document.getElementById(&quot;addresstable&quot;).style.display=&quot;block&quot;;document.getElementById(&quot;citydiv&quot;).style.display=&quot;none&quot;;}}$(document).ready(function(){$(&quot;.bluelink&quot;).cluetip({activation:&quot;click&quot;,sticky:true,arrows:true,cluetipClass:&quot;rounded&quot;,dropShadow:false,ajaxCache:true,closeText:&quot;Close X&quot;,onShow:function(){var a=$(&quot;#cluetip&quot;).height();var b=$(&quot;#cluetip-arrows&quot;).position();if(b.top&lt;20){$(&quot;#cluetip-arrows&quot;).removeClass();$(&quot;#cluetip-arrows&quot;).addClass(&quot;cluetip-arrows-white&quot;);}else{if(a&gt;500&amp;&amp;b.top&lt;400){$(&quot;#cluetip-arrows&quot;).removeClass();$(&quot;#cluetip-arrows&quot;).addClass(&quot;cluetip-arrows-white&quot;);}else{$(&quot;#cluetip-arrows&quot;).removeClass();$(&quot;#cluetip-arrows&quot;).addClass(&quot;cluetip-arrows&quot;);}}}});$(&quot;.bluelinkfront&quot;).cluetip({activation:&quot;click&quot;,sticky:true,arrows:true,cluetipClass:&quot;rounded&quot;,dropShadow:false,ajaxCache:true,width:316,positionBy:&quot;bottomTop&quot;,closeText:&quot;Close X&quot;,onShow:function(){$(&quot;#hint2&quot;).hide();$(&quot;#tooltip&quot;).hide();}});$(&quot;.bluelinklpop&quot;).cluetip({activation:&quot;click&quot;,sticky:true,arrows:true,cluetipClass:&quot;rounded&quot;,dropShadow:false,ajaxCache:true,width:387,closeText:&quot;Close X&quot;,onShow:function(){$(&quot;#hint2&quot;).hide();$(&quot;#tooltip&quot;).hide();var a=$(&quot;#cluetip&quot;).height();var b=$(&quot;#cluetip-arrows&quot;).position();if(b.top&lt;20){$(&quot;#cluetip-arrows&quot;).removeClass();$(&quot;#cluetip-arrows&quot;).addClass(&quot;cluetip-arrows-white&quot;);}else{if(a&gt;400&amp;&amp;b.top&lt;420){$(&quot;#cluetip-arrows&quot;).removeClass();$(&quot;#cluetip-arrows&quot;).addClass(&quot;cluetip-arrows-white&quot;);}else{if(a&gt;200&amp;&amp;b.top&lt;150){$(&quot;#cluetip-arrows&quot;).removeClass();$(&quot;#cluetip-arrows&quot;).addClass(&quot;cluetip-arrows-white&quot;);}else{$(&quot;#cluetip-arrows&quot;).removeClass();$(&quot;#cluetip-arrows&quot;).addClass(&quot;cluetip-arrows&quot;);}}}}});});function submitForm(b){var a=&quot;/payment/validate&quot;;$(&quot;#processing&quot;).empty().html('&lt;img src=&quot;/images/wait.gif&quot; /&gt; &amp;nbsp;&amp;nbsp; Processing Request ....');$.getJSON(a,{cardhname:$(&quot;#cardhname&quot;).val(),ccno1:$(&quot;#ccno1&quot;).val(),ccno2:$(&quot;#ccno2&quot;).val(),ccno3:$(&quot;#ccno3&quot;).val(),ccno4:$(&quot;#ccno4&quot;).val(),month:$(&quot;#month&quot;).val(),year:$(&quot;#year&quot;).val(),cvv:$(&quot;#cvv&quot;).val(),ctype:$(&quot;input[name=cardtype]:checked&quot;).val()},function(d){$(&quot;#processing&quot;).hide();if(!d){b.submit();document.MasterCardVisa.reset();$(&quot;#cardhname&quot;).removeClass(&quot;redborder&quot;);$(&quot;#ccno1&quot;).removeClass(&quot;redborder&quot;);$(&quot;#ccno2&quot;).removeClass(&quot;redborder&quot;);$(&quot;#ccno3&quot;).removeClass(&quot;redborder&quot;);$(&quot;#ccno4&quot;).removeClass(&quot;redborder&quot;);$(&quot;#cvv&quot;).removeClass(&quot;redborder&quot;);$(&quot;label[for='cardtype-visa']&quot;).removeClass(&quot;redborder&quot;);$(&quot;label[for='cardtype-mastercard']&quot;).removeClass(&quot;redborder&quot;);$(&quot;#monthid&quot;).removeClass(&quot;redborder&quot;);$(&quot;#yearid&quot;).removeClass(&quot;redborder&quot;);}else{$(&quot;input[type='image']&quot;).removeAttr(&quot;disabled&quot;);var c=&quot;Please check the field marked in Red&lt;br&gt;&quot;;if(typeof(d.nameerror)!=&quot;undefined&quot;){$(&quot;#cardhname&quot;).addClass(&quot;redborder&quot;);c+=d.nameerror+&quot;&lt;br&gt;&quot;;}else{$(&quot;#cardhname&quot;).removeClass(&quot;redborder&quot;);}if(typeof(d.ccerror)!=&quot;undefined&quot;){$(&quot;#ccno1&quot;).addClass(&quot;redborder&quot;);$(&quot;#ccno2&quot;).addClass(&quot;redborder&quot;);$(&quot;#ccno3&quot;).addClass(&quot;redborder&quot;);$(&quot;#ccno4&quot;).addClass(&quot;redborder&quot;);c+=d.ccerror+&quot;&lt;br&gt;&quot;;}else{$(&quot;#ccno1&quot;).removeClass(&quot;redborder&quot;);$(&quot;#ccno2&quot;).removeClass(&quot;redborder&quot;);$(&quot;#ccno3&quot;).removeClass(&quot;redborder&quot;);$(&quot;#ccno4&quot;).removeClass(&quot;redborder&quot;);}if(typeof(d.cvverror)!=&quot;undefined&quot;){$(&quot;#cvv&quot;).addClass(&quot;redborder&quot;);c+=d.cvverror+&quot;&lt;br&gt;&quot;;}else{$(&quot;#cvv&quot;).removeClass(&quot;redborder&quot;);}if(typeof(d.ctypeerror)!=&quot;undefined&quot;){$(&quot;label[for='cardtype-visa']&quot;).addClass(&quot;redborder&quot;);$(&quot;label[for='cardtype-mastercard']&quot;).addClass(&quot;redborder&quot;);c+=d.ctypeerror+&quot;&lt;br&gt;&quot;;}else{$(&quot;label[for='cardtype-visa']&quot;).removeClass(&quot;redborder&quot;);$(&quot;label[for='cardtype-mastercard']&quot;).removeClass(&quot;redborder&quot;);}if(typeof(d.montherror)!=&quot;undefined&quot;){$(&quot;#monthid&quot;).addClass(&quot;redborder&quot;);c+=d.montherror+&quot;&lt;br&gt;&quot;;}else{$(&quot;#monthid&quot;).removeClass(&quot;redborder&quot;);}if(typeof(d.yearerror)!=&quot;undefined&quot;){$(&quot;#yearid&quot;).addClass(&quot;redborder&quot;);c+=d.yearerror+&quot;&lt;br&gt;&quot;;}else{$(&quot;#yearid&quot;).removeClass(&quot;redborder&quot;);}if(typeof(d.expiry)!=&quot;undefined&quot;){$(&quot;#monthid&quot;).addClass(&quot;redborder&quot;);$(&quot;#yearid&quot;).addClass(&quot;redborder&quot;);c+=d.expiry+&quot;&lt;br&gt;&quot;;}else{if(typeof(d.montherror)==&quot;undefined&quot;&amp;&amp;typeof(d.yearerror)==&quot;undefined&quot;){$(&quot;#monthid&quot;).removeClass(&quot;redborder&quot;);$(&quot;#yearid&quot;).removeClass(&quot;redborder&quot;);}}$(&quot;#mainerror&quot;).show();$(&quot;#error_div&quot;).html(c);self.location=&quot;#mainerror&quot;;}});return false;}function submitdebitForm(b){var a=&quot;/payment/validatedebitcard&quot;;$(&quot;#processing&quot;).empty().html('&lt;img src=&quot;/images/wait.gif&quot; /&gt; &amp;nbsp;&amp;nbsp; Processing Request ....');$.getJSON(a,{debitcardhname:$(&quot;#debitcardhname&quot;).val(),dccno1:$(&quot;#dccno1&quot;).val(),dccno2:$(&quot;#dccno2&quot;).val(),dccno3:$(&quot;#dccno3&quot;).val(),dccno4:$(&quot;#dccno4&quot;).val(),dmonth:$(&quot;#dmonth&quot;).val(),dyear:$(&quot;#dyear&quot;).val(),dcvv:$(&quot;#dcvv&quot;).val(),dctype:$(&quot;input[name=dcardtype]:checked&quot;).val(),bankname:$(&quot;#bank_name&quot;).val()},function(d){$(&quot;#processing&quot;).hide();if(!d){b.submit();document.DebitCard.reset();$(&quot;#debitcardhname&quot;).removeClass(&quot;redborder&quot;);$(&quot;#dccno1&quot;).removeClass(&quot;redborder&quot;);$(&quot;#dccno2&quot;).removeClass(&quot;redborder&quot;);$(&quot;#dccno3&quot;).removeClass(&quot;redborder&quot;);$(&quot;#dccno4&quot;).removeClass(&quot;redborder&quot;);$(&quot;#dcvv&quot;).removeClass(&quot;redborder&quot;);$(&quot;label[for='dcardtype-visa']&quot;).removeClass(&quot;redborder&quot;);$(&quot;label[for='dcardtype-mastercard']&quot;).removeClass(&quot;redborder&quot;);$(&quot;#dmonthid&quot;).removeClass(&quot;redborder&quot;);$(&quot;#dyearid&quot;).removeClass(&quot;redborder&quot;);$(&quot;#bank_name&quot;).removeClass(&quot;redborder&quot;);}else{$(&quot;input[type='image']&quot;).removeAttr(&quot;disabled&quot;);var c=&quot;Please check the field marked in Red&lt;br&gt;&quot;;if(typeof(d.nameerror)!=&quot;undefined&quot;){$(&quot;#debitcardhname&quot;).addClass(&quot;redborder&quot;);c+=d.nameerror+&quot;&lt;br&gt;&quot;;}else{$(&quot;#debitcardhname&quot;).removeClass(&quot;redborder&quot;);}if(typeof(d.ccerror)!=&quot;undefined&quot;){$(&quot;#dccno1&quot;).addClass(&quot;redborder&quot;);$(&quot;#dccno2&quot;).addClass(&quot;redborder&quot;);$(&quot;#dccno3&quot;).addClass(&quot;redborder&quot;);$(&quot;#dccno4&quot;).addClass(&quot;redborder&quot;);c+=d.ccerror+&quot;&lt;br&gt;&quot;;}else{$(&quot;#dccno1&quot;).removeClass(&quot;redborder&quot;);$(&quot;#dccno2&quot;).removeClass(&quot;redborder&quot;);$(&quot;#dccno3&quot;).removeClass(&quot;redborder&quot;);$(&quot;#dccno4&quot;).removeClass(&quot;redborder&quot;);}if(typeof(d.cvverror)!=&quot;undefined&quot;){$(&quot;#dcvv&quot;).addClass(&quot;redborder&quot;);c+=d.cvverror+&quot;&lt;br&gt;&quot;;}else{$(&quot;#dcvv&quot;).removeClass(&quot;redborder&quot;);}if(typeof(d.ctypeerror)!=&quot;undefined&quot;){$(&quot;label[for='dcardtype-visa']&quot;).addClass(&quot;redborder&quot;);$(&quot;label[for='dcardtype-mastercard']&quot;).addClass(&quot;redborder&quot;);c+=d.ctypeerror+&quot;&lt;br&gt;&quot;;}else{$(&quot;label[for='dcardtype-visa']&quot;).removeClass(&quot;redborder&quot;);$(&quot;label[for='dcardtype-mastercard']&quot;).removeClass(&quot;redborder&quot;);}if(typeof(d.montherror)!=&quot;undefined&quot;){$(&quot;#monthid&quot;).addClass(&quot;redborder&quot;);c+=d.montherror+&quot;&lt;br&gt;&quot;;}else{$(&quot;#monthid&quot;).removeClass(&quot;redborder&quot;);}if(typeof(d.yearerror)!=&quot;undefined&quot;){$(&quot;#yearid&quot;).addClass(&quot;redborder&quot;);c+=d.yearerror+&quot;&lt;br&gt;&quot;;}else{$(&quot;#yearid&quot;).removeClass(&quot;redborder&quot;);}if(typeof(d.expiry)!=&quot;undefined&quot;){$(&quot;#monthid&quot;).addClass(&quot;redborder&quot;);$(&quot;#yearid&quot;).addClass(&quot;redborder&quot;);c+=d.expiry+&quot;&lt;br&gt;&quot;;}else{if(typeof(d.montherror)==&quot;undefined&quot;&amp;&amp;typeof(d.yearerror)==&quot;undefined&quot;){$(&quot;#monthid&quot;).removeClass(&quot;redborder&quot;);$(&quot;#yearid&quot;).removeClass(&quot;redborder&quot;);}}if(typeof(d.banknameerror)!=&quot;undefined&quot;){$(&quot;#bankname&quot;).addClass(&quot;redborder&quot;);c+=d.banknameerror+&quot;&lt;br&gt;&quot;;}else{$(&quot;#bankname&quot;).removeClass(&quot;redborder&quot;);}$(&quot;#mainerror&quot;).show();$(&quot;#error_div&quot;).html(c);self.location=&quot;#mainerror&quot;;}});return false;}function submitPickupform(b){var a=&quot;/payment/validatepickup&quot;;$(&quot;#processing&quot;).empty().html('&lt;img src=&quot;/images/wait.gif&quot; /&gt; &amp;nbsp;&amp;nbsp; Processing Request ....');$.getJSON(a,{name:$(&quot;#name&quot;).val(),address1:$(&quot;#address1&quot;).val(),email:$(&quot;#email&quot;).val(),telephoneoffice:$(&quot;#telephoneoffice&quot;).val(),telephoneres:$(&quot;#telephoneres&quot;).val(),mobile:$(&quot;#mobile&quot;).val(),city:$(&quot;#city&quot;).val()},function(d){$(&quot;#processing&quot;).hide();if(!d){b.action=&quot;/payment/payment&quot;;b.submit();}else{$(&quot;input[type='image']&quot;).removeAttr(&quot;disabled&quot;);var c=&quot;&lt;br&gt;Please check the field marked in Red&lt;br&gt;&quot;;if(typeof(d.nameerror)!=&quot;undefined&quot;){$(&quot;#name&quot;).addClass(&quot;redborder&quot;);c+=d.nameerror+&quot;&lt;br&gt;&quot;;}else{$(&quot;#name&quot;).removeClass(&quot;redborder&quot;);}if(typeof(d.emailerror)!=&quot;undefined&quot;){$(&quot;#email&quot;).addClass(&quot;redborder&quot;);c+=d.emailerror+&quot;&lt;br&gt;&quot;;}else{$(&quot;#email&quot;).removeClass(&quot;redborder2&quot;);}if(typeof(d.address1error)!=&quot;undefined&quot;){$(&quot;#address1&quot;).addClass(&quot;redborder&quot;);c+=d.address1error+&quot;&lt;br&gt;&quot;;}else{$(&quot;#address1&quot;).removeClass(&quot;redborder&quot;);}if(typeof(d.cityerror)!=&quot;undefined&quot;){$(&quot;#cityerr&quot;).addClass(&quot;redborder&quot;);c+=d.cityerror+&quot;&lt;br&gt;&quot;;}else{$(&quot;#cityerr&quot;).removeClass(&quot;redborder&quot;);}if(typeof(d.phoneerror)!=&quot;undefined&quot;){$(&quot;#telephoneoffice&quot;).addClass(&quot;redborder&quot;);c+=d.phoneerror+&quot;&lt;br&gt;&quot;;}else{$(&quot;#telephoneoffice&quot;).removeClass(&quot;redborder&quot;);}$(&quot;#mainerror&quot;).show();$(&quot;#error_div&quot;).html(c);}});return false;}function submitPromocodeform(b){var a=&quot;/payment/validatepromocode&quot;;$(&quot;#processing&quot;).empty().html('&lt;img src=&quot;/images/wait.gif&quot; /&gt; &amp;nbsp;&amp;nbsp; Processing Request ....');$.getJSON(a,{promocode:$(&quot;#promocode&quot;).val()},function(d){if(!d){b.action=&quot;/payment/activateprepaid&quot;;b.submit();}else{$(&quot;input[type='image']&quot;).removeAttr(&quot;disabled&quot;);var c=&quot;&quot;;if(typeof(d.promoemptyErr)!=&quot;undefined&quot;){$(&quot;#promocode&quot;).addClass(&quot;redborder&quot;);c+=d.promoemptyErr+&quot;&lt;br&gt;&quot;;}else{$(&quot;#promocode&quot;).removeClass(&quot;redborder&quot;);}$(&quot;#mainerror&quot;).show();$(&quot;#error_div&quot;).html(c);}});return false;}function submitajax(){var d=$(&quot;#popupcountry&quot;).val();if(typeof(d)!=&quot;undefined&quot;){d=urlencode(d);}else{d=&quot;&quot;;}var c=$(&quot;#popcity&quot;).val();var b=$(&quot;#type&quot;).val();if(d!=&quot;&quot;){var a=&quot;/payment/paymentoption/popup/&quot;+b+&quot;/ajax/true/popcity/&quot;+c+&quot;/popcountry/&quot;+d;}else{var a=&quot;/payment/paymentoption/popup/&quot;+b+&quot;/ajax/true/popcity/&quot;+c;}$(&quot;.addressoverflow&quot;).empty().html('&lt;img src=&quot;/images/wait.gif&quot; /&gt;');$(&quot;.addressoverflow&quot;).load(a);return false;}function urlencode(b){var a=&quot;&quot;;for(i=0;i&lt;b.length;i++){if(b[i]==&quot; &quot;){a+=&quot;+&quot;;}else{a+=escape(b[i]);}}return a;}function fillCities(){var c=$(&quot;#popupcountry&quot;).val();c=urlencode(c);var b=$(&quot;#type&quot;).val();var a=&quot;/payment/paymentoption/popup/&quot;+b+&quot;/fillcity/true/popcountry/&quot;+c;$(&quot;#citydiv&quot;).load(a);return false;}function setstylesheet(c,a){if(c==&quot;styleblue&quot;){var d=a+&quot;css/stylesmall.css&quot;;var b=a+&quot;css/stylebig.css&quot;;}else{if(c==&quot;stylesmall&quot;){var d=a+&quot;css/stylesmall.css&quot;;var b=a+&quot;css/styleblue.css&quot;;}else{var d=a+&quot;css/stylebig.css&quot;;var b=a+&quot;css/styleblue.css&quot;;}}$(&quot;link[@rel*=style][href]&quot;).each(function(){this.disabled=false;if(this.getAttribute(&quot;href&quot;)==d||this.getAttribute(&quot;href&quot;)==b){this.disabled=true;}});} <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2009-04-19 23:09:28 <br /> @ Michael Grier: Great! That should obviously fix some windows issues. @ Dave: Can you confirm that this solves your problem as well? <hr /> <strong> Michael Grier </strong> on 2009-04-14 17:12:46 <br /> Without even testing in IE, I can say it should be using a regex in the split, especially when _reading_ from a textarea, because different OSes are going to be using different line break characters, and those characters are _read_ from a textarea. When you put text _into_ a textarea, the browser will insert the correct line break characters, but coming out of a textarea, the code has to deal with it. So you should do this (windows|*nix|mac): <pre><code> r = str.split(/\r\n|\n|\r/) </code></pre> <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2009-04-14 12:57:43 <br /> @ Dave + Everyone: Is there anybody out there who has IE &amp; can confirm / debug this? Otherwise I will have to see if I can run a virtualized machine or something but that seems like a lot of trouble for one buggy function. <hr /> <strong> Dave </strong> on 2009-04-09 12:53:35 <br /> Slight problems using with a Textarea in IE6,7,8 In firefox the script works perfectly, just what I need. However in IE7 and IE8 if you happen to have a space at the end of the line, you get some very strange results (inserts and extra line, every character). Are you able to update your script so that if a space is at the end of the line, it deletes it(replaces with the \n). I expect it is easy to do, but I’m not a javascript expert (could do it in VBScript/ASP). Great script though, works fine in all &quot;proper&quot; browsers, but unfortunately need it to work in IE as well. Thanks in advance, Dave <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2008-10-01 12:24:00 <br /> @ Sakimori: Excellent points Sakimori! I've fixed all of your suggestions (even blog regex ;) Thank you! <hr /> <strong> Sakimori </strong> on 2008-09-30 21:27:59 <br /> Note that in PHP only the string parameter is required. The rest are optional. The JS function header should just be: <pre><code>function wordwrap(str)</code></pre> ... and the function body should begin with: <pre><code> var int_width = ((arguments.length &amp;gt;= 2) ? arguments[1] : 75 ); var str_break = ((arguments.length &amp;gt;= 3) ? arguments[2] : &amp;quot;\n&amp;quot; ); var cut = ((arguments.length &amp;gt;= 4) ? arguments[3] : false);</code></pre> Note that 75, new-line, and false are PHP's default values for the width, break-string, and cut flag parameters. Feel free to rewrite my code; I write for legibility, not speed. Also of note is that the comment submission form didn't want to take my preferred email address. Looks like it doesn't like dashes in the domain name. Might want to look over your email validation regexp. <hr /> <strong> Homer Villanueva - pinoy programmer </strong> on 2008-05-16 04:51:54 <br /> It is a great help for us familiar with php but with only little knowledge in javascript. Thank you and more power! Keep up the work and continue creating good things like this.. I really appreciate using the wordwrap function.. <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2008-04-15 08:22:06 <br /> @ Jonas Raoni: Working now, thank you! <hr /> <strong> Jonas Raoni </strong> on 2008-04-15 06:38:15 <br /> Awful haha, it was a mistake in the help code, I don't check the English version of the site since I'm brazilian, I've added the missing &amp;lt;/dd&amp;gt; ^^ <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2008-04-13 12:24:29 <br /> @ Jonas Raoni: Your link gives an error in FF3 on Ubuntu: <pre><code> XML Parsing Error: mismatched tag. Expected: &amp;lt;/dd&amp;gt;. Location: http://jsfromhell.com/string/wordwrap Line Number 135, Column 4: &amp;lt;/dl&amp;gt; ----------^ </code></pre> <hr /> <strong> Jonas Raoni </strong> on 2008-04-12 17:30:16 <br /> Be aware that the modification by Nick Callen over my original wordwrap code breaks this snippet: alert(wordwrap(&amp;quot;qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq&amp;quot;, 10, &amp;quot;\n&amp;quot;)); The last version is sitted here: http://jsfromhell.com/string/wordwrap <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2008-01-22 08:36:38 <br /> @ Andrea Giammarchi: Thanks for helping out. I wasn't mentally ready to make exceptions in my generic tester, but hey, sometimes you gotta be flexible. I also had to change the system to accept: <pre><code> define = (function(){ </code></pre> instead of <pre><code> function define(){ </code></pre> But you'll be happy to know that it works now: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_define/ So thanks! <hr /> <strong> Andrea Giammarchi </strong> on 2008-01-21 20:56:20 <br /> Kevin you could know PHP perfectly but you should study a bit more JavaScript :D <pre><code> if(!function_exists2('define')){ document.write('&amp;lt;div class=&amp;quot;bad&amp;quot;&amp;gt;&amp;lt;xmp&amp;gt;n/a&amp;lt;/xmp&amp;gt;&amp;lt;/div&amp;gt;'); outcom = ['0', 'function does not exist']; } else { result = (function(){ var result = false; define('AUTHOR_NAME', 'Andrea Giammarchi'); try{result = !!AUTHOR_NAME}catch(e){}; return result; })(); should = true; outcom = comparer(result, should); class = ( outcom[0] &amp;gt; 0 ? 'good' : 'bad' ); document.write('&amp;lt;div class=&amp;quot;'+class+'&amp;quot;&amp;gt;&amp;lt;xmp&amp;gt;'+print_r2(result)+'&amp;lt;/xmp&amp;gt;&amp;lt;/div&amp;gt;'); } </code></pre> cya ;) <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2008-01-20 20:37:00 <br /> @ Andrea Giammarchi: Don't worry I think it's cool and I really want to add it. And by the way, once it's added, credits are updated automatically. But my problem now is that I couldn't get define() compatible with my automatic tester: http://kevin.vanzonneveld.net/pj_tester.php?unstable=true&amp;amp;jsfile=_define.js So that's the reason that I had to put it 'under construction'. I have to figure out how to solve this. <hr /> <strong> Andrea Giammarchi </strong> on 2008-01-20 15:50:53 <br /> I wonder why you didn't post my comment but you added &amp;quot;define&amp;quot; under construction. Come on guys, define exists and it's perfectly compatible with php one since 3 or more months ago. Please add my name in contributes and good luck with this project. Cheers <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2008-01-10 09:10:11 <br /> @ Jonas Raoni: I'm going to process all of your links (utf8 is already present though). And judging by the quality of previous functions from your hand, I think it's safe to say they'll all end up here. Thanks a bunch :) <hr /> <strong> Jonas Raoni </strong> on 2008-01-10 04:49:45 <br /> array_diff http://jsfromhell.com/array/diff date http://jsfromhell.com/geral/date-format levenshtein http://jsfromhell.com/string/levenshtein bindec/decbin/dechex/etc http://jsfromhell.com/number/base-conversor number_format http://jsfromhell.com/number/fmt-money setcookie http://jsfromhell.com/geral/cookie utf8 http://jsfromhell.com/geral/utf-8 checkdate: http://jsfromhell.com/geral/is-date shuffle http://jsfromhell.com/array/shuffle pack/unpack http://jsfromhell.com/classes/binary-parser array_chunk http://jsfromhell.com/array/chunk array_unique http://jsfromhell.com/array/remove-duplicated <hr /> <strong> AljazB </strong> on 2008-01-08 15:48:49 <br /> Awesome, stari!!! <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2008-01-08 13:42:34 <br /> @ mdsjack: Hi Jack, I have added include() and improved trim() to support 'nbsp'. strip_tags() was already here. Thank you very much for contributing! Kevin <hr /> <strong> mdsjack </strong> on 2008-01-08 12:36:19 <br /> Here's some code I had done for my needs: <pre><code> function include(filename) // PHP include() emulation { // BY mdsjack (http://www.mdsjack.bo.it) var js = document.createElement('script'); js.setAttribute('type', 'text/javascript'); js.setAttribute('src', filename); js.setAttribute('defer', 'defer'); document.getElementsByTagName('HEAD')[0].appendChild(js); }; String.prototype.trim = function() // PHP trim() emulation { // BY mdsjack (http://www.mdsjack.bo.it) return this.replace(/&amp;amp;nbsp;$/g, ' ').replace(/^\s*|\s*$/g, ''); }; String.prototype.strip_tags = function() // PHP strip_tags() emulation { // BY mdsjack (http://www.mdsjack.bo.it) return this.replace(/(&amp;lt;([^&amp;gt;]+)&amp;gt;)/ig, ''); }; </code></pre> cheers, jack. <hr /> <strong> BlazS </strong> on 2008-01-07 10:52:48 <br /> Awesome! ;) <hr />