Skip to content

Instantly share code, notes, and snippets.

dojo.provide("dojotype._base.Number");
(function(d){
/*=====
dojo.Number = function(){
// summary: A series of prototype-extending Number functions.
// description:
// All the Math.* functions available in stock JavaScript
// applied to the Number prototype. Unfortunately, the
// syntax would be weird/bad/confusing:
(function(){
// normal ass object:
var obj = {
me:37
};
function mangler(arg, num){
// `arg` is literally `obj`
arg.me = num;
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
#baz {
border:8px solid #ededed;
padding:20px;
background:#ccc;
width:600px;
position:absolute;
(function(d){
d.Timer = function(args){
// summary: The constructor function. Anytime we `new` up a Timer,
// this function is called, passing anything passed.
//
// example:
// | var x = new dojo.Timer({ a:b });
// | x.a == b // true
d.mixin(this, args);
(function(d){
// change to fit needs:
var acct = "UA-843203-1", page = "someIdentifier", delay = 300;
// won't need to change much (if any) below here:
var h = d.getElementsByTagName("head")[0], s = d.createElement("script");
s.src = ("https:" == d.location.protocol ? "https://ssl." : "http://www.")
+ "google-analytics.com/ga.js";
(function(bug){
buggyfunction = function(msg){
// summary: Alert some message.
// msg: String|Object
// If string, just show this message. If object,
// use obj.message for display, and hide
// obj.delay ms
var delay;
if(typeof msg == "string"){
dojo.provide("plugd.layout");
(function(d){
var clsCache = {},
doit = function(part){
// do some mangling:
var dtype = part.type, kids = part.children;
if(!clsCache[dtype]){ clsCache[dtype] = d.getObject(dtype); }
if(part.id){ part.props.id = part.id; }
<!DOCTYPE html>
<html>
<head>
<title>Do Nothing.</title>
</head>
<body>
<script>
(function(){
// some boilerplate load-a-script-code
dojo.extend(dijit._Widget, {
on: function(ev, cb, scp){
if(scp){ cb = dojo.hitch(cb, scp) }
this.connect(this, ev, cb);
return this; // or return this.connect(...), can't decide
}
});
// examples:
//
(function(){
var wow = function(arg){ console.log(arg); };
wow(bar); // bar defined later, but ready
wow(foo); // foo undefined just yet
var foo = function(){}
wow(foo); // foo now works