This commit is contained in:
Hilmer, Carsten
2016-10-13 22:35:38 +02:00
parent 686986d6ee
commit 551cfa5030
210 changed files with 208860 additions and 0 deletions

77
www/js/app.js Normal file
View File

@@ -0,0 +1,77 @@
// 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', 'ngCordova', 'starter.controllers', 'starter.services'])
.run(function($ionicPlatform) {
$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();
}
});
})
.config(function($stateProvider, $urlRouterProvider) {
// 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.spiel1', {
url: '/spiel1',
views: {
'tab-spiel1': {
templateUrl: 'templates/spiel1.html',
controller: 'Spiel1Ctrl'
}
}
})
.state('tab.spiel2', {
url: '/spiel2',
views: {
'tab-spiel2': {
templateUrl: 'templates/spiel2.html',
controller: 'Spiel2Ctrl'
}
}
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/tab/dash');
});

262
www/js/controllers.js Normal file
View File

@@ -0,0 +1,262 @@
angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope, $cordovaMedia, $state) {
$scope.play = function(src) {
var media = new Media(src, null, null);
$cordovaMedia.play(media);
}
$scope.starte_spiel1 = function() {
var media = new Media('/android_asset/www/sounds/spiel1.mp3', goto_spiel1, null);
$cordovaMedia.play(media);
}
$scope.starte_spiel2 = function() {
var media = new Media('/android_asset/www/sounds/spiel2.mp3', goto_spiel2, null);
$cordovaMedia.play(media);
}
function goto_spiel1() {
$state.go('tab.spiel1');
}
function goto_spiel2() {
$state.go('tab.spiel2');
}
})
.controller('Spiel2Ctrl', function($scope, $cordovaMedia, $state) {
$scope.spiele=[];
var tier = {
bild: 'elefant.jpg',
sound1: 'sound_elefant.mp3',
sound2: ''
};
$scope.spiele.push(tier);
var tier1 = {
bild: 'esel.jpg',
sound1: 'sound_esel.mp3',
sound2: ''
};
$scope.spiele.push(tier1);
var tier2 = {
bild: 'hahn.jpg',
sound1: 'sound_hahn.mp3',
sound2: ''
};
$scope.spiele.push(tier2);
var tier3 = {
bild: 'hund.jpg',
sound1: 'sound_hund.mp3',
sound2: ''
};
$scope.spiele.push(tier3);
var tier4 = {
bild: 'katze.jpg',
sound1: 'sound_katze.mp3',
sound2: ''
};
$scope.spiele.push(tier4);
var tier5 = {
bild: 'kuh.jpg',
sound1: 'sound_kuh.mp3',
sound2: ''
};
$scope.spiele.push(tier5);
var tier6 = {
bild: 'maus.jpg',
sound1: 'sound_maus.mp3',
sound2: ''
};
$scope.spiele.push(tier6);
var tier7 = {
bild: 'schaf.jpg',
sound1: 'sound_schaf.mp3',
sound2: ''
};
$scope.spiele.push(tier7);
$scope.play = function(src) {
var media = new Media(src, null, null);
$cordovaMedia.play(media);
}
})
.controller('Spiel1Ctrl', function($scope, $cordovaMedia, $state, $timeout) {
$scope.spiele=[];
$scope.sounds=[];
$scope.tierfinden='';
$scope.randomid=0;
$scope.error = false;
$scope.sounds.push('');
var tier = {
id: 1,
bild: 'elefant.jpg',
sound1: 'sound_elefant.mp3',
antwort: ''
};
$scope.spiele.push(tier);
$scope.sounds.push('finde_elefant.mp3');
var tier1 = {
id: 2,
bild: 'esel.jpg',
sound1: 'sound_esel.mp3',
antwort: ''
};
$scope.spiele.push(tier1);
$scope.sounds.push('finde_esel.mp3');
var tier2 = {
id: 3,
bild: 'hahn.jpg',
sound1: 'sound_hahn.mp3',
antwort: ''
};
$scope.spiele.push(tier2);
$scope.sounds.push('finde_hahn.mp3');
var tier3 = {
id: 4,
bild: 'hund.jpg',
sound1: 'sound_hund.mp3',
sound2: ''
};
$scope.spiele.push(tier3);
$scope.sounds.push('finde_hund.mp3');
var tier4 = {
id: 5,
bild: 'katze.jpg',
sound1: 'sound_katze.mp3',
sound2: ''
};
$scope.spiele.push(tier4);
$scope.sounds.push('finde_katze.mp3');
var tier5 = {
id: 6,
bild: 'kuh.jpg',
sound1: 'sound_kuh.mp3',
sound2: ''
};
$scope.spiele.push(tier5);
$scope.sounds.push('finde_kuh.mp3');
var tier6 = {
id: 7,
bild: 'maus.jpg',
sound1: 'sound_maus.mp3',
sound2: ''
};
$scope.spiele.push(tier6);
$scope.sounds.push('finde_maus.mp3');
var tier7 = {
id: 8,
bild: 'schaf.jpg',
sound1: 'sound_schaf.mp3',
sound2: ''
};
$scope.spiele.push(tier7);
$scope.sounds.push('finde_schaf.mp3');
$scope.answer = function(src) {
if (src==$scope.randomid){
$timeout(function () {
$scope.spiele=shuffleArray($scope.spiele);
$timeout(function () {
$scope.spiele=shuffleArray($scope.spiele);
$timeout(function () {
$scope.spiele=shuffleArray($scope.spiele);
}, 500);
}, 500);
}, 500);
$scope.playwait('/android_asset/www/sounds/bravo.mp3')
}
else{
$scope.play('/android_asset/www/sounds/falsch.mp3');
$scope.error = true;
$timeout(function () {
$scope.error = false;
}, 1000);
}
}
var shuffleArray = function(array) {
var m = array.length, t, i;
// While there remain elements to shuffle
while (m) {
// Pick a remaining element…
i = Math.floor(Math.random() * m--);
// And swap it with the current element.
t = array[m];
array[m] = array[i];
array[i] = t;
}
return array;
}
function goto_newspiel() {
$scope.randomid = getRandomInt(1, 8);
$scope.play('/android_asset/www/sounds/' + $scope.sounds[$scope.randomid]);
}
function getRandomInt(min, max) {
var tmpInt=0;
min = Math.ceil(min);
max = Math.floor(max);
tmpInt = Math.floor(Math.random() * (max - min + 1)) + min;
if (tmpInt > max){
tmpInt=max;
}
if (tmpInt < min){
tmpInt=min;
}
return tmpInt;
}
$scope.play = function(src) {
var media = new Media(src, null, null);
$cordovaMedia.play(media);
}
$scope.playwait = function(src) {
var media = new Media(src, goto_newspiel, null);
$cordovaMedia.play(media);
}
goto_newspiel();
});

50
www/js/services.js Normal file
View 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;
}
};
});