Sqlite-Plugin, DB-Copy plugin added und integriert

This commit is contained in:
2016-01-15 00:59:23 +01:00
parent 337215938a
commit 7c683d7450
243 changed files with 308639 additions and 253 deletions

View File

@@ -238,6 +238,22 @@ module.exports = [
"clobbers": [
"window.FileTransfer"
]
},
{
"file": "plugins/cordova-sqlite-storage/www/SQLitePlugin.js",
"id": "cordova-sqlite-storage.SQLitePlugin",
"pluginId": "cordova-sqlite-storage",
"clobbers": [
"SQLitePlugin"
]
},
{
"file": "plugins/me.rahul.plugins.sqlDB/www/sqlDB.js",
"id": "me.rahul.plugins.sqlDB.sqlDB",
"pluginId": "me.rahul.plugins.sqlDB",
"clobbers": [
"window.plugins.sqlDB"
]
}
];
module.exports.metadata =
@@ -252,7 +268,9 @@ module.exports.metadata =
"ionic-plugin-keyboard": "1.0.8",
"cordova-plugin-inappbrowser": "1.1.1",
"cordova-plugin-file": "3.0.0",
"cordova-plugin-file-transfer": "1.4.0"
"cordova-plugin-file-transfer": "1.4.0",
"cordova-sqlite-storage": "0.7.15-pre",
"me.rahul.plugins.sqlDB": "1.0.3"
}
// BOTTOM OF METADATA
});

View File

@@ -3,6 +3,7 @@
font-family: 'Lobster', cursive;
}
.lobsterMiddle{
font-family: 'Lobster', cursive;
font-size: 1.2em;
@@ -22,35 +23,45 @@
.item-divider{
background-image: linear-gradient(
hsla(340, 100%, 35%, 1) 20%,
hsl(340,100%,54%) 90%
hsla(0, 94%, 33%, 1) 20%,
hsl(0,94%,54%) 90%
);
color:white;
}
.tabs-addddssertive > .tabs{
background-image: linear-gradient(
hsla(340, 100%, 35%, 1) 20%,
hsl(340,100%,54%) 90%
hsla(0, 94%, 33%, 1) 20%,
hsl(0,94%,54%) 90%
) !important;
}
.tabs-assertive > .tabs{
background-color: #BD0340 !important;
.tabs-assertive > .tabs{
background-color: #A50505 !important;
}
.bar-custom{
background-image: linear-gradient(
hsla(340, 100%, 35%, 1) 20%,
hsl(340,100%,54%) 90%
hsla(0, 94%, 33%, 1) 20%,
hsl(0,94%,54%) 90%
) !important;
font-family: 'Bubblegum Sans', cursive;
}
.button-custom{
background-color: #C60545;
text-decoration: none;
border: 1px solid #C60545;
border-color: #F9135F #F9135F #F9135F #F9135F;
color: #fff
}
font-family: 'Bubblegum Sans', cursive;
background-color: #A50505;
text-decoration: none;
border: 1px solid #A50505;
color: #fff
}
.oleo{
font-family: 'Bubblegum Sans', cursive;
font-size: 1.3em !important;
}

View File

@@ -8,6 +8,7 @@
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Oswald:400,300,700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Bubblegum+Sans' rel='stylesheet' type='text/css'>
<link href="css/style.css" rel="stylesheet">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
@@ -16,7 +17,7 @@
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="js/ng-cordova.min.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>

View File

@@ -5,21 +5,55 @@
// the 2nd parameter is an array of 'requires'
// 'starter.services' is found in services.js
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])
var db;
.run(function($ionicPlatform, $ionicPopup) {
angular.module('starter', ['ionic', 'ngCordova', 'starter.controllers', 'starter.services'])
.run(function($ionicPlatform, $window, $ionicHistory, $database, $ionicPopup, $state, $localstorage, $rootScope) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
$ionicPlatform.registerBackButtonAction(function(event) {
// Handle Android back button to avoid the application exits accidentaly
if ($state.current.name=="tab.dash") {
$ionicPopup.confirm({
title: 'System-Hinweis',
template: 'Möchten Sie die App beenden?'
}).then(function(res) {
if (res) {
ionic.Platform.exitApp();
}
});
} else {
$ionicHistory.clearCache();
$ionicHistory.nextViewOptions({
historyRoot: true
});
$state.go('tab.dash');
}
}, 100);
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
// Mandatory for InAppBrowser plugin
if(window.cordova){
window.open = cordova.InAppBrowser.open;
}
// Copy the populated database to mobile device destination
//if (window.sqlitePlugin && window.cordova) {
if (window.sqlitePlugin && window.cordova) {
window.plugins.sqlDB.copy("raataar_wrk.db", function (e) {
console.log(e);
});
}
function successHandler (result) {
var strResult = "";
@@ -39,7 +73,16 @@ angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])
if((window.device && device.platform == "Android") && typeof inappbilling !== "undefined") {
inappbilling.init(successHandler, errorHandler, {showLog:true});
}
// Initialize database through $database service
db = $database.initDB();
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
})

View File

@@ -1,6 +1,6 @@
angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope,$ionicPopup,$http, $localstorage) {
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database) {
$scope.preis="";
$scope.name="";
@@ -8,7 +8,9 @@ angular.module('starter.controllers', [])
$scope.items=[];
$scope.item=[];
$scope.items=$localstorage.getObject('items');
//db = Database.getDb();
//$scope.items=$localstorage.getObject('items');
$scope.validate = function() {
@@ -22,16 +24,30 @@ angular.module('starter.controllers', [])
};
$scope.loaddata = function() {
$scope.items=$localstorage.getObject('items');
alert(JSON.stringify($scope.items));
$scope.items=[];
$database.getAllBuys().then(function (result) {
if(result.length>0){
alert("daten da");
for(i=0;i<result.length;i++){
$scope.items.push(result[i]);
alert(i);
}
} else {
$scope.items=[];
}
});
};
$scope.savedata = function() {
$scope.item={name: $scope.name, freitext: $scope.freitext, rosen: $scope.preis, bild: "test"};
alert(JSON.stringify($scope.item));
$scope.item={name: $scope.name, bild: "test"};
$scope.items.push($scope.item);
$localstorage.setObject('items',$scope.items);
$database.setBuys($scope.name,"test");
};
function successBuyHandler (result) {
@@ -78,14 +94,22 @@ angular.module('starter.controllers', [])
})
.controller('BuysCtrl', function($scope, $localstorage,$location) {
.controller('BuysCtrl', function($scope, $database,$location) {
$scope.items=[];
$scope.items=$localstorage.getObject('items');
//$scope.items=$localstorage.getObject('items');
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
if ($location.path() == "/tab/buys") {
$scope.items=$localstorage.getObject('items');
}
$database.getAllBuys().then(function (result) {
if(result.length>0){
for(i=0;i<result.length;i++){
$scope.items.push(result[i]);
}
} else {
$scope.items=[];
}
});
}
});

File diff suppressed because one or more lines are too long

View File

@@ -1,19 +1,94 @@
angular.module('starter.services', [])
.factory('$localstorage', ['$window', function($window) {
return {
set: function(key, value) {
$window.localStorage[key] = value;
},
get: function(key, defaultValue) {
return $window.localStorage[key] || defaultValue;
},
setObject: function(key, value) {
$window.localStorage[key] = JSON.stringify(value);
},
getObject: function(key) {
return JSON.parse($window.localStorage[key] || '{}');
return {
set: function(key, value) {
$window.localStorage[key] = value;
},
get: function(key, defaultValue) {
return $window.localStorage[key] || defaultValue;
},
setObject: function(key, value) {
$window.localStorage[key] = angular.toJson(value);
},
getObject: function(key) {
return JSON.parse($window.localStorage[key] || '[]');
},
destroy: function(key) {
$window.localStorage.removeItem(key);
},
log: function(key, defaultValue) {
console.log($window.localStorage[key] || defaultValue);
},
logObject: function(key) {
console.log(JSON.stringify($window.localStorage[key] || '{}'));
}
};
}])
.factory('$database',['$cordovaSQLite', function($cordovaSQLite) {
var self = this;
self.db = null;
var query;
//this updateTable function is for ilustrative use here, it can be changed to manage all queries indeed.
updateTable=function (table, column, value, condition) {
if(!condition){
query = "UPDATE " + table + " SET " + column + " = " + value;
} else{
query = "UPDATE " + table + " SET " + column + " = " + value + " WHERE " + condition;
}
}
}]);
return $cordovaSQLite.execute(self.db,query,[]).
then(function(result) {
console.log(query);
query=null;
return result;
},function(error) {
console.error(error);
query=null;
return error;
});
};
return {
initDB: function() {
if(window.cordova){
//self.db = sqlitePlugin.openDatabase({name: "data.db", location: 2, createFromLocation: 1});
self.db = $cordovaSQLite.openDB("raataar_wrk.db");
} else {
self.db = window.openDatabase('raataar_wrk.db','1','my',800*1024); // only available when WebSQL is available in Browser
}
console.log('Database opened');
return self.db;
},
setBuys: function(itemName,itemBild) {
query="INSERT INTO buys (Name, Bild) VALUES (?,?);";
return $cordovaSQLite.execute(self.db,query,[itemName,itemBild]).
then(function(result) {
console.log("Gespeichert");
query=null;
}, function(error) {
console.error(error);
});
},
getAllBuys: function(){
var ArrayQ=[];
query="SELECT * FROM buys order by id ASC";
return $cordovaSQLite.execute(self.db,query).
then(function(result) {
for(j=0;j<result.rows.length;j++){
var List={};
//console.log(result.rows.item(j));
List.name=result.rows.item(j).Name;
List.bild=result.rows.item(j).Bild;
ArrayQ.push(List);
}
//console.log(ArrayQ);
return ArrayQ;
},function(e){
console.error(error);
return error;
});
}
};
}]);

View File

@@ -1,4 +1,4 @@
@charset "UTF-8";
@charset "UTF-8";
/*!
* Copyright 2014 Drifty Co.
* http://drifty.com/

View File

@@ -0,0 +1,576 @@
cordova.define("cordova-sqlite-storage.SQLitePlugin", function(require, exports, module) { (function() {
var DB_STATE_INIT, DB_STATE_OPEN, READ_ONLY_REGEX, SQLiteFactory, SQLitePlugin, SQLitePluginTransaction, argsArray, dblocations, newSQLError, nextTick, root, txLocks;
root = this;
READ_ONLY_REGEX = /^\s*(?:drop|delete|insert|update|create)\s/i;
DB_STATE_INIT = "INIT";
DB_STATE_OPEN = "OPEN";
txLocks = {};
newSQLError = function(error, code) {
var sqlError;
sqlError = error;
if (!code) {
code = 0;
}
if (!sqlError) {
sqlError = new Error("a plugin had an error but provided no response");
sqlError.code = code;
}
if (typeof sqlError === "string") {
sqlError = new Error(error);
sqlError.code = code;
}
if (!sqlError.code && sqlError.message) {
sqlError.code = code;
}
if (!sqlError.code && !sqlError.message) {
sqlError = new Error("an unknown error was returned: " + JSON.stringify(sqlError));
sqlError.code = code;
}
return sqlError;
};
nextTick = window.setImmediate || function(fun) {
window.setTimeout(fun, 0);
};
/*
Utility that avoids leaking the arguments object. See
https://www.npmjs.org/package/argsarray
*/
argsArray = function(fun) {
return function() {
var args, i, len;
len = arguments.length;
if (len) {
args = [];
i = -1;
while (++i < len) {
args[i] = arguments[i];
}
return fun.call(this, args);
} else {
return fun.call(this, []);
}
};
};
SQLitePlugin = function(openargs, openSuccess, openError) {
var dbname;
if (!(openargs && openargs['name'])) {
throw newSQLError("Cannot create a SQLitePlugin db instance without a db name");
}
dbname = openargs.name;
if (typeof dbname !== 'string') {
throw newSQLError('sqlite plugin database name must be a string');
}
this.openargs = openargs;
this.dbname = dbname;
this.openSuccess = openSuccess;
this.openError = openError;
this.openSuccess || (this.openSuccess = function() {
console.log("DB opened: " + dbname);
});
this.openError || (this.openError = function(e) {
console.log(e.message);
});
this.open(this.openSuccess, this.openError);
};
SQLitePlugin.prototype.databaseFeatures = {
isSQLitePluginDatabase: true
};
SQLitePlugin.prototype.openDBs = {};
SQLitePlugin.prototype.addTransaction = function(t) {
if (!txLocks[this.dbname]) {
txLocks[this.dbname] = {
queue: [],
inProgress: false
};
}
txLocks[this.dbname].queue.push(t);
if (this.dbname in this.openDBs && this.openDBs[this.dbname] !== DB_STATE_INIT) {
this.startNextTransaction();
} else {
if (this.dbname in this.openDBs) {
console.log('new transaction is waiting for open operation');
} else {
console.log('database is closed, new transaction is [stuck] waiting until db is opened again!');
}
}
};
SQLitePlugin.prototype.transaction = function(fn, error, success) {
if (!this.openDBs[this.dbname]) {
error(newSQLError('database not open'));
return;
}
this.addTransaction(new SQLitePluginTransaction(this, fn, error, success, true, false));
};
SQLitePlugin.prototype.readTransaction = function(fn, error, success) {
if (!this.openDBs[this.dbname]) {
error(newSQLError('database not open'));
return;
}
this.addTransaction(new SQLitePluginTransaction(this, fn, error, success, false, true));
};
SQLitePlugin.prototype.startNextTransaction = function() {
var self;
self = this;
nextTick((function(_this) {
return function() {
var txLock;
if (!(_this.dbname in _this.openDBs) || _this.openDBs[_this.dbname] !== DB_STATE_OPEN) {
console.log('cannot start next transaction: database not open');
return;
}
txLock = txLocks[self.dbname];
if (!txLock) {
console.log('cannot start next transaction: database connection is lost');
return;
} else if (txLock.queue.length > 0 && !txLock.inProgress) {
txLock.inProgress = true;
txLock.queue.shift().start();
}
};
})(this));
};
SQLitePlugin.prototype.abortAllPendingTransactions = function() {
var j, len1, ref, tx, txLock;
txLock = txLocks[this.dbname];
if (!!txLock && txLock.queue.length > 0) {
ref = txLock.queue;
for (j = 0, len1 = ref.length; j < len1; j++) {
tx = ref[j];
tx.abortFromQ(newSQLError('Invalid database handle'));
}
txLock.queue = [];
txLock.inProgress = false;
}
};
SQLitePlugin.prototype.open = function(success, error) {
var openerrorcb, opensuccesscb;
if (this.dbname in this.openDBs) {
console.log('database already open: ' + this.dbname);
nextTick((function(_this) {
return function() {
success(_this);
};
})(this));
} else {
console.log('OPEN database: ' + this.dbname);
opensuccesscb = (function(_this) {
return function() {
var txLock;
if (!_this.openDBs[_this.dbname]) {
console.log('database was closed during open operation');
}
if (_this.dbname in _this.openDBs) {
_this.openDBs[_this.dbname] = DB_STATE_OPEN;
}
if (!!success) {
success(_this);
}
txLock = txLocks[_this.dbname];
if (!!txLock && txLock.queue.length > 0 && !txLock.inProgress) {
_this.startNextTransaction();
}
};
})(this);
openerrorcb = (function(_this) {
return function() {
console.log('OPEN database: ' + _this.dbname + ' failed, aborting any pending transactions');
if (!!error) {
error(newSQLError('Could not open database'));
}
delete _this.openDBs[_this.dbname];
_this.abortAllPendingTransactions();
};
})(this);
this.openDBs[this.dbname] = DB_STATE_INIT;
cordova.exec(opensuccesscb, openerrorcb, "SQLitePlugin", "open", [this.openargs]);
}
};
SQLitePlugin.prototype.close = function(success, error) {
if (this.dbname in this.openDBs) {
if (txLocks[this.dbname] && txLocks[this.dbname].inProgress) {
console.log('cannot close: transaction is in progress');
error(newSQLError('database cannot be closed while a transaction is in progress'));
return;
}
console.log('CLOSE database: ' + this.dbname);
delete this.openDBs[this.dbname];
if (txLocks[this.dbname]) {
console.log('closing db with transaction queue length: ' + txLocks[this.dbname].queue.length);
} else {
console.log('closing db with no transaction lock state');
}
cordova.exec(success, error, "SQLitePlugin", "close", [
{
path: this.dbname
}
]);
} else {
console.log('cannot close: database is not open');
if (error) {
nextTick(function() {
return error();
});
}
}
};
SQLitePlugin.prototype.executeSql = function(statement, params, success, error) {
var myerror, myfn, mysuccess;
mysuccess = function(t, r) {
if (!!success) {
return success(r);
}
};
myerror = function(t, e) {
if (!!error) {
return error(e);
}
};
myfn = function(tx) {
tx.addStatement(statement, params, mysuccess, myerror);
};
this.addTransaction(new SQLitePluginTransaction(this, myfn, null, null, false, false));
};
SQLitePluginTransaction = function(db, fn, error, success, txlock, readOnly) {
if (typeof fn !== "function") {
/*
This is consistent with the implementation in Chrome -- it
throws if you pass anything other than a function. This also
prevents us from stalling our txQueue if somebody passes a
false value for fn.
*/
throw newSQLError("transaction expected a function");
}
this.db = db;
this.fn = fn;
this.error = error;
this.success = success;
this.txlock = txlock;
this.readOnly = readOnly;
this.executes = [];
if (txlock) {
this.addStatement("BEGIN", [], null, function(tx, err) {
throw newSQLError("unable to begin transaction: " + err.message, err.code);
});
}
};
SQLitePluginTransaction.prototype.start = function() {
var err, error1;
try {
this.fn(this);
this.run();
} catch (error1) {
err = error1;
txLocks[this.db.dbname].inProgress = false;
this.db.startNextTransaction();
if (this.error) {
this.error(newSQLError(err));
}
}
};
SQLitePluginTransaction.prototype.executeSql = function(sql, values, success, error) {
if (this.finalized) {
throw {
message: 'InvalidStateError: DOM Exception 11: This transaction is already finalized. Transactions are committed after its success or failure handlers are called. If you are using a Promise to handle callbacks, be aware that implementations following the A+ standard adhere to run-to-completion semantics and so Promise resolution occurs on a subsequent tick and therefore after the transaction commits.',
code: 11
};
return;
}
if (this.readOnly && READ_ONLY_REGEX.test(sql)) {
this.handleStatementFailure(error, {
message: 'invalid sql for a read-only transaction'
});
return;
}
this.addStatement(sql, values, success, error);
};
SQLitePluginTransaction.prototype.addStatement = function(sql, values, success, error) {
var j, len1, params, t, v;
params = [];
if (!!values && values.constructor === Array) {
for (j = 0, len1 = values.length; j < len1; j++) {
v = values[j];
t = typeof v;
params.push((v === null || v === void 0 || t === 'number' || t === 'string' ? v : v instanceof Blob ? v.valueOf() : v.toString()));
}
}
this.executes.push({
success: success,
error: error,
sql: sql,
params: params
});
};
SQLitePluginTransaction.prototype.handleStatementSuccess = function(handler, response) {
var payload, rows;
if (!handler) {
return;
}
rows = response.rows || [];
payload = {
rows: {
item: function(i) {
return rows[i];
},
length: rows.length
},
rowsAffected: response.rowsAffected || 0,
insertId: response.insertId || void 0
};
handler(this, payload);
};
SQLitePluginTransaction.prototype.handleStatementFailure = function(handler, response) {
if (!handler) {
throw newSQLError("a statement with no error handler failed: " + response.message, response.code);
}
if (handler(this, response) !== false) {
throw newSQLError("a statement error callback did not return false: " + response.message, response.code);
}
};
SQLitePluginTransaction.prototype.run = function() {
var batchExecutes, handlerFor, i, mycb, mycbmap, request, tropts, tx, txFailure, waiting;
txFailure = null;
tropts = [];
batchExecutes = this.executes;
waiting = batchExecutes.length;
this.executes = [];
tx = this;
handlerFor = function(index, didSucceed) {
return function(response) {
var err, error1;
try {
if (didSucceed) {
tx.handleStatementSuccess(batchExecutes[index].success, response);
} else {
tx.handleStatementFailure(batchExecutes[index].error, newSQLError(response));
}
} catch (error1) {
err = error1;
if (!txFailure) {
txFailure = newSQLError(err);
}
}
if (--waiting === 0) {
if (txFailure) {
tx.abort(txFailure);
} else if (tx.executes.length > 0) {
tx.run();
} else {
tx.finish();
}
}
};
};
i = 0;
mycbmap = {};
while (i < batchExecutes.length) {
request = batchExecutes[i];
mycbmap[i] = {
success: handlerFor(i, true),
error: handlerFor(i, false)
};
tropts.push({
qid: 1111,
sql: request.sql,
params: request.params
});
i++;
}
mycb = function(result) {
var j, last, q, r, ref, res, type;
last = result.length - 1;
for (i = j = 0, ref = last; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) {
r = result[i];
type = r.type;
res = r.result;
q = mycbmap[i];
if (q) {
if (q[type]) {
q[type](res);
}
}
}
};
cordova.exec(mycb, null, "SQLitePlugin", "backgroundExecuteSqlBatch", [
{
dbargs: {
dbname: this.db.dbname
},
executes: tropts
}
]);
};
SQLitePluginTransaction.prototype.abort = function(txFailure) {
var failed, succeeded, tx;
if (this.finalized) {
return;
}
tx = this;
succeeded = function(tx) {
txLocks[tx.db.dbname].inProgress = false;
tx.db.startNextTransaction();
if (tx.error) {
tx.error(txFailure);
}
};
failed = function(tx, err) {
txLocks[tx.db.dbname].inProgress = false;
tx.db.startNextTransaction();
if (tx.error) {
tx.error(newSQLError("error while trying to roll back: " + err.message, err.code));
}
};
this.finalized = true;
if (this.txlock) {
this.addStatement("ROLLBACK", [], succeeded, failed);
this.run();
} else {
succeeded(tx);
}
};
SQLitePluginTransaction.prototype.finish = function() {
var failed, succeeded, tx;
if (this.finalized) {
return;
}
tx = this;
succeeded = function(tx) {
txLocks[tx.db.dbname].inProgress = false;
tx.db.startNextTransaction();
if (tx.success) {
tx.success();
}
};
failed = function(tx, err) {
txLocks[tx.db.dbname].inProgress = false;
tx.db.startNextTransaction();
if (tx.error) {
tx.error(newSQLError("error while trying to commit: " + err.message, err.code));
}
};
this.finalized = true;
if (this.txlock) {
this.addStatement("COMMIT", [], succeeded, failed);
this.run();
} else {
succeeded(tx);
}
};
SQLitePluginTransaction.prototype.abortFromQ = function(sqlerror) {
if (this.error) {
this.error(sqlerror);
}
};
dblocations = ["docs", "libs", "nosync"];
SQLiteFactory = {
/*
NOTE: this function should NOT be translated from Javascript
back to CoffeeScript by js2coffee.
If this function is edited in Javascript then someone will
have to translate it back to CoffeeScript by hand.
*/
opendb: argsArray(function(args) {
var dblocation, errorcb, first, okcb, openargs;
if (args.length < 1) {
return null;
}
first = args[0];
openargs = null;
okcb = null;
errorcb = null;
if (first.constructor === String) {
openargs = {
name: first
};
if (args.length >= 5) {
okcb = args[4];
if (args.length > 5) {
errorcb = args[5];
}
}
} else {
openargs = first;
if (args.length >= 2) {
okcb = args[1];
if (args.length > 2) {
errorcb = args[2];
}
}
}
dblocation = !!openargs.location ? dblocations[openargs.location] : null;
openargs.dblocation = dblocation || dblocations[0];
if (!!openargs.createFromLocation && openargs.createFromLocation === 1) {
openargs.createFromResource = "1";
}
if (!!openargs.androidDatabaseImplementation && openargs.androidDatabaseImplementation === 2) {
openargs.androidOldDatabaseImplementation = 1;
}
if (!!openargs.androidLockWorkaround && openargs.androidLockWorkaround === 1) {
openargs.androidBugWorkaround = 1;
}
return new SQLitePlugin(openargs, okcb, errorcb);
}),
deleteDb: function(first, success, error) {
var args, dblocation;
args = {};
if (first.constructor === String) {
args.path = first;
args.dblocation = dblocations[0];
} else {
if (!(first && first['name'])) {
throw new Error("Please specify db name");
}
args.path = first.name;
dblocation = !!first.location ? dblocations[first.location] : null;
args.dblocation = dblocation || dblocations[0];
}
delete SQLitePlugin.prototype.openDBs[args.path];
return cordova.exec(success, error, "SQLitePlugin", "delete", [args]);
}
};
root.sqlitePlugin = {
sqliteFeatures: {
isSQLitePlugin: true
},
openDatabase: SQLiteFactory.opendb,
deleteDatabase: SQLiteFactory.deleteDb
};
}).call(this);
});

View File

@@ -0,0 +1,11 @@
cordova.define("me.rahul.plugins.sqlDB.sqlDB", function(require, exports, module) { var exec = require('cordova/exec');
exports.copy = function(dbname, location, success, error) {
exec(success, error, "sqlDB", "copy", [dbname, location]);
};
exports.remove = function(dbname, location, success,error) {
exec(success, error, "sqlDB", "remove", [dbname, location]);
};
});

Binary file not shown.

View File

@@ -1,11 +1,11 @@
<ion-view view-title="Gekaufte Rosen">
<ion-content>
<ion-content class="padding">
<div style="padding-bottom:15px;">
<div class="item item-divider oswald">Hier können Sie Ihre gekauften Rosen ansehen oder nochmals versenden!</div>
<ul class="list card">
<div class="item item-divider oleo">Hier können Sie Ihre gekauften Rosen ansehen oder nochmals versenden!</div>
<ul class="list">
<a class="item item-thumbnail-left item-button-right" href="#" ng-repeat="i in items" ng-model="items">
<img src="img/rose1.png">
<h1>{{i.name}}</h1>
@@ -21,10 +21,6 @@
</a>
</ul>
</div>

View File

@@ -1,43 +1,28 @@
<ion-view view-title='Rosen kaufen'>
<ion-content class="padding">
<div class="list card">
<div class="item item-divider oswald">Wolle Rose kaufen?</div>
<div class="item item-body lobster">
<div style="padding-bottom:25px;">
Schenken Sie einem besonderen Menschen eine aussergewöhnliche Aufmerksamkeit.
</div>
<div class="item item-divider oswald">An wen wollen Sie die Rose verschenken</div>
<div class="list list-inset" style="padding-bottom:15px;">
<div class="item item-divider oleo">Schenken Sie einem besonderen Menschen eine außergewöhnliche Aufmerksamkeit!</div>
<label class="item item-input item-stacked-label">
<span class="input-label">Name Ihres Liebsten:</span>
<input type="text" placeholder="" class="lobster" ng-model="$parent.name">
<input type="text" placeholder="" class="oleo" ng-model="$parent.name">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Ihre persönliche Nachricht:</span>
<textarea placeholder="" rows="4" cols="10" class="lobster" ng-model="$parent.freitext"></textarea>
<textarea placeholder="" rows="4" cols="10" class="oleo" ng-model="$parent.freitext"></textarea>
</label>
</div>
<div style="padding-bottom:15px;">
<div class="item item-divider oleo">Wählen Sie Ihre Rosen aus</div>
<div class="item item-divider oleo">Wählen Sie Ihre Rosen aus:</div>
<ion-list>
<ion-radio ng-model="$parent.preis" ng-value="'1xrose'" class="item item-thumbnail-left item-text-wrap"><img src="img/rose1.png"><h2 class="lobster">1 Rose </h2><p>Preis: 0,50 € (inkl. Mwst 0,59 €)</p></ion-radio>
<ion-radio ng-model="$parent.preis" ng-value="'3xrose'" class="item item-thumbnail-left item-text-wrap"><img src="img/rose3.png"><h2 class="lobster">3 Rosen</h2><p>Preis: 1,00 € (inkl. Mwst 1,19 €)</p></ion-radio>
<ion-radio ng-model="$parent.preis" ng-value="'9xrose'" class="item item-thumbnail-left item-text-wrap"><img src="img/rose10.png"><h2 class="lobster">9 Rosen</h2><p>Preis: 2,00 € (inkl. Mwst 2,38 €)</p></ion-radio>
<ion-radio ng-model="$parent.preis" ng-value="'1xrose'" class="item item-thumbnail-left item-text-wrap"><img src="img/rose1.png"><h2 class="oleo">1 Rose </h2><p>Preis: 0,50 € (zzgl. gesetzl. MwSt.)</p></ion-radio>
<ion-radio ng-model="$parent.preis" ng-value="'3xrose'" class="item item-thumbnail-left item-text-wrap"><img src="img/rose3.png"><h2 class="oleo">3 Rosen</h2><p>Preis: 1,00 € (zzgl. gesetzl. MwSt.)</p></ion-radio>
<ion-radio ng-model="$parent.preis" ng-value="'9xrose'" class="item item-thumbnail-left item-text-wrap"><img src="img/rose10.png"><h2 class="oleo">9 Rosen</h2><p>Preis: 2,00 € (zzgl. gesetzl. MwSt.)</p></ion-radio>
</ion-list>
<label class="item item-input item-select">
<div class="input-label">
Farbe
</div>
<select>
<option selected>Rot</option>
<option>Gelb</option>
<option>Weiß</option>
</select>
</label>
</div>
<div class="item item-divider oswald">Rosen kaufen?</div>
</div>
<div class="list card">
<div class="item item-divider oleo">Rosen jetzt kaufen?</div>
<div class="row">
<div class="col col-50"><button class="button button-full button-small icon-left ion-image button-custom" ng-disabled="!$parent.preis || !$parent.name || !$parent.freitext" ng-click="validate()">Vorschau</button></div>
<div class="col col-50"><button class="button button-full button-small icon-left ion-social-euro button-custom" ng-disabled="!$parent.preis || !$parent.freitext || !$parent.name" ng-click="buyRose()">Jetzt Kaufen</button></div>
@@ -47,7 +32,7 @@
<div class="col col-50"><button class="button button-full button-small icon-left ion-image button-custom" ng-disabled="!$parent.preis || !$parent.name || !$parent.freitext" ng-click="loaddata()">Laden</button></div>
<div class="col col-50"><button class="button button-full button-small icon-left ion-social-euro button-custom" ng-disabled="!$parent.preis || !$parent.freitext || !$parent.name" ng-click="savedata()">Speichern</button></div>
</div>
</div>
</div>
</div>