Popular JavaScript recipes http://code.activestate.com/recipes/langs/javascript/2017-06-06T03:48:09-07:00ActiveState Code RecipesInteractive Mandelbrot Fractal Using HTML5 Canvas (JavaScript) 2017-06-06T03:48:09-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/580804-interactive-mandelbrot-fractal-using-html5-canvas/ <p style="color: grey"> JavaScript recipe 580804 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/canvas/">canvas</a>, <a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/math/">math</a>). </p> <p>Interactive Mandelbrot Fractal Using HTML5 Canvas.</p> <p>(Download and save as html file and open it.)</p> <p>(Tested only using Firefox browser.)</p> Bader-Offer Method (Hagenbach-Bischoff) (JavaScript) 2015-01-14T11:14:06-08:00elazarhttp://code.activestate.com/recipes/users/4187847/http://code.activestate.com/recipes/579002-bader-offer-method-hagenbach-bischoff/ <p style="color: grey"> JavaScript recipe 579002 by <a href="/recipes/users/4187847/">elazar</a> (<a href="/recipes/tags/calculation/">calculation</a>). </p> <p>A recipe for calculating the seats allocated to each party in the Knesset.</p> <p>More information:</p> <ul> <li><a href="http://www.knesset.gov.il/lexicon/eng/seats_eng.htm" rel="nofollow">http://www.knesset.gov.il/lexicon/eng/seats_eng.htm</a></li> <li><a href="https://en.wikipedia.org/wiki/Hagenbach-Bischoff_system" rel="nofollow">https://en.wikipedia.org/wiki/Hagenbach-Bischoff_system</a></li> <li>(Hebrew) <a href="http://bechirot.gov.il/election/about/Pages/CalculatingSeatsMethod.aspx" rel="nofollow">http://bechirot.gov.il/election/about/Pages/CalculatingSeatsMethod.aspx</a></li> <li>(Hebrew) <a href="http://main.knesset.gov.il/About/Lexicon/Pages/seats.aspx" rel="nofollow">http://main.knesset.gov.il/About/Lexicon/Pages/seats.aspx</a></li> </ul> eMail address list validation (JavaScript) 2014-02-05T22:21:03-08:00SoftMoon WebWarehttp://code.activestate.com/recipes/users/4189155/http://code.activestate.com/recipes/578823-email-address-list-validation/ <p style="color: grey"> JavaScript recipe 578823 by <a href="/recipes/users/4189155/">SoftMoon WebWare</a> . Revision 0. </p> <p>A bit of Regular Expressions to test whether a given string conforms to being an eMail address or comma-separated list of them.</p> JavaScript WebSocket client for Python + Go WebSocket-based system monitoring example (JavaScript) 2014-01-03T21:09:54-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/578806-javascript-websocket-client-for-python-go-websocke/ <p style="color: grey"> JavaScript recipe 578806 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/golang/">golang</a>, <a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/sysadmin/">sysadmin</a>, <a href="/recipes/tags/unix/">unix</a>, <a href="/recipes/tags/websockets/">websockets</a>, <a href="/recipes/tags/windows/">windows</a>). </p> <p>This recipe is the JavaScript client side of an overall recipe that shows how to do system monitoring using WebSockets, Python, Go (using websocketd), and JavaScript + HTML. The server side of the recipe (in Python, and using websocketd which is written in Go), is here:</p> <p><a href="http://code.activestate.com/recipes/578803-using-websocketd-with-python-for-web-based-system-/?in=user-4173351" rel="nofollow">http://code.activestate.com/recipes/578803-using-websocketd-with-python-for-web-based-system-/?in=user-4173351</a></p> <p>The system monitoring example shows the system disk space info (total, used and free) using the Python psutil module.</p> eMail address list validation (JavaScript) 2014-02-05T22:20:41-08:00SoftMoon WebWarehttp://code.activestate.com/recipes/users/4189155/http://code.activestate.com/recipes/578822-email-address-list-validation/ <p style="color: grey"> JavaScript recipe 578822 by <a href="/recipes/users/4189155/">SoftMoon WebWare</a> . Revision 0. </p> <p>A bit of Regular Expressions to test whether a given string conforms to being an eMail address or comma-separated list of them.</p> CSS line with px value adds a new line with rem (JavaScript) 2013-11-20T21:15:22-08:00Magnus Axelssonhttp://code.activestate.com/recipes/users/4188509/http://code.activestate.com/recipes/578769-css-line-with-px-value-adds-a-new-line-with-rem/ <p style="color: grey"> JavaScript recipe 578769 by <a href="/recipes/users/4188509/">Magnus Axelsson</a> (<a href="/recipes/tags/convert/">convert</a>, <a href="/recipes/tags/css/">css</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>). </p> <p>Put your cursor on a CSS line that ends with a value in px (do not select any text). Run the script and it will insert a new line there the px value is converted to a rem value. </p> <p>You need to edit the code to modify your rem base matching the one you use in your own CSS. The default value is 16.</p> <p>Example: font-size: 12px; (run the script with the cursor in this line) font-size: 0.75rem (new line added by script) </p> Canvas: static forms (JavaScript) 2013-08-08T13:34:41-07:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578626-canvas-static-forms/ <p style="color: grey"> JavaScript recipe 578626 by <a href="/recipes/users/4184115/">greg zakharov</a> (<a href="/recipes/tags/canvas/">canvas</a>). Revision 2. </p> <p>Drawing static forms with canvas.</p> Verify html form with JavaScript (JavaScript) 2013-07-15T12:19:53-07:00Captain DeadBoneshttp://code.activestate.com/recipes/users/4184772/http://code.activestate.com/recipes/578606-verify-html-form-with-javascript/ <p style="color: grey"> JavaScript recipe 578606 by <a href="/recipes/users/4184772/">Captain DeadBones</a> (<a href="/recipes/tags/form/">form</a>, <a href="/recipes/tags/javascript/">javascript</a>). </p> <p>I wrote this for a <a href="http://thelivingpearl.com/2013/07/15/the-guest-book-problem/">php Guest Book</a> app I wrote. </p> Trimming strings (JavaScript) 2013-07-09T14:31:18-07:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578597-trimming-strings/ <p style="color: grey"> JavaScript recipe 578597 by <a href="/recipes/users/4184115/">greg zakharov</a> (<a href="/recipes/tags/trim/">trim</a>). </p> <p>I do not like jQuery that's why I wrote own implementation for trimming strings. There are two ways how to do it.</p> Music player (JavaScript) 2013-05-18T18:18:15-07:00Granning Stolinehttp://code.activestate.com/recipes/users/4186069/http://code.activestate.com/recipes/578517-music-player/ <p style="color: grey"> JavaScript recipe 578517 by <a href="/recipes/users/4186069/">Granning Stoline</a> (<a href="/recipes/tags/music/">music</a>, <a href="/recipes/tags/playlist/">playlist</a>). Revision 2. </p> <p>Music player</p> Komodo JS Macro - show git blame for the current editor line (JavaScript) 2013-05-28T18:59:52-07:00Philip Cooperhttp://code.activestate.com/recipes/users/4168074/http://code.activestate.com/recipes/578537-komodo-js-macro-show-git-blame-for-the-current-edi/ <p style="color: grey"> JavaScript recipe 578537 by <a href="/recipes/users/4168074/">Philip Cooper</a> (<a href="/recipes/tags/blame/">blame</a>, <a href="/recipes/tags/git/">git</a>, <a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/scc/">scc</a>). </p> <p>A <a href="http://www.activestate.com/komodo">Komodo</a> JavaScript macro that can show the SCC repository information for who last changed the current line in the Komodo editor - see the screenshot below.</p> <p><img src="http://community.activestate.com/files/images/svn_blame.png" alt="svn blame image" /></p> Eight queen problem (Javascript) (JavaScript) 2013-03-20T19:03:44-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578497-eight-queen-problem-javascript/ <p style="color: grey"> JavaScript recipe 578497 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/queen/">queen</a>, <a href="/recipes/tags/queens/">queens</a>). </p> <ul> <li>Adding this for my old <a href="http://code.activestate.com/recipes/577438/">recipe 577438</a> (in Python).</li> <li>Use node.js or HTML as execution (see comments in "log" function)</li> </ul> Hex2Dec (JavaScript) 2013-07-04T07:41:53-07:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578506-hex2dec/ <p style="color: grey"> JavaScript recipe 578506 by <a href="/recipes/users/4184115/">greg zakharov</a> . Revision 2. </p> <p>Web hex2dec sample without additional libraries.</p> Is enabled.. (cookie, javascript & java)? (JavaScript) 2013-03-19T11:23:28-07:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578495-is-enabled-cookie-javascript-java/ <p style="color: grey"> JavaScript recipe 578495 by <a href="/recipes/users/4184115/">greg zakharov</a> (<a href="/recipes/tags/cookie/">cookie</a>, <a href="/recipes/tags/java/">java</a>, <a href="/recipes/tags/javascript/">javascript</a>). </p> <p>I'm not sure that the following method is universal in all cases to detect is enabled or disabled cookie, javascript and java in user browser at current moment. This is just an example.</p> Reversing string (JavaScript) 2013-02-18T09:27:33-08:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578464-reversing-string/ <p style="color: grey"> JavaScript recipe 578464 by <a href="/recipes/users/4184115/">greg zakharov</a> (<a href="/recipes/tags/reverse/">reverse</a>, <a href="/recipes/tags/string/">string</a>). </p> <p>Two ways reverse string.</p> Komodo JS macro: example chess match (JavaScript) 2012-10-24T16:59:51-07:00Todd Whitemanhttp://code.activestate.com/recipes/users/2666241/http://code.activestate.com/recipes/578304-komodo-js-macro-example-chess-match/ <p style="color: grey"> JavaScript recipe 578304 by <a href="/recipes/users/2666241/">Todd Whiteman</a> (<a href="/recipes/tags/chess/">chess</a>, <a href="/recipes/tags/editor/">editor</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>). </p> <p>This is an example macro that will play a specific chess game (Deep Blue v's Garry Kasparov) inside the Komodo editor.</p> Komodo JS Macro -- Escape HTML Special Characters in current file (JavaScript) 2012-05-25T20:04:49-07:00Keegan Brownhttp://code.activestate.com/recipes/users/4182206/http://code.activestate.com/recipes/578146-komodo-js-macro-escape-html-special-characters-in-/ <p style="color: grey"> JavaScript recipe 578146 by <a href="/recipes/users/4182206/">Keegan Brown</a> (<a href="/recipes/tags/characters/">characters</a>, <a href="/recipes/tags/html/">html</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/special/">special</a>, <a href="/recipes/tags/xhtml/">xhtml</a>). </p> <p>Escapes all Special Characters to their HTML Special Character equivalent.</p> Komodo JS Macro: Execute JavaScript (JavaScript) 2012-05-07T13:21:30-07:00Patrick Clokehttp://code.activestate.com/recipes/users/4180275/http://code.activestate.com/recipes/578120-komodo-js-macro-execute-javascript/ <p style="color: grey"> JavaScript recipe 578120 by <a href="/recipes/users/4180275/">Patrick Cloke</a> (<a href="/recipes/tags/debug/">debug</a>, <a href="/recipes/tags/debugging/">debugging</a>, <a href="/recipes/tags/editor/">editor</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>). </p> <p>Executes a JavaScript file (or the selected text) and display the results in the command output window.</p> Komodo JS Macro - Add CSS3 Prefixes (JavaScript) 2012-05-25T20:02:50-07:00Keegan Brownhttp://code.activestate.com/recipes/users/4182206/http://code.activestate.com/recipes/578145-komodo-js-macro-add-css3-prefixes/ <p style="color: grey"> JavaScript recipe 578145 by <a href="/recipes/users/4182206/">Keegan Brown</a> (<a href="/recipes/tags/css/">css</a>, <a href="/recipes/tags/macro/">macro</a>). </p> <p>Simple macro to add vendor prefixes to a CSS declaration under the cursor. Isn't smart and doesn't know what needs a prefix and what doesn't, just adds all the prefixes. </p> Triangle Tooth Gear for Physion (JavaScript) 2012-05-10T16:42:33-07:00Isendrak Skatasmidhttp://code.activestate.com/recipes/users/4182031/http://code.activestate.com/recipes/578124-triangle-tooth-gear-for-physion/ <p style="color: grey"> JavaScript recipe 578124 by <a href="/recipes/users/4182031/">Isendrak Skatasmid</a> (<a href="/recipes/tags/addon/">addon</a>). </p> <p>This Script adds a Function for creating a Gear with Triangle shaped Teeth to Physion.</p>