Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Kinlan PaulKinlan

View GitHub Profile
View dataUriForStylesheet.js
var toDataURI = function(datatype, data) {
return "data:" + datatype +";base64," + window.btoa(data);
};
var renderStyleSheet = function() {
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = toDataUri("text/css", "body { background-color: red;}" );
document.head.appendChild(link);
};
@PaulKinlan
PaulKinlan / gist:1222849
Created Sep 16, 2011 — forked from ianb/gist:1222633
Web Intent use case brainstorm
View gist:1222849

Use Cases

Screen scrape microdata:

  • grab an ical event (send)
  • grab an hcard
  • atom feed
  • make note of an hreview (actually I can't think of what you'd do with an hreview)
  • ? generic grabbing, or we specifically figure out support for particular kinds of data (i.e., microformats.org specs)
View subscribe.html
<!doctype html>
<html>
<head>
<intent action="http://webintents.org/subscribe" type="application/atom+xml" />
<script src="http://webintents.org/webintents.min.js"></script>
</head>
<body>
<button id="go">Go</button>
</body>
View edit-intent-tag.html
<intent
action="http://webintents.org/edit"
type="image/*"
href="edit.html"
/>
View gist:2853817
var i = new Intent({
"action": "http://webintents.org/save",
"type": "image/*",
"data": blob
})
var onsuccess = function(data) {
var img1 = document.getElementById("img1");
img1.src = URL.createObjectURL(data);
};
View gist:2853874
window.addEventListener("load", function() {
if(window.intent && window.intent.action === "http://webintents.org/save") {
var data = window.intent.data;
if(data instanceof Blob) {
// do something with the blob.
}
else {
// do something with the object.
View gist:2853982
var i = new Intent({
"action": "http://webintents.org/save",
"type": "image/*",
"extras": { "url": "http://placekitten.com/g/200/300" }
})
var onsuccess = function(data) {
var img1 = document.getElementById("img1");
if(data instanceof Blob) {
img1.src = URL.createObjectURL(data);
View gist:2854138
var i = new Intent({
"action": "http://webintents.org/save",
"type": "text/uri-list",
"data": "http://placekitten.com/g/200/300"
})
var onsuccess = function(data) {
};
var onerror = function(){ };
@PaulKinlan
PaulKinlan / dabblet.css
Created Jul 19, 2012
The first commented line is your dabblet’s title
View dabblet.css
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@PaulKinlan
PaulKinlan / gist:4160675
Created Nov 28, 2012
Encapsulating Request Animation Frame
View gist:4160675
/*
Javascript is a funny thing.
Here are two things that will hit you with requestAnimationFrame
1) If you alias the window.requestAnimationFrame function on to anything other
than a window object, you get an Illegal Invocation Error.
You can solve this by using call() with the window object set.