javascript

A tricky javascript question

I'll probably best explain this through code. I got something like this: var object1 = function(){ //do something } var object2 = function(){ //do something else } var objects = { 'o1' : object1, 'o2' : object2 }; var actions = []; function addAction( actionName ){ var object = objects[actionName]; actions.push( functio...

how to load a webpage into the google map bubble rather than a textnode of text

rather than using a textnode to show content im trying to figure out how to load a webpage with params into the google map. here is the code im working with if (GBrowserIsCompatible()) { var map = document.getElementById("map_canvas"); var m = new GMap2(map); m.setCenter(new GLatLng(36.158887, -86.782056), 13); m.openInfo...

Algorithms for positioning objects in a canvas

Where can i find some algorithm to position some objects in canvas in a clever way? I'm using javascript (with Raphael svg library), but examples with other languages (or pseudo-language) are welcome. Geometry isn't my strong point =) For example have 600x800 canvas, and i want to place n objects sized 60x60 in smart ways, for example: ...

Overwriting the Array constructor does not affect [], right?

I just read this: http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx I was under the impression that overwriting Object or Array only had an effect if you chose to use the constructor functions when creating arrays/objects, but, according to that article, it also has an effect on literal creation ({} and [...

using the jquery validation plugin, how can I add a regex validation on a textbox?

Hi, I am using the jquery validation plugin from: http://bassistance.de/jquery-plugins/jquery-plugin-validation/ How can I add a regex check on a particular textbox? I want to check to make sure the input is alphanumeric. ...

Opera: .js file won't load.

Hi All, I have a page that calls a script in the header, like so: <script type="text/javascript" src="http://www.discoverfire.net/analytics/l/a.js"&gt;&lt;/script&gt; (Note you will NOT be able to load this script as it is DND'd locally as a staging domain) Very Simple. Firefox, IE, Chrome all have no problem with this basic, squar...

Get element with highest occurrence in an array

Hi, I'm looking for an elegant way of determining which element has the highest occurrence in a javascript array. For example in ['pear', 'apple', 'orange', 'apple'] the 'apple' element is the most frequent one. ...

How to convert a Title to a URL slug in jQuery?

I'm working on an app in CodeIgniter, and I am trying to make a field on a form dynamically generate the URL slug. What I'd like to do is remove is punctuation, convert it to lowercase, and replace the spaces with hyphens. So for example, Shane's Rib Shack would become shanes-rib-shack. Here's what I have so far. the lowercase part was ...

ASP.NET MVC Rich Text Editor

Goal The goal of this wiki entry is to create a comprehensive list of available rich text editors for err... traditional websites. By traditional we mean anything that isn't asp.net with server controls and viewstate. Open source and commercial options are both viable for discussion. Why This Wiki I have found bits and pieces of use...

Jquery Horizontal Accordion Webkit Bug

I'm trying to build a horizontal accordion with Jquery. It seems to be working "ok" in Firefox. But in Webkit (Safari 3 + 4, and Chrome) the sub-level UL flashes after the Hide function. Any help would be greatly appreciated. To see a working demo: http://ableobject.com/horaccordion1.html Here is what I'm working on: <html xmlns="ht...

Javascript Double-Click Element

Hey guys.. Quick question: I wrote a simple JS that opens lightBox for image viewing when an image link is clicked. Basically, using jQuery (yes, I was that lazy), I detect the click of an anchor tag, use a regex to make sure that the HREF attribute is to an image file, and if it is, it opens the image in lightBox. It all works fine, ex...

Hiding/UnHiding Flash Videos With Javascript

I am attempting to load an embedded Youtube video when my page loads, and then hide it right away once it has loaded. This is working fine, however when I want to make it visible it appears for just a second then it disappears. This is happening in both Firefox 3.0 and Safari 4, I haven't tried it in any other browsers. I have tried hid...

What is the best way to write to several logs that are continuously being updated?

Working on an irc client in Adobe AIR in JavaScript, and thinking about logging. Each channel would have its own log file. I wouldn't keep all of the logs open while the app was running would I? I'd log every few minutes? What's the best way to do this? ...

iframe's onload event not firing in firefox (related to ASP.NET file uploading)

Main Page: <iframe src="/files/new" onload="alert('onload');"></iframe> and inside the iframe, /files/new renders: <form action="/files/create" method="post" enctype="multipart/form-data" > <input type="file" name="file1" size="28" /> <input type="submit" value="submit" value="Submit" /> </form> If I submit a file, iframe's...

Alternative to innerHTML

I kind of feel like I'm abusing the DOM with my code... for(var i=0; i<json.length; ++i){ var newobj = document.createElement("div"); var inner = "<img src='"+json[i].picture+"' alt='Item preview' class='icon' />"; inner += "<p>"+json[i].id+"<br />qty:"+json[i].qty; inner += "<a href=\"javascript:clearProduct('"+jso...

Critique on jQuery Use

I'm busy introducing myself to jQuery by implementing a little system where onmouseover on an element causes a text balloon to pop up close to the element. I feel like I'm using too much vanilla JS here, so please suggest where I can improve and what is wrong with this code: <head runat="server"> <script type="text/javascript" src=...

Adobe After effects scripting on Vista

Hi All, i have the following snippet of xml that should point to a file. <pathurl>file:///E:/P2%20Cards/16-11-08/Scenes1/Reel58/CONTENTS/VIDEO/1061MK.MXF</pathurl> and that is taken in by a script including a whole lot of other information into after effects in what is in Extendscript/javascript.. the following is the code that i...

Wondering if there is a .html() equiv that can used for xml ?

$.ajax({ type: "GET", url: "awards.xml", dataType: "xml", success: parseXml }); function parseXml(xml) { I see $("#xml_test").append($(this).find("award").text()); }); returns all the text from my award nodes $("#xml_test").append($(this).find("award").html()); }); my award nodes have some html in them so i was hoping i coul...

load video in shadowbox on page load

I need to load a video in shadowbox when the homepage loads I need to know what the code would be and specifically where the onload code would go to make this happen Thank you DeZiner76hd ...

Changing the browser zoom level

I have need to create 2 buttons on my site that would change the browser zoom level (+) (-). I'm requesting browser zoom and not css zoom because of image size and layout issues. Well, is this even possible? I've heard conflicting reports... Thanks! ...