javascript Programming Glossary: math.min
Is the Gideon Sundback zipper doodle[Google,24th April] completely javascript? http://stackoverflow.com/questions/10295980/is-the-gideon-sundback-zipper-doodlegoogle-24th-april-completely-javascript b 0 b x b b a W J.G 3 b a 2 c W J.B 3 b d a A 50 a Math.min 1 a B 50 a if H a 0 j.save j.globalAlpha a W J.v 0 A c ..
Sort an array by the “Levenshtein Distance” with best performance in Javascript http://stackoverflow.com/questions/11919065/sort-an-array-by-the-levenshtein-distance-with-best-performance-in-javascript d I j 1 d i J 1 d I J c b J J I return d len1 1 len2 1 Math.min false How can I work with algorithm or a similar one into my.. if i 1 j 1 s_i t.charAt j 2 s.charAt i 2 t_j d i j Math.min d i j d i 2 j 2 cost Step 7 return d n m share improve this..
Truncate a string straight javascript http://stackoverflow.com/questions/1301512/truncate-a-string-straight-javascript document.referrer var trimmedPathname pathname.substring 0 Math.min length pathname.length document.getElementById foo .innerHTML..
JavaScript: min & max Array values? http://stackoverflow.com/questions/1669190/javascript-min-max-array-values about augmenting the built in Array object to use Math.max Math.min instead Array.prototype.max function return Math.max.apply null.. null this Array.prototype.min function return Math.min.apply null this Augmenting the built ins can cause collisions.. just apply 'ing Math.xxx to your array directly var min Math.min.apply null arr max Math.max.apply null arr share improve this..
jQuery animate backgroundColor http://stackoverflow.com/questions/190560/jquery-animate-backgroundcolor g.end b g.end g.colorInit true g.elem.style e rgb Math.max Math.min parseInt g.pos g.end 0 g.start 0 g.start 0 255 0 Math.max Math.min.. parseInt g.pos g.end 0 g.start 0 g.start 0 255 0 Math.max Math.min parseInt g.pos g.end 1 g.start 1 g.start 1 255 0 Math.max Math.min.. parseInt g.pos g.end 1 g.start 1 g.start 1 255 0 Math.max Math.min parseInt g.pos g.end 2 g.start 2 g.start 2 255 0 .join function..
Turn a number into star rating display using jQuery and CSS http://stackoverflow.com/questions/1987524/turn-a-number-into-star-rating-display-using-jquery-and-css is in 0 5 range multiply to get width var size Math.max 0 Math.min 5 val 16 Create stars holder var span ' span ' .width size Replace..
How can I differentiate a manual scroll (via mousewheel/scrollbar) from a Javascript/jQuery scroll? http://stackoverflow.com/questions/2834667/how-can-i-differentiate-a-manual-scroll-via-mousewheel-scrollbar-from-a-javasc stop when window.scrollTop reaches its maximum. var y Math.min target.offset .top document .height window .height also don't..
How do you get the hue of a #xxxxxx colour? http://stackoverflow.com/questions/3732046/how-do-you-get-the-hue-of-a-xxxxxx-colour r g b r 255 g 255 b 255 var max Math.max r g b min Math.min r g b var h s l max min 2 if max min h s 0 achromatic else var..
jquery ui drag easing/inertia http://stackoverflow.com/questions/4443526/jquery-ui-drag-easing-inertia dY y2 y1 dMs Math.max t2 t1 1 Speeds var speedX Math.max Math.min dX dMs 1 1 speedY Math.max Math.min dY dMs 1 1 Distance moved.. var speedX Math.max Math.min dX dMs 1 1 speedY Math.max Math.min dY dMs 1 1 Distance moved Euclidean distance var distance Math.sqrt..
Creating a textarea with auto-resize http://stackoverflow.com/questions/454202/creating-a-textarea-with-auto-resize adjustedHeight if maxHeight adjustedHeight Math.min maxHeight adjustedHeight if adjustedHeight text.clientHeight..
javascript shorten string without cutting words http://stackoverflow.com/questions/5454235/javascript-shorten-string-without-cutting-words the middle of a word trimmedString trimmedString.substr 0 Math.min trimmedString.length trimmedString.lastIndexOf share improve..
Convert RGB-->RGBA http://stackoverflow.com/questions/6672374/convert-rgb-rgba 4 2 16 r parseInt r.substr 0 2 16 var min a 255 min Math.min r g b 255 return r r 0 r min a g g 0 g min a b b 0 b min a a..
Get cursor or text position in pixels for input element http://stackoverflow.com/questions/6930578/get-cursor-or-text-position-in-pixels-for-input-element 0 if selectionStart 0 selectionStart 0 else selectionStart Math.min input.value.length selectionStart if typeof selectionEnd string.. if selectionEnd 0 selectionEnd 0 else selectionEnd Math.min input.value.length selectionEnd If available thus IE use the..
jquery pagination + twitter bootstrap http://stackoverflow.com/questions/8400804/jquery-pagination-twitter-bootstrap var start current_page ne_half Math.max Math.min current_page ne_half upper_limit 0 0 var end current_page ne_half.. ne_half upper_limit 0 0 var end current_page ne_half Math.min current_page ne_half np Math.min opts.num_display_entries np.. end current_page ne_half Math.min current_page ne_half np Math.min opts.num_display_entries np return start end This is the event..
|