background preloader

Javascript 1

Facebook Twitter

Ajax

Node.js. A re-introduction to JavaScript - MDC. Why a re-introduction? Because JavaScript is notorious for being the world's most misunderstood programming language. It is often derided as being a toy, but beneath its layer of deceptive simplicity, powerful language features await. JavaScript is now used by an incredible number of high-profile applications, showing that deeper knowledge of this technology is an important skill for any web or mobile developer. It's useful to start with an overview of the language's history. Several months later, Microsoft released JScript with Internet Explorer 3.

Because it is more familiar, we will refer to ECMAScript as "JavaScript" from this point on. Unlike most programming languages, the JavaScript language has no concept of input or output. Overview JavaScript is a multi-paradigm, dynamic language with types and operators, standard built-in objects, and methods. Let's start off by looking at the building blocks of any language: the types. And there are some built-in Error types as well. Numbers. Introducing Closure Tools. Writing Efficient JavaScript. APE (Ajax Push Engine) :: Real time data streaming. 100 Best JavaScript Resources | Spoonfed Design. JavaScript is an extremely useful scripting language for enhancing user experience and usability.

It is becoming more and more popular, as more developers begin to make cool techniques accessible. Here are 100 excellent JavaScript (and a few AJAX) techniques, plugins, and resources based on the major libraries of jQuery, Prototype, Scriptaculous, MooTools, and Dojo. JavaScript Techniques and Tutorials Coda Pop-Up Tutorial Build An Incredible Login Form with jQuery Create a Slick Tabbed Content Area using CSS & jQuery Create a Simple, Intelligent Accordion Effect Using Prototype and Scriptaculus Create a Simple, Powerful Product Highlighter with MooTools Creating a Dynamic Poll with jQuery and PHP Creating a “Filterable” Portfolio with jQuery Leopard Desktop with jQuery using jqDock Adding to Our Leopard Desktop with jQuery Use the jQuery UI to Control the Size of Your Text Animated Drop Down Menu with jQuery Animated Menus Using jQuery Fancy Box Easiest Tooltip and Image Preview Using jQuery. JavaScript Keywords Reference Index.

Below is a listing of all JavaScript Keywords language. Click on an item to visit its documentation. Use to add a single line comment, or comment out a single line of code. Use to add a multi-line comment, or comment out multiple lines of code. Adds two values together or concatenates two strings into a single string. Subtracts the value of a number from another number. Multiples the values of two numbers. Divides a number by another number. Divides a number by another number and returns the remainder. Increments the value of a number by 1. Decrements the value of a number by 1. - (unary) Changes the sign of a signed integer. Assigns a value to a variable or other object.

Adds the value of the first item to the second item and assigns the total to the first item as a new value. Subtracts the value of the second item from the first item and assigns the total to the first item as a new value. Divides the value of the first item by the second item and assigns the total to the first item as a new value. WWW SQL Designer. JSLint, The JavaScript Verifier. Mike Davidson: How To Keep Widgets From Slowing Down Sites: WEDJ. The whole world is going to widgets. This overused, overhyped term refers to third-party code one places on their website or blog in order to display such things as Flickr photos, Twitter status, or iTunes playlists.

Everybody and their mom is putting out widgets these days, and although only about 1% of them are useful or interesting, they are an important new distribution mechanism that is changing the way companies think about syndication. But there is a big problem with widgets: they slow down the sites that use them . In the best case, you have a company like Flickr whose servers are almost always snappy, and in the worst case, you have a young startup that is constantly struggling against increasing demand and occasionally can’t serve up any code at all. The problem is that in either of these cases, the completion of your site’s loading and rendering depends on someone else’s code living on someone else’s server. Following is a breakdown: Root Causes The Solution: WEDJE Caveats 1. 2. SimpleJS.

Performance tips for JavaScript. 3 performance tips for JavaScript As our JavaScript applications get larger and ever more sophisticated, the need for efficient scripting becomes increasingly important and hard to bypass. Back in the days when all that JavaScript could do was change your document's background color, or validate a simple form, abuse in terms of efficiency in our codes was common, with the browser not having a problem with it at all. Now, especially with the language's marriage with DHTML, in turn, the ability to create almost full blown applications, efficiency is no longer something we can sweep under the rug, and forget about. In this tutorial, I'll show you a trio of important and generic tips for improving performance in your JavaScript codes. Pop in your favorite tune, and let's sweat JavaScript to the old East!

Tip 1: Cache your objects! One of the best kept secrets to boosting script performance is to cache your objects. In the above, the object "document.images" is what's accessed multiple times. You think you know (JavaScript) but you have no idea. Harry Maugans » How to Create an Animated, Sliding, Collapsible. jQuery: The Write Less, Do More, JavaScript Library. JavaScript - Table of Contents. Writing Responsible JavaScript. Without a doubt, JavaScript has been making something of a comeback in the last year. If you’re involved in client-side development in any way at all, chances are that you’re finding yourself writing more JavaScript now than you have in a long time.

If you learned most of your JavaScript back when DHTML was all the rage and before DOM Scripting was in vogue, there have been some big shifts in the way scripts are written. Most of these are in the way event handlers are assigned and functions declared. Both of these changes are driven by the desire to write scripts that are responsible page citizens, both in not tying behaviour to content and in taking care not to conflict with other scripts. I thought it may be useful to look at some of these more responsible approaches to learn how to best write scripts that are independent of the page content and are safely portable between different applications. Event Handling <a id="anim-link" href="#" onclick="playAnimation()">Play the animation</a> Six JavaScript features we do not need any longer - Wait till I. Notice: The following is a “best practice document”.

You can follow its advice and live happily ever after, but there might be situations where you cannot apply the ideas mentioned within. This is especially the case when you have to maintain an old product or complex web application. You cannot replace everything in those in one go – as you are very lucky indeed if you get the time and budget – but you can tackle those step by step.

According to many web designers at @media2005, JavaScript is sexy again, and in demand. Ajax is the new CSS was a quote in one of the presentations, that – taken out of context – makes my stomach go wonky. Working largely with b2b sites and restricted environments, I never knew it was out of fashion. It is a tool, much like a shovel, a screwdriver or a towel. You can use a screwdriver to screw in screws or to clean your ears, however, the latter needs real skill, determination and a lack of fear of injuring yourself. Things that should make you go On request. UI Library. Webmonkey: The Web Developers Resource. Top 10 custom JavaScript functions of all. Wednesday Nov 30 2005 UPDATE: For anyone who lands on this article months after the fact, there is now a podcast entry about this article reviewing each and every function. If there was ever a universal common.js shared among the entire develosphere, you'd fine these ten (plus one bonus) functions.

It would be the swiss army knife no developer would go into production without. They have no doubt been tested tried and true and have proven usefulness and helpfulness to all those who've used them. 10) addEvent() Surely a staple to event attachment! Scott Andrew's original addEvent() function function addEvent(elm, evType, fn, useCapture) { if (elm.addEventListener) { elm.addEventListener(evType, fn, useCapture); return true; } else if (elm.attachEvent) { var r = elm.attachEvent('on' + evType, fn); return r; } else { elm['on' + evType] = fn; } } 9) addLoadEvent() addLoadEvent() by Simon Willison function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload ! 7) cssQuery() Tooltips, Popups, Javascript, Dhtml - BoxO.

Mootools.net. JavaScript Shell. JavaScript Reference. JavaScript Made Easy: Free JavaScripts Tu. JavaScript Cake Tutorials and Script. Cript.aculo.us - web 2.0 javascript. [tw] : Creating Custom Events with JavaScr. The Elevator Pitch Many "Web 2.0" applications suffer from too-tight-coupling between the various javascript objects used to model the data and control the interface. This has always been seen as a necessary evil because there seemed to be no good alternative. One common solution in desktop applications is called "event driven programming.

" Not just user-supplied events like mouse clicks, hovers, and window scrolls (obviously, we do all of that in our javascript apps already), but actual data-driven or state-driven events such as "message selected" or "preference changed". Truly custom events, when used correctly, allow you to decouple many of the objects in your application. This leads to better self-containment and maintainability. It has generally been considered impossible — or at least too difficult — to create truly custom events in our applications.

Keep reading and we'll examine the problem a little more closely, and consider my solution to it. In a hurry? Assumption Introduction. 9 Javascript(s) you better not miss !! This tutorial is aimed at those who have a working knowledge of Javascript. So the examples are not explained in great detail. Only the important parts are highlighted. I have presented 9 Javascript examples that I have found very useful while designing professional websites. There are many ways to implement these examples here. Please not that that wherever there is a mention of any .jpg , .gif or any other .html files, see to it that you have a dummy .gif, .jpg or .html file in the same directory as the script file so that the script finds these files. Example 1 : A Single click for checking-unchecking multiple check boxes You must have seen this script working at many places.

Note : The VALUE tag for the checkboxes seem to have no use. Example 2 : Opening a page (existing as well as dynamic) in a new window without bars, buttons, etc. The setCount() take 2 parameters, the no of checkboxes and the target program to which the contents have to be submitted to. I have shown 2 ways.. Editable select. Prototype JavaScript Framework: Class-styl. Date Formatting And F. Interpreter - JavaScript Interactive Inter. Javascript/ Calendars : A collection of JavaScript Cal. Primers/jsp/ Dojo, the Javascript Toolkit: brought to y. Aprils A1 JavaScript(TM) Resources - The h. Detecting, Analyzing, and Exploiting Intra. JavaScript Closures for Dummies | Developing thoughts — Morris J.

Curiosity is bliss: Javascript Shell bookmarklet for IE. The Javascript Shell is an awesome utility for javascript development. It was written by Jesse Ruderman and some other contributors. The bookmarklet version is the most useful, but it unfortunately only works in Firefox. Remote loading: The first problem with supporting IE is IE's limitation in bookmarklet size. Since version 5.5, IE only allows 512 characters in bookmarklets.

The simple workaround is to use a small bookmarklet which acts as a bootstrap but doesn't contain the actual code. Instead it inserts a Brad Neuberg has an implementation of this remote loading bookmarklet, which I re-used. Finding the caret position: The second problem was in the Javascript Shell code itself, with a function that figures out the position of the caret inside a textarea. Here is the fixed getcaretpos method, which uses a technique described by Mihai Bazon: function getcaretpos(inp) { if(inp.selectionEnd ! Enumerating members of a javascript object: Any suggestions on how to work around this? Ajax Digest // JavaScript Performance tips for IE. Programming tricks While investigating the performance issues on script heavy sites we noticed several design patterns that resulted in less than optimal script performance.

Changing these design patterns on the site end often resulted in huge performance wins (4x to 10x increase) to the user, so I wanted to share these recommendations with everyone. To that end, this blog will be the first in a 3 part series focusing on developing performance optimized scripts for web pages, covering the following: Symbolic Look-up recommendations JavaScript code inefficiencies Script and performance considerations specific to Internet Explorer Please let me know if there are other useful performance topics you’d like to hear about.

Symbolic Look-up Recommendations A primary source of JavaScript performance issues when running inside of IE come from constant symbolic look-up. Evaluating Local Variables function WorkOnLocalVariable(){ local_variable = ObtainValueFromDOM(); return (local_variable + 1);} Javascript Animation: Tutorial, Part 1 - Schillmania.com.