Skip to content

Instantly share code, notes, and snippets.

View RhinoLance's full-sized avatar

Lance Conry RhinoLance

View GitHub Profile
@RhinoLance
RhinoLance / gist:6590770
Created September 17, 2013 06:38
DeviceReady call for Cordova / Phonegap
$(document).ready(function () {
if (document.URL.indexOf('http://') === -1 && document.URL.indexOf('https://') === -1) {
document.addEventListener("deviceready", OnLoad, true);
}
else {
OnLoad();
}
});
@RhinoLance
RhinoLance / gist:7555760
Last active December 28, 2015 20:09
Helping et4891 on IRC#phonegap
NOTE: I added these too
in config.xml
<plugin name="Camera" value="org.apache.cordova.CameraLauncher" />
in AndroidManifest
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
@RhinoLance
RhinoLance / Gruntfile.js
Created December 3, 2013 22:12
Gruntfile for automated Cordova builds.
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner: '/*! <%= pkg.name || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
@RhinoLance
RhinoLance / build
Created December 3, 2013 22:43
Modified cordova ios build for deployment
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
@RhinoLance
RhinoLance / gist:7935597
Created December 12, 2013 21:15
Using angular to query detail from list
<!--detail popup-->
<div class="popupContainer" ng-show="detailVisible">
<div class="pop-dialog full detailPopup" ng-show="detailVisible">
<div class="body">
<div class="close-icon" ng-click="detailVisible = false"><i class="icon-remove-sign"></i></div>
<h3>{{activeInspection.ModuleName | lineToSpace}}</h3>
<h5>{{activeInspection.Class | lineToSpace}}</h5>
<div class="settings">
<div class="items">
<table>
@RhinoLance
RhinoLance / gist:9059555
Last active August 29, 2015 13:56
Cordova notification wrappers
if (typeof navigator.notification === 'undefined') {
navigator.notification = {
confirm: function (message, confirmCallback, title, buttonLabels) {
setTimeout(function (){
if (window.confirm(message)) {
confirmCallback(1);
}
else {
confirmCallback(2);
@RhinoLance
RhinoLance / gist:9333441
Created March 3, 2014 20:03
Save and move images taken with Cordova camera plugin.
ModFormCommon.PhotoSuccess = function (imageURI) {
var fsSuccess = function (fileEntry) {
//alert("got image file entry: " + fileEntry.fullPath);
var gotFileSystem = function (fileSystem) {
fileSystem.root.getDirectory(
ModPhoto.FileStore,
{ create: true },
@RhinoLance
RhinoLance / gist:9497816
Created March 12, 2014 00:07
Local caching
_loadTile: function (tile, tilePoint) {
//try{
var that = this;
tile._layer = this;
tile.onload = this._tileOnLoad;
tile.onerror = this._tileOnError;
tilePoint.z = this._getZoomForUrl();
//This doesn't work. The test can't find the service
angular.module('RhinoLib').service('sqLite', function( $q ) {
this.initPromise = null;
this.oDb = null;
}
//This works perfectly. I just renoved the $q parameter for the service
angular.module('RhinoLib').service('sqLite', function() {
@RhinoLance
RhinoLance / fileCatcher.js
Created April 24, 2014 07:16
node.js file upload trouble
var http = require('http');
var fs = require('fs');
http.createServer(function(request,response){
response.writeHead(200);
var destinationFile = fs.createWriteStream(fileName);
request.pipe(destinationFile);
var fileSize = request.headers['content-length'];