Skip to content

Instantly share code, notes, and snippets.

// not sure I like:
!function(a, b){ /* ... */ }(1, 2);
// over:
(function(a, b){ /* ... */ })(1, 2);
<!DOCTYPE html>
<html>
<head>
<title>Dojo x-domain Skeleton</title>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js"></script>
<script>
dojo.require("dojo.DeferredList");
dojo.ready(function(){
var xhrs = dojo.map(["dfdlist.html", "dfdlist.html", "dfdlist.html", "dfdlist.html", "dfdlist.html"], function(url){
dojo.provide("Foo"); // always first
dojo.require("All.Your.Code.Are"); // always second
dojo.require("Belong.To.Us");
(function(d){ // optional wrapper / privatizer / closure
// privates for this module
var yep = true,
nope = false,
dojo.declare("Foo", null, {
constructor: function(a){ dojo.mixin(this, a); },
bar: function(a, b){
console.log(a, b);
}
});
dojo.declare("Baz", Foo, {
bar: function(b, a){
// "bar" is name, "arguments" is required, "[a,b] is new arguments to pass"
dojo.require("dojo.io.script")
dojo.io.script.get({
url: 'http://search.yahooapis.com/WebSearchService/V1/webSearch',
content: {
appid: 'azvpxZ_V34H8C732JoAieOR1opWXQNw0MyaG2RuMPIplVFkMnKNi8SPZ0mlgf4E-',
query: "foo",
output: 'json'
},
timeout: 60000,
dojo.declare("Foo", null, {
url:"/example.txt",
constructor: function(){
dojo.xhrGet({
url: this.url,
// pass a string as 2nd to hitch(). means this._handler():
load: dojo.hitch(this, "_handler"),
<!DOCTYPE html>
<html>
<head>
<title>Dojo x-domain Skeleton</title>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js" djConfig="isDebug:true"></script>
<script>
dojo.ready(function(){
var dojoUrl = "http://ajax.googleapis.com/ajax/libs/dojo/1.5/"
function addScript(src){
var script = document.createElement("script");
script.src = src;
script.onload = script.onreadystatechange = function(e){
if(e && e.type == "load" || /loaded|complete/.test(script.readyState)){
script.onload = script.onreadystatechange = null;
console.log("foo.js added and ready");
}
}
<?php
// Simple single-file doc validation utility, using our php-based `jsdoc` parser.
// To be used as a post-commit hook?
//
// to use:
// php -q parsefile.php dojox/data/AndOrReadStore.js
//
// exits normally (status 0) if OK, with status 255 if failed, other values are from PHP untrapped.
//
function noteval(code, doc){
// add some javascript to a document, like an iframe
//
// var iframe = document.getElementById("theframe");
// noteval('alert("hi")', iframe.contentDocument || iframe.)
var e = doc.createElement("script"),
how = "text" in e ? "text" :
"textContent" in e ? "textContent" :