new version
This commit is contained in:
parent
7ff899a7fd
commit
a032d1eded
0
dist/.gitkeep
vendored
Normal file
0
dist/.gitkeep
vendored
Normal file
11
dist/asset-manifest.json
vendored
Normal file
11
dist/asset-manifest.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"files": {
|
||||
"main.css": ".css/main.570157dd.css",
|
||||
"main.js": ".index.bundle.js",
|
||||
"index.html": ".index.html"
|
||||
},
|
||||
"entrypoints": [
|
||||
"css/main.570157dd.css",
|
||||
"index.bundle.js"
|
||||
]
|
||||
}
|
||||
18
dist/config.xml
vendored
Normal file
18
dist/config.xml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
|
||||
<name>HelloCordova</name>
|
||||
<description>
|
||||
A sample Apache Cordova application that responds to the deviceready event.
|
||||
</description>
|
||||
<author email="dev@cordova.apache.org" href="http://cordova.io">
|
||||
Apache Cordova Team
|
||||
</author>
|
||||
<content src="index.html" />
|
||||
<access origin="*" />
|
||||
<allow-intent href="http://*/*" />
|
||||
<allow-intent href="https://*/*" />
|
||||
<allow-intent href="tel:*" />
|
||||
<allow-intent href="sms:*" />
|
||||
<allow-intent href="mailto:*" />
|
||||
<allow-intent href="geo:*" />
|
||||
</widget>
|
||||
90
dist/cordova-js-src/confighelper.js
vendored
Normal file
90
dist/cordova-js-src/confighelper.js
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var config;
|
||||
|
||||
function Config(xhr) {
|
||||
function loadPreferences(xhr) {
|
||||
var parser = new DOMParser();
|
||||
var doc = parser.parseFromString(xhr.responseText, "application/xml");
|
||||
|
||||
var preferences = doc.getElementsByTagName("preference");
|
||||
return Array.prototype.slice.call(preferences);
|
||||
}
|
||||
|
||||
this.xhr = xhr;
|
||||
this.preferences = loadPreferences(this.xhr);
|
||||
}
|
||||
|
||||
function readConfig(success, error) {
|
||||
var xhr;
|
||||
|
||||
if(typeof config != 'undefined') {
|
||||
success(config);
|
||||
}
|
||||
|
||||
function fail(msg) {
|
||||
console.error(msg);
|
||||
|
||||
if(error) {
|
||||
error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
var xhrStatusChangeHandler = function() {
|
||||
if (xhr.readyState == 4) {
|
||||
if (xhr.status == 200 || xhr.status == 304 || xhr.status === 0 /* file:// */) {
|
||||
config = new Config(xhr);
|
||||
success(config);
|
||||
}
|
||||
else {
|
||||
fail('[Browser][cordova.js][xhrStatusChangeHandler] Could not XHR config.xml: ' + xhr.statusText);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
xhr = new XMLHttpRequest();
|
||||
xhr.addEventListener("load", xhrStatusChangeHandler);
|
||||
|
||||
|
||||
try {
|
||||
xhr.open("get", "config.xml", true);
|
||||
xhr.send();
|
||||
} catch(e) {
|
||||
fail('[Browser][cordova.js][readConfig] Could not XHR config.xml: ' + JSON.stringify(e));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a preference value from config.xml.
|
||||
* Returns preference value or undefined if it does not exist.
|
||||
* @param {String} preferenceName Preference name to read */
|
||||
Config.prototype.getPreferenceValue = function getPreferenceValue(preferenceName) {
|
||||
var preferenceItem = this.preferences && this.preferences.filter(function(item) {
|
||||
return item.attributes.name && item.attributes.name.value === preferenceName;
|
||||
});
|
||||
|
||||
if(preferenceItem && preferenceItem[0] && preferenceItem[0].attributes && preferenceItem[0].attributes.value) {
|
||||
return preferenceItem[0].attributes.value.value;
|
||||
}
|
||||
};
|
||||
|
||||
exports.readConfig = readConfig;
|
||||
114
dist/cordova-js-src/exec.js
vendored
Normal file
114
dist/cordova-js-src/exec.js
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*jslint sloppy:true, plusplus:true*/
|
||||
/*global require, module, console */
|
||||
|
||||
var cordova = require('cordova');
|
||||
var execProxy = require('cordova/exec/proxy');
|
||||
|
||||
/**
|
||||
* Execute a cordova command. It is up to the native side whether this action
|
||||
* is synchronous or asynchronous. The native side can return:
|
||||
* Synchronous: PluginResult object as a JSON string
|
||||
* Asynchronous: Empty string ""
|
||||
* If async, the native side will cordova.callbackSuccess or cordova.callbackError,
|
||||
* depending upon the result of the action.
|
||||
*
|
||||
* @param {Function} success The success callback
|
||||
* @param {Function} fail The fail callback
|
||||
* @param {String} service The name of the service to use
|
||||
* @param {String} action Action to be run in cordova
|
||||
* @param {String[]} [args] Zero or more arguments to pass to the method
|
||||
*/
|
||||
module.exports = function (success, fail, service, action, args) {
|
||||
|
||||
var proxy = execProxy.get(service, action);
|
||||
|
||||
args = args || [];
|
||||
|
||||
if (proxy) {
|
||||
|
||||
var callbackId = service + cordova.callbackId++;
|
||||
|
||||
if (typeof success === "function" || typeof fail === "function") {
|
||||
cordova.callbacks[callbackId] = {success: success, fail: fail};
|
||||
}
|
||||
try {
|
||||
|
||||
|
||||
|
||||
// callbackOptions param represents additional optional parameters command could pass back, like keepCallback or
|
||||
// custom callbackId, for example {callbackId: id, keepCallback: true, status: cordova.callbackStatus.JSON_EXCEPTION }
|
||||
var onSuccess = function (result, callbackOptions) {
|
||||
callbackOptions = callbackOptions || {};
|
||||
var callbackStatus;
|
||||
// covering both undefined and null.
|
||||
// strict null comparison was causing callbackStatus to be undefined
|
||||
// and then no callback was called because of the check in cordova.callbackFromNative
|
||||
// see CB-8996 Mobilespec app hang on windows
|
||||
if (callbackOptions.status !== undefined && callbackOptions.status !== null) {
|
||||
callbackStatus = callbackOptions.status;
|
||||
}
|
||||
else {
|
||||
callbackStatus = cordova.callbackStatus.OK;
|
||||
}
|
||||
cordova.callbackSuccess(callbackOptions.callbackId || callbackId,
|
||||
{
|
||||
status: callbackStatus,
|
||||
message: result,
|
||||
keepCallback: callbackOptions.keepCallback || false
|
||||
});
|
||||
};
|
||||
var onError = function (err, callbackOptions) {
|
||||
callbackOptions = callbackOptions || {};
|
||||
var callbackStatus;
|
||||
// covering both undefined and null.
|
||||
// strict null comparison was causing callbackStatus to be undefined
|
||||
// and then no callback was called because of the check in cordova.callbackFromNative
|
||||
// note: status can be 0
|
||||
if (callbackOptions.status !== undefined && callbackOptions.status !== null) {
|
||||
callbackStatus = callbackOptions.status;
|
||||
}
|
||||
else {
|
||||
callbackStatus = cordova.callbackStatus.OK;
|
||||
}
|
||||
cordova.callbackError(callbackOptions.callbackId || callbackId,
|
||||
{
|
||||
status: callbackStatus,
|
||||
message: err,
|
||||
keepCallback: callbackOptions.keepCallback || false
|
||||
});
|
||||
};
|
||||
proxy(onSuccess, onError, args);
|
||||
|
||||
} catch (e) {
|
||||
console.log("Exception calling native with command :: " + service + " :: " + action + " ::exception=" + e);
|
||||
}
|
||||
} else {
|
||||
|
||||
console.log("Error: exec proxy not found for :: " + service + " :: " + action);
|
||||
|
||||
if(typeof fail === "function" ) {
|
||||
fail("Missing Command Error");
|
||||
}
|
||||
}
|
||||
};
|
||||
46
dist/cordova-js-src/platform.js
vendored
Normal file
46
dist/cordova-js-src/platform.js
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
id: 'browser',
|
||||
cordovaVersion: '4.2.0', // cordova-js
|
||||
|
||||
bootstrap: function() {
|
||||
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
var channel = require('cordova/channel');
|
||||
|
||||
modulemapper.clobbers('cordova/exec/proxy', 'cordova.commandProxy');
|
||||
|
||||
channel.onNativeReady.fire();
|
||||
|
||||
document.addEventListener("visibilitychange", function(){
|
||||
if(document.hidden) {
|
||||
channel.onPause.fire();
|
||||
}
|
||||
else {
|
||||
channel.onResume.fire();
|
||||
}
|
||||
});
|
||||
|
||||
// End of bootstrap
|
||||
}
|
||||
};
|
||||
1594
dist/cordova.js
vendored
Normal file
1594
dist/cordova.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
30
dist/cordova_plugins.js
vendored
Normal file
30
dist/cordova_plugins.js
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
cordova.define('cordova/plugin_list', function(require, exports, module) {
|
||||
module.exports = [
|
||||
{
|
||||
"file": "plugins/cordova-plugin-nativestorage/www/mainHandle.js",
|
||||
"id": "cordova-plugin-nativestorage.mainHandle",
|
||||
"pluginId": "cordova-plugin-nativestorage",
|
||||
"clobbers": [
|
||||
"NativeStorage"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-nativestorage/www/LocalStorageHandle.js",
|
||||
"id": "cordova-plugin-nativestorage.LocalStorageHandle",
|
||||
"pluginId": "cordova-plugin-nativestorage"
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-nativestorage/www/NativeStorageError.js",
|
||||
"id": "cordova-plugin-nativestorage.NativeStorageError",
|
||||
"pluginId": "cordova-plugin-nativestorage"
|
||||
}
|
||||
];
|
||||
module.exports.metadata =
|
||||
// TOP OF METADATA
|
||||
{
|
||||
"cordova-plugin-whitelist": "1.3.5",
|
||||
"cordova-plugin-webpack": "1.0.5",
|
||||
"cordova-plugin-nativestorage": "2.3.2"
|
||||
}
|
||||
// BOTTOM OF METADATA
|
||||
});
|
||||
BIN
dist/favicon.ico
vendored
Normal file
BIN
dist/favicon.ico
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
100439
dist/index.bundle.js
vendored
Normal file
100439
dist/index.bundle.js
vendored
Normal file
File diff suppressed because one or more lines are too long
15
dist/index.html
vendored
Normal file
15
dist/index.html
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<!doctype html>
|
||||
<html lang="en" dir="ltr">
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
|
||||
<meta http-equiv="refresh" content="0;URL=http://localhost:8080/">
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
11
dist/manifest.json
vendored
Normal file
11
dist/manifest.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"background_color": "#FFF",
|
||||
"display": "standalone",
|
||||
"name": "HelloCordova",
|
||||
"short_name": "HelloCordova",
|
||||
"version": "io.cordova.hellocordova",
|
||||
"description": "A sample Apache Cordova application that responds to the deviceready event.",
|
||||
"author": "Apache Cordova Team",
|
||||
"icons": [],
|
||||
"start_url": "index.html"
|
||||
}
|
||||
44
dist/plugins/cordova-plugin-nativestorage/www/LocalStorageHandle.js
vendored
Normal file
44
dist/plugins/cordova-plugin-nativestorage/www/LocalStorageHandle.js
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
cordova.define("cordova-plugin-nativestorage.LocalStorageHandle", function(require, exports, module) { var NativeStorageError = require('./NativeStorageError');
|
||||
|
||||
// args = [reference, variable]
|
||||
function LocalStorageHandle(success, error, intent, operation, args) {
|
||||
var reference = args[0];
|
||||
var variable = args[1];
|
||||
|
||||
if (operation.startsWith('put') || operation.startsWith('set')) {
|
||||
try {
|
||||
var varAsString = JSON.stringify(variable);
|
||||
if (reference === null) {
|
||||
error(NativeStorageError.NULL_REFERENCE);
|
||||
return;
|
||||
}
|
||||
localStorage.setItem(reference, varAsString);
|
||||
success(variable);
|
||||
} catch (err) {
|
||||
error(NativeStorageError.JSON_ERROR);
|
||||
}
|
||||
} else if (operation.startsWith('get')) {
|
||||
var item = {};
|
||||
item = localStorage.getItem(reference);
|
||||
if (item === null) {
|
||||
error(NativeStorageError.ITEM_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var obj = JSON.parse(item);
|
||||
//console.log("LocalStorage Reading: "+obj);
|
||||
success(obj);
|
||||
} catch (err) {
|
||||
error(NativeStorageError.JSON_ERROR);
|
||||
}
|
||||
} else if (operation === 'keys') {
|
||||
var keys = [];
|
||||
for(var i = 0; i < localStorage.length; i++){
|
||||
keys.push(localStorage.key(i));
|
||||
}
|
||||
success(keys);
|
||||
}
|
||||
}
|
||||
module.exports = LocalStorageHandle;
|
||||
|
||||
});
|
||||
25
dist/plugins/cordova-plugin-nativestorage/www/NativeStorageError.js
vendored
Normal file
25
dist/plugins/cordova-plugin-nativestorage/www/NativeStorageError.js
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
cordova.define("cordova-plugin-nativestorage.NativeStorageError", function(require, exports, module) { /**
|
||||
* NativeStorageError
|
||||
* @constructor
|
||||
*/
|
||||
var NativeStorageError = function(code, source, exception) {
|
||||
this.code = code || null;
|
||||
this.source = source || null;
|
||||
this.exception = exception || null;
|
||||
};
|
||||
|
||||
// Make NativeStorageError a real Error, you can test with `instanceof Error`
|
||||
NativeStorageError.prototype = Object.create(Error.prototype, {
|
||||
constructor: { value: NativeStorageError }
|
||||
});
|
||||
|
||||
NativeStorageError.NATIVE_WRITE_FAILED = 1;
|
||||
NativeStorageError.ITEM_NOT_FOUND = 2;
|
||||
NativeStorageError.NULL_REFERENCE = 3;
|
||||
NativeStorageError.UNDEFINED_TYPE = 4;
|
||||
NativeStorageError.JSON_ERROR = 5;
|
||||
NativeStorageError.WRONG_PARAMETER = 6;
|
||||
|
||||
module.exports = NativeStorageError;
|
||||
|
||||
});
|
||||
519
dist/plugins/cordova-plugin-nativestorage/www/mainHandle.js
vendored
Normal file
519
dist/plugins/cordova-plugin-nativestorage/www/mainHandle.js
vendored
Normal file
@ -0,0 +1,519 @@
|
||||
cordova.define("cordova-plugin-nativestorage.mainHandle", function(require, exports, module) { var inBrowser = false;
|
||||
var NativeStorageError = require('./NativeStorageError');
|
||||
|
||||
|
||||
function isInBrowser() {
|
||||
inBrowser = (window.cordova && (window.cordova.platformId === 'browser' || window.cordova.platformId === 'osx')) || !(window.phonegap || window.cordova);
|
||||
return inBrowser;
|
||||
}
|
||||
|
||||
function storageSupportAnalyse() {
|
||||
if (!isInBrowser()) {
|
||||
return 0;
|
||||
//storageHandlerDelegate = exec;
|
||||
} else {
|
||||
if (window.localStorage) {
|
||||
return 1;
|
||||
//storageHandlerDelegate = localStorageHandle;
|
||||
} else {
|
||||
return 2;
|
||||
//console.log("ALERT! localstorage isn't supported");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if storage not available gracefully fails, no error message for now
|
||||
function StorageHandle() {
|
||||
this.storageSupport = storageSupportAnalyse();
|
||||
switch (this.storageSupport) {
|
||||
case 0:
|
||||
var exec = require('cordova/exec');
|
||||
this.storageHandlerDelegate = exec;
|
||||
break;
|
||||
case 1:
|
||||
var localStorageHandle = require('./LocalStorageHandle');
|
||||
this.storageHandlerDelegate = localStorageHandle;
|
||||
break;
|
||||
case 2:
|
||||
console.log("ALERT! localstorage isn't supported");
|
||||
break;
|
||||
default:
|
||||
console.log("StorageSupport Error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
StorageHandle.prototype.initWithSuiteName = function(suiteName, success, error) {
|
||||
if (suiteName === null) {
|
||||
error("Null suiteName isn't supported");
|
||||
return;
|
||||
}
|
||||
this.storageHandlerDelegate(success, error, "NativeStorage", "initWithSuiteName", [suiteName]);
|
||||
};
|
||||
|
||||
StorageHandle.prototype.set = function(reference, value, success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
if (reference === null) {
|
||||
error("The reference can't be null");
|
||||
return;
|
||||
}
|
||||
if (value === null) {
|
||||
error("a Null value isn't supported");
|
||||
return;
|
||||
}
|
||||
switch (typeof value) {
|
||||
case 'undefined':
|
||||
error("an undefined type isn't supported");
|
||||
break;
|
||||
case 'boolean': {
|
||||
this.putBoolean(reference, value, success, error);
|
||||
break;
|
||||
}
|
||||
case 'number': {
|
||||
// Good now check if it's a float or an int
|
||||
if (value === +value) {
|
||||
if (value === (value | 0)) {
|
||||
// it's an int
|
||||
this.putInt(reference, value, success, error);
|
||||
} else if (value !== (value | 0)) {
|
||||
this.putDouble(reference, value, success, error);
|
||||
}
|
||||
} else {
|
||||
error("The value doesn't seem to be a number");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'string': {
|
||||
this.putString(reference, value, success, error);
|
||||
break;
|
||||
}
|
||||
case 'object': {
|
||||
this.putObject(reference, value, success, error);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
error("The type isn't supported or isn't been recognized");
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
/* removing */
|
||||
StorageHandle.prototype.remove = function(reference, success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
if (reference === null) {
|
||||
error("Null reference isn't supported");
|
||||
return;
|
||||
}
|
||||
|
||||
if (inBrowser) {
|
||||
try {
|
||||
localStorage.removeItem(reference);
|
||||
success();
|
||||
} catch (e) {
|
||||
error(e);
|
||||
}
|
||||
} else {
|
||||
this.storageHandlerDelegate(success, error, "NativeStorage", "remove", [reference]);
|
||||
}
|
||||
};
|
||||
|
||||
/* clearing */
|
||||
StorageHandle.prototype.clear = function(success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
if (inBrowser) {
|
||||
try {
|
||||
localStorage.clear();
|
||||
success();
|
||||
} catch (e) {
|
||||
error(e);
|
||||
}
|
||||
} else {
|
||||
this.storageHandlerDelegate(success, error, "NativeStorage", "clear", []);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* boolean storage */
|
||||
StorageHandle.prototype.putBoolean = function(reference, aBoolean, success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
if (reference === null) {
|
||||
error("Null reference isn't supported");
|
||||
return;
|
||||
}
|
||||
|
||||
if (aBoolean === null) {
|
||||
error("a Null value isn't supported");
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof aBoolean === 'boolean') {
|
||||
this.storageHandlerDelegate(function(returnedBool) {
|
||||
if ('string' === typeof returnedBool) {
|
||||
if ( (returnedBool === 'true') ) {
|
||||
success(true);
|
||||
} else if ( (returnedBool === 'false') ) {
|
||||
success(false);
|
||||
} else {
|
||||
error("The returned boolean from SharedPreferences was not recognized: " + returnedBool);
|
||||
}
|
||||
} else {
|
||||
success(returnedBool);
|
||||
}
|
||||
}, error, "NativeStorage", "putBoolean", [reference, aBoolean]);
|
||||
} else {
|
||||
error("Only boolean types are supported");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
StorageHandle.prototype.getBoolean = function(reference, success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
if (reference === null) {
|
||||
error("Null reference isn't supported");
|
||||
return;
|
||||
}
|
||||
this.storageHandlerDelegate(function(returnedBool) {
|
||||
if ('string' === typeof returnedBool) {
|
||||
if ( (returnedBool === 'true') ) {
|
||||
success(true);
|
||||
} else if ( (returnedBool === 'false') ) {
|
||||
success(false);
|
||||
} else {
|
||||
error("The returned boolean from SharedPreferences was not recognized: " + returnedBool);
|
||||
}
|
||||
} else {
|
||||
success(returnedBool);
|
||||
}
|
||||
}, error, "NativeStorage", "getBoolean", [reference]);
|
||||
};
|
||||
|
||||
/* int storage */
|
||||
StorageHandle.prototype.putInt = function(reference, anInt, success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
if (reference === null) {
|
||||
error("Null reference isn't supported");
|
||||
return;
|
||||
}
|
||||
this.storageHandlerDelegate(success, error, "NativeStorage", "putInt", [reference, anInt]);
|
||||
};
|
||||
|
||||
StorageHandle.prototype.getInt = function(reference, success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
if (reference === null) {
|
||||
error("Null reference isn't supported");
|
||||
return;
|
||||
}
|
||||
this.storageHandlerDelegate(success, error, "NativeStorage", "getInt", [reference]);
|
||||
};
|
||||
|
||||
|
||||
/* float storage */
|
||||
StorageHandle.prototype.putDouble = function(reference, aFloat, success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
if (reference === null) {
|
||||
error("Null reference isn't supported");
|
||||
return;
|
||||
}
|
||||
this.storageHandlerDelegate(success, error, "NativeStorage", "putDouble", [reference, aFloat]);
|
||||
};
|
||||
|
||||
StorageHandle.prototype.getDouble = function(reference, success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
if (reference === null) {
|
||||
error("Null reference isn't supported");
|
||||
return;
|
||||
}
|
||||
this.storageHandlerDelegate(function(data) {
|
||||
if (isNaN(data)) {
|
||||
error('Expected double but got non-number');
|
||||
} else {
|
||||
success(parseFloat(data));
|
||||
}
|
||||
}, error, "NativeStorage", "getDouble", [reference]);
|
||||
};
|
||||
|
||||
/* string storage */
|
||||
StorageHandle.prototype.putString = function(reference, s, success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
if (reference === null) {
|
||||
error("Null reference isn't supported");
|
||||
return;
|
||||
}
|
||||
this.storageHandlerDelegate(success, error, "NativeStorage", "putString", [reference, s]);
|
||||
};
|
||||
|
||||
StorageHandle.prototype.getString = function(reference, success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
if (reference === null) {
|
||||
error("Null reference isn't supported");
|
||||
return;
|
||||
}
|
||||
this.storageHandlerDelegate(success, error, "NativeStorage", "getString", [reference]);
|
||||
};
|
||||
|
||||
/* object storage COMPOSITE AND DOESNT CARE FOR BROWSER*/
|
||||
StorageHandle.prototype.putObject = function(reference, obj, success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
var objAsString = "";
|
||||
try {
|
||||
objAsString = JSON.stringify(obj);
|
||||
} catch (err) {
|
||||
error(err);
|
||||
}
|
||||
this.putString(reference, objAsString, function(data) {
|
||||
var obj = {};
|
||||
try {
|
||||
obj = JSON.parse(data);
|
||||
success(obj);
|
||||
} catch (err) {
|
||||
error(err);
|
||||
}
|
||||
}, error);
|
||||
};
|
||||
|
||||
StorageHandle.prototype.getObject = function(reference, success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
this.getString(reference, function(data) {
|
||||
var obj = {};
|
||||
try {
|
||||
obj = JSON.parse(data);
|
||||
success(obj);
|
||||
} catch (err) {
|
||||
error(err);
|
||||
}
|
||||
}, error);
|
||||
};
|
||||
|
||||
/* API >= 2 */
|
||||
StorageHandle.prototype.setItem = function(reference, obj, success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
var objAsString = "";
|
||||
try {
|
||||
objAsString = JSON.stringify(obj);
|
||||
} catch (err) {
|
||||
error(new NativeStorageError(NativeStorageError.JSON_ERROR, "JS", err));
|
||||
return;
|
||||
}
|
||||
if (reference === null) {
|
||||
error(new NativeStorageError(NativeStorageError.NULL_REFERENCE, "JS", ""));
|
||||
return;
|
||||
}
|
||||
this.storageHandlerDelegate(function(data) {
|
||||
try {
|
||||
obj = JSON.parse(data);
|
||||
success(obj);
|
||||
} catch (err) {
|
||||
error(new NativeStorageError(NativeStorageError.JSON_ERROR, "JS", err));
|
||||
}
|
||||
}, function(code) {
|
||||
error(new NativeStorageError(code, "Native", ""));
|
||||
}, "NativeStorage", "setItem", [reference, objAsString]);
|
||||
};
|
||||
|
||||
StorageHandle.prototype.getItem = function(reference, success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
if (reference === null) {
|
||||
error(new NativeStorageError(NativeStorageError.NULL_REFERENCE, "JS", ""));
|
||||
return;
|
||||
}
|
||||
var obj = {};
|
||||
|
||||
this.storageHandlerDelegate(
|
||||
function(data) {
|
||||
try {
|
||||
obj = JSON.parse(data);
|
||||
success(obj);
|
||||
} catch (err) {
|
||||
error(new NativeStorageError(NativeStorageError.JSON_ERROR, "JS", err));
|
||||
}
|
||||
},
|
||||
function(code) {
|
||||
error(new NativeStorageError(code, "Native", ""));
|
||||
}, "NativeStorage", "getItem", [reference]);
|
||||
};
|
||||
|
||||
/* API >= 2 */
|
||||
StorageHandle.prototype.setSecretItem = function(reference, obj, encryptConfig, success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
var objAsString = "";
|
||||
try {
|
||||
objAsString = JSON.stringify(obj);
|
||||
} catch (err) {
|
||||
error(new NativeStorageError(NativeStorageError.JSON_ERROR, "JS", err));
|
||||
return;
|
||||
}
|
||||
if (reference === null) {
|
||||
error(new NativeStorageError(NativeStorageError.NULL_REFERENCE, "JS", ""));
|
||||
return;
|
||||
}
|
||||
|
||||
var action = "setItem";
|
||||
var params = [reference, objAsString];
|
||||
switch (encryptConfig.mode) {
|
||||
case "password":
|
||||
action = "setItemWithPassword";
|
||||
params = [reference, objAsString, encryptConfig.value];
|
||||
break;
|
||||
case "key":
|
||||
action = "setItemWithKey";
|
||||
break;
|
||||
case "none":
|
||||
break;
|
||||
default: {
|
||||
error(new NativeStorageError(NativeStorageError.WRONG_PARAMETER, "JS", ""));
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.storageHandlerDelegate(function(data) {
|
||||
try {
|
||||
obj = JSON.parse(data);
|
||||
success(obj);
|
||||
} catch (err) {
|
||||
error(new NativeStorageError(NativeStorageError.JSON_ERROR, "JS", err));
|
||||
}
|
||||
}, function(code) {
|
||||
error(new NativeStorageError(code, "Native", ""));
|
||||
}, "NativeStorage", action, params);
|
||||
};
|
||||
|
||||
StorageHandle.prototype.getSecretItem = function(reference, encryptConfig, success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
if (reference === null) {
|
||||
error(new NativeStorageError(NativeStorageError.NULL_REFERENCE, "JS", ""));
|
||||
return;
|
||||
}
|
||||
var obj = {};
|
||||
|
||||
var action = "getItem";
|
||||
var params = [reference];
|
||||
switch (encryptConfig.mode) {
|
||||
case "password":
|
||||
action = "getItemWithPassword";
|
||||
params = [reference, encryptConfig.value];
|
||||
break;
|
||||
case "key":
|
||||
action = "getItemWithKey";
|
||||
break;
|
||||
case "none":
|
||||
break;
|
||||
default: {
|
||||
error(new NativeStorageError(NativeStorageError.WRONG_PARAMETER, "JS", ""));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.storageHandlerDelegate(
|
||||
function(data) {
|
||||
try {
|
||||
obj = JSON.parse(data);
|
||||
success(obj);
|
||||
} catch (err) {
|
||||
error(new NativeStorageError(NativeStorageError.JSON_ERROR, "JS", err));
|
||||
}
|
||||
},
|
||||
function(code) {
|
||||
error(new NativeStorageError(code, "Native", ""));
|
||||
}, "NativeStorage", action, params);
|
||||
};
|
||||
|
||||
/* list keys */
|
||||
StorageHandle.prototype.keys = function(success, error) {
|
||||
|
||||
//if error is null then replace with empty function to silence warnings
|
||||
if(!error){
|
||||
error = function(){};
|
||||
}
|
||||
|
||||
this.storageHandlerDelegate(success, error, "NativeStorage", "keys", []);
|
||||
};
|
||||
|
||||
|
||||
var storageHandle = new StorageHandle();
|
||||
module.exports = storageHandle;
|
||||
|
||||
});
|
||||
BIN
dist/static/media/errorIcon.4cbb21d3.png
vendored
Normal file
BIN
dist/static/media/errorIcon.4cbb21d3.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
@ -6,7 +6,7 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "tsc",
|
||||
"build": "cordova prepare browser",
|
||||
"start": "cordova run -- --livereload",
|
||||
"eslint": "eslint 'src/**/*.tsx'"
|
||||
},
|
||||
|
||||
7
tools/build-release.sh
Executable file
7
tools/build-release.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
npm run build
|
||||
rm -rf dist
|
||||
mv platforms/browser/www dist
|
||||
|
||||
git add dist -v
|
||||
Loading…
x
Reference in New Issue
Block a user