Wolle-Rosen-Kaufen/www/js/controllers.js
2016-01-07 21:34:26 +01:00

92 lines
2.1 KiB
JavaScript

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) {
});