background preloader

Javascript

Facebook Twitter

Dynamically loading an external JavaScript or CSS file. Dynamically loading an external JavaScript or CSS file The conventional way to loading external JavaScript (ie: .js) and CSS (ie: .css) files on a page is to stick a reference to them in the HEAD section of your page, for example: Files that are called this way are added to the page as they are encountered in the page's source, or synchronously. For the most part, this setup meets our needs just fine, though in the world of synchronous Ajax design patterns, the ability to also fire up JavaScript/ CSS on demand is becoming more and more handy.

In this tutorial, lets see how it's done. Dynamically loading external JavaScript and CSS files To load a .js or .css file dynamically, in a nutshell, it means using DOM methods to first create a swanky new "SCRIPT" or "LINK" element, assign it the appropriate attributes, and finally, use element.appendChild() to add the element to the desired location within the document tree. What is Node.js? Node.js. It’s the latest in a long line of “Are you cool enough to use me?” Programming languages, APIs, and toolkits. In that sense, it lands squarely in the tradition of Rails, and Ajax, and Hadoop, and even to some degree iPhone programming and HTML5.

Go to a big technical conference, and you’ll almost certainly find a few talks on Node.js, although most will fly far over the head of the common mortal programmer. Dig a little deeper, and you’ll hear that Node.js (or, as it’s more briefly called by many, simply “Node”) is a server-side solution for JavaScript, and in particular, for receiving and responding to HTTP requests. If that doesn’t completely boggle your mind, by the time the conversation heats up with discussion of ports, sockets, and threads, you’ll tend to glaze over.

Is this really JavaScript? The good news is that you’re hearing (and thinking) about the right things. A warning to the Node experts out there Node: A few basic examples Skipping hello world . Click to enlarge. Node.js Step by Step: Introduction. Node.js is an amazing new technology, but, unless you're specifically a JavaScript developer, the process of becoming acquainted with it can quickly become a bit overwhelming. But that's why we're here! If you want to really learn how to use Node.js, this set of articles and screencasts will do the trick. Hi guys, my name is Christopher Roach, and I'll be your guide throughout this series of screencasts on Node.js. In this series we'll be using Node to create a simple blog engine, like the one made famous in the popular Ruby on Rails introductory video.

The goal of this series is to give you, the viewer, a real feel for how Node works so that, even when working with any of the popular web development frameworks out there, such as Express or Getty, you'll feel comfortable enough with the inner workings of Node to be able to drop down into its source and make changes to suit your needs as necessary.

Node is JavaScript on the server. The other key phrase in that statement is evented I/O. Photoshop Scripting. Drawing Lines Photoshop CS4 using JavaScript. You could start by looking at the sample scripts that ship with photoshop to see a coding sample of stroking a selection. Then look at the doc on making selection and paths etc. // Copyright 2002-2007. Adobe Systems, Incorporated. All rights reserved. // Create a stroke around the current selection. // Set the stroke color and width of the new stroke. // enable double clicking from the Macintosh Finder or the Windows Explorer #target photoshop // in case we double clicked the file app.bringToFront(); // debug level: 0-2 (0:disable, 1:break on error, 2:break at beginning) // $.level = 0; // debugger; // launch debugger on next line if (app.documents.length > 0) if (app.activeDocument.activeLayer.isBackgroundLayer == false) var strtRulerUnits = app.preferences.rulerUnits; app.preferences.rulerUnits = Units.PIXELS; var selRef = app.activeDocument.selection; var offset = 10; selRef.select(selBounds); selRef.selectBorder(5); var strokeColor = new SolidColor(); strokeColor.cmyk.cyan = 20; selRef = null; else.

Photoshop Scripting. PhotoShop Scripting by mlk : Hot Summer Month of 2004 You’ve probably wanted at one time or another to combine the power of Photoshop’s tools to those of programming scripts. Adobe has made this possible for you with the ‘Scripting Plug-in’, a nifty plug-in that allows users to write little scripts (in Javascript, VBScript or AppleScript) that will take over Photoshop and do what you couldn’t with you mouse and keyboard… This tool is also aimed at designers which wish to increase the workflow speed (you'll see example scripts by the end of the tutorial which allow you to save all your current images, or save each layer to a separate file etc...). Even though we do use a scripting language, it is not hardcore programming and designers which hate programming should not be scared of this, the step by step tutorial will help you create your first simple scripts and you will later be able to move on to more advanced scripts.

[An excerpt from the yearbook, done by the scripting plug-in] Photoshop Scripting. PhotoShop Scripting by mlk : Hot Summer Month of 2004 V. Non-Documented Functions: Using the Script Listener Using the script listener to create undocumented functions. Well, sadly enough you cannot script everything in Photoshop (check out the scripting limitations in the 7th chapter later on). However, there are some functions which you can script but are not documented. To make that plug-in work, here's what you have to do: When you installed Scripting (for PS 7 users) there was a folder called 'Utilities' containing the plug-in 'Scriplistener'.

Reading what the script listener outputs is indeed a real pain, and re-using it even more, most probably because the Photoshop team decided not to elaborate it, since only a handful of people would use it. I will use the script listener to find out how to create circle selections in Photoshop. If you haven't done so before, turn on the script listener (place the plug-in in the 'scripting' folder or rename it correctly). Code Avengers, learn Javascript. Eloquent JavaScript: A Modern Introduction to Programming. Creating objects. Netscape 4, IE 4 on Windows and Mac, and IE 5 on Mac do not support the operator. Any function in JavaScript can be used to create custom object classes, simply by calling it using the keyword new . When called in this way, the special variable inside the function references the new object that is being constructed (it normally refers to the 'current' object, which is usually , except inside methods).

The function should not return a value. The following function can be used as demonstrated to create an object of class : function myobject() { this.containedValue = 0; this.othercontainedValue = 0; this.anothercontainedValue = 0; } var mything = new myobject(); And there you go, is now an instance of class . It will have the following properties, all of which will be 0: You could also now write this: myobject.prototype.newContainedValue = someValue; This will cause all instances of class will have the property with value . Creating an object with methods nameOfCircle.retArea() Singletons. Using Multiple JavaScript Onload Functions. JavaScript is one of the most popular programming languages in use on the World Wide Web. It can create interactive pages through the use of menus, forms and calendars.

It can also be used to track a visitor's history on your site, play games and many other things. When scripts are written they're used to accomplish a given task, e.g., create a rotating picture gallery, or to validate a form. This means that for each different type of usage, a separate script is necessary. Loading the Page When a Web page is loaded, the code on the page — whether HTML, CSS, PHP, or some other type — is generally processed from the top down. Function func1() { alert("This is the first. "); } window.onload=func1; When the page is loaded, the browser will stop at the script above and execute it. Move it to the Bottom One method is to place the script at the bottom of the Web page, just above the closing </body> tag. The onload Function The window object in JavaScript has an event handler called onload. Examples of Javascript in KML <description> tag for GE 5.0? - Advanced Support for KML.