javascript

Google Maps: geocode addresses asynchronously, but get their responses in order

I'm trying to plot lines between two or more addresses in Google Maps. The idea is that addresses are in an array (in the order of the route taken), then the array is looped over and geocoded via Google Maps, so I then have an array of co-ordinates: function showRoute(routes) { var points = []; var geocoder = new GClientGeocoder...

asp.net button use javascript return function

Hi, I have an asp:button control and am using the "CommandName" and "CommandArgument" parameters in the .aspx file. The CommandName is found with <%# Eval("Name") %>, but the CommandArgument has to be found via a javascript function. However, I'm not quite sure how to do this inline. The function returns a number (integer), which is t...

Getting user specified javascript executed for all pages

Is there a way for the user to get browsers to load a (small) piece of Javascript code for every page they view? ...

jQuery not creating area tags

I'm trying to use jQuery to dynamically create an image map, and I ran into a weird behavior: alert( $('<area />').size() ); // 1 alert( $('<area shape="circle" />').size() ); // 0 alert( $('<area />').attr("shape", "circle").size() ); // 1 In other words, I can't create an area tag all at once; if I s...

How to pass external variables to a private javascript outer closure function?

I may have made some poor design choices on this one. I have several objects being instanced like this. core.modules.trial = function(sandbox){ return{ alert_private : function(){ alert(omgpi); } }; }; I would like to do this: core.modules.trial[omgpi] = "external private var"; var trial = core.modules.trial...

What character encoding is this?

%D1%81%D0%BE%D0%B2%D0%B5%D1%82%D1%81%D0%BA%D0%B0%D1%8F%20%D0%B3%D0%B0%D0%B2%D0%B0%D0%BD%D1%8C ...

How to carry out MVC in developing html/js/css?

Is it possible? The ultimate goal I want to achieve is that: When I want to add a new feature to a page,just do something like: importhtml(html.file); importcss(css.file); importjs(js.file); ...

How do I simulate a bitwise rotation of a 64-bit (unsigned) integer in JavaScript?

I need to perform a circular left shift of a 64-bit integer in JavaScript. However: JavaScript numbers are doubles JavaScript converts them to 32-bit signed ints when you start with the << and the >> and the >>> and the ~ and all of the bit-twiddling business. And then it's back to doubles when you're done. I think. I don't want the...

Adding form elements using JQuery

This is probably a very basic question and I know how to do it using plain DOM but would like to learn the JQuery way of doing it. After identifying the set of nodes using the appropriate JQuery selector, I would like to append a textarea, Save and Cancel button to each node with appropriate callback functions attached to the buttons to...

Random 2d movement (similar to flies) in Unity3d

I want to add random movement to some of my game objects similar to the way flies swarm in Unity3D. I've developed a method using the addforce() method but would like to bypass the physics engine. Any help is appriciated ...

Bezier timed animation path

Hi, I'm trying to define a path of points. Each point has an x, y, and time. I then want to query this path and get the current position at that point in time. Let me share some pseudo code. point {x, y, time} function initialisePath(point[] path) { ... // Create Bezier Path } function getXYAtTime(time) { return ... // Ge...

(javascript) what is the wrap function used for regarding event handlers?

I'm trying to understand why people use a wrap function for my event handlers. For example: Example.prototype.wrap = function(obj, method) { return function(event) { obj[method](event); } } Basically, what is wrap used for? Edit: From the example linked below, the code is: String.prototype.capitalize = String.prototype.c...

(javacript) what are prototypes?

What is a prototype for a javascript class? In other words, what is the different between Example.prototype.method {} and Example.method{} when defining the Example class? edit: for those interested, i found a great explanation (in addition to the answer below) here for the difference between class methods and constructor methods...

simple Javascript code - toggle function - please explain

Can someone please explain this javascript. Maybe give comments for each line explaining how it works? It works perfectly I would just like to know how it works. Thanks function toggleMe(a){ var e =document.getElementById(a); if(!e)return true; if(e.style.display=="none"){ e.style.display="block" } else { e.style...

Executing JavaScript when a link is clicked

Which is preferable, assuming we don't care about people who don't have JavaScript enabled? <a href="#" onclick="executeSomething(); return false"></a> Or <a href="javascript:executeSomething()"></a> Is there any difference? Or there any other ways I'm missing besides attaching an event to the anchor element with a JavaScript lib...

Javascript Complex classes

I have the folowing scenario:- I need to create a Request class (in Javascript) with the following structure <Request> <a/> <filter> <x/> <y/> <z/> </filter> <c/> <d/> </Request> The initial question is, how do I accomplish this in Javascript. Now, for the broader picture:- This request is an input ...

using javascript find the height a div is going to take before it is rendered

I have a div which contains different amount of text at different moments (determined by what the server decides to send). I want to find the height this div would take if rendered. At the point when I want the height, the div is not being rendered (display:none). The display is to be set to 'block' later. I have tried .offsetHeight and...

(javascript) why do i need to use a wrap function for event handlers?

I'm trying to understand why in the following code I need Dragger.prototype.wrap and why I can't just use the event handling methods directly: function Dragger(id) { this.isMouseDown = false; this.element = document.getElementById(id); this.element.onmousedown = this.wrap(this, "mouseDown"); } Dragger.prototype.wrap = func...

Flash vs. (Ex)Canvas vs. SVG/VML

Hi Guys, If you were to design a graphics-heavy interactive web application (say a game like Mario Bros.) today, which of the three available technologies would you prefer - Flash, (Ex)Canvas or SVG/VML? What parameters would you consider and how would you rate these technologies on each parameter? I can think of the following: a) Spe...

How to click TinyMCE toolbar's button programmatically ?

I want to make preview button as usual form button next to submit button(as it made in most cases of "Post new topic" forms). How can I programmatically simulate toolbar's preview button click ? I tried $('#article_body_preview').click() but it didn't work. (I use jQuery lib and #article_body_preview is toolbar's preview button elemen...