Skip to content

Instantly share code, notes, and snippets.

View purplecabbage's full-sized avatar
:shipit:
shippin'

Jesse MacFadyen purplecabbage

:shipit:
shippin'
View GitHub Profile
@purplecabbage
purplecabbage / configPath
Created February 28, 2014 23:26
Cross platform access to the cordova config.xml file.
(function(){
var configPath = "../config.xml";
if( ["android","amazon-fireos"].indexOf(cordova.platformId) > -1 ) {
configPath = "../../android_res/xml/config.xml";
}
else if( ["blackberry10","firefoxos"].indexOf(cordova.platformId) > -1 ) {
configPath = "config.xml";
}
Object.defineProperty(cordova,'configPath', {enumerable: true, value: configPath });
@purplecabbage
purplecabbage / imageDate.js
Created December 9, 2013 22:30
Simple function to convert camera captured image path to base64 encoded data.
// callback handler for a call to cordova camera.getPicture with return type of FILE_URL
function gotPhoto(res) {
var img = document.createElement("img");
img.onload = function () {
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
var ctx = canvas.getContext('2d');
@purplecabbage
purplecabbage / SystemTray.cs
Last active December 29, 2015 14:39
Show or hide the systemtray from anywhere in WP7 + WP8
PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
if (frame != null)
{
PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
if (page != null)
{
SystemTray.SetIsVisible(page, false);
}
}
@purplecabbage
purplecabbage / sheen.js
Last active December 21, 2015 03:59
sheen
(function(window){
var repStr = "linear-gradient( ANGLEdeg, rgba(255,255,255,0.2), rgba(255,255,255,0.1) 400px, rgba(0,0,0,0) 401px)";
var sheen = document.createElement("div");
var props = {
position:"absolute",
zIndex:"666666",
width:"100%",
height:"100%",
@purplecabbage
purplecabbage / SingleTest.js
Last active December 19, 2015 19:38
Only run the (jasmine) test you are working on by junk-punching it.
var _it = it;
it = function (text,funk) {
if (text.indexOf("filetransfer.spec.5") == 0) {
return _it(text, funk);
}
else {
console.log("Skipping Test : " + text);
}
}
@purplecabbage
purplecabbage / cordova-current.js
Created October 15, 2012 23:35
cordova-current.js
(function(){
var VERSION = '2.2.0',
currentScript = 'cordova-' + VERSION + '.js',
scripts = document.getElementsByTagName('script');
for (var n = 0; n < scripts.length; n++) {
if (scripts[n].src.indexOf('cordova-current.js') > -1) {
var cordovaPath = scripts[n].src.replace('cordova-current.js', currentScript);
var scriptElem = document.createElement("script");
@purplecabbage
purplecabbage / ET_Test.js
Created June 27, 2012 17:46
ElementTree error with 'real' utf8 file
#!/usr/bin/env node
var et = require('elementtree');
var fs = require('fs');
var docStr = fs.readFileSync('test1.xml','utf8');
var projDoc = new et.ElementTree(et.XML(docStr));
console.log("projDoc.getroot = " + projDoc.getroot());
@purplecabbage
purplecabbage / hello-world.js
Created May 29, 2012 19:23 — forked from purdrew/helloCordova.html
Hello World Cordova
(function(win, doc){
var onDeviceReady = function() {
console.log('Cordova initialized');
doc.getElementById('infoTag').innerHTML = 'Hello world from Cordova ' + device.cordova;
}
doc.addEventListener('deviceready', onDeviceReady, true);
})(window,document);
@purplecabbage
purplecabbage / regCommandProxy.js
Created February 23, 2012 08:09
Registers a command proxy for platforms that don't require a full native implementation.
Cordova.commandProxies = {};
Cordova.regCommandProxy = function(service,action,funk)
{
Cordova.commandProxies[service + action] = funk;
};
// possibly an un-reg as well ...
document.getElementById("container").innerHTML="";
var con = document.getElementById("container");
var ul = "<ul>";
var i;
for (i = 0; i < 100; i++) {
var li = "<li>hello world NoFramework</li>";
ul += li;
}
ul += "</ul>";