javascript

How to assign a variable to an element in Javascript like in Actionscript?

In Actionscript I can do var thing:MovieClip = new MovieClip (); thing.somevar = 1; and the thing object would have a variable called somevar. Can I do the same in Javascript if I created an element using createElement? ...

how to determine if date is weekend in javascript

if i have a date coming into a function, how can i tell if its a weekend day? ...

Google Visualization Column Chart - How to make labels as currency.

I'm just trying to figure out to format my labels to be shown as a currency and not just a number: ` echo ' google.load("visualization", "1", {packages:["corechart"]}); google.setOnLoadCallback(drawChart); function drawChart() { var data = new google.visualization.DataTable()...

Asynchronous Unit Tests in Ruby

I'm testing some javascript libraries I've built by using ruby's harmony. Everything is working perfectly except AJAX calls — does anyone have any ideas how to achieve this? My code looks something like this (I'm using RightJS): my.js function makerequest(argument) { new Xhr('http://mysite.com/some/jsonp'),{ jsonp: true, ...

How to prevent XMLSerializer.serializeToString() from re-ordering attributes?

I'm using jQuery to load arbitrary XML strings (fragments of a larger document) into the browser DOM and manipulate them, then using XMLSerializer to load them back to strings and send them back to the server, where they are processed (by python and lxml) and re-integrated into a full XML document. The XML starts and ends in a git repos...

jQuery UI close dynamic dialog...or just the open dialog

I am trying to close an open dialog at the end of a function call and also use my current button element to close the dialog. Here is the code that opens the dialog. It is being called dynamically using the 'rel' attribute of the '.modal_btn'. It opens just as expected: modalDialog = function(dialogId){ $(dialogId).dialog(...

jQuery get attribute out of style

I need to extract something out of the "style" attribute: the "top" and "left" attribute <div style="top: 250px; left: 250px;" id="1" class="window ui-draggable"> What's the best way of doing this with jQuery? Is there an easy way, or will I have to resort to string functions? ...

GLatLngBound from variables in javascript

Hi I have images to overlay on google maps by using checkboxes. I made this script to not create the separate individual script for each overlay but it returns the error of proprty not supported in main.js of google maps api. However, i tried getting the output value in javascript alert and it returns the values as expected. Could anyon...

javascript : extract http urls from a string of multiple urls

Hi All, I have a huge string of multiple URLs in javascript which is of the following format: var urls = "http://..... , http://..... , http://......" I need to extract all URLs from the string into individual variables of part of an array. I cant do a urls.split(",") as some urls seem to have commas in them.Is there a good regex I c...

Is there a memory performance benefit of assigning a function to the prototype in Javascript?

I read that adding functions to an object will chew up more memory then adding functions to the prototype of the object. function Obj() { this.M = function() { // do something }; } var o = new Obj(); The idea was that for every construction of Obj, a new function is created and applied to Obj, thus increasing memory use. For 1000...

Sort day/month array in Javascript

Hi guys, I'm trying to sort an Array of dates from latest to oldest, and unfortunately list.sort (by default) only sorts the first number. My array looks like this: var MyArray = ["13 Jun", "09 Jun", "25 Aug", "30 Jun", "13 Aug"]; I tried to make a function for the .sort to reference, but the whole process is somewhat confusing to me...

JavaScript: How to replace 0-9 with a-j

Using JavaScript's replace and regex, how do I replace numbers 0-9 with the letters a-j ? example mapping: 0 = a, 1 = b, 2 = c, 3 = d, 4 = e and so on. so, before: x = 3; after: x = 'd'; ...

Greasemonkey script for changing "inbox" to "test" at yahoo mail

Hi all, with Greasemonkey script, I would like to change the link "inbox" to "test", it's probably in AJAX. How to do it? Ram Update from OP remark, below: Well i'm a newbie, could some one please write the script to change the word "inbox" to "test" on yahoo mail? (Andy's script didn't work for me) ...

How can I scroll to and possibly highlight text within div with overflow: true?

I have a div that contains some text content and I'd like to scroll and possibly highlight this within Javascript. I found this link that describes how to scroll an entire page, but it doesn't seem to work when only using a div. Update I just attempted 2 approaches. Only the uncommented one worked, but it didn't really scroll enough....

Preventing special character input to html text field

I have an input text field that needs to be limited as to what characters can be typed in. As one form of defense against faulty input, I'm trying to not even let the user type in incorrect things. The input can be [a-zA-Z-._] characters and is limited to 32 characters. <input id="aliasEntry" type="text" maxlength="32"> As you can s...

Finding a set of coordinates within a certain range from latitude longitide

I am working on a project in javascript involving google maps. The goal is to figure out 16-20 coordinate points within n kilometers from a set of latitude longitude coordinates such that the 16 points if connected will form a circle around the original coordinates. The end goal is to make it so I can figure out coordinates to plot and...

Advice needed... Javascript OOP/namespacing

Hi everybody, right now i am at a point where i feel that i need to improve my javascript skills because i already see that what i want to realize will get quite complex. I've iterrated over the same fragment of code now 4 times and i am still not sure if it's the best way. The task: A user of a webpage can add different forms to a web...

Testing the existence of a method

I'm trying to make some existing JS backwards compatible. I need to override a method if it does not exist, otherwise just return the existing method. Here is the code I have so far: this.grid.getDataSource = function(){ if (getDataSource == undefined) return getStore(); else return getDataSource(); } However ...

how to format javascript date

how can i format a javascript date object to print as "10-Aug-2010" ...

Controlling textbox/overflow scrolling using javascript

I am trying to build a web console application at the moment. I have coded all the most major parts of the app, but I still need a way to display the text appropriately once I have brought it into the browser. There will be more text than the box should be displaying at any one time, so there obviously needs to be some sort of scroll. A ...