Archive for the 'javascript' Category

11 Mar 2015

replace a frame

11:59 | javascript | 872 views

Goal: remove marker from a text The problem is simple. I have a markered text like this: and I want to remove the marker structure quickly. The solution with regex back-reference: where x the markered text itself $1 (not used) is the main regex: (<span class=”mark”>…) $2 (what we need to keep) is the second […]


14 Feb 2015

quick js editor

23:41 | javascript, web trick | 907 views

Goal: a simple js editor from the browser put the following to the address line… 1. simple way: try this this one is poor because of not focus, but here is the fixed version: 1.1 simple way with focus in the window: try this 2. extended editor (big respect for the ace team! check it […]


28 Sep 2014

check ctrl key is pressed

18:30 | javascript | 719 views

Goal: etxend mouse interaction by handling the ctrl key


18 Sep 2014

javascript array rotate

22:28 | javascript | 792 views

Goal: to rotate a javascript array This is similar to the assembly shift operation with bites 01011 -> rotate left 2 -> 01101 The solution is simple: for (var i = 0; i < 2; i++) { array.push(array.shift()); } [/js] The shift() will cut/remove the first element from the array. The second step is to […]


13 Sep 2014

js array Cheet Sheet

19:26 | , javascript | 936 views

Goal: Collect the array manipulation methods 1. add item to an array shift: The shift() method removes the first element from an array and returns that element. This method changes the length of the array. pop: The pop() method removes the last element from an array and returns that element. 3. insert item to an […]


3 Sep 2014

edit in place

14:56 | javascript, web trick | 733 views

Goal: To create a simple editable field on my page There is a simple way to create an editable DIV field. We can start the editing by click or simple on getting focus. So in this case the editor is the container itself. Forget to create input boxes or textarea-s and forget the additional event […]


21 Jul 2014

javascript remove comments safely and correctly

9:04 | .net, javascript | 735 views

Goal: remove the code comments correctly One part of my javascript minimize process is to remove the comments from the code. As we know the there are two comment types in js: Here is a simple c# code to drop the comments. This code is seemingly correct but there are some special cases like the […]


10 Jul 2014

javascript float strange behavior

21:58 | javascript, tricky | 976 views

Goal: to discover some black hole Javascript is perfect but… check this small piece of code for(var i = 0;i < 5; i+=.1){console.log(i);} [/js] This is a simple iteration but the result is terrible: (with other arguments like .2, .3 ... the result will be different but bad as well - try) [js] 0 0.1 […]


3 Jul 2014

setTimeout with parameters

18:26 | javascript, tricky | 763 views

Goal: to find a compatible form of setTimeout calling with parameters The general form is easy, but not working under ie… The following form is ie compatible…


18 Jun 2014

simple cookie manager class

0:18 | javascript | 769 views

Goal: to create a simple js class for manage cookies I’ve written a simple class to manage cookies. var cookies = new function(){ return { get: function(name){ var r = document.cookie.split(‘; ‘); if(name){ for(var i = 0, l = r.length; i < l; i++){ if(r[i].indexOf(name + '=') == 0){ return r[i].split('=')[1]; } } } else{ […]


#sidebar a { color:#fff; } #sidebar ul ul li { color: #DEF585; } #sidebar h2 { color: #fff; } #sidebar ul p, #sidebar ul select { color: #BEDDBE; } #backfly { background: url(images/golfBallWallPaper.jpg) left bottom fixed repeat-x #65a51d; }