javascript

Can I assign Objects operators? "e.g. +, -"

So I have a simple Javascript Object: function Vector(x, y){ this.x = x; this.y = y; this.magnitude = function(){}; this.add = function(vector){}; this.minus = function(vector){}; this.normalise = function(){}; this.dot = function(vector){} //... } I would like to perform the following ope...

How to parameterize/transliterate in Javascript?

In Ruby on Rails you can easily convert "any" text into a format which would work for subdomains/pathnames. 1) "I am nobody." -> "i-am-nobody" 2) "Grünkohl is a german word." -> "grunkohl-is-a-german-word" I'd like to do this on the client-side for high responsiveness (alternative would be via Ajax). The last example is called transl...

unexpected call to a function in Javascript

Hi, i'm not really good at javascript so I'm here asking. Below is a sample code. <html> <head> <script> function test(one) { alert('surprise! first function with one parameter'); } function test(one,two) { alert('expected: second function with two parameters'); } </script> </head> <body onload="javascript:test('first')"> </body> </ht...

Strange bug with OpenLayers + CloudMade

Hi, I am trying something fairly simple, you can see a demo here: http://www.jsfiddle.net/VVe8x/19/ This bug only appears in Firefox, so to see it press either one of the links once (it will take you to either NY or Israel) then press the other link. The bug is that it will not show me the tiles in that location, instead it will show m...

Javascript equivalent to C strncmp (compare string for length)

Is there an equivalent in Javascript to the C function strncmp? Strncmp takes two string arguments and an integer length argument. It would compare the two string up to length and determine if they were equal as far as length went. Does javascript have an equivalent built in function? ...

jQuery week calendar plugin.

Hi, I have search the net and found nothing. Maybe someone here might have used something that google can't give me. I wanted to use a week calendar. I am using this and have many difficulty in it. One is when my date and time are the same, they overlap in one another and only the one at the top can be clicked. I have tried to hack the...

Setting anonymous function scope of 'this' in jQuery utility / ajax methods

As noted in this blog post you can set the scope of this in an anonymous function in Javascript. Is there a more elegant way of scoping this in the anonymous function call on success of the AJAX request (i.e. not using that)? For example: var Foo = { bar: function(id) { var that = this; $.ajax({ url: "www.somedomain...

Jquery disable theming for a specific element

Is there a way to disable the theming on one element in the page? I have some Jquery UI element but I need to have one of these element not themed. How to do that? ...

Return only time irrelevant date javascript

Hello guys My question is more about logic not code.I created something called prepared messages with time i supply to each new message, i compare the time with current time and give each row a background. Is it possible for me to fetch the time with javascript only the current time NO DATE. Regards ...

JQUERY, Calling a Dialog that I created? Not finding it...

Hello, I'm using the following code to create a Dialog box using JQUERY/UI: var $dialog2 = $('<div id="sharerdialog2"></div>') .html('<p>Loading...</p>') .dialog({ autoOpen: false, title: 'Image Stuffer', position: ['center',150], width: 450, focus:function(event, ui) { $('#dialogcloser').click(function() { ...

Stop a youtube video with jquery?

I have a jquery slider that I have built, basically just three pannels that slide by applying negative left CSS values. Works great, but I have a youtube video in one slide that wont stop when I slide. I've tried display:none and Visibility:hidden which works in all but IE, the audio keeps going in IE. Is there an easy way to kill a vid...

Multiple drag and drop in JQuery: event after dragging

Hey everyone, I am actually trying to make a .php page where I am going to have 3 draggable elements which have to be dragged to 3 droppable elements -each draggable to a droppable, and they are unique, so one each droppable will only accept a certain draggable. The thing is that I need to control that all of the elements have been dra...

How to determine when fancybox is open?

I need to know that fancybox has been open up that to allow or deny another function to start. Build-in functions Fancybox like 'onStart' or 'onClosed' not work. I'm talking about version 1.3.0 RC2 ...

how to detect which level on the dom is selected

I have the following selector $('#navigation ul li a').click(function(evt) {} this get the elements i need, but also retries child elements. ie i get me this as well #navigation ul li li a // extra li Just wondering the best way to detect what level of the dom i am selecting. ...

Getting rid of Value attribute of a textBox when using clone method in jQuery

Hi, Im having problem with this form im working on. Whenever I add, or refresh the page, the values are still there. I believe this is because the clone method copies the value attribute from the textBox. Is there any way I can get rid of them when i add another textBox. <html> <head> <title>JQuery Example</title> <script type...

click-event doesn't fire if blur changes layout

I have a form with blur-events bound to the required fields. Then there is a "Cancel" Button which simply calls an URL (button is an image with click-event). When leaving one of the required fields a warning is written to the page saying that field xy is required. -> this causes a layout shift, meaning all the fields and the buttons are...

good jquery exention for on-the-fly CRUD

Hi I have a user profile page, and I'd like to have an extension that will let the user edit his details on the page, on the fly. The way I figure this happening is once any value is clicked (i.e., "my nickname") it is converted to an editable textarea, and on blur of said textarea, the data is submitted via ajax to the sever, and the f...

Can someone help with this self invoking function stuff?

I've been trying to debug this script all day and I got nothing any help would be greatly appreciated. I keep getting an error that it's missing a curly brace or a square brace or a parenthetical. And also when I try to get the value of my options it says x is undefined but when I input 0 as my index I can retrieve opts.value, my quest...

Greasemonkey Javascript Key Press Help

So I'm currently trying to make a GreaseMonkey script that will allow a user to press left or right on their keyboard and have that go to a previous comic strip or go to the next strip. I currently have some code up but it's not giving me any results. function KeyCheck() { var KeyID = event.keyCode; alert(KeyID); } document.onKeyDown =...

How do I create separately collapsible divs for dynamic content?

I want to create a list that is actually a list of collapsible divs on my site. So when you click on an item on the list, more information will become visible. I'm using animatedcollapse from http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm The problem is that since I'm looping over divs, they all have the same id, and ...