javascript

Regular expression for matching quantities and unit

I need to extract the quantity and unit from strings like this 1 tbsp 1tbsp 300ml 300 ml 10grams 10 g The quantities will always be numbers, then there may or may not be a space then the unit. They may be 15 - 20 different units which can come from a list that we define (perhaps an array) The solution can be in either javascript or...

How to get Javascript to "communicate" with PHP

Hey All I have the following code (PHP): $link = array( "<ul> <li><a href="index.html" class="active">Home</a></li> <li><a href="whatwedo.html">What We Do</a></li> <li><a href="howitworks.html">How It Works</a></li> <li><a href="support.html">Support</a></li> <li><a href="lalalala...

jQuery Ajax tooltip

I try to do Ajax tooltip via this jQuery plugin: http://jquery.bassistance.de/tooltip/demo/ I have some thing like this: <p id="foottip"> <span href="/last_votes/6">footnote</span>. </p> <script type="text/javascript"> $(function() { $("#foottip span").tooltip({ bodyHandler: function() { //dj ajax here and cache ...

Should ajax calls go through as few as possible entry points to an application or many specific methods

I'm building a web app with a lot of ajax calls to be made. Should I be trying to keep a small number of methods, and just pass in information about what type of request it is, and then switch based on that type inside the method or Many smaller methods, so don't have to pass in type, but more code to write setting up each method. Cu...

Javascript tostring issue

Hello, I'm working on a WYSIWYG text editor and I'm working on the ability to switch between the WYSIWYG mode and BBcode mode. I'm having trouble getting it to display back in WYSIWYG mode after you make the switch. function editormode() { var html; var bbcode = new Array(); var htmlcode = new Array(); htmlcode[0] = "<b>"; bbc...

Present XMLHTTPRequest Response to the Client?

I am using an XMLHTTPRequest to fake a RESTful interface. After the response object returns data from the request, how can i present that to the user? For example, in a PUT request, the server actually responds with a full HTML page of data (in most cases), and i want to display this whole page to the client. Any idea how? I'm sure there...

Jquery! Error with variables ?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Shout!</title> <script type="text/javascript" src="http://ajax.googleapis.co...

javascript regex match function syntax help

Hi, I have an input textbox that runs a js function on the keyup event to match for a valid string (domain name pattern match, the regex was found on here). I wrote the if statements to test whether the input is a valid pattern first and then more than 3 characters long. Apparently, my ifs don't work like I wanted them to. When th...

Javascript show server load and update every few seconds

Hello, I am trying to show server load on a web page. The server load is fetched in PHP by executing the shell command "/proc/loadavg" and displaying the output as it is. However, I want to display the same output using Javascript (jQuery is fine) and have it updated every 10 seconds. How do I do so? I was thinking of using Ajax quer...

Javascript equivalent to php's urldecode()

Hi, I wrote a custom xml parser and its locking up on special characters. So naturally I urlencoded them into my database. I can't seem to find an equivalent to php's urldecode() are there any extentions for jquery or javascript that can accomplish this? ...

XML Validation: Error Parsing Attribute Name

Hi, I've got an XML validation problem. This bit: <script type="text/javascript"> oxm_ad = {"website":"cca9e4b4-7ed2-848z-ffea-067efabc891a", "size":"468x60", "floor":"0.01", "beacon":"<div id='beacon_017a6c9ega' style='position: absolute; left: 0px; top: 0px; visibility: hidden;'><img src='http://www.website.com/openx/www/delivery/lg.p...

Shortest way of creating a "new function" alias in javascript

What's the shortest way (characters) of creating a "new function" alias. Basically this is for code golf and minifying code beyond reason. So when you usually would write: a=function(a,b,c){return a+b+c;} You could write something like (also let's abstract return keyword as well with global variable R): a=$("a,b,c","R=a+b+c") a=$(a,...

JavaScript Special Characters

Possible Duplicate: What are carriage return, linefeed, and form feed? I'm still learning JavaScript, and I came across think link for escaping special characters. http://www.w3schools.com/js/js_special_characters.asp I understand the other characters, but what are carriage return, backspace, and form feed for? Are carriage ...

jQuery function error

Here is my piece of code : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Shout!</title> <script type="text/javascript" sr...

XMLHttpRequest responseText & javascript

So I have two pages: index.php and contents.php. Index.php is doing an XMLHttpRequest to grab a table from contents.php... But when Index.php displays the response.Text, it doesn't run the Javascript originally on contents.php (because it's just displaying the contents, not running the script). Trying to solve this problem, I simply pu...

How come eval doesn't have access to the scoped variables under a with statement?

Why can't you access scoped variables using eval under a with statement? For example: (function (obj) { with (obj) { console.log(a); // prints out obj.a eval("console.log(a)"); // ReferenceError: a is not defined } })({ a: "hello" }) EDIT: As the knowledgeable CMS pointed out, this appears to be a browser bug (brow...

preload swf with jquery / JS

I would like to preload the SWF before showing them to the user. SWF are dynamic and I dont have the FLA files. I would love to do it using Javascript or jquery if possible. Thanks. ...

safari 5 extension - javascript problem - safari seems to cache the page and the DOM state

I've written a greasemonkey javascript that works fine in NinjaKit the new Safari userscript manager, but when I try and compile the same script using the Safari 5 extension builder I get some very weird behaviour. The script gives the user an options editing screen, when you click the save button, the script saves the users preferences...

Zoom to different parts of SVG depending on mouse position

So I've found a script which seems to do just that , but it zooms a <g> that wraps whole svg contents by applying a transformation matrix to it (though it doesn't zoom in Opera because of sniffing). Wrapping all lements in a <g> is not an option because I'm making an image viewer and different files may be loaded. Setting transform="m...

GWT JSON cross-site request fails

imo i did everything according to the tutorial here Googles x-site /** * Make call to remote server. */ public native static void getJson(int requestId, String url, StockWatcher handler) /*-{ var callback = "callback" + requestId; // [1] Create a script element. var script = document.createElement("script"); ...