javascript

My first JavaScript. Any errors?

Good Sunday morning! After fiddling around with some JavaScript this weekend, I finally wrote my first script. It is a Tooltip generator. It works great in FF 3 + 3.5, IE 6 + 7, Safari 4, Chrome 2 + 3, and Opera 9 + 10. Before putting my new code into production, I thought I'd ask if you see any glaring problems -- or maybe it's perfec...

How To Keep a Javascript Working with ResonseText Data

I've been building an application with php/mysql and javascript with Prototype/Scriptaculous. A page has a search contacts field, with a default set of data in an HTML table. A user types in some characters, and the table get updated. What's actually happening is the table is getting replaced with a new table and new data. I've got a ...

Drag Table Rows in jQuery

Using jQuery (and UI), I want to be able to drag table rows out of the table and drop them on some element. The rows themselves should not leave the table, similar to how iTunes works when dragging multiple selected songs. I need to use a table since this is tabular data and I already have a table sort plugin in place. Any idea how to ...

Combining the power of Processing.js and Web Workers

I've been doing some reading about two (relatively) new concepts in the Javascript language - Web Workers and John Resig's awesome Processing.js (well, not really a new 'Javascript concept', but you get my idea). Some great examples of both wander the internets, but I have yet to find one that employs both techniques effectively. It look...

Enabling and Disabling Radio Buttons Depending on User Selection

I'm looking to write jQuery to only enable radio buttons depending on which radio buttons are currently selected in accordance with some business logic. Essentially there are 3 groups of 3 radio buttons, which end up looking something like (my apologies for being verbose with this example HTML, but hoping this will show what I mean): <...

how to concatenate regular expressions in javascript?

this is not what i'm asking for: http://stackoverflow.com/questions/680446/concatenate-multiple-regexes-into-one-regex/680454 is there a way to append a regex into another one (in javascript language) ? the reason for doing so is to simplify code maintenance (e.g. if the included string is long or easier to maintain by a non-programme...

Prevent Highlight of Text

I have a table, and I'm allowing users to 'select' multiple rows. This is all handled using jQuery events and some CSS to visually and data-wise indicate the row is 'selected'. When the user presses shift, it is possible to select multiple rows. However, sometimes this cause text to become highlighted. Is there anyway to programmatically...

Jquery ajax live validation / timeout question

Hello, I'm still kindof new to jQuery, so there probably is an easy solution, but I can't find anything. I've made this registration form, that checks if the username or email is taken as the user is typing in the username. Basically it just makes a json request that returns true or false depending on if the username / email is already t...

How to send 2 sets of data back with Jquery Ajax.Post

Hi I am using asp.net mvc and I am trying to send 2 sets of database from jquery to my Mvc view. Now my view will look like this public ActionResult MyView(Product one, Product two) { } now how do I send the stuff back so everything will be binded correctly? I know how to do it with one set of data but not with 2. Like if I only ne...

Prototype vs. Not, what are benefits?

Here I made two objects; one has accessor methods created in the constructor, the other in the prototype. Why would one choose one of these over the other? function spy1(name){ this.name = name; var secret; this.setSecret = function(message){ secret = message; }; this.getSecret = function(){ return secret; }; } funct...

How to find the function name of namespaced constructors in javascript?

For example, compare these two: function Person(name) { this.name = name; } var john = new Person('John'); console.log(john.constructor); // outputs: Person(name) var MyJSLib = { Person : function (name) { this.name = name; } } var john2 = new MyJSLib.Person('John'); console.log(john2.constructor); // outputs: function() The fi...

Selectively enable enter key in HTML textarea (javascript)

Hi, I am using openjs.com's shortcut handling (1) to disable the enter key in my html forms. However, inside of textareas in those forms I want enter key to emit the normal CR-LF pair (because that's what users expect). At the moment assuming I have a form/input structure as follows: <form id="f1"> <fieldset> <input> <textarea i...

javascript code doesn't change font color anymore

Someone made a nice code for me, but after some changes to have the output lined out in a table, the array picks font doesn't change anymore which are controlled by the following CSS. .win { color: lime; font-weight: bold } .loss { color: red; font-weight: bold } Can somebody help me edit the code so the array picks are lime and red ...

Javascript to convert Markdown/Textile to HTML (and, ideally, back to Markdown/Textile)

There are several good Javascript editors for Markdown / Textile (e.g.: http://attacklab.net/showdown/, the one I'm using right now), but all I need is a Javascript function that converts a string from Markdown / Textile -> HTML and back. What's the best way to do this? (Ideally it would be jQuery-friendly -- e.g., $("#editor").markdown...

Make sure a range object doesn't start or end in the middle of a word

My application requires heavy use of ranges (https://developer.mozilla.org/en/DOM/range). In particular, users frequently highlight text and then manipulate it. Sometimes users accidentally highlight text that includes a fragment of a word, and this produces weird results. I'd like to be able to, given a range, check to see whether it s...

Is there a way that I can detect if Firefox will open a particular URL in an IE tab?

I have a web page that links to another web application, which unfortunately only completely functions in IE, so, when viewing the original page with another browser (like Chrome or Safari) I display a warning that the application won't operate fully operate unless opened in IE. Of course, some savvy users of Firefox have the IE tabs ex...

Get title string from url within iframe using jQuery?

Hi all, I wonder if it is possible to get the page title of an url within IFRAME. I tried to use jQuery $('#iframe').attr('title') but that doesn't work. Please help. Thanks. ...

Jquery Hover is delayed

http://wesbos.com/tf/shutterflow/?cat=3 when one hovers over an image .cover is faded in. I use jquery to change the opacity because CSS doesn't work in IE for this purpose. My code is: $(document).ready( function() { $('.slide').hover( function() { $(".cover").animate({ opacity: 0.7 },300 ).fadeIn('300...

JavaScript charts with highlighting and drilldown features

Hello, I'm looking for a JavaScript plugin which would help me to create charts. I would need stacked bar, bar, pie and line charts with drilldown and highlighting features. Everything I found with these features are just flash and I would prefer using JavaScript. Does someone have an idea or a suggestion? Thank you by advance -Yoan...

Javascript function to turn URLs and email addresses into clickable links

Is there a Javascript library that exposes a function to automatically turn URLs and email addresses into clickable links? Basically I'm looking for something that duplicates the Rails helper auto_link(). ...