Simplifying A Large Number Of Similar Object Definitions?
Mar 24, 2009
I am looking for a way to simplify a large series of �object definitions� in the form:
var Img0 ={init:function(){Img0.div = document.getElementById("img0"); Img1.init();}};
var Img1 ={init:function(){Img1.div = document.getElementById("img1"); Img2.init();}};
[Code]....
The program I have developed (for animated greeting cards) works fine but for a large number of images there are an equal number of these object definitions. I am aware of such techniques as using �+i+� in place of the numbers 0, 1, 2, ... and assigning an increasing value to i in a loop. However, I do not see a way to use such a loop here.
I'd like to make a Degree object that inherits from the Number object and uses the Number constructor but adds a .rad() method that returns the value in radians.
If I do something like:
It generally works but I don't get Number's methods like toString and toPrecision.
I use a bunch of overlapping divs. They operate as pop ups i.e. user clicks button, calls function to show div, it also hides any other divs that might have been open previously i.e. only one div open at one time i.e sample code:
i.e. I thought that if I put the pop divs in another container i.e. another div, then told the container div to hide, then all the embeded divs will also be hidden. This did not seem to work
I have a element when click, it will trigger some other elements to be selected. and those elements will trigger elements in next level.
It is a three levels hierarchy so to speak. but each element will send an ajax request when selected. Those requests will become out of control especially when I repeatedly click the root element.
Can I queue those XHR request in a queue and send them one by one? or maybe add a delay before send so that they can collect their information into one batch request and send one request after that.
The standard Number.toString() method returns values in scientific notation once they exceed 10^20. In many cases, this is not an expected or desired result.
The toLongString() method provides a solution by always returning a literal numeric value regardless of the number's size. However, the value returned will not be accurate beyond the first [log base (radix) of (10^15)] digits.
radix: Optional. A number between 2 and 36, inclusive.Number.prototype.toLongString = function(){ var radix, n = this, d, t = '', p = '' if(arguments.length>0 && typeof(arguments[0])=='number'){ radix = Math.round(arguments[0]); if(radix<2) radix = 2; if(radix>36) radix = 36; } else { radix = 10; } if(n < 0){ n *= -1; p = '-' } while(n > radix){ d = n % radix; n = (n-d)/radix; t = d.toString(radix) + t; } return p + n.toString(radix) + t; }
I have a rather old script that uses XMLHttpRequest to retrieve some html and pops it into a div using innerHTML. I'd like to switch over to using append child since not only is it standardized, but it'll save me bandwidth in the long run. Code:
What I am kooking for is not really a pop-up but more like a tool-tip. I was not sure what else to call it. What I need is a small little area with a different background color and perhaps a border to open next to a word when the symbol next to it is clicked on. This word or phrase would be in a sentence that would require some further explanation or definition.
I guess this would be similar to how someone like iStock Photo does with their thumbnails only it will require a click as opposed to a rollover and it will not be an image, just some text.
I've always had this limitation when adding inline content using JQuery. Such as adding one more text field inline let's say. Basically, if I had defined some code related to input fields outside the scope of the function that adds the inline code, this new input field will not recognize it.
Something like
Code:
However, Ive always solved it by adding the click event another time after the code in placed inline
Code:
But I'm trying now to avoid this repetition, how is it possible?
I'm hacking on a LISP interpreter in JS [1], and running into trouble with numbers and Number objects.
This is what I have:
var a = new Number(1); var b = a; document.writeln(a == b); // true b = 2; document.writeln(a == b); // false document.writeln(a); // 1
Instead of replacing the *Number object* b with the *number* 2, I'd like to assign 2 to the value of the Number object, which should still be referenced by b *and* a. In other words, the two last lines should output "true" and "2".
I 'm using Ajax to build pages with xml files. In my page, I want to have 2 doms for the same xml file : one for the initials datas, ant another which will be modified by the web page. When the user validate the page, the second dom is is copied into the first.
In my page, I have javascript code that modify nodes of the xmlDoc1, but the xmlDoc2 is modified also, but I don't want this dom to be modified! What is the problem with my code?
I have a 'confirm' form that hides a table when a certain field contains a null value.I actually need 3 fields to be null in order for the table not to show rather than one.here part of the working code.
Code: if (document.getElementById('FIELDNAME').value=='') { document.getElementById('ID_OF_TABLE').style.display='none'; }
How or what do i do to allow for 3 (or multiple) fields?This is doing my Head in.I know getElementById is most likely not the way to go as it only allows for one.
I was wondering if anyone knew of a syntax checker/varifier that can be run command line in Linux. I recently ran across JsLint, an online JS verifier that works pretty good. The verification code is written in JavaScript, but he did provide an explanation on how to run it command line using WSH (windows script host).
Does anyone know of something similar on Linux (I'm actually running FreeBSD, but figured Linux would get more responses )? Is there a way to execute javasript command line? Or is there a similar program that varifies javascript?
The reason I'm asking is I would love it if I could check javascript syntax while editing in Vim (I can do this with php, and I can't live without it now ). I thought about maybe creating a wrapper html that runs the script and outputs the errors, but figured why create something new (and not elegant) when there might be a solution out there already.
I have upload image script. where user can upload their images. The width and height of the images are not limited. Users can upload any kind of images. Now the problem I am facing is if users upload large images and small images, the layout get scattered. So I decided to do layout similar to here they have aligned the images very nicely. They looks prety aligned in the way of rows and columns. they are not scattered. So I would like to get exact same layout.
We have to develop a small engine which the client uses. It supposed to work like this. Our engine resides in a frame (frameA) which will be loaded only once and it provides set of functions. The client can call these functions. We inturn should get the values from the server or set the values in the server and return with the values. The way we are planning to implement is that we will have have another frame (frameB hidden) and submit it whenever the client (frameClient) calls our function and wait till the page reloads and return with the value ( set in the reloaded page by the server). The problem we face now is that we don't have any sleep functionality in javascript ( being event driven) and if we have a loop waiting for the reply, it will consume the cpu cycles and the the frameB wont load.
Every 2 to 3 days I check the ticket system to see how the development of the latest JQueryUI 1.9 is doing and how the JQuery is doing. After several weeks of this I have found way too many tickets about IE6 issues and I started to ask myself why does JQuery and actually, many other projects still try to solve problems for somethings that is beyond repair. With this am talking to the fact that:
how to start designing a similar web page as gucci? I will be making a website for jewelery, and i will be using PayPal.Should i create a XHTML page? or CSS ?im using Dreamweaver CS3, Flash CS3, Photoshop CS3
I have a basic page which has a PHP form. It creates a record and uploads a picture. When they user clicks submit, I need it to display a "loading" notice of some description. I was using this:
[Code]....
and then placed a div in the page but it shows the message right at the top of the screen. As the form is long, the user cannot see the message. I need to create some sort of notice so users know the form is being processed.
I was looking for an alternative to lightbox 2 which has a similar look & feel to lightbox that is either stand-alone JS or based on jQuery and supports swf.
Most of the lightbox alternatives I've found don't seem to be very intuitive for visitors (close button in odd places, the prev/next buttons in odd places, excessive use of animations, etc)
Is there anything that's around that you like to use?
Does anyone know how to create a grid with grouping similar to itunes? I have searched the web and cannot find anything. I want to have a category and to the left and several topics to be grouped with that category. See image below.
I posted a while ago about the Truncate plugin not preserving html links in FF. I like the plugin, but it needs to present properly in FF. I couldn't figure it out and nobody responded. Is there any other plugins that provide similar funcationality?
I need a countup script with commas similar to what is on sendgrid.com. I have a script which outputs the countup exactly how I need it but without commas. I have found several formatting scripts that will add commas but as I am terrible at javascript I have been unsuccessful at implementing the formatting. Can anyone provide assistance for adding commas to the countup
Code HTML4Strict: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">