Skip to content

Instantly share code, notes, and snippets.

@smebberson
Created April 18, 2016 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smebberson/9992be02afc4e230847bc34028b454ee to your computer and use it in GitHub Desktop.
Save smebberson/9992be02afc4e230847bc34028b454ee to your computer and use it in GitHub Desktop.
phonegap
<!DOCTYPE html>
<!--
Copyright (c) 2012-2016 Adobe Systems Incorporated. All rights reserved.
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
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html data-ng-app="appMobile" data-ng-controller="AppCtrl">
<head>
<meta charset="utf-8" />
<title>app</title>
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
<!-- This is a wide open CSP declaration. To lock this down for production, see below. -->
<!-- <meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *" /> -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self' * 'unsafe-inline'; media-src * 'unsafe-inline'" />
<!-- Good default declaration:
* gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
* https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
* Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
* Enable inline JS: add 'unsafe-inline' to default-src
* Enable eval(): add 'unsafe-eval' to default-src
* Create your own at http://cspisawesome.com
-->
<!-- <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: 'unsafe-inline' https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *" /> -->
<link rel="stylesheet" type="text/css" href="css/index.css" />
<link rel="stylesheet" type="text/css" href="css/vendor/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/vendor/bootstrap-slider.css">
<link rel="stylesheet" type="text/css" href="css/vendor/select.css">
<link rel="stylesheet" type="text/css" href="fonts/black-tie/css/black-tie.min.css">
<link rel="stylesheet" type="text/css" href="css/vendor/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
<body data-ng-controller="BodyCtrl" class="latest">
...
<div class="application">
<div data-ui-view></div>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
</script>
<!-- for debugging -->
<script src="http://weinre.mobile.app.ngrok.io/target/target-script-min.js#anonymous"></script>
<!-- load in the remaining libraries as per normal -->
<script src="js/vendor/jquery-2.2.3.min.js"></script>
<script src="js/vendor/shim.find-index.js"></script>
<script src="js/vendor/howler.min.js"></script>
<script src="js/vendor/angular.min.js"></script>
<script src="js/vendor/angular-route.min.js"></script>
<script src="js/vendor/angular-sanitize.min.js"></script>
<script src="js/vendor/angular-ui-router.min.js"></script>
<script src="js/vendor/bootstrap.min.js"></script>
<script src="js/vendor/bootstrap-slider.js"></script>
<script src="js/vendor/bootstrap-angular-ui.custom.tpls.min.js"></script>
<script src="js/vendor/moment-with-langs.min.js"></script>
<script src="js/vendor/moment-timezone.min.js"></script>
<script src="js/vendor/moment-timezone-data.js"></script>
<script src="js/vendor/jstz.min.js"></script>
<script src="js/vendor/chroma.min.js"></script>
<script src="js/vendor/semver.min.js"></script>
<script src="js/vendor/keyCatch.js"></script>
<script src="js/preferences.js"></script>
<script src="js/timer.js"></script>
<script src="js/logger.js"></script>
<script src="js/angular-preferences.js"></script>
<script src="app/app-combined.js"></script>
<script type="text/javascript">
//
// Reload the app if server detects local change
//
(function() {
var url = 'http://' + document.location.host + '/__api__/autoreload';
function postStatus() {
var xhr = new XMLHttpRequest();
xhr.open('post', url, true);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.onreadystatechange = function() {
if (this.readyState === 4 && /^[2]/.test(this.status)) {
}
}
xhr.send();
}
function checkForReload() {
var xhr = new XMLHttpRequest();
xhr.open('get', url, true);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.onreadystatechange = function() {
if (this.readyState === 4 && /^[2]/.test(this.status)) {
var response = JSON.parse(this.responseText);
if (response.content.outdated) {
postStatus();
window.location.reload();
}
}
}
xhr.send();
}
setInterval(checkForReload, 1000 * 3);
})(window);
</script>
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script type="text/javascript">
(function(window) {
var socket = io('http://' + document.location.host);
var previousConsole = window.console || {};
window.console = {
log:function(msg){
previousConsole.log && previousConsole.log(msg);
socket.emit('console','log', msg);
},
warn:function(msg){
previousConsole.warn && previousConsole.warn(msg);
socket.emit('console','warn', msg);
},
error:function(msg){
previousConsole.error && previousConsole.error(msg);
socket.emit('console','error', msg);
},
assert:function(assertion, msg){
previousConsole.assert && previousConsole.assert(assertion, msg);
if(assertion){
socket.emit('console','assert', msg);
}
}
}
})(window);
</script>
<script type="text/javascript">
//
// Go to app's homepage on a three-finger tap.
//
(function() {
var currentTouches = {},
eventName = { touchstart: 'touchstart', touchend: 'touchend' };
if (window.navigator.msPointerEnabled) {
eventName = { touchstart: 'MSPointerDown', touchend: 'MSPointerUp' };
}
document.addEventListener(eventName.touchstart, function(evt) {
var touches = evt.touches || [evt],
touch;
for(var i = 0, l = touches.length; i < l; i++) {
touch = touches[i];
currentTouches[touch.identifier || touch.pointerId] = touch;
}
}, false);
document.addEventListener(eventName.touchend, function(evt) {
var touchCount = Object.keys(currentTouches).length;
currentTouches = {};
if (touchCount === 3) {
evt.preventDefault();
window.history.back(window.history.length);
}
}, false);
})(window);
</script>
<script type="text/javascript">
//
// Proxy
///
// Intercept XHR calls that would violate single-origin policy.
// These requests will be proxied through the server.
//
(function() {
var xhr = {};
xhr.open = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function(method, url) {
var parser = document.createElement('a');
parser.href = url;
// WP8 does not set hostname on some XHRs
if (!parser.hostname) {
parser.hostname = window.location.hostname;
}
// proxy the cross-origin request
if (!parser.hostname.match(window.location.hostname)) {
url = '/proxy/' + encodeURIComponent(url);
}
xhr.open.apply(this, arguments);
};
})(window);
</script>
<script type="text/javascript">
//
// Refresh the app on a four-finger tap.
//
(function() {
var currentTouches = {},
eventName = { touchstart: 'touchstart', touchend: 'touchend' };
if (window.navigator.msPointerEnabled) {
eventName = { touchstart: 'MSPointerDown', touchend: 'MSPointerUp' };
}
document.addEventListener(eventName.touchstart, function(evt) {
var touches = evt.touches || [evt],
touch;
for(var i = 0, l = touches.length; i < l; i++) {
touch = touches[i];
currentTouches[touch.identifier || touch.pointerId] = touch;
}
});
document.addEventListener(eventName.touchend, function(evt) {
var touchCount = Object.keys(currentTouches).length;
currentTouches = {};
if (touchCount === 4) {
evt.preventDefault();
window.location.reload(true);
}
}, false);
})(window);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment