javascript

Get Value Outside of db.transaction Scope in Web SQL DB

Pretty sure the answer to this question is "closures" but I'm having a hard time getting it right. Given the following: var total = 0; db.readTransaction(function (tx) { tx.executeSql('SELECT COUNT(id) AS mytotal FROM sometable', [], function (tx, results) { total =results.rows.item(0).mytotal; conso...

Js RegExp every other character

I have random strings that are similar to this: 2d4hk8x37m or whatever. I need to split it at every other character. To split it at every character its simply: '2d4hk8x37m'.split(''); But i need every other character so the array would be like this: ['2d', '4h', 'k8', 'x3', '7m'] Your help is appreciated. Thanks! ...

drag & drop w/ reordering - reordering 2 side-by-side elements at once

I have had no luck figuring out how to do this. I was originally using jQuery UI sortable, but I am not sure it will work with this workflow: I have a table with multiple columns. I want to be able to drag an element in column A AND the element next to it in column B at once and drop them into a different position. After the drop, th...

How can I change the last component of a url path?

"http://something.com:6688/remote/17/26/172" if I have the value 172 and I need to change the url to 175 "http://something.com:6688/remote/17/26/175" how can i do that in JavaScript? ...

How to highlight pinned tab in Chromium via javascript

There is a feature in Chrome - you can right-click on a tab and select "Pin Tab", then tab is moved to the left corner and looks like an icon with text. So there is the question: how can I highlight this tab? Maybe there is some API? For example, gmail can highlight this tab when new mail message is come. Thank you. ...

When to use equality ("==") instead of identity ("===")?

Possible Duplicate: Javascript === vs == : Does it matter which equal operator I use? Many recommend using === for comparison everywhere in your JavaScript instead of ==, and it sounds reasonable. I was wondering are there any situations where using == would be actually beneficial over ===? ...

window.onbeforeunload tips and tricks

I'd like to create an onbeforeunload "You have made edits to the page. Stay On This Page, Leave This Page" jQuery plugin. The plugin will need to: Accept a containing element. $(".editableFieldContainer").beforeUnload() Autodetect changes to not(:hidden) input/textarea/selects. Prompt user to stay on the page if elements within the co...

Precision error when transforming coordinates using proj4js.

Hello everyone. I am using the library Proj4js to transform coordinates. I'm transforming coordinates from EPSG: 23029 to EPSG: 4326. The problem is that by transforming the coordinates there is some deviation from the precision used in the processing load. I noticed this by transforming a coordinate system from origin to destination and...

How to check identical array in most efficient way?

Hi, I want to check if the two arrays are identical (not content wise, but in exact order). For example: array1 = [1,2,3,4,5] array2 = [1,2,3,4,5] array3 = [3,5,1,2,4] Array 1 and 2 are identical but 3 is not. Is there a good way to do this in JavaScript? ...

Loop through array an insert values into it javscript

hello, I have populated an array with databack from a webservice and need to populate the UI based on the last 6 years, even if they do not exist in the data. The Data coming back can be in terms of the UI incomplete, so what I need to do is insert values into the array for the "missing pieces". Example Data returns {2010, 2007} Wha...

Custom Styled controls for Bing Ajax maps

Hi need some help in implementing custom controls for Bing Ajax maps, Can I simply overwrite current styles is this the best method or do I need to go deeper into the javascript and api? any links to good resources would be appreciated Cheers ...

Triggering event handler attached to it's own object, but inside a chain?

Right now I have: $("#myElement").bind("buildTimeline", function (event, newViewObj) { curDomObj = $(this).children(".timeline"); //this refers to #myElement curDomObj.draggable({ axis:"x", drag:curDomObj.trigger("drag") }); }); I'd much rather just have one chain, but is there a way to refer to the curren...

GWT and setting "file://" on HREFs

Greetings, I'm using GWT and trying to set an href to a file uri (to a network share) and insert it into a cell of a FlexTable and can't seem to make it work. I have inspected the dynamic anchor in chrome (inspector) and the format is correct but nothing happens when I click on it. I have tried setting through an Anchor, HTML objec...

Is there a way to turn this JavaScript code into Objective-C?

http://static.reclaimprivacy.org/javascripts/privacyscanner.js Or at least to understand the code as it is very difficult to read? ...

As javascript in <head> blocks HTML rendering, is it not the case with CSS also?

As JavaScript in blocks HTML rendering, and it's good practice to keep JavaScript at bottom, just before closing body tag , is it not the case with CSS also? I know we can't keep external CSS outside . ...

Internet Explorer and jQuery issues

I have a script that works in Firefox, Safari, and Chrome. It just doesn't work in Internet Explorer for whatever reason. The code is fairly simple: <script type="text/javascript"> (function( $ ){ $.fn.tabSwap = function() { return this.each(function() { $('.current').removeClass('current'); $(this)...

How do I check whether the scrollbar is at the beginning or end?

Hi Folks, how do I check whether the scrollbar is at the beginning or end with jquery? For the beginning part i would check if $(window).scrollTop <= 0, but what should i use for the end? Thank you ...

missing : after property ID

I don't understand what I'm doing wrong here... line 3 is reporting missing : after property ID $(document).ready(function() { $('#imagegallery img').each(function({$(this).css({ width: '100%'});}); $('#imagegallery').cycle({ timeout: 0, fx: 'scrollHorz', width: '100%', height: 'auto', n...

Parse XML response from API, Javascript, Ajax

I have a rails app and i wanna to parse the xml response from API using Javascript (ajax). I tried: $(document).ready(function() { $.ajax({ type: "GET", url: "http://localhost:3000/users/mike.xml", dataType: "xml", success: parseXml }); }); function parseXml(xml) { ... } but don't ...

Arrays in Javascript

I always had this silly doubt in mind but never had come up with the solution. I have seen several kind of arrays but I don't know the difference between them. I don't know how to explain exactly but it's most when passing parameters with jQuery. See: { 'choices[]': ["Jon", "Susan"] } in $("#objectID").load("test.php", { 'choices[]': ...