Skip to content

Instantly share code, notes, and snippets.

@videlais
videlais / accelerometer.js
Created December 25, 2013 12:14
Complete Accelerometer.js code
/**
* An accelerometer object for detecting device orientation
* and motion (if supported)
*
* Chrome 7+, Firefox 6+, IE11+, iOS Safari 4.0+, Android Browser 3.0, Blackberry 10.0
* http://caniuse.com/#feat=deviceorientation
*
* The DeviceOrientationEvent.alpha value represents the motion of the device around the z axis,
* represented in degrees with values ranging from 0 to 360.
*
@videlais
videlais / geolocation.js
Created December 30, 2013 15:52
Complete Geolocation.js
/*
* A Geolocation object
*
* Note: Uses GPS or similar hardware for data if available through
* the browser, but will fall back to using (Google) geolocation
* services with current IP address automatically.
*
* @property {boolean} supported If the geolocation functions are available in the current context
* @property {function} onsuccess The function to be called if the geolocation services are successful
* @property {function} onerror The function to be called if an error occurs
@videlais
videlais / Gamepad.js
Last active July 17, 2021 09:36
Complete Gamepad.js code
/**
* (Note: Depends on window.requestAnimationFrame for polling.)
*
* An experimental Gamepad object for detecting
* and parsing gamepad input.
*
* Current code borrows heavily from Marcin Wichary's work:
* http://www.html5rocks.com/en/tutorials/doodles/gamepad/
*
* Also uses deadzone values from
@videlais
videlais / noclickjQueryTwine.js
Last active January 17, 2020 21:17
No-click Twine (1.4) using jQuery
// First, create a reference to the Wikifier.createInternalLink function.
// (Internally, this is what Twine uses to connect passages together.
// It is the last step in parsing double-bracked content into links.)
var oldCreateInternalLink = Wikifier.createInternalLink;
// Then, create a new function that mimics its functionality.
Wikifier.createInternalLink = function(place, title) {
// By calling the old function, it returns
// the DOM element (the link) it was about to
@videlais
videlais / PlayState.as
Last active May 2, 2018 03:36
ActionScript 3 Example 6 PlayState Version 2
package
{
/**
* ...
* @author Dan Cox
*/
import org.flixel.*;
public class PlayState extends FlxState
@videlais
videlais / map1.txt
Last active May 2, 2018 03:34
Txt (CSV) for Map 1
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,6,3,3,3,3,3,3,3,3,3,3,3,3,2,
2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,6,3,3,3,3,3,3,3,3,3,3,3,3,2,
2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,6,3,3,3,3,3,3,3,3,3,3,3,3,2,
2,1,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,1,1,1,4,6,3,3,3,3,3,3,3,3,3,3,3,3,2,
2,1,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,1,1,1,4,6,3,3,3,3,3,3,3,3,3,3,3,3,2,
2,1,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,1,1,1,4,6,1,1,1,1,1,1,1,1,1,1,1,3,2,
2,1,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,1,1,1,4,6,1,1,1,1,1,1,1,1,1,1,1,3,2,
2,1,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,1,1,1,4,6,1,1,1,1,1,1,1,1,1,1,1,3,2,
2,1,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,1,1,1,4,6,1,1,1,1,1,1,1,1,1,1,1,3,2,
@videlais
videlais / visitedLinks.js
Last active January 3, 2016 22:19
Highlighting 'visited' links in Twine
@videlais
videlais / loadJS.js
Created January 19, 2014 00:12
LoadJS Twine Macro
macros['loadJS'] =
{
handler: function(place, object, parameters)
{
var se = document.createElement("script");
se.type = 'text/javascript';
se.src = parameters[0];
var hT = document.getElementsByTagName("HEAD")[0];
hT.appendChild(se);
if(se.innerText) {eval(se.innerText);}
@videlais
videlais / notifications.js
Created December 29, 2013 16:28
Complete Notifications.js
/**
* A Notifications object
*
* http://caniuse.com/notifications
* Currently supported only in Firefox 22+, Chrome 22+, and Safari 6+ (on Mac OSX 10.8+).
*
* Note: requestPermission() MUST be called from a user gesture event in Chrome
* to be valid. It will fail silently otherwise!
*
* Note: Firefox and Safari will close notifications themselves
@videlais
videlais / fullscreen.js
Created December 27, 2013 22:01
Complete Fullscreen.js
/**
* A Fullscreen object
*
* Current support (http://caniuse.com/#feat=fullscreen)
* is limited to Firefox 22+ (moz), Chrome 28+, Safari 6.0+, Opera 16.0+ (webkit),
* and IE11+ (ms)
*
* @property {boolean} supported If fullscreen support exists in the current context
* @property {boolean} isFullscreen If an element is currently fullscreen or not
*/