background preloader

Javascript

Facebook Twitter

Jquery

Ajax. Regex. Rx. Express - node web framework. RequireJS. SlexAxton's yepnope.js at master - GitHub. Wtfjs. Rubyists: Meet Underscore.js, your new favorite Javascript library - Blog. One of my favorite aspects of developing in Rails is the console. The ability to load and interact with my Ruby objects without using the browser is powerful. Thanks to Firebug for Firefox and Web Inspector for Webkit, I also have a console for my client-side JavaScript. I wish jQuery were as powerful when traversing raw JavaScript objects as it is traversing the DOM. Well it seems I have two wishes left for the first has been granted in Underscore.js. Underscore.js: 2kb of pure JavaScript horsepower!

Underscore.js is a new JavaScript framework from DocumentCloud that brings a powerful set of utility functions to JavaScript with a disctinct Ruby flavor and without monkey-patching the native JavaScript types by extending via prototype. Just as Prototype.js and jQuery employ the $ function, Underscore adds all of this goodness via the _ function. So, what's in the box? Nifty, huh? >>> _.map([1, 2, 3], function(num){ return num*num });=> [1, 4, 9] Pretty straightforward. Whoa! Bind template. SU - C# Wrapper for Google Closure Compiler - Compressing Javascript Files on-the-fly with ASP.NET and Closure Compiler. Closure Compiler - Javascript Compiler by Google - Compress Javascript with Closure Compiler. Yesterday, Google introduced Closure Tools (announcement) to enable easy creation of web applications. The tool set contains: Closure Compiler, Closure Library and Closure Templates. Closure Compiler is a Javascript optimizer that compiles javascript code into a compact, high performance form.

The compiler does more than a standard Javascript compressor. The Closure Compiler reduces the size of your JavaScript files and makes them more efficient, helping your application to load faster and reducing your bandwidth needs. Moreover, it removes dead code, rewrites the code to improve code running speed on browsers' Javascript engines. Closure Compiler by Google - reduces the size of your JavaScript files and makes them more efficient As mentioned before, Closure compiler is more than a standard Javascript compressor.

The compiler also offers a Firebug extension, named Inspector, for better debugging. Closure Compiler by Google does more than removing whitespace. Closure Compiler - Google Code. What is the Closure Compiler? The Closure Compiler is a tool for making JavaScript download and run faster. Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript. It parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what's left. It also checks syntax, variable references, and types, and warns about common JavaScript pitfalls. How can I use the Closure Compiler? You can use the Closure Compiler as: An open source Java application that you can run from the command line. To get started with the compiler, see "How do I start" below.

What are the benefits of using Closure Compiler? Efficiency. Mouse wheel programming in JavaScript. Quick links: source · test page · long test page (with scrollbars) · compatibility Though many people still find this page useful, there have been some changes in the browsers since last update of this page, and I generally consider some information here to be outdated. However, I suggest using MooTools or other general Javascript frameworks that provide portable and maintainable basis for writing Javascript code. Web applications are becoming more and more like “normal” desktop applications. Of course, they are more and more functional, but smooth user interface acts the primary role. So we have drag and drop, autocompletition, and much more.

Many of those nice features got possible only with help of AJAX. This page, however, is not about AJAX (or any other buzzword). Annotated code Below is annotated javascript code, which should explain the magic behind mouse wheel generated events. /** This is high-level function. * It must react to delta being more/less than zero. Handler function. Javascript code snippets. Password checker. Password Strength Test.

People wonder if their password is a good password. I often come across two distinct groups of people. The first would fall into a "just use any word" category, which is a very bad practice for picking passwords. The second group will mix in a few numbers in order to make the password a lot harder to guess. But, how do you know if you have a secure passphrase? Good passwords / passphrases: ... should be 8 characters or longer, which forces you to use multiple words or extra symbols. ... should have upper case, lower case, symbols, and numbers; or at least three of those four groups. ... should not be a common word and should not be a common phrase. ... should not contain a date, a name, or other things that can be associated with you. ... should be created randomly or semi-randomly. ... should not be a suggestion when you type in the first few characters into Google.

This password checker will gauge your password and give it a score based on how good of a password it is. Script# Framework. The Book of the Day Script. JavaScript Kit Free JavaScripts! Enumerating JavaScript Objects. Enumeration lies at the heart of DOM Scripting: var lists = document.getElementsByTagName("UL"); for (var i = 0; i < lists.length; i++) { lists[i].className = "menu"; } for (var i = 0; i < array.length; i++) { print(array[i]); } for (var key in object) { print(object[key]); } Us JavaScripters are forever writing loops like these. To ease the strain on our keyboards Mozilla recently introduced a handy forEach method for arrays: array.forEach(print); If you don’t understand the code above then go and read the documentation.

That’s fine for arrays but what about DOM node lists? Var lists = document.getElementsByTagName("UL"); Array.forEach(lists, function(list) { list.className = "menu"; }); Cool huh? We can easily implement this method for non-Mozilla browsers: if (! I’ve been using this technique for enumeration quite a lot recently and I decided to extend the idea: This allows me to write loops without knowing what kind of object I’m dealing with: Explanation The Kick-Ass Bit Conclusion.

CodeGuru: A Better Fixed GridView Header for AS... The first ten lines or so beginning with this of var define public members and fields for the PositionClass. As you might expect, you need to store the position and instance of the header as well as the caption, if present. It is these items that you will need to resize (absolutely) if the grid scrolls or the window is scrolled or resized. Any element that you want to be a public member you need to assign to a local-named element with the this keyword, for instance this.Width = width.

Statements like the preceding will introduce an externally accessible member Width (note the capital W) and associate it with variable width (note the lowercase w). This relationship is similar to the field and property relationship in VB. Because you are defining controls such as a GridView in code-behind, and these controls will generate an HTML table with a specific client-id, it is convenient to store the actual client-id in the PositionClass. setClientID does this. Summary About the Author. ActiveWidgets Ajax/Javascript GUI Components. Jquery Wizard Plugin » Worcester Web Site Devel... After looking for a jquery plugin that will emulate a windows wizard I decided to make my own (with the help of cody lindley’s css step menu). I am using Jquery which can be found here and css step menu found here. The code: First we need a simple javascript function will hide and display a div, this method is used with jquery and you can learn how to use this here function loadnext(divout,divin){$(".

" + divout).hide();$(". " + divin).fadeIn("slow");} Next the html code, notice how each step is wrapped in the ID wizardwrapper and each div is assigned a class for the corresponding step number. Step 1 Step 1: XXXXXXXXEt nequ a quam turpis duisi Step 2: XXXXXXXXEt nequ a quam turpis duisi Step 3: XXXXXXXXEt nequ a quam turpis duisi Step 4: XXXXXXXXEt nequ a quam turpis duisiStep 5: XXXXXXXX Et nequ a quam turpis duisi Step 2 Step 3 Step 4 Step 5 A Demo of the wizard. jQuery: The Write Less, Do More, JavaScript Lib... Tutorials:How jQuery Works - jQuery JavaScript ... This is a basic tutorial, designed to help you get started using jQuery. If you don't have a test page setup yet, start by creating the following HTML page: The src attribute in the <script> element must point to a copy of jQuery. Download a copy of jQuery from the Downloading jQuery page and store the jquery.js file in the same directory as your HTML file.

Note: When you download jQuery, the file name may contain a version number, e.g., jquery-x.y.z.js. To ensure that their code runs after the browser finishes loading the document, many JavaScript programmers wrap their code in an onload function: Unfortunately, the code doesn't run until all images are finished downloading, including banner ads.

Note: The jQuery library exposes its methods and properties via two properties of the window object called jQuery and $. $ is simply an alias for jQuery and it's often employed because it's shorter and faster to write. For example, inside the ready event, you can add a click handler to the link: Ext JS - Client-side JavaScript Framework. Extsharp - Google Code. I really love Ext but coding in javascript just gives me the chills. So I went out and found a way to use my favorite js library (Ext) and my favorite programming language (C#) at the same time. By using a project called Script# I am able to write C# code and have it converted into javascript, similar to GWT. Building on that, Script# also allows you to code against external APIs, but you need to create the types, methods, properties, etc. for everything in the javascript library.

So what I did was write a little console app that parses all of the ExtJS source files extracting out the script comments and writing C# files for each class. The end result is a programmable C# API to access all of the Ext objects and I threw in a couple new things to make life a little easier. This forum post has somewhat of a history of how this project began: Intellisense Method Signatures with param info Method Overloads for varying params Compile-time error checking. Jquery-checktree - Google Code. Overview CheckTree is a jQuery plugin, written for jQuery 1.2.6, that allows you to easily turn a standard ordered list into hierarchical tree that is both check-able and collapse-able.

It, like jQuery, is licensed under either the GPL or MIT license. Copyright (C) 2012 JJ Geewax Updates 19-Jun-2009 I saw a fork of CheckTree by ycTIN that looked to be much faster. I can't really say for sure whether it is fully backwards compatible and bug free, so use at your own risk. Jstree - Google Code. Jquery-option-tree - Google Code. This jquery plugin converts passed JSON option tree into dynamically created <select> elements allowing you to choose one nested option from the tree. It should be attached to a (most likely hidden) <input> element.

It requires an option tree object. Object property names become labels of created select elements, each non-leaf node in the tree contains other nodes. Leaf nodes contain one value - it will be inserted into attached <input> element when chosen. The plugin also supports loading additional levels via AJAX calls and preselecting given items at load. $('input[type=hidden].nested').optionTree(option_tree); It will display a select element with three options: "Choose When client finally chooses a leaf option ("Suboption", "Subsub X" in the example), its value (represented by numbers here) is assigned to selected <input> element and its change() event is triggered.

Plugin accepts config object as 2nd parameter. $('input.nested').optionTree(option_tree, config); A Plugin Development Pattern » Learning jQuery ... I've been developing jQuery plugins for quite a while now, and I've become rather comfortable with a particular style of plugin development for my scripts. This article is meant to share the pattern that I've found especially useful for plugin authoring. It assumes you already have an understanding of plugin development for jQuery; if you're a novice plugin author, please review the jQuery Authoring Guidelines first. There are a few requirements that I feel this pattern handles nicely: Claim only a single name in the jQuery namespace Accept an options argument to control plugin behavior Provide public access to default plugin settings Provide public access to secondary functions (as applicable) Keep private functions private Support the Metadata Plugin I'll cover these requirements one by one, and as we work through them we'll build a simple plugin which highlights text.

Claim only a single name in the jQuery namespace This implies a single-plugin script. JavaScript: Putting it All Together. Native JSON Parsing: What does it mean? - Rick Strahl&#039;s Web Log. JSON support is part of the EcmaScript 3.1 standard and so is likely to become ubiquitous in all browsers going forward. Internet Explorer 8 now includes native JSON parsing. FireFox 3.5 and the next version of WebKit/Safari too have or shortly will have native JSON support inside of the browser.

This is good news as it helps simplify a common task for AJAX applications that send data back and forth between clients. You can check out the native JSON support today: Internet Explorer 8 FireFox 3.1 Beta 3 (new FF 3.5 Beta 4 expected next week) Native JSON Support finally – sort of IE 8 is the first shipping browser with native JSON support. The native JSON object is based on Douglas Crockford’s JSON2 interface, which provides .stringify() and .parse() methods to encode and decode JSON data respectively.

So, using either Crockford’s json2.js or the native JSON object you can do: Those pesky Dates – Still! One prickly issue with JSON parsing in general is date parsing and serialization. Best Practices for RESTful JSON Web Services. Edwin Khodabakchian, once one of the key people behind the Collaxa BPEL product that subsequently found itself part of the core of Oracle's SOA strategy, has been working independently for several years on Feedly which "weaves twitter and Google Reader into a magazine like experience". Recently Edwin posted an experience-based cookbook on best practices for building JSON-based Web Services. No doubt this is a work in progress, but so far the guidelines it provides include: Phase 1 – Defining a simple resource/service | Take a sample resource such as Customer Information, model it as JSON.

Build a simple servlet where PUT creates a new customer, GET returns the customer information based on the customer key, DELETE deletes the customer and POST updates the customer information. And: Phase 3 – Adding validation | Change your service implementation to add some data validation to the JSON resource which is being received during PUT and POST. Or: Creating a quick and dirty jQuery contentEditab... Testing Your Presentation Layer.