Skip to content

Commit 37b873b

Browse files
committed
fix readfile on android
1 parent c6b7822 commit 37b873b

3 files changed

Lines changed: 10 additions & 14 deletions

File tree

OpenFlow/src/public/CommonControllers.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ module openflow {
3232
this.gettoken();
3333
// cleanup();
3434
});
35-
// var cleanup2 = this.$rootScope.$on('cordovadetected', (event, data) => {
36-
// if (event && data) { }
37-
// console.log("cordovadetected, reload token");
38-
// this.gettoken();
39-
// cleanup2();
40-
// });
4135
['log', 'warn', 'debug', 'error'].forEach((methodName) => {
4236
//['error2'].forEach((methodName) => {
4337
const originalMethod = console[methodName];
@@ -325,12 +319,12 @@ module openflow {
325319
}
326320
export class JSONfn {
327321
public static stringify(obj) {
328-
return JSON.stringify(obj, function (key, value) {
322+
return JSON.stringify(obj, function(key, value) {
329323
return (typeof value === 'function') ? value.toString() : value;
330324
});
331325
}
332326
public static parse(str) {
333-
return JSON.parse(str, function (key, value) {
327+
return JSON.parse(str, function(key, value) {
334328
if (typeof value != 'string') return value;
335329
return (value.substring(0, 8) == 'function') ? eval('(' + value + ')') : value;
336330
});
@@ -383,7 +377,7 @@ module openflow {
383377
return new Promise((resolve) => {
384378
try {
385379
if (locale === null || locale === undefined) { return resolve(); }
386-
locale.ready(lib).then(function () {
380+
locale.ready(lib).then(function() {
387381
var value = locale.getString(lib + "." + key);
388382
if (value !== null && value !== undefined && value !== "") {
389383
resolve(value);
@@ -425,15 +419,15 @@ module openflow {
425419
this.locale.ready(lib).then(() => {
426420
var value: string = null;
427421
if (ngModelCtrl !== null) {
428-
ngModelCtrl.$formatters.push(function (value) {
422+
ngModelCtrl.$formatters.push(function(value) {
429423
return calculateValue(value);
430424
});
431425
// value = calculateValue(ngModelCtrl.$viewValue);
432426
// ngModelCtrl.$setViewValue(this.result);
433427
// ngModelCtrl.$render();
434428
} else {
435429
var hashCode = (s: string) => {
436-
return s.split("").reduce(function (a, b) { a = ((a << 5) - a) + b.charCodeAt(0); return a & a }, 0);
430+
return s.split("").reduce(function(a, b) { a = ((a << 5) - a) + b.charCodeAt(0); return a & a }, 0);
437431
}
438432
var watchFunction = () => {
439433
if (attr.value !== null && attr.value !== undefined) {
@@ -542,7 +536,7 @@ module openflow {
542536
async DeleteOne(model: any): Promise<any> {
543537
this.loading = true;
544538
await this.api.Delete(this.collection, model);
545-
this.models = this.models.filter(function (m: any): boolean { return m._id !== model._id; });
539+
this.models = this.models.filter(function(m: any): boolean { return m._id !== model._id; });
546540
this.loading = false;
547541
if (!this.$scope.$$phase) { this.$scope.$apply(); }
548542
}

OpenFlow/src/public/WebSocketClient.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ module openflow {
3737
public jwt: string = null;
3838
public device: any = null;
3939
public usingCordova: boolean = false;
40+
public plugins: any = null;
4041
public scanCount: number = 0;
4142
public oneSignalId: string = null;
4243
public location: any;
@@ -45,7 +46,7 @@ module openflow {
4546
constructor(public $rootScope: ng.IRootScopeService, public $location, public $window: any) {
4647
try {
4748
var path = this.$location.absUrl().split('#')[0];
48-
this.usingCordova = (path.indexOf("/android/") > -1 || path.indexOf("/ios/") > -1);
49+
// this.usingCordova = (path.indexOf("/android/") > -1 || path.indexOf("/ios/") > -1);
4950
} catch (error) {
5051
}
5152
this.init();
@@ -158,6 +159,7 @@ module openflow {
158159
document.addEventListener("deviceready", async () => {
159160
console.log("deviceready");
160161
if ((window as any).plugins) {
162+
this.plugins = (window as any).plugins;
161163
var oneSignal = (window as any).plugins.OneSignal;
162164
if (oneSignal) {
163165
try {

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.280
1+
0.0.281

0 commit comments

Comments
 (0)