background preloader

Javascript

Facebook Twitter

Creating an auto-caching Data Store in Sencha Touch and Ext JS 4 | Druck-I.T. Ext.define('<span class="skimlinks-unlinked">MyApp.store.LocalCache</span>', { extend: '<span class="skimlinks-unlinked">Ext.data.Store</span>', requires: [ 'Ext.device.Connection', '<span class="skimlinks-unlinked">Ext.data.proxy.LocalStorage</span>', 'Ext.DateExtras' config: { remoteProxy: { }, localStorageProxy: { }, lastUpdated: '2013-04-02 06:36:00 -8:00', storeId: 'MyStore' constructor: function(config) { this.callParent(arguments); this.expireField = <span class="skimlinks-unlinked">Ext.app.Application.appInstance.getName</span>() + "-" + this.getLocalStorageProxy().id + '-lastupdated'; if (Ext.Object.getSize(this.getRemoteProxy()) == 0) this.setRemoteProxy(this.getProxy().getInitialConfig()); load: function(options, scope) { var online = Ext.device.Connection.isOnline(); var me = this; if (online && this.isCacheMiss()) { this.setProxy(this.getLocalStorageProxy()); this.callParent([{ scope: this, callback: function() { this.removeAll(); <span class="skimlinks-unlinked">this.sync</span>(); options = {

HTTP access control (CORS) - HTTP. A resource makes a cross-origin HTTP request when it requests a resource from a different domain than the one which the first resource itself serves. For example, an HTML page served from makes an <img> src request for Many pages on the web today load resources like CSS stylesheets, images and scripts from separate domains. For security reasons, browsers restrict cross-origin HTTP requests initiated from within scripts. For example, XMLHttpRequest and Fetch follow the same-origin policy.

So, a web application using XMLHttpRequest or Fetch could only make HTTP requests to its own domain. To improve web applications, developers asked browser vendors to allow cross-domain requests. The Cross-Origin Resource Sharing (CORS) mechanism gives web servers cross-domain access controls, which enable secure cross-domain data transfers. This article is for web administrators, server developers, and front-end developers. Overview Simple requests Origin. Closure Tools. Sinon.JS - Documentation. This page contains the entire Sinon.JS API documentation along with brief introductions to the concepts Sinon implements. Please ask questions on the mailing list if you're stuck. I also really appreciate suggestions to improve the documentation so Sinon.JS is easier to work with. Get in touch! Test spies API reference What is a test spy?

A test spy is a function that records arguments, return value, the value of this and exception thrown (if any) for all its calls. When to use spies? Test spies are useful to test both callbacks and how certain functions/methods are used throughout the system under test. "test should call subscribers on publish": function () { var callback = sinon.spy(); PubSub.subscribe("message", callback); PubSub.publishSync("message"); assertTrue(callback.called);} Spying on existing methods sinon.spy can also spy on existing functions.

Creating spies: sinon.spy() var spy = sinon.spy(); var spy = sinon.spy(myFunc); Spies on the provided function Spy API spy.callCount spy.args. Simplifying Grunt Jasmine tests for Ext.js | Matt Goldspink. Are you wanting to unit test you Ext.js code but not sure where to start? Do you feel frustrated that everytime you get a bug raised you don’t know how to apply TDD techniques to your JavaScript because it’s just “not the same kind of code” as your Java, Ruby, .Net?

Since I’ve worked with Ext.js and Sencha Touch, testing has long been an issue that I’ve fought with. Initially I did no testing other than opening the browser hitting refresh and retracing my steps. However last year I went to Full Frontal and attended Rebecca Murphy’s talk (video & slides) and workshop on how to write testable JavaScript. Since then I’ve been cranking out test, after test, after test, and it’s improved the quality of code and its stability drastically. However it did take me a while to understand how to setup Jasmine for an Ext.js project, so I thought something could be done about this to make life simpler. So I created a new Grunt plugin: grunt-sencha-jasmine Like this: Like Loading... Tobeytailor.s3.amazonaws.com/get_barcode_from_image/get_barcode_from_image.js. CS98SI Introduction to JavaScript. Announcements Homework 2 Homework 2 is here!

AJAX demo In the AJAX lecture, we build a small web application, which you can download here. HTML Template You can get a blank HTML template here. Piazza This quarter we will be using Piazza for class discussion. Course information Course information can be found here. Previous labs In-class labs can be found here. Homework Homework 1 (released April 22, due May 8) Homework 2 (TBD) Syllabus. #267 CoffeeScript Basics. CoffeeScript allows you to write JavaScript in a concise, elegant fashion. Here I convert JavaScript code to CoffeeScript in a Rails 3.1 app. Download: source codeProject Files in Zip (84 KB)mp4Full Size H.264 Video (21 MB)m4vSmaller H.264 Video (12.2 MB)webmFull Size VP8 Video (14.2 MB)ogvFull Size Theora Video (33.9 MB) CoffeeScript. CoffeeScript is a little language that compiles into JavaScript.

Underneath that awkward Java-esque patina, JavaScript has always had a gorgeous heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way. The golden rule of CoffeeScript is: "It's just JavaScript". The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime.

Latest Version: 1.7.1 sudo npm install -g coffee-script Overview CoffeeScript on the left, compiled JavaScript output on the right. number = 42 opposite = true number = -42 if opposite square = (x) -> x * x list = [1, 2, 3, 4, 5] math = root: Math.sqrt square: square cube: (x) -> x * square x race = (winner, runners...) -> print winner, runners alert "I knew it! " run: cubes Installation The CoffeeScript compiler is itself written in CoffeeScript, using the Jison parser generator. To install, first make sure you have a working copy of the latest stable version of Node.js, and npm (the Node Package Manager). Testing Ext JS and Sencha Touch.

Ext Spec.

Calendars

How to Load Dinamically (On Demand) external javascript with ExtJS 4??? How To Use ExtJS 4 TreePanels with Both Static Data and Model Stores. Wireframe showing tree with both static and dynamically-loaded items I recently needed to build an “admin” screen for a webapp using ExtJS 4. The wireframe called for a tree to navigate the various admin settings, including settings for individual users (something like what you see at right). To build a tree like this with ExtJS, you usually use the Ext.tree.Panel class (a.k.a., a TreePanel). Unfortunately I couldn’t find any examples of how to make a TreePanel with a mixture of both static and dynamic nodes, so figuring it out took longer than it should have. With that in mind, I thought I’d share what I learned. A working example of the solution I came up with is shown below (if the embedded version doesn’t appear for some reason, you can open it here).

Note that you can actually run the code in your browser and see the results–just click the play button. The first thing the code does is define a basic model class for user data, called UserModel: Tags: extjs4. FireEvent [アーカイブ] - Sencha Forum. This is just back of the envelope; if the object is not a direct child, say like a field in a form for instance you need to set the bubble target; here's and example of setting the bubble target pulled from the sencha docs. This can also be used like: Corsi | AndreaCammarata.com. Sencha Touch In this course you will learn to move your first steps in the one that today, is without doubt, the most innovative mobile web oriented framework, thanks to it’s full compatibility with HTML5 and CSS3, but even to it’s stunning webkit animations. Ext An unique framework developed, like Sencha Touch, by Sencha Inc. This framework will you able to create innovative and dynamics web applications.

Nested JSON and hasMany associations.

Nodejs

Downloading jQuery. Compressed and uncompressed copies of jQuery files are available. The uncompressed file is best used during development or debugging; the compressed file saves bandwidth and improves performance in production. You can also download a sourcemap file for use when debugging with a compressed file. The map file is not required for users to run jQuery, it just improves the developer's debugger experience. As of jQuery 1.11.0/2.1.0 the //# sourceMappingURL comment is not included in the compressed file. To locally download these files, right-click the link and select "Save as... " from the menu. For help when upgrading jQuery, please see the upgrade guide most relevant to your version. Download the compressed, production jQuery 3.6.2 Download the uncompressed, development jQuery 3.6.2 Download the map file for jQuery 3.6.2 You can also use the slim build, which excludes the ajax and effects modules: Download the compressed, production jQuery 3.6.2 slim build jQuery 3.6.2 blog post with release notes.

Google I/O 2011: Chrome Dev Tools Reloaded. Learning Advanced JavaScript. JavaScript Guide. The JavaScript Guide shows you how to use JavaScript and gives an overview of the language. If you need exhaustive information about a language feature, have a look at the JavaScript reference. This Guide is divided into the following chapters. Introduction Grammar and types Control flow and error handling Loops and iteration Functions Expressions and operators Numbers and dates Text formatting Indexed collections Keyed collections Working with objects Details of the object model Promises Iterators and generators.

Insanely fast, headless full-stack testing using Node.js. JavaScript Development Tools Debug. Project Overview The JSDT debug project brings a variety of JavaScript debugging support to the JSDT using a common UI and communicating using a common protocol - JavaScript Debug Interface (JSDI). The common interface for the debugger emulates that of the platform and JDT debugger to allow a smooth transition and ease of use for the JSDT debugger. Currently we have debugging support for Rhino and an incubation version of Crossfire / Firebug support. JSDT Debug Bundles The JSDT debugger is broken down into the following bundles: A team project set file for JSDT debug can be found here. Development Resources All things related to hacking the code and using the tools can be found in this section.

Rhino Debug Wire Protocol To provide support for the Rhino interpreter, we had to create both sides of the coin - the debugger and the client. JavaScript Debug Interface (JSDI) Up To The Minute JSDT Debug is preparing to release version 3.2.1! JavaScript Plugin - Sonar. Maven plugins for javascript. Talios/coffee-maven-plugin - GitHub. Smooth CoffeeScript.