Skip to content

Instantly share code, notes, and snippets.

💭
Tired

Jake Archibald jakearchibald

💭
Tired
Block or report user

Report or block jakearchibald

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:8a9c47094b6e31de5cb2
function assertOkResponse(response) {
if (response.type === 'opaque' || response.status === 200) {
return response;
}
throw Error("Bad response: " + response.status);
}
fetch(url, {'mode': 'cors'}).then(assertOkResponse).then(function(response) {
// cache
}).catch(function(err) {
View gist:157041
glow.events.addListener("#twit", "mouseover", function () {
clearTimeout(myTimeout);
myInfoPanel.show();
});
glow.events.addListener("#twit", "mouseout", closeAfterDelay);
var myTimeout = 0;
function closeAfterDelay() {
myTimeout = setTimeout(function() {
View gist:157973
// here are the month names how we want to display them...
var fullMonthNames = [
"Janurary",
"Feburary",
"March",
"April",
"May",
"June",
"July",
View gist:165192
function trimFormField(selector, on) {
var field = glow.dom.get(selector);
return ["custom", {
on: on,
arg: function(values, opts, callback, formData) {
field.val( glow.lang.trim(values[0]) );
callback(glow.forms.PASS, "");
}
}];
}
View gist:165088
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
<head profile="http://dublincore.org/documents/dcq-html/">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Glow drag tests</title>
<script src="http://www.bbc.co.uk/glow/glow/1.6.0-rc1/core/core.js" type="text/javascript"></script>
<script src="http://www.bbc.co.uk/glow/glow/1.6.0-rc1/widgets/widgets.debug.js" type="text/javascript"></script>
<link href="http://www.bbc.co.uk/glow/glow/1.6.0-rc1/widgets/widgets.css" type="text/css" rel="stylesheet" />
<style type='text/css'>
View Glow trim form fields
// create our form
var myForm = new glow.forms.Form("#fmcustomer")
var myForm = glow.lang.trim("txtCompany","txtForename","txtSurname2)
// add tests for First Name
.addTests(
"txtCompany",
["required", {
on: "change submit",
message: "Please tell us your company name"
}]
View gist:167239
glow.events.addListener("#yourForm", "submit", function() {
glow.net.post(
// make a request to the place the form posts to
this.action,
// get the data from the form to send to the server
glow.dom.get(this).val(),
{
onLoad: function(response) {
// response.text() is the response from the server
}
View gist:172088
var functions = [],
functionsLen = 0;
function buildMassiveString() {
// build a ~1mb string
return new Array(1024*1024).join('#');
}
function addListener() {
var massiveString = buildMassiveString();
View gist:172042
var functions = [],
functionsLen = 0;
function buildMassiveString() {
return new Array(1024*1024).join('#');
}
function addFunction() {
var massiveString = buildMassiveString();
functions[ functionsLen++ ] = function() {};
View gist:173814
var MyClass;
(function() {
MyClass = function() {
this.val = 2;
}
MyClass.prototype.publicFunction = function() {
return privateFunction.call(this);
You can’t perform that action at this time.