javascript

motionpack.js remember state with cookie?

Hi there, I'm currently using Harry Maugans's motionpack.js toggle javascript file in order to collapse divs. I'd like to know if it's possible to put it so that there is a cookie value assigned to it? That way it remembers if a certain div has been collapsed or open. I'm currently new to javascript, so it'd really appreciate it if s...

Checkboxs: ticking me off!

Hi, this is a small, but very annoying, glitch in my form. I have a checkbox, that if clicked displays others checkboxes and input fields for the user to add more information. If this trigger checkbox is unclicked, the extra options dissapear. However (the plot thickens), if another checkbox is checked in the form, the trigger checkbox...

HTML5 DB error callback, how to know the sql request throwing error ?

I use the html5 database in safari like that (simplified code) : createContent : function() { this.database.transaction(function(transaction){ for (var elm in lotOfElm) { transaction.executeSql('INSERT....VALUES (?, ...?)', [elm.att1, elm.att2...], nullDataHandler, errorHandler); } }); }, errorHandler: fun...

Better way to call superclass method in ExtJS

All the ExtJS documentation and examples I have read suggest calling superclass methods like this: MyApp.MyPanel = Ext.extend(Ext.Panel, { initComponent: function() { // do something MyPanel specific here... MyApp.MyPanel.superclass.initComponent.call(this); } }); I have been using this pattern for quite some time and the ...

Managing a shared resource with functional programming style in JavaScript

How does the functional programming paradigm deal with shared resources that need to maintain state? I have a JavaScipt program that allows access from multiple callers to a shared resource, a authenticated HTTP session in this case. The resource has bunch of state information associated with it including things like credentials, cache...

calling a variable inside html

I am trying to make a script that when you type in a hex value and press submit itchanges the text color to the color inputted. It seems the problem is the way i am calling the variable "userInput" inside the variable new html Any Ideas? <script type="text/javascript"> function changeText3(){ var userInput = document.getElementB...

Javascript Event Handlers supported on SVG by Firefox 3.5

Hi Guys, I have been wracking my brains for the whole day on this one. It appears that the SVG DOM manipulations supported by Firefox 3.5 are very limited. A few properties like this.style.cursor can be successfully manipulated with an onmouseover handler but interesting properties like this.style.fill or this.style.stroke cannot be! D...

[JS] /PM regex syntax for sending message in chat-room

I am working on a AJAX/PHP chatroom and am currently stuck on the regex to detect if a user has send a PM & then work out who it is too and what the message is. If the user types something like /pm PezCuckow Hi There you so awesome! I would like to first test if my string matched that pattern then get 'PezCuckow' and 'Hi There you...

How to implement an Enterprise-grade JavaScript "framework" for web designers?

I have been tasked with improving the current mess that is our JavaScript "strategy"; we're an online shopping company and my boss has given me time to do this properly. He is very keen on keepin this modular and increase the reusability of the components. Our HTML is being rendered with JSP and we have lots of custom tags writing out, ...

How to click a link from javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? Thanks ...

Updating on screen count as javascript code runs.

Hey, I've just started learning JavaScript and I'm making a little script that generates two numbers, the first number stays the same but the second number gets regenerated if it doesn't match the first number. Here is my script: function randomNumberMatcher(){ $(document).ready(function(){ var number1 = Math.floor(1000000*Mat...

Set element style/property in for loop

I'm trying to set properties of some elements through a for loop, but am confused about the implementation. Here is the code: var fiArray = new Array('name','address','address2','phone','fax','misc1','misc2'); function disableFields(){ for(i=0,x=fiArray.length; i < x; i++){ var disEl = "$('formID')."+fiArray[i]; disE...

Should we validate method arguments in JavaScript API's?

I'm developing a JavaScript library that will be used by 3rd party developers. The API includes methods with this signature: function doSomething(arg1, arg2, options) arg1, arg2 are 'required' simple type arguments. options is a hash object containing optional arguments. Would you recommend to validate that: - argument types are val...

Cause of pointer shape change over dropdown fields in IE6?

I have a web page with a form with several dropdown fields. For certain users, using IE6, there is a strange bug where mousing over the dropdown fields will cause the mouse cursor image to flicker between the standard 'arrow' icon and the capital-I shaped text-field icon. Specifically, every time you move the mouse one pixel while hoveri...

What is the fastest or most elegant way to compute a set difference using Javascript arrays?

Let A and B be two sets. I'm looking for really fast or elegant ways to compute the set difference (A - B or A \B, depending on your preference) between them. The two sets are stored and manipulated as Javascript arrays, as the title says. Notes: Gecko-specific tricks are okay I'd prefer sticking to native functions (but I am open to ...

[jQuery] What is the rule? when do i use $(this) and when is "this" enough?

I know that $(this) results in a jQuery object, but i often see (especieally in jQuery plugins) the use of return this.whatever what is the general rule? Thanks ...

intermediate in javascript looking for a book to learning object oriented programming

I am an intermediate javaScript programmer, and i am interested in expanding my knowledge in object oriented programming (especially object oriented JavaScript). I would prefer a book over browsing scattered web resources, does anyone have an idea of which book will be best to get a head start with? Thanks ...

Calling a JavaScript function named in a variable

I have a JavaScript variable which contains the name of a JavaScript function. This function exists on the page by having been loaded in and placed using $.ajax, etc. Can anyone tell me how I would call the javascript function named in the variable, please? The name of the function is in a variable because the URL used to load the page...

RSV Prototype Example

I'm trying to get Ben Keen's RSV for Prototype working. I found a suggestion for Ben Keen's component but, I'm having trouble getting it working with Prototype. Here is my code, it doesn't seem to be working. The error is RSV isn't a function. I'm not sure how to translate the jQuery example to Prototype. function DomLoaded() { var ...

Calling js function in external js file

I'm trying to call a simple function with alert but it wont work when i try call the function (contained in an external js file) from my html page. I have a import and the call is very simple. Any suggestions? <head> <script src="/js/jsFunctions.js" type="text/javascript"></script> In my code I call <a href="javascript:displayAl...