javascript

Best way to get two nibbles out of a byte in javascript?

I'm parsing a binary file in javascript that is storing two pieces of information per byte, one per nibble. The values are, of course, 0-16 and 0-16. In all other parts of the file format, each byte represents one piece of information, so I have been using the following to successfully get the number values I need: var num = str.charCo...

sanitizing untrusted url strings that will be passed to location.replace

I'm getting a string from the current window's fragment identifier (location.hash). I want to use that string as the argument to location.replace(str). Under normal circumstances, the string will come from code I control, so I'm not worried about validating that the string is a URL. If the string isn't a URL, the call to replace will ...

Mobile web development book

I am looking for a mobile web development book(s). Possibly one book about design best practices and one or two about the actual implementation of the technologies for mobile, namely JavaScript, HTML, CSS, accessing device API such as location and messaging through browser. Any book suggestions and descriptions of said book would be ve...

Twitter and Javascript

I just came across something extremely annoying that took me ages to figure out. I was calling window.open('http://www.twitter.com/share?url=...&text=...','twitterShare','width=500,height=400') in a JS function for a SWF file to trigger and for the life of me the freakin' message wouldn't properly unencode hashtags and spaces (%23 an...

defining a page id in javascript

Is there anyway of defining a pageID sort of thing to an html page, for using in javascript code... ...

what technology combination should I use to make a video player with custom User Interface in the new HTML 5

I am trying to do something simple for now. I am making a video player for autistic kids. The idea being: a video player runs on a tablet (ipad / android). A tap (anywhere on the screen) toggles the video state between play/pause. For now, I'm trying to get it to just work on a chrome/firefox browser + PC combination. I have been readin...

select a child element in jquery object

Hi, I'm new to jquery and I have a basic question now. I have a jquery object got from a jquery selector. e.g var obj = $('#certainTR'); Now, I want to get the element in this object and I cannot use '#certainTR > date' in a selector because '#certain' is not passed in my subroutine. Is there anyway to make a selection base on a obj...

Javascript array, Parse each element multiply each element by 'x'

How do I parse through an array and for each element multiply its value field by 'x' I want to pass through a a native array that contains 60 elements as follows: [ [value, key], [value, key], [value, key] ] In the above example the key field will be a number starting at 60 and counting down to 0. The value field can be any nu...

Help with Javascript to C# converter

I find a algorithm writen by javascript,now i want to convert it to C#, Any tool can do this? ...

How to set object property in prototype function (scope problem)?

This is something trivial, which I've forgotten. There are possibly duplicates - I searched a little, found similar, but couldn't find as concise. String.prototype.test = function(){this.bar = this.length + 2;} var str = "foo"; str.test(); console.log(str); // foo console.log(str.bar); ...

Suggestion needed for NON JavaScript version of an input autocomplete

I'm building an App that is heavy on jQuery. Most of it I can handle without the use of JS and still have a functioning site, however there is one bit that is eluding me. (note, I'm using ASP.NET MVC but that shouldn't matter in this instance) I have an input field that is making great use of jQuery-UI AutoComplete. The behavior is ver...

Javascript calculator as users type numbers

I'm a noob at Javascript, but I'm trying to implement something on my website where users can type a quantity, and the subtotal updates dynamically as they type. For example: if items are 10 dollars each, and a user types 5 in the text field I would like it to show $50 next to the text box. Pretty simple multiplication, but I don't know ...

How to pass javascript variables from one html page to other html page

I have the following code to pass variable from example1.html to example2.html , what will be the syntax in window.location.href to navigate to example2.html with username and keyword. example1.html <script type="text/javascript"> var username = ($("#username").val()); var keyword = ($("#keyword").val()); $("#button1").cli...

Javascript looping through a JSON string

Hi there, Ok, a little new to JSON format.. I have the following JSON string returned from an AJAX call, which firebug actually displays in a tree quite nicely.. however I can't seem to be able to work out how to loop through the content... {"data":{"item":[{"@id":"7","fromMemberID":"7","FromMember":"david","notificationsType":"event"...

Approaches for embedding script required data in markup

What approaches can be used to embed additional meta data in HTML markup, where that data is required by client side javascript. Some simple examples of what I mean: A list of contacts which when clicked shows their position in a map. ie: how to associate a lat/long with each contact. A set of images which when clicked pops up a drag...

ASP.NET 4 Form inside a webform page..

I am new to programming but attempting to learn. Im running visual studio 2010 with an asp.net webform project using C#. I am trying to implement paypals buy now buttons on one of the pages and the code that is generated is in form tags also. No matter which button it is, the first button on the page never works and there is a solid blue...

Is there a way to make JSLint happy with this regex?

When running my Javascript through JSLint, I get the following two errors from the same line of code. Problem at line 398 character 29: Insecure '.'. if (password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/)) Problem at line 398 character 41: Unescaped '^'. if (password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/)) I understand that JSLint m...

Getting dates as string using from a jQuery UI datepicker

I need to grab a date in string format from jQuery UI datepicker. At the moment the best I can come up with is: $.datepicker.formatDate("yy/mm/dd", $("#fromDate").datepicker("getDate")) Is there a cleaner way to do this? ...

Download file in javascript is not working in Chrome.

below is the code function ExportToExcel() { if ($("#dateRange").val() != "") { var frm = $("#frmProjectReport").serialize(); var url = "/Reports/ProjectExcelReport?" + frm; Download(url); } } function Download(url) { alert(url); ...

Javascript newbie question.

Hi there, i am using a jquery plugin to upload files, the plugin checks the file dimension and return back the appropriate error message. the error message i am displaying is with this code. $('#divmsg6').append("<p class = 'red'>Incorrect file dimension, try again</p>"); now if the user keep on trying the error will keep on appendin...