All topics
 
member picmember pic
 
Snippets by author: A
 
Overall visits to all the topics: 4,982,353
Daily average (Calculated from the website subscription day): 2,065.652
Optional sorting commands:
Order by amount of visits: click here
Order by vote (attention: this may exclude from the returned results all the entries that have no votes): click here
Normal order: click here
Current order: by category: Programming Javascript
Other categories available for this author (Limited data report: 100):
Advice: Martial Arts and Self Defense(4), Books(236), Critical Reviews and Essays(4), Dictionaries(1), Emergency Care(4), Epistles Letters and Advice(5), Fantasy Epics and Fables(1), History and Documents(5), Humor and Jokes(2), Methematics(2), Music and Lyrics(6), News Digests and Press Reviews(1), Novels Poetry and Stories(3), Philosophy Reviews(7), Poetry(1), Programming(4), Programming Ajax(2), Programming Javascript(82), Programming Php(52), Psychology(1), Quotes(1), Religion Esoterica and Spirituality(12), Scientifical Reviews(4), Self Improvement(1), Sport Activities and Apparels(2), Tarots(1)
Showing topics: 11, 20
Available total: 448
This subscriber has a blog too: Read the blog. Shoutbox: 103 reviews: 153
 
Javascript Insert Text In Textarea Or Input Field At Caret Cursor Position Identification Number: 421 http://en.wikipedia.org/wiki/File:Miniaturk_009.jpg Preview: OBJECTIVE : given a textarea or an input of the text type, insert at the caret position (where the mouse is/was positioned) any text of your choice.function insertInField(obj, text) obj.value=obj.value.substring(0, obj.selectionStart)+text+obj.value.substring(obj.selectionEnd)   INPUTS : first argument a valid Dom object , such as one passed via document.getElementById: yet it must be either a textarea object or an input object.   Second argument, a string representing the text you mean to insert.     RETURNS : nothing.     Caveats : it is worth to mention that a finer way to achieve this goal could have been possible on a textarea tag, and more precisely this:(obj.childNodes.length)?obj.childNodes 0 .insertData(obj.selectionEnd, text):o... read more: click here Visitors: 12,670 Tagged by its author as: Programming Javascript This author also has a Blog Javascript Select Menu Replace Option Store Old Properties Identification Number: 417 http://en.wikipedia.org/wiki/File:Miniaturk_009.jpg Preview: OBJECTIVE : given a select tag menu, replace an option upon a given event and be sure you can still read the removed option properties.function replaceOption(optionObject, newValue, newText)   if(!optionObject !optionObject 'nodeName' optionObject 'nodeName' .toLowerCase()!='option')return false; ;   if(typeof newValue=="undefined" newValue===false) newValue=optionObject.value; ; if(typeof newText=="undefined" newText===false) newText=optionObject.text; ;   var select=optionObject.parentNode; var i=optionObject.index;   select.replaceChild(document.createElement('OPTION'), optionObject);   select.options i .text=newText; select.options i .value=newValue; select.options i .style.cssText=optionObject.style.cssText;   return (select.selectedIndex=i), optionObject/*.value .text*/ ;   /*keep this comment to reuse freely   http://www.fullposter.com/?1... read more: click here Visitors: 9,237 Tagged by its author as: Programming Javascript This author also has a Blog Javascript Roll Dice Get Numbers In Range And Overall Statistical Frequencies Identification Number: 416 http://en.wikipedia.org/wiki/File:Miniaturk_009.jpg Preview: OBJECTIVE : roll a virtual dice in javascript and return a set of data about the drawn instances.function dice(max, min)   this.max=Math.abs(max) 0; this.min=parseInt(min) 0; if(this.min>this.max)var tmp=this.max; this.max=this.min; this.min=tmp; ;   this.diff=this.max-Math.abs(this.min);   this.maxDrawn=0; /*private:*/this.maxDrawntmp=0;   this.casts=0; this.sum=0; this.average=this.average;   this.otherDrawn=   ; this.drawn=   ; for(var i=this.min; i=this.maxDrawntmp) this.maxDrawntmp=this.drawn this.cast ; this.maxDrawn=this.cast; ;   this.otherDrawn this.cast =this.casts-this.drawn this.cast ;     /*keep this comment to reuse freely   http://www.fullposter.com/?1*/   INPUTS : two numbers representing the maximum... read more: click here Visitors: 8,799 Tagged by its author as: Programming Javascript This author also has a Blog Javascript Fast Human-Friendly-Date Format Date Validation Identification Number: 415 http://en.wikipedia.org/wiki/File:Miniaturk_009.jpg Preview: OBJECTIVE : given an user supplied date, which must be a string in a specific and yet human friendly format (the specificity of such format is detailed further on), determine whether such data exists (that is, there is not for instance the typical February 29 chosen for a year that is not a leap year, or an altogether non existent month) or not.     The advantage of this function is that it is so short: most approaches we find on the internet to tackle this challenge seem totally unaware that the javascript date object already takes care of correcting wrong inputs without custom extensive validation procedures being necessary at all.function dateValidation(dateString, splitter)   splitter=splitter '/'; var dateString2=dateString.split(splitter), foo, mfoo, dfoo;   foo=new Date(parseInt(dateString2 2 ) 0, (parseInt(dateString2 1 )-1) 0, p... read more: click here Visitors: 10,113 Tagged by its author as: Programming Javascript This author also has a Blog Javascript Form Clear Default Input Values Upon Submit Identification Number: 414 http://en.wikipedia.org/wiki/File:Miniaturk_009.jpg Preview: OBJECTIVE : given a form, before submitting it remove all the default values of its editable inputs.   A similar task is Javascript Form Reset Elements Values By Elements Shared Name Plus Suffix. function unDefault(form)   var editables='text':true, 'textarea':true   for(var e=0; e... read more: click here Visitors: 11,111 Tagged by its author as: Programming Javascript This author also has a Blog Javascript Cross Browser Iframe Events With designMode Or contentEditable Identification Number: 413 http://en.wikipedia.org/wiki/File:Miniaturk_009.jpg Preview: OBJECTIVE : given an iframe, make its content editable and allow the onclick event on it.     Despite the apparently simplicity of this task, it may cause significant problems in order to implement it as cross browser: not all events are allowed in the same way on iframes depending on the client's browser.function b(iframe, yourFunction)   if(document 'all' )iframe.contentWindow.document.designMode='On'; ;   iframe.contentWindow.document.documentElement.contentEditable="true";   if(yourFunction) iframe.contentWindow.document.onclick=yourFunction; ;   /*keep this comment to reuse freely   http://www.fullposter.com/?1*/     INPUT : only one representing the iframe object. Ideally it is passed as keyword this from an onfocus event set on the iframe tag.   Second argument, an object function (that is the name of a function of your desig... read more: click here Visitors: 10,860 Tagged by its author as: Programming Javascript This author also has a Blog Javascript Sum Dates: Add Or Subtract Any Amount Of Time From Any Given Date Identification Number: 411 http://en.wikipedia.org/wiki/File:Miniaturk_009.jpg Preview: OBJECTIVE : provided a date or the current date, add or subtract time to it and return the subsequent timestamp.   Similar task, with caveats that may apply here too: Javascript Date Verify Whether A Date Falls Within Any Given Time Range. function dateAdd(value, unit, dateObject)   value=parseInt(value) 0; unit=parseInt(unit) 0; if(typeof dateObject!='object')dateObject=new Date(); ;   var y=0, M=0, d=0, h=0, m=0, s=0, ms=0;   switch(unit)   case -2: y=value; break;   case -1: M=value; break;   case 0: d=value; break;   case 1: h=value; break;   case 2: m=value; break;   case 3: s=value; break;   case 4: ms=value; break;   default: d=value;     return new Date(dateObject.getFullYear()+y, dateObject.getMonth()+M, dateObject.getDate()+d, dateObject.getHours()+h, dateObject.getMinutes()+m, dateObject.getSeconds()+s, dateObject.getMilliseconds()+ms)   /*keep this comment to reuse freely   http://www.fullposter.com/?1*/   ... read more: click here Visitors: 9,654 Tagged by its author as: Programming Javascript This author also has a Blog Javascript Date Difference: Calculate The Difference Between Two Dates Identification Number: 410 http://en.wikipedia.org/wiki/File:Miniaturk_009.jpg Preview: OBJECTIVE : make a date difference calculation in javascript.function dateDiff(date1, date2, justReturn)   date1=(date1 new Date()).getTime(); date2=(date2 new Date()).getTime();   var diff=date1-date2; if(justReturn)return diff; ;   diff/=(1000*60*60*24);//milliseconds in 1 day   var preh=diff*24; var h=Math.floor(preh);   var prem=(preh - Math.floor(preh)) * 60; var m=Math.floor(prem);   var press=(prem - Math.floor(prem)) * 60; var s=Math.floor(press);   return diff, h, m, s ;   /*keep this comment to reuse freely   http://www.fullposter.com/?1*/     INPUTS : both the first two arguments must be javascript data objects initialized as the signature wants:   new Date(year, month, day, hours, minutes, seconds, milliseconds);   however milliseconds are optional. Remember that months in javascript are represented starting with zero for January, therefore December is 11.   It is not... read more: click here Visitors: 10,651 Tagged by its author as: Programming Javascript This author also has a Blog Javascript Select And Unselect Multiple Options Without Using CTRL Or Loops Identification Number: 409 http://en.wikipedia.org/wiki/File:Miniaturk_009.jpg Preview: OBJECTIVE : given a drop down menu (select tag) that allows multiple selections of options, create a function that permits the multiple selections and deselections without keeping pressed the ctrl key on the keyboard, and also without having to loop all the options in order to achieve the goal (which may cause significant delays in case of menus that include a few hundreds of options, which may happen).function selections(sel)   if(!sel 'storage' )sel 'storage' =   ; ;if(sel 'size' >sel.options.length) sel 'size' =sel.options.length; ;if(sel.selectedIndex... read more: click here Visitors: 11,190 Tagged by its author as: Programming Javascript This author also has a Blog Javascript Toggle Layers By Class Names Or Id. Show Some Hide Others Or Reverse Identification Number: 408 http://en.wikipedia.org/wiki/File:Miniaturk_009.jpg Preview: OBJECTIVE Given a set of layers, toggle their visibility so that either only the ones that belong to specified class name(s) are showed and all the others hidden, or so that only the ones that belong to specified class name(s) are hidden and all the others are showed.   function toggler(wrapper, typesToShow, reverse) //2.1.0.0   /*INITIALIZATION:*/   if(typeof wrapper=='object' && !wrapper 'length' )/*is a wrapping layer*/wrapper= wrapper ;   else if(typeof wrapper=='object' && wrapper 'length' )/*is an array of wrapping layers*/   for(var w=0; w... read more: click here Visitors: 9,344 Tagged by its author as: Programming Javascript This author also has a Blog