par exemple tu fais :
function q(selector){ return [].slice.apply(document.querySelectorAll(selector)); }
ensuite si tu as une page web avec :
<ul><li>un</li><li>deux</li><li>trois</li></ul>
et que tu fais :
| (function () { | |
| var Customer = Species.Class({ | |
| Extends : Species.Model, | |
| Name : { | |
| get : function() { return this.name; }, | |
| set : function(value) { this.name = value; } | |
| }, | |
| Budget : { |
| window.BBExtModel = Backbone.Model.extend({ | |
| initialize : function() { | |
| function defineProperty(o,p) { | |
| Object.defineProperty(o,p,{ | |
| get : function() { return o.get(p);}, | |
| set : function(value) { | |
| var v = {}; v[p] = value; | |
| o.set(v); | |
| }, | |
| enumerable: true, |
| #lexical analysis | |
| #http://ariya.ofilabs.com/2011/08/math-evaluator-in-javascript-part1.html | |
| class Lexer | |
| constructor:-> | |
| @expression = '' | |
| @length = 0 | |
| @index = 0 | |
| @marker = 0 | |
| #from @bennadel experiment : http://www.bennadel.com/blog/2269-Creating-A-Private-Scope-By-Extending-The-Public-THIS-Scope-In-JavaScript.htm | |
| class Human | |
| constructor:(name)-> | |
| @name = name | |
| privateScope = Object.create @ | |
| privateScope.nickName = "???" | |
| @getNickName = -> |
| # see http://docs.sencha.com/touch/2-0/#!/guide/getting_started | |
| class TabPanel extends Ext.TabPanel | |
| constructor:-> | |
| super | |
| fullscreen : true | |
| tabBarPosition: 'bottom' | |
| items : [ | |
| { | |
| title : 'Home' |
| var lib = require("./manifest.js"); | |
| lib.mkmanifest({ | |
| filename : "cache" | |
| ,path : "../coffee" | |
| ,version : "02" | |
| ,exclude : ['/.DS_Store', '/.htaccess', '/cache.manifest'] | |
| /* | |
| ,network : ['/connect.php','/read.php'] | |
| ,fallback : ['/offline.html'] |
| __ = (from,name,member,annotation)-> | |
| if not from.annotations then from.annotations = {} | |
| if not from.annotations[name] then from.annotations[name] = {} | |
| from.annotations[name][member] = annotation | |
| class Human | |
| __ @, "Model", "constructor", "localStorage" | |
| __ @, "gui", "name", "name:input type = text" | |
| __ @, "gui", "weight", "weight:input type = text" |
| #--- MODEL --- | |
| class Task extends bob.Model | |
| @storage : "Tasks_Storage" | |
| constructor:(label)-> | |
| @label = label | |
| @numericalId = 0 | |
| #--- CONTROLLER --- | |
| class window.Tasks extends bob.Controller |
| <body> | |
| <h1>TODO LIST</h1> | |
| <!-- MESSAGE VIEW --> | |
| <script type="text/template" id="message_template"> | |
| <h2>#{message}</h2> | |
| </script> | |
| <div id="message_view"></div> |
par exemple tu fais :
function q(selector){ return [].slice.apply(document.querySelectorAll(selector)); }
ensuite si tu as une page web avec :
<ul><li>un</li><li>deux</li><li>trois</li></ul>
et que tu fais :