<div> <div> ... </div> <div> <div> ... </div> </div> </div>To new Semantics Tag
<section> <article> <header> .... <header> ... </article> <aside> <nav> ... </nav> </aside> </section>
html5shiv, html5shiv (github), accessifyhtml5.js
Required Text |
<input type="text" required=""/> |
Email Text |
<input type="email" value="some@email.com"/> |
Date Text |
<input type="date" min="2010-08-14" max="2011-08-14" value="2010-08-14"/> |
Range Element |
<input type="range" min="0" max="50" value="10"/> |
Telephone Text |
<input type="tel" placeholder="(555) 555-5555" pattern="^\(?\d{3}\)?[-\s]\d{3}[-\s]\d{4}.*?$"/> |
Color Element |
<input type="color" placeholder="e.g. #bbbbbb"/> |
Step Element |
<input type="number" step="1" min="-5" max="10" value="0"/> |
Search Text |
<input results="10" type="search" placeholder="Search..."/> |
<video width="640" height="368" id="myVideo" controls> <source src="...../videos/madagascar3.webm" type='video/webm; codecs="vp8.0, vorbis"'> <source src="...../videos/madagascar3.ogv" type='video/ogg; codecs="theora, vorbis"'> <source src="...../videos/madagascar3.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'> </video>
var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); ctx.fillStyle = "#00A308"; ctx.beginPath(); ctx.arc(220, 220, 50, 0, Math.PI*2, true); ctx.closePath(); ctx.fill(); ctx.fillStyle = "#FF1C0A"; ctx.beginPath(); ctx.arc(100, 100, 100, 0, Math.PI*2, true); ctx.closePath(); ctx.fill(); //the rectangle is half transparent ctx.fillStyle = "rgba(255, 255, 0, .5)" ctx.beginPath(); ctx.rect(15, 150, 120, 120); ctx.closePath(); ctx.fill();
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <rect x="10" y="10" height="100" width="100" style="stroke:#ff0000; fill: #0000ff"/> </rect> <rect x="50" y="50" height="110" width="110" style="stroke:#ff0000; fill: #ccccff" transform="translate(30) rotate(45 50 50)" > </rect> <text x="70" y="100" transform="translate(30) rotate(45 50 50)"> Hello World </text> <circle class="myGreen" cx="140" cy="40" r="24"/> <circle class="myRed" cx="140" cy="100" r="24"/> </svg>
//Open Web Socket Connection var socket = new WebSocket('ws://localhost:5000/echo'); //Callback for successful Connection socket.onopen = function(event) { console.log("WebSocket connected Successfully"); }; //Send Message to Server socket.send('Hello, WebSocket'); //Callback for receiving message sent by the Server socket.onmessage = function(event) { console.log("Got message from server "+event.data); } //Callback when WebSocket Connection is terminated socket.onclose = function(event) { console.log("WebSocket connection is terminated"); }
//Simple Message data: this is a simple message //Multi line JSON Message data: { data: "name":"Rohit Ghatol", data: "city":"Pune" data: } //Messages with ID id: 33 data: this is line one data: this is line two //Messages with <> id: 36 event: price data: 103.34
var source = new EventSource('http://xyz.com/events'); //Callback called when connection is established source.onopen = function () { connectionOpen(true); }; //Callback called when connection issues occurs source.onerror = function () { connectionOpen(false); }; //Callback called when server sends a data source.onmessage = function (event) { console.log("Server sent "+event.data); }; source.addEventListener('<custom event>', function(event){ console.log("Got Data "+event.data+" for <custom event>"); }, false);
flXHR (requires crossdomain.xml)
<div id="sidebar"> <h3>Super team:</h3> <ul id="nav"> <li> <a data-email="chriscoyier@gmail.com" href="mailto:chriscoyier@gmail.com"> Chris Coyier </a> </li> <li> <a data-email="isuredo@likeher.com" href="mailto:isuredo@likeher.com"> Elisabeth Moss </a> </li> <li> <a data-email="marry@me.com" href="mailto:marry@me.com"> Amanda Righetti </a> </li> </ul> </div>
//Default CSS for the Email Link #sidebar ul li a { color: #900; text-decoration: none; padding: 3px 0; display: block; } //CSS when the Width beyond 1001px @media all and (min-width: 1001px) { #sidebar ul li a:after { content: " (" attr(data-email) ")"; font-size: 11px; font-style: italic; color: #666; } } //CSS when the Width between 700px and 1000px @media all and (max-width: 1000px) and (min-width: 700px) { #sidebar ul li a:before { content: "Email: "; font-style: italic; color: #666; } } //CSS when the Width between 520px and 699px or Beyond 1151px @media all and (max-width: 699px) and (min-width: 520px), (min-width: 1151px) { #sidebar ul li a { padding-left: 21px; background: url(../images/email.png) left center no-repeat; } }
var worker = new Worker('Worker.js'); button.addEventListener("click", function(){ outputElem.innerHTML = "Calculating...."; var index = indexElem.value; worker.postMessage(index); }); worker.addEventListener('message', function(e){ outputElem.innerHTML=e.data; });Worker.js
//Web Worker importScripts('fibonacci.js'); addEventListener('message', function(e){ var index = parseInt(e.data); var result = fibonacci(index); postMessage(result); })
Modernizr.load({ test: Modernizr.geolocation, yep : 'geo.js', nope: 'geo-polyfill.js' });
Person = Backbone.Model.extend({ initialize: function(){ alert("Welcome to this world"); } }); var person = new Person({ name: "Thomas", age: 67});
Ext.define('FirstApp.model.Place',{ extend:'Ext.data.Model', config:{ fields:['id','recordId','name','icon','vicinity'] } })
<head> <script src=“model.js”></script> <script src=“store.js”></script> <script src=“view.js”></script> <script src=“controller.js”></script> <script src=“app.js”></script> </head>
<head> <script src=“require.js” data-main=“app.js”></script> </head>
//Model.js define( [], function(){ return { "name":"Todo Model" }; } );
//Store.js - with CRUD Operation define( [‘Model’], function(model){ return { “create”:function(){..}, “retrieve”:function(){..}, “update”:function(){..}, “delete”:function(){..}, }; } );
//View.js define( [’jQuery’,’Model’,’Store'], function($,model, store){ store.update(model); //render $(“.view”).html(…); return ..; } ) ;
//Controller.js define( [’jQuery’,’View’,’Store'], function($,view, store){ view.setStore(store); $(“#placeholder”).html(view.el()); return ..; } ) ;
//app.js require( [‘jQuery’,’Controller’], function($,controller){ $(“#loading”).html(“”); controller.initialize(); } );
<div id="placeholder"></div> <script type="text/javascript"> // Compile the template using underscore var tmplTxt = $("#search_template").html() //_ stands for underscroe var template = _.template(tmplTxt, {label:"Hello World"} ); $("placeholder").html( template ); </script> //Template put in the script tag <script type="text/template" id="search_template"> <label><%=label%></label> <input type="text" id="search_input" /> <input type="button" id="search_button" value="Search" /> </script>
<table> <tbody data-bind="foreach: seats"> <tr> <td data-bind="text: name"></td> <td data-bind="text: meal().mealName"></td> <td data-bind="text: meal().price"></td> </tr> </tbody> </table>
<!doctype html> <html ng-app> <head> <script src="/libs/angularjs/1.0.7/angular.min.js"></script> </head> <body> <div> <label>Name:</label> <input type="text" ng-model="yourName" placeholder="Enter a name here"> <hr> <h1>Hello {{yourName}}!</h1> </div> </body> </html>