javascript

Representation of number sequence in JavaScript

can this array of numbers sequence be represented in less characters (excluding whitespace) than this? i = [0,1,2,3,4,5,6,7,8,0,3,6,1,4,7,2,5,8,0,4,8,6,4,2]; (52 chars) or a function i which returns the same values in under 52 chars the aim is to reduce the number of characters used to represent the code. ...

Fancybox gets javascript "not implemented" error in IE8 compatibility mode

When doing a modal pop up using jquery.fancybox-1.2.6.js it works on every platform I have tried except IE8 when set to compatibility mode. When the modal tries to display I get a javascript "not implemented" error on the page that keeps the modal from ever popping up. It gives the line number (line 207) the error occurs on in jquery.f...

Scope of "this" in JavaScript

I have a JavaScript class that looks like this: function SomeFunction() { this.doSomething(function() { this.doSomethingElse(); }); this.doSomethingElse = function() { } } This code throws an error because the scope of "this" inside the function that is passed into doSomething() is different that than...

Regular Expression for formatting numbers in JavaScript

I need to display a formatted number on a web page using JavaScript. I want to format it so that there are commas in the right places. How would I do this with a regular expression? I've gotten as far as something like this: myString = myString.replace(/^(\d{3})*$/g, "${1},"); ...and then realized this would be more complex than I thi...

YUI3 IO program flow question

This may also be simple Javascript related but here is the link to IO just in case: YUI3 IO I have a YUI instance created and am using the io function to retrieve data from the server. YUI().use('event', 'node', 'io', function(Y) { Y.on('io:start', onstart, this, true); Y.on('io:success', changecontent, this); Y.on('io:en...

How can I access Java list elements from my client-side JavaScript code?

I have the following simple script, which I am using to dynamically create the list elements in a <ul> <script type="text/javascript"> function generate(){ var arr = new Array(); <c:forEach items="${articles}" var="a" varStatus="status"> $('#listitems').append( "<li>"+${a.title}+"</li>" ...

Calling Javascript from Objective-C via WebScriptObject

Hello, I decided I would change how I implement printing in my Cocoa app by having my app provide string-data to a webpage in an embedded webview, and then I would print that webview/frame. The problem is that my code isn't being called and I don't see an error being returned. Here is the setup: 1) Use Dashcode and build a webpage. ...

Django-tinymce not working; Getting a normal textarea instead

I'm trying to use django-tinymce to make fields that are editable through Django's admin with a TinyMCE field. I am using tinymce.models.HTMLField as the field for this. The problem is it's not working. I get a normal textarea. I check the HTML source, and it seems like all the code needed for TinyMCE is there. I also confirmed that the...

jQuery: Get request (GET/POST) parameters from ajax request in Javascript

I am using jQueryUI dialog to open a modal form on my site. The form has a hidden input to pass on an affiliate code that is passed in the query string, like http://mydomain.com/page1_with_form?affiliate=Chuck%20Norris http://mydomain.com/page2_with_form?affiliate=Chuck%20Berry I am using a jQuery plugin to make grabbing the GET valu...

Executing a function passed as an argument in Javascript?

Hey all, I'm trying to write a generic function that will block out the UI while an AJAX call is made. What I'm trying to do is have a function A run any other function passed in as an argument. This is what I've got so far: function blockWhileLoading(fn, msg) { if (msg == null) { msg = 'Please wait while the next page is loa...

Custom scroll bar visualization with HTML/CSS/JavaScript

I am creating a highly specialized application where I want to experiment with a custom scroll bar. Ideally, I'd disable the built-in scroll-bar and draw my own. The page would look and feel like any other page, just that the scroll bar wouldn't be visible. The arrow keys, the scroll wheel, and any other mean of scrolling the page, shou...

javascript change innerhtml

ok im new at javascript, but im trying to change the innerhtml of a div tag, heres my script and its not working: <head> <script type="text/javascript"> function var1() { document.getElementById('test').innerHTML = 'hi'; } window.onLoad = var1(); </script> </head> <body> <div id="test">change</div> </body> it should work but for some ...

Designing a tool for PHP debugging

EDIT: Like I said, Xdebug type responses are not really that helpful here. I've added some more info below: I am planning on writing a small PHP debugging solution and would like to poll Stack Overflow for some ideas before I get started. The goal is to simplify debugging a PHP based web app. The tool should be able to plug into an ex...

I'm trying to finish an animation in an each loop before starting the next one

Here's a sample: http://jsbin.com/idepo/5 The padding and everything seems to look better when not using that, but oh well. My question is, if you click one of the menu items (right now, only the left most one will do anything) then a list of sub menu items slides down. What I would like to do is have one slide down, then another slide ...

Figuring out when a XMLHttpRequest request was made without callbacks

I'm trying to overload the XMLHttpRequest.* method in JavaScript so a webpage can figure out if an Ajax request took place without using any intrusive callbacks. Now, something like this works relatively fine when using most JS frameworks: XMLHttpRequest.prototype.getResponseHeader = function() { alert('O hai, looks like you made an AJ...

Day/Date/Time/Temperature Info bar

Hi All, Thanks for looking at my question. I am looking to have a London information bar on a website. Something that will show the following information: London, England: 9:27PM Friday 12 February 10°C/50°F Can anyone please help? Thanks :) TO LET ALL KNOW, I DO JUST WANT IT FOR LONDON. NO MATTER WHERE YOU ARE VIEWING IT FROM. NO...

Print the contents of a DIV

Whats the best way to print the contents of a DIV? ...

Javascript: Get the Index Value from an Array

Hi All, This is for a Java script course that Im taking... I need to create a simple user-login script. When the page loads a prompt pops up asking for the user name. If the correct username is entered, another prompt is displayed asking for a password. If both the username and valid, then you a sucessful message, otherwise you get ...

How to break an functional-style iteration?

I'm experimenting with functional-style Javascript and have encountered an interesting situation. I have a foreach function that takes a collection and function object: var Utils = {}; // Applies a functor to each item in a collection. Utils.foreach = function(collection, functor) { for (var i = 0; i < collection.length; i++) { ...

Need help with creating image upload form

Hi, I'm not really gr8 with ajax and javascript so I ask for help. Here is the deal, I have the image form upload working the old fashion way: <form action="db/photo/do_upload" method="post" enctype="multipart/form-data"> <fieldset id="upload_form"> <input type="file" name="userfile" size="20" /> </fieldset> <button type...