javascript

JavaScript: Possible uses for #debug directive?

Where I work, all our JavaScript is run through a compiler before it's deployed for production release. One of the things this JavaScript compiler does (beside do things like minify), is look for lines of code that appear like this, and strip them out of the release versions of our JavaScript: //#debug alert("this line of code will not ...

Relative time function in js for format YYYY-MM-DDTHH:MM:SS+0000

Hey, I was wondering if anyone knew how I could parse this type of date format: 2010-07-26T18:02:46+0000 into the relative time such as "30 seconds ago" I already have a function which does it for a similar but different time format: function relative_time(time_value, is_relative) { var values = time_value.split(" "), ...

Problem when using Javascript to redirect user on form submit

Hi, I have a webpage on which I have a form. This form contains a button and a textbox. When the button is clicked or when the form is submitted I would like to take the text from the text box and append it to a url. The code looks like this: <form name="askaquestion" id="ask-a-question" onSubmit="window.location.href='http...

getElementsByClassName not working

I coded a php page that displays information from a mysql database neatly into tables. I would like to hide empty table rows with an onLoad event handler. Here is a sample table with code that hides a <td> when it has no content. but i can only get it to work with different IDs: <script type="text/javascript"> function ...

Mustache.js - accepts inputs as vars, but not as ajax gets: How to import or troubleshoot

Using this as the example: http://mustache.github.com/#demo, the template and json can functionally be moved to a var: template = '<h1>{{header}}</h1>{{#items}}{{#first}}<li><strong>{{name}}</strong></li> {{/first}}{{#link}} <li><a href="{{url}}">{{name}}</a></li> {{/link}}{{/items}}{{#empty}} <p>The list is empty.</p>{{/empty}}'; Thi...

JavaScript: Create global Object from inside Prototype dom loaded event

I want to create an object that is globally accessible after the DOM has loaded. My approach is to use prototypes dom:loaded event and instantiate the Object. The JavaScript Code: document.observe("dom:loaded", function() { var globalPAO = new picArrayObject(); alert(globalPAO.picArray[0]); // alerts [object HTMLDivElement]...

What issues cannot be solved by jQuery as compared to JavaScript ?

Possible Duplicate: Is jQuery always the answer? Now-a-days everyone is talking only about jQuery at my work place, there are some Sr. Developer who work mostly with JavaScript and they have their rights reserved for jQuery. I am kind of little confused between jQuery vs JavaScript What are the programming challenges which ca...

HTTP Headers of Included Files VS Browsing Location!

When an http header is sent by a browser because the url is included in another page is it any different than when it is called by browsing to that page. for example if I have myjavascript.php am I gonna be able to tell if its being viewed by someone browsing to it rather than it being included in a tag? ...

Is it possible to create a php based iphone/android app with PhoneGap or Appcelerator?

I want to be able to make an iphone and android app using php. I have looked at phonegap and appcelerator and it seems like only html and javascript can be used. These frameworks want to make it easy to make apps using web technologies and PHP i would argue is one of the biggest web technologies, but I'm not seeing much (if any) support....

Is there anything bad about attaching a variable to a function in Javascript?

I'm writing some Javascript code and I need to keep track of a global state. The state is only ever changed by a single function, but it needs to be widely accessible from other functions. I'm currently doing it in this manner: function foo(bar) { var self = arguments.callee; if (!self.state) { self.state = 0; // calle...

javascript jquery show/hide of columns

<table id='mytab'> <tr> <td colspan="6">OS</td> </tr> <tr> <td></td> <td>Fedora</td> <td>Cent Os</td> <td>Ubuntu</td> <td>Suse</td> <td>Redhat</td> </tr> <tr> <td colspan="6">Versions</td> </tr> <tr> <td></td> <td>6</td> <t...

How To Breadcrumb Menus

Hi, Hoping someone can assist with how to incorporate a breadcrumb menu into my website. I basically have a sidebar menu with submenus, which I also want to setup as a breadcrumb menu. Would appreciate some help on how to achieve this. Any "how to" urls would be great. Thanks. ...

Script in iPhone SDK

Hi all, Can any one help me, how to write a script in iPhone SDK,without HTML string. I am trying this: [webView stringByEvaluatingJavaScriptFromString:@ "var script = document.createElement('script');" "script.type = 'text/javascript';" "script.text = alert(); " "document.getElementsByTagName('body').appendChild(script);"...

Can we make an ajax request to a usercontrol (.ascx)?

I have a page that contains a user control. Can i make an ajax request directly to the control? I know I can make an ajax request to .aspx or .ashx; however, is it possible to go direct to the .ascx? ...

ASP.NET MVC 2 Data Validation: Make C# Regex work for both C# and JavaScript simultaneously?

I have this C# regex: ^\s?((?<qty>\d+)\s?/)?\s?[$]?\s?(?<price>\d{0,2}(?:\.\d{1,2})?)\s?$ and use MVC's data validation at the client. JavaScript says this regex is invalid, although C# works perfectly fine. Any idea how to get it to work for both C# and JavaScript, since it doesn't seem possible to provide a separate JavaScript Reg...

What is returned from a constructor?

If I return some value or object in constructor function, what will the var get? function MyConstroctor() { //what in case when return 5; //what in case when return someObject; } var n = new MyConstroctor(); what n will get in both cases? Actually its a quiz question, what will be the answer? What is returned from a custom o...

JS restrict mouse movement with axis when shift pressed (for draggable element)

When shift button pressed I want user to be able to only move mouse strictly up/down or left/right. My current rough idea is to intercept all movements when shift is pressed and use events simulation to pass needed event (which will contain only needed axis movement) further. I use jQuery Draggable so other idea is to determine when shi...

How to prevent form from being submitted?

I have a form that has a submit button in it somewhere. However, I would like to somehow 'catch' the submit event and prevent it from occurring. Is there some way I can do this? I can't modify the submit button, because it's part of a custom control. ...

Parsing XML-to-JSON converted object in Javascript

Hello all I've an XML object converted into the following JSON object "{"?xml":{"@version":"1.0","@encoding":"utf-8"},"Response":{"Users":null,"Messages":{"Tell":{"Notify":{"@From":"abc","@Message":"hi system, its abc<br/>"}},"Group":null},"PersistedMessages":{"Tell":null,"Group":null}}}" How can i get the values inside the xml nodes...

could script timeout cause javascript to fail at end of page?

I have a simple PHP upload page that when finished uploading runs a bit of JavaScript to show a form and 'save' button that I enter various bits of info in. When I upload a large file 100-200mb I find that the upload hangs or seems to hang in that the javascript form never shows up. Is there a way to set the script execution time for j...