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 […]
Archive for the 'javascript' Category
replace a frame
11:59 |
javascript |
872 views
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 […]
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 […]
check ctrl key is pressed
18:30 |
javascript |
719 views
Goal: etxend mouse interaction by handling the ctrl key
Goal: etxend mouse interaction by handling the ctrl key
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 […]
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 […]
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 […]
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 […]
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 […]
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 […]
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 […]
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 […]
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 […]
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 […]
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…
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…
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{ […]
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{ […]