javascript

Passive view in JavaScript

I'm thinking about an implementation of MVP - Passive View pattern in JavaScript. In most case the view will be simple dom elements where the presenter attaching event listeners. But when it comes to widgets like JavaScript based pseudo selectboxes, auto suggest or aria features, should this be part of a JavaScript view class or should ...

jQuery Slider - How do I make a group of sliders having max value depending on another Slider?

Here is a hard one I have been trying to get it work. It does work half way however I think the logic is the problem. I will explain the situation and the problem below. Situation: Want to use a slider controller to select number of Adult,Child,Infant that can occupy inside a room. For example, a Room which can accommodate 3 person, whe...

how to change dimensions of html5 canvas without it scaling content

I init my canvas like this: <canvas id="canvasDiv" width="20" height="20"></canvas> and somewhere in the code I want to resize it to it's final size: var canvas = document.getElementById("canvasDiv"); canvas.style.width = 200; canvas.style.height = 100; However, any pixel I plot on my canvas is scaled (so it's not 1 pixel anymore)....

js regex escaping quotes

I want to escape all quotes that comes only after the text H1: For instance, : H1: "text here" should become: H1: &quot;text here&quot; This would be easy with lookbehind, but that's not in JS. something I tried: .replace(/H1:(.*)(")(.*)/ig, "H1:$1&quot;$2") Also it should work on other similar text like: H1: ""text here"" H1...

How to execute javascript code on IFrame load

I am dynamically creating an iframe with javascript inside the body. iframe = m_oYDOM.get("ifAdwords"); iframe.contentWindow.document.body.innerHTML = <script type=\"text/javascript\">function Test(){alert(\"Success\");Test();}</script>"; I am not able to get the alert to work. Can someone help me! ...

Preparing XML Data for Chart Library

I am using a flash chart library that takes an xml file/string as input. The xml file is generated using a xml.builder file, but I am not sure the generated xml file is actually being found. If there is a (name).xml.builder file and a (name).html.erb file, does that mean both an html/xml file is generated, when format.html and format...

What's the purpose of creating jQuery code inside this elements like this...

(function ($) { ... } ) (jQuery); ...

Jquery all my functions work except the following

(function($) { var selectIds = new Array(); var sortOnSelect = false; var nameModifier = "tsms"; function removeFormField() { $(id).remove(); } All the other functions after this work. This function says it undefined using firebug. removeFormField is not defined Another function creates this field and the top function i...

Form element added using jQuery is not sent on POST

I have a zend_form where I'm allowing the user to add form elements dynamically. Elements are added dynamically using jQuery : something like... $(function(){ $('#more_answers').click(function(){ var elemNum = $('.dummy-element').size(); $("<dd class='dummy-element' id='dummyanswer_"+elemNum+"-element'><input type='text' valu...

javascript timer or intervals created in loop using closure

I'm using jQuery to setup a timer or interval loop on a few elements to check them every couple seconds. I've tried setting a timer and checking if I should restart it, or setting and interval and checking if I should stop it. Although simplified, this is basically what I need: var mytimers = new Array(); $('div.items').each(function(...

playing with javascript objects and functions, discovered this (probably common)

ok, I was experimenting (getting straight in my head) all this object oriented like stuff javascript can do, and Im simulating inheritance with functions, adding functions to functions (too cool!) and I had a AHA! moment. var myArray = [function(){console.log("im in an array!");}, 2, "fly feet!"]; myArray[0](); Of course, now that Ive...

What does Google Analytics use to keep track of user activity?

Hi folks, just wondering if anyone knows what technologies are used by the tracking software? Edit: I meant client-side. How is data sent to the Google API? Long polling? Streaming? =) Thanks guys! ...

Difference between window[] and eval() - Javascript

I've been using both in javascript ... really don't know the difference. Googling always shows results for the "window object" or "opening a new window in javascript" so couldn't find anything there. eval("v"+e) window["v"+e] Sometimes window works for me and at other times eval works .... So what's the difference between eval() an...

Asynchronous programming in javascript (NOT AJAX)

Is it possibly to do things asynchronously in javascript (AJAX aside)? For example, to iterate multiple arrays at the same time. How is it done? A brief example would be nice. Searching for this was hard, due to all the ajax pollution, which is not what I am looking for. Thanks in advance. ...

How does one get or create a selection or range from a dom coordinate point in javascript?

Hopefully this is possible by invoking a method that gets executed by browser internal code. Given a point x,y in dom coordinates. (that is can get relative to any node) in an element containing text I want effectively charIndex = characterUnderPoint(textNode,nodex,nodey); I figure if there is some sort of facilty to do range = xx.c...

align nested tables in IE

Hey, This is my first question here so let me know if i have not understood the site ethos ;) I have written a html page for showing and hiding nested tables. I would like to get the columns to align correctly. I have got close by setting the columns to have a specific width in both IE and firefox the columns are a few pixels out... ...

Javascript prototype bind

I'm new to prototype based languages and have read this question: http://stackoverflow.com/questions/2025789/preserving-a-reference-to-this-in-javascript-prototype-functions I'm wondering what value there is, of using a prototype based signature to attach methods to an object. Why not just attach the method to the object's property in...

jQuery Selector + SVG Incompatible?

I've been working with an HTML5 document with inline SVG and javascript animation. I'd like to have a box pop up when the user clicks anywhere, and I'd like the box to go away when the user clicks somewhere that isn't the box. This means I can't use $(window).click(), which works. I've tried selecting the SVGs on top by giving them cla...

Javascript: highlight substring keeping original case but searching in case insensitive mode

Hi everybody, I'm trying to write a "suggestion search box" and I cannot find a solution that allows to highlight a substring with javascript keeping the original case. For example if I search for "ca" I search server side in a case insensitive mode and I have the following results: Calculator calendar ESCAPE I would like to view t...

Javascript: get full object hierarchy as string

In Javascript how can I get the full ancestral hierarchy in a string given just a single object? Right now I can't even think about how to ask the question... so I can't even google it. Here's an example: var lvl1 = { one: "one", two: "two" }; lvl1.lvl2 = {flip:"flip", flam:"flam"}; lvl1.lvl2.lvl3 = {who:"who", what:"what"}; test(o)...