Initial-Release
This commit is contained in:
86
www/js/app.js
Normal file
86
www/js/app.js
Normal file
@@ -0,0 +1,86 @@
|
||||
// Ionic Starter App
|
||||
|
||||
// angular.module is a global place for creating, registering and retrieving Angular modules
|
||||
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
|
||||
// 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'])
|
||||
|
||||
.run(function($ionicPlatform, $ionicPopup) {
|
||||
$ionicPlatform.ready(function() {
|
||||
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
|
||||
// for form inputs)
|
||||
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();
|
||||
}
|
||||
|
||||
function successHandler (result) {
|
||||
var strResult = "";
|
||||
if(typeof result === 'object') {
|
||||
strResult = JSON.stringify(result);
|
||||
} else {
|
||||
strResult = result;
|
||||
}
|
||||
alert("SUCCESS: \r\n"+strResult );
|
||||
}
|
||||
|
||||
function errorHandler (error) {
|
||||
alert("ERROR: \r\n"+error );
|
||||
}
|
||||
|
||||
|
||||
if((window.device && device.platform == "Android") && typeof inappbilling !== "undefined") {
|
||||
inappbilling.init(successHandler, errorHandler, {showLog:true});
|
||||
}
|
||||
|
||||
});
|
||||
})
|
||||
|
||||
.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) {
|
||||
|
||||
// Ionic uses AngularUI Router which uses the concept of states
|
||||
// Learn more here: https://github.com/angular-ui/ui-router
|
||||
// Set up the various states which the app can be in.
|
||||
// Each state's controller can be found in controllers.js
|
||||
$stateProvider
|
||||
|
||||
// setup an abstract state for the tabs directive
|
||||
.state('tab', {
|
||||
url: '/tab',
|
||||
abstract: true,
|
||||
templateUrl: 'templates/tabs.html'
|
||||
})
|
||||
|
||||
// Each tab has its own nav history stack:
|
||||
|
||||
.state('tab.dash', {
|
||||
url: '/dash',
|
||||
views: {
|
||||
'tab-dash': {
|
||||
templateUrl: 'templates/tab-dash.html',
|
||||
controller: 'DashCtrl'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
.state('tab.buys', {
|
||||
url: '/buys',
|
||||
views: {
|
||||
'tab-buys': {
|
||||
templateUrl: 'templates/tab-buys.html',
|
||||
controller: 'BuysCtrl'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// if none of the above states are matched, use this as the fallback
|
||||
$urlRouterProvider.otherwise('/tab/dash');
|
||||
$ionicConfigProvider.tabs.position('bottom');
|
||||
});
|
||||
91
www/js/controllers.js
Normal file
91
www/js/controllers.js
Normal file
@@ -0,0 +1,91 @@
|
||||
angular.module('starter.controllers', [])
|
||||
|
||||
.controller('DashCtrl', function($scope,$ionicPopup,$http) {
|
||||
|
||||
$scope.preis="";
|
||||
$scope.name="";
|
||||
$scope.freitext="";
|
||||
var showAlert=0;
|
||||
|
||||
$scope.validate = function() {
|
||||
showAlert=0;
|
||||
if ($scope.name.length < 1){
|
||||
showAlert=1;
|
||||
}
|
||||
if ($scope.freitext.length < 1){
|
||||
showAlert=1;
|
||||
}
|
||||
|
||||
if (showAlert==1){
|
||||
$scope.showAlert();
|
||||
return;
|
||||
}
|
||||
|
||||
var link = 'http://api.raataar.de/rosen/vorschau.php';
|
||||
|
||||
$http.post(link, {name : $scope.name, freitext: $scope.freitext, rosen: $scope.preis}).then(function (res){
|
||||
$scope.response = res.data;
|
||||
window.open($scope.response, '_system', 'location=yes');
|
||||
return false;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
$scope.showAlert = function() {
|
||||
var alertPopup = $ionicPopup.alert({
|
||||
title: 'Uuuupppsssiii',
|
||||
template: 'Bitte prüfe deine Eingaben.'
|
||||
});
|
||||
alertPopup.then(function(res) {
|
||||
console.log('Thank you for not eating my delicious ice cream cone');
|
||||
});
|
||||
};
|
||||
|
||||
function buysuccessHandler (result) {
|
||||
inappbilling.consumePurchase(successHandler, errorHandler, "3xrose");
|
||||
}
|
||||
|
||||
function successHandler (result) {
|
||||
var strResult = "";
|
||||
if(typeof result === 'object') {
|
||||
strResult = JSON.stringify(result);
|
||||
} else {
|
||||
strResult = result;
|
||||
}
|
||||
alert("SUCCESS: \r\n"+strResult );
|
||||
}
|
||||
|
||||
function errorHandler (error) {
|
||||
alert("ERROR: \r\n"+error );
|
||||
}
|
||||
|
||||
$scope.buyAdFree = function() {
|
||||
|
||||
alert($scope.preis);
|
||||
|
||||
if((window.device && device.platform == "Android") && typeof inappbilling !== "undefined") {
|
||||
inappbilling.buy(buysuccessHandler, errorHandler,"3xrose");
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
.controller('BuysCtrl', function($scope) {
|
||||
// With the new view caching in Ionic, Controllers are only called
|
||||
// when they are recreated or on app start, instead of every page change.
|
||||
// To listen for when this page is active (for example, to refresh data),
|
||||
// listen for the $ionicView.enter event:
|
||||
//
|
||||
//$scope.$on('$ionicView.enter', function(e) {
|
||||
//});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
.controller('Dummy', function($scope) {
|
||||
});
|
||||
50
www/js/services.js
Normal file
50
www/js/services.js
Normal file
@@ -0,0 +1,50 @@
|
||||
angular.module('starter.services', [])
|
||||
|
||||
.factory('Chats', function() {
|
||||
// Might use a resource here that returns a JSON array
|
||||
|
||||
// Some fake testing data
|
||||
var chats = [{
|
||||
id: 0,
|
||||
name: 'Ben Sparrow',
|
||||
lastText: 'You on your way?',
|
||||
face: 'img/ben.png'
|
||||
}, {
|
||||
id: 1,
|
||||
name: 'Max Lynx',
|
||||
lastText: 'Hey, it\'s me',
|
||||
face: 'img/max.png'
|
||||
}, {
|
||||
id: 2,
|
||||
name: 'Adam Bradleyson',
|
||||
lastText: 'I should buy a boat',
|
||||
face: 'img/adam.jpg'
|
||||
}, {
|
||||
id: 3,
|
||||
name: 'Perry Governor',
|
||||
lastText: 'Look at my mukluks!',
|
||||
face: 'img/perry.png'
|
||||
}, {
|
||||
id: 4,
|
||||
name: 'Mike Harrington',
|
||||
lastText: 'This is wicked good ice cream.',
|
||||
face: 'img/mike.png'
|
||||
}];
|
||||
|
||||
return {
|
||||
all: function() {
|
||||
return chats;
|
||||
},
|
||||
remove: function(chat) {
|
||||
chats.splice(chats.indexOf(chat), 1);
|
||||
},
|
||||
get: function(chatId) {
|
||||
for (var i = 0; i < chats.length; i++) {
|
||||
if (chats[i].id === parseInt(chatId)) {
|
||||
return chats[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user