javascript

Javascript/HTML - converting byte array to string

Hi, How do I convert a byte array into a string? I have found these functions that do the reverse: function string2Bin(s) { var b = new Array(); var last = s.length; for (var i = 0; i < last; i++) { var d = s.charCodeAt(i); if (d < 128) b[i] = dec2Bin(d); else { var c = s.ch...

Webkit download pre-built database

I have a rather large db (as in many records). I'd rather let the client download a pre-built db instead of forcing them to load a bunch of text, then insert all the records before being able to use the db. The closest thing to a spec I can find is this: http://developer.apple.com/safari/library/documentation/iphone/conceptual/safarijsd...

Adding a clientside onload function to an ASP.NET control in 4.0 encodes my quotes

I'm trying to add a Javascript function to the onLoad event of a asp:Panel. It goes something like this: string clickFunction = "$('[id*=lblHiddenPageArray]').text('');" PagesPanel.Attribues.Add("onLoad", clickFunction); I'm attaching this function to other controls (Checkboxes and Buttons) and it's working fine. But in the PagesPa...

Remove element by class using parent()

I am making changes to a jQuery validator, when there is an error it inserts a div to the parent element. I am trying to remove an the inserted div with by the specific class name from the parent. $(element).parent().remove('.removeThis'); I thought the above code would work but it does not remove the the div. ...

Sorting an array of objects in Chrome

I just got a report that some code I wrote is breaking on Chrome. I've tracked it down to a custom method I'm using to sort an array of objects. I am really tempted to call this a bug, but I'm not sure it is. In all other browsers when you sort an array of objects, if two objects resolve to the same value their order in the updated arra...

Shorten JavaScript

Hello, I got some help a few weeks ago on some code for a drop down menu but I am wondering if it is possible to make the code shorter because the current code shown below is quite big, any help would be great. $(document).ready(function(){ $("#zone-bar li em").mouseenter(function() { var hidden = $(this).parents("li").children("...

Quick AJAX responses from Rails application

I have a need to send alerts to a web-based monitoring system written in RoR. The brute force solution is to frequently poll a lightweight controller with javascript. Naturally, the downside is that in order to get a tight response time on the alerts, I'd have to poll very frequently (every 5 seconds). One idea I had was to have the A...

how do I check for a specific text in a ajax response

I have a button on a page which when clicked makes a ajax request. Viewing the response in firebug and looking at the page it basically returns the exact same page in the browser with the addition of an image and some text wrapped in a table. How would I check this response and see if it contains this text and image and if it find it red...

Disable "Browse" button if the radio button isn't selected

<form action="" method="post" name="site_avatar" id="avatar" enctype="multipart/form-data"> <input type="radio" name="avatar" value="gravatar" /> <input type="radio" name="avatar" value="local" /> <input size="25" name="file" type="file" /> <input name="site_avatar" type="submit" value="Submit" /> </form> This is my form with two radio...

JavaScript/JQuery string replace

Hi, I have the following string which is a CSS selector: #downloads > ul > li:nth-of-type(1) > ul > li:nth-of-type(3) > a This CSS selector works fine in FireFox, CHrome and Safari but IE 6 does not support the nth-of-type selector. The CSS selectors I am working with are generated by Nokogiri and I can not change them. Threw testi...

How to create simple javascript/jquery client side captcha?

How to create simple javascript/jquery client side captcha? How it may be realize, thx. ...

Can you make a dojo.data store from properties of another dojo.data store?

The title says it all. Is it possible to make another dojo.data.ItemFileWriteStore out of the properties of items from an existing dojo.data.ItemFileWriteStore? For example, i have a store containing an item with an array as a property. I want to make a new store out of the properties of one of those arrays, like so: ... new dojo.data....

Issues with dynamic google maps integration

I have ran into a very strange issue with Google Maps in Chrome 5.0.375.99: if you dynamically create more than one Maps instance, the second and on have a strange bug where it does not display properly, is only shows in a fraction of the map space. Some Example Pages: one default - When you click addOne, the new object has the problem...

jquery selectors

Hi. I need to select a class in my javascript and change one of its property. but since that class is being used with different divs, I need to change the property of the class I hover upon only and not the other ones. is that possible? the html structure looks like this: <div class="home_linkbox_href"><a href=""><div class="home_link...

addLoadEvent is not helping with onload conflict

Hello I'm using the popular addLoadEvent as follows for all my JS loading: function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoa...

jQuery infinite function execution

We want to know if it is possible to have a function using jQuery to inspect a number of elements and, depending on the types assigned to them by one click, perform other functions. Basically, a function that would run forever, while the user does not refresh the page. The idea is not to depend on events clicks to perform a function, bu...

Dojo: How to get an element of an element variable

For example, ideally I'd like to go: newelement = myElement.query('whatever'); Basically how mootools does this: element = oldemement.getElement('whatever'); What the equivalent in dojo? If it makes a different, I am using this in a drag and drop creator function: function myCreator( item, hint ) { console.log(item); var a...

Redirecting in ASP.NET MVC using Javascript or something else the best way ?

I have a confirm box and redirect to an action but it is not working.. <script type="text/javascript"> function quitProgram() { var answer = confirm("Are you sure you want to quit your current program?"); if (answer) window.location("http://www.google.com"); else window.location("h...

Is there a JavaScript function to serialize and unserialize arrays like PHP?

I'm making a PHP model to store a serialized array in a database. The array is then accessed via AJAX through an HTTP request. Is there a JavaScript function to serialize and unserialize arrays like PHP? EDIT: This is the php function http://uk.php.net/manual/en/function.serialize.php ...

Setting an event with DOM javascript

I am trying to set an event in JavaScript but it is not really working. I am pretty sure I am doing it correctly too. // in index.htm: function foo() { // Load gets code from a php file via ajax document.getElementById('div').innerHTML = load('phppage.php'); document.getElementById('element').onClick = func; } // in lib.js: func...