Skip to content

Instantly share code, notes, and snippets.

@DrMabuse23
Created May 29, 2014 22:15
Show Gist options
  • Save DrMabuse23/a711ede7012f74649d4f to your computer and use it in GitHub Desktop.
Save DrMabuse23/a711ede7012f74649d4f to your computer and use it in GitHub Desktop.
'use strict';
angular.module('app')
.controller('FilemanagerCtrl', function ($scope) {
var rootPath = null;
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail);
function onFileSystemSuccess(fileSystem) {
console.log('fileSystem.name : '+ fileSystem.name);
console.log('fileSystem.root.name : '+ fileSystem.root.name);
console.log('fullPath',fileSystem.root.fullPath);
rootPath = fileSystem.root.fullPath;
function success(entries) {
for (var i = 0; i < entries.length; i++) {
console.log(entries[i].name);
}
}
// Get a directory reader
var directoryReader = fileSystem.root.createReader();
// Get a list of all the entries in the directory
directoryReader.readEntries(success, fail);
}
function fail(error) {
alert("Failed to list directory contents: " + error.code);
}
});
'use strict';
/**
* check is online
*/
function onNetworkOnline(){
console.log('I am online');
}
/**
* check is offline
*/
function onNetworkOffline(){
console.log('I am offline');
}
/**
* check device is ready
*/
function onDeviceReady() {
conzole.open();
document.addEventListener("online", onNetworkOnline, false);
document.addEventListener("offline", onNetworkOffline, false);
if (parseFloat(window.device.version) >= 7) {
angular.bootstrap(document, ['app']);
console.log('device is ready angular is bootstrapped');
}else{
alert('Your ios is outdated plz upgrade to >=7');
}
checkConnection();
debugOptions();
}
/**
* check the connection
*/
function checkConnection() {
var networkState = navigator.connection.type;
var states = {};
states[Connection.UNKNOWN] = 'Unknown connection';
states[Connection.ETHERNET] = 'Ethernet connection';
states[Connection.WIFI] = 'WiFi connection';
states[Connection.CELL_2G] = 'Cell 2G connection';
states[Connection.CELL_3G] = 'Cell 3G connection';
states[Connection.CELL_4G] = 'Cell 4G connection';
states[Connection.CELL] = 'Cell generic connection';
states[Connection.NONE] = 'No network connection';
console.log('Connection type: ' + states[networkState]);
}
function debugOptions(){
console.log('Device Name: ' + device.name);
console.log('Device Cordova: ' + device.cordova);
console.log('Device Platform: ' + device.platform);
console.log('Device UUID: ' + device.uuid);
console.log('Device Model: ' + device.model);
console.log('Device Version: ' + device.version);
}
/**
* add deviceReady Listener
*/
document.addEventListener('deviceready', onDeviceReady, false);
//angular.element(document).ready(function() {
// angular.bootstrap(document, ['app']);
//});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment