Neues Initialrelease mit IonicMaterial

This commit is contained in:
Carsten Hilmer
2016-08-22 12:55:52 +02:00
parent 30a5df79aa
commit 45e482b14d
1249 changed files with 305225 additions and 68794 deletions

View File

@@ -1,195 +1,640 @@
// 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
var db;
angular.module('starter', ['ionic', 'ngCordova', 'jett.ionic.filter.bar','starter.controllers', 'starter.services','ionic-material'])
.run(function($ionicPlatform, $window, $ionicHistory, $database, $ionicPopup, $state, $window, $rootScope) {
$ionicPlatform.ready(function() {
//
//Welcome to app.js
//This is main application config of project. You can change a setting of :
// - Global Variable
// - Theme setting
// - Icon setting
// - Register View
// - Spinner setting
// - Custom style
//
//Global variable use for setting color, start page, message, oAuth key.
var db = null; //Use for SQLite database.
window.globalVariable = {
//custom color style variable
color: {
appPrimaryColor: "",
dropboxColor: "#017EE6",
facebookColor: "#3C5C99",
foursquareColor: "#F94777",
googlePlusColor: "#D73D32",
instagramColor: "#517FA4",
wordpressColor: "#0087BE"
},// End custom color style variable
startPage: {
url: "/app/contractlist",//Url of start page.
state: "app.contractlist"//State name of start page.
},
message: {
errorMessage: "Technical error please try again later." //Default error message.
},
oAuth: {
dropbox: "your_api_key",//Use for Dropbox API clientID.
facebook: "your_api_key",//Use for Facebook API appID.
foursquare: "your_api_key", //Use for Foursquare API clientID.
instagram: "your_api_key",//Use for Instagram API clientID.
googlePlus: "your_api_key",//Use for Google API clientID.
},
adMob: "your_api_key" //Use for AdMob API clientID.
};// End Global variable
$rootScope.storeinit=99;
$rootScope.adfree=0;
angular.module('starter', ['ionic','ngIOS9UIWebViewPatch', 'starter.controllers', 'starter.services', 'ngMaterial', 'ngMessages', 'ngCordova'])
.run(function ($ionicPlatform, $cordovaSQLite, $rootScope, $ionicHistory, $state, $mdDialog, $mdBottomSheet) {
//Create database table of contracts by using sqlite database.
//Table schema :
//Column Type Primary key
// id Integer Yes
// firstName Text No
// lastName Text No
// telephone Text No
// email Text No
// note Text No
// createDate DateTime No
// age Integer No
// isEnable Boolean No
function initialSQLite() {
db = window.cordova ? $cordovaSQLite.openDB("pokedex.db") : window.openDatabase("pokedex.db", "1.0", "IonicMaterialDesignDB", -1);
};
// End creating SQLite database table.
// Create custom defaultStyle.
function getDefaultStyle() {
return "" +
".material-background-nav-bar { " +
" background-color : " + appPrimaryColor + " !important; " +
" border-style : none;" +
"}" +
".md-primary-color {" +
" color : " + appPrimaryColor + " !important;" +
"}";
}// End create custom defaultStyle
// Create custom style for product view.
function getProductStyle() {
return "" +
".material-background-nav-bar { " +
" background-color : " + appPrimaryColor + " !important;" +
" border-style : none;" +
" background-image : url('img/background_cover_pixels.png') !important;" +
" background-size : initial !important;" +
"}" +
".md-primary-color {" +
" color : " + appPrimaryColor + " !important;" +
"}";
}// End create custom style for product view.
// Create custom style for contract us view.
function getContractUsStyle() {
return "" +
".material-background-nav-bar { " +
" background-color : transparent !important;" +
" border-style : none;" +
" background-image : none !important;" +
" background-position-y : 4px !important;" +
" background-size : initial !important;" +
"}" +
".md-primary-color {" +
" color : " + appPrimaryColor + " !important;" +
"}";
} // End create custom style for contract us view.
// Create custom style for Social Network view.
function getSocialNetworkStyle(socialColor) {
return "" +
".material-background-nav-bar {" +
" background : " + socialColor + " !important;" +
" border-style : none;" +
"} " +
"md-ink-bar {" +
" color : " + socialColor + " !important;" +
" background : " + socialColor + " !important;" +
"}" +
"md-tab-item {" +
" color : " + socialColor + " !important;" +
"}" +
" md-progress-circular.md-warn .md-inner .md-left .md-half-circle {" +
" border-left-color : " + socialColor + " !important;" +
"}" +
" md-progress-circular.md-warn .md-inner .md-left .md-half-circle, md-progress-circular.md-warn .md-inner .md-right .md-half-circle {" +
" border-top-color : " + socialColor + " !important;" +
"}" +
" md-progress-circular.md-warn .md-inner .md-gap {" +
" border-top-color : " + socialColor + " !important;" +
" border-bottom-color : " + socialColor + " !important;" +
"}" +
"md-progress-circular.md-warn .md-inner .md-right .md-half-circle {" +
" border-right-color : " + socialColor + " !important;" +
" }" +
".spinner-android {" +
" stroke : " + socialColor + " !important;" +
"}" +
".md-primary-color {" +
" color : " + socialColor + " !important;" +
"}" +
"a.md-button.md-primary, .md-button.md-primary {" +
" color : " + socialColor + " !important;" +
"}";
}// End create custom style for Social Network view.
$ionicPlatform.registerBackButtonAction(function(event) {
function initialRootScope() {
$rootScope.appPrimaryColor = appPrimaryColor;// Add value of appPrimaryColor to rootScope for use it to base color.
$rootScope.isAndroid = ionic.Platform.isAndroid();// Check platform of running device is android or not.
$rootScope.isIOS = ionic.Platform.isIOS();// Check platform of running device is ios or not.
};
// 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();
}
function hideActionControl() {
//For android if user tap hardware back button, Action and Dialog should be hide.
$mdBottomSheet.cancel();
$mdDialog.cancel();
};
// createCustomStyle will change a style of view while view changing.
// Parameter :
// stateName = name of state that going to change for add style of that page.
function createCustomStyle(stateName) {
var customStyle =
".material-background {" +
" background-color : " + appPrimaryColor + " !important;" +
" border-style : none;" +
"}" +
".spinner-android {" +
" stroke : " + appPrimaryColor + " !important;" +
"}";
switch (stateName) {
case "app.productList" :
case "app.productDetail":
case "app.productCheckout":
case "app.clothShop" :
case "app.catalog" :
customStyle += getProductStyle();
break;
case "app.dropboxLogin" :
case "app.dropboxProfile":
case "app.dropboxFeed" :
customStyle += getSocialNetworkStyle(window.globalVariable.color.dropboxColor);
break;
case "app.facebookLogin" :
case "app.facebookProfile":
case "app.facebookFeed" :
case "app.facebookFriendList":
customStyle += getSocialNetworkStyle(window.globalVariable.color.facebookColor);
break;
case "app.foursquareLogin" :
case "app.foursquareProfile":
case "app.foursquareFeed" :
customStyle += getSocialNetworkStyle(window.globalVariable.color.foursquareColor);
break;
case "app.googlePlusLogin" :
case "app.googlePlusProfile":
case "app.googlePlusFeed" :
customStyle += getSocialNetworkStyle(window.globalVariable.color.googlePlusColor);
break;
case "app.instagramLogin" :
case "app.instagramProfile":
case "app.instagramFeed" :
customStyle += getSocialNetworkStyle(window.globalVariable.color.instagramColor);
break;
case "app.wordpressLogin" :
case "app.wordpressFeed":
case "app.wordpressPost" :
customStyle += getSocialNetworkStyle(window.globalVariable.color.wordpressColor);
break;
case "app.contractUs":
customStyle += getContractUsStyle();
break;
default:
customStyle += getDefaultStyle();
break;
}
return customStyle;
}// End createCustomStyle
// Add custom style while initial application.
$rootScope.customStyle = createCustomStyle(window.globalVariable.startPage.state);
$ionicPlatform.ready(function () {
ionic.Platform.isFullScreen = true;
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
StatusBar.styleDefault();
}
// Copy the populated database to mobile device destination
//if (window.sqlitePlugin && window.cordova) {
if (window.sqlitePlugin && window.cordova) {
window.plugins.sqlDB.copy("pokedex.db", function (e) {
console.log(e);
});
}
initialSQLite();
initialRootScope();
//Checking if view is changing it will go to this function.
$rootScope.$on('$ionicView.beforeEnter', function () {
//hide Action Control for android back button.
hideActionControl();
// Add custom style ti view.
$rootScope.customStyle = createCustomStyle($ionicHistory.currentStateName());
});
});
} else {
$ionicHistory.clearCache();
$ionicHistory.nextViewOptions({
historyRoot: true
});
$state.go('tab.dash');
}
}, 100);
// 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);
}
// 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("pokedex.db", function (e) {
console.log(e);
});
}
/*
* Google-Stroe Initialisieren START
*/
function StoreInitsuccessHandler (result) {
$rootScope.storeinit=1;
inappbilling.getPurchases(purchasessuccess, purchasesfail);
}
function StoreIniterrorHandler (error) {
$rootScope.storeinit=0;
}
if((window.device && device.platform == "Android") && typeof inappbilling !== "undefined") {
inappbilling.init(StoreInitsuccessHandler, StoreIniterrorHandler, {showLog:true});
}
//FlateRate gekauft?
function purchasessuccess (result) {
var p = result[0];
if(p['productId'] == 'rosenflatrate') {
$rootScope.flatrate=1;
}
}
function purchasesfail (error) {
alert("ERROR: \r\n"+error );
}
/*
* Google-Stroe Initialisieren ENDE
*/
// Initialize database through $database service
db = $database.initDB();
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
})
.config(function($stateProvider, $urlRouterProvider,$ionicConfigProvider,$ionicFilterBarConfigProvider) {
// 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
if(ionic.Platform.isAndroid()){
$ionicConfigProvider.scrolling.jsScrolling(false);
}
$stateProvider
.state('init', {
url: '/init',
templateUrl: 'templates/init.html',
controller: 'InitCtrl'
})
.state('firstrun', {
url: '/first',
templateUrl: 'templates/firstrun.html',
controller: 'FirstRunCtrl'
})
.state('imagedownload', {
url: '/imagedownload',
templateUrl: 'templates/imagedownload.html',
controller: 'ImageDownloadCtrl'
})
// 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.chats', {
url: '/chats',
views: {
'tab-chats': {
templateUrl: 'templates/tab-chats.html',
controller: 'ChatsCtrl'
}
}
})
.state('tab.chat-detail', {
url: '/chats/:chatId',
views: {
'tab-chats': {
templateUrl: 'templates/chat-detail.html',
controller: 'ChatDetailCtrl'
}
}
})
.state('tab.account', {
url: '/account',
views: {
'tab-account': {
templateUrl: 'templates/tab-account.html',
controller: 'AccountCtrl'
}
}
});
.config(function ($ionicConfigProvider, $stateProvider, $urlRouterProvider, $mdThemingProvider, $mdIconProvider, $mdColorPalette, $mdIconProvider) {
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/init');
$ionicConfigProvider.tabs.position('bottom');
});
// Use for change ionic spinner to android pattern.
$ionicConfigProvider.spinner.icon("android");
$ionicConfigProvider.views.swipeBackEnabled(false);
// mdIconProvider is function of Angular Material.
// It use for reference .SVG file and improve performance loading.
$mdIconProvider
.icon('facebook', 'img/icons/facebook.svg')
.icon('twitter', 'img/icons/twitter.svg')
.icon('mail', 'img/icons/mail.svg')
.icon('message', 'img/icons/message.svg')
.icon('share-arrow', 'img/icons/share-arrow.svg')
.icon('more', 'img/icons/more_vert.svg');
//mdThemingProvider use for change theme color of Ionic Material Design Application.
/* You can select color from Material Color List configuration :
* red
* pink
* purple
* purple
* deep-purple
* indigo
* blue
* light-blue
* cyan
* teal
* green
* light-green
* lime
* yellow
* amber
* orange
* deep-orange
* brown
* grey
* blue-grey
*/
//Learn more about material color patten: https://www.materialpalette.com/
//Learn more about material theme: https://material.angularjs.org/latest/#/Theming/01_introduction
$mdThemingProvider
.theme('default')
.primaryPalette('purple')
.accentPalette('deep-purple');
appPrimaryColor = $mdColorPalette[$mdThemingProvider._THEMES.default.colors.primary.name]["500"]; //Use for get base color of theme.
//$stateProvider is using for add or edit HTML view to navigation bar.
//
//Schema :
//state_name(String) : Name of state to use in application.
//page_name(String) : Name of page to present at localhost url.
//cache(Bool) : Cache of view and controller default is true. Change to false if you want page reload when application navigate back to this view.
//html_file_path(String) : Path of html file.
//controller_name(String) : Name of Controller.
//
//Learn more about ionNavView at http://ionicframework.com/docs/api/directive/ionNavView/
//Learn more about AngularUI Router's at https://github.com/angular-ui/ui-router/wiki
$stateProvider
.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu/html/menu.html",
controller: 'menuCtrl'
})
.state('app.dashboard', {
url: "/dashboard",
params:{
isAnimated:false
},
views: {
'menuContent': {
templateUrl: "templates/material-user-interface/dashboard/html/dashboard.html",
controller: 'dashboardCtrl'
}
}
})
.state('app.dashboardSetting', {
url: "/dashboardSetting",
views: {
'menuContent': {
templateUrl: "templates/material-user-interface/dashboard/html/dashboard-setting.html",
controller: "dashboardSettingCtrl"
}
}
})
.state('app.contractlist', {
url: "/contractlist",
cache: false,
params:{
isAnimated:(ionic.Platform.isAndroid()==false)
},
views: {
'menuContent': {
templateUrl: "templates/application-storage/sqLite/html/contract-list.html",
controller: 'contractListCtrl'
}
}
})
.state('app.contractdetail', {
url: "/contractdetail",
params: {
contractdetail: null,
actionDelete: false
},
views: {
'menuContent': {
templateUrl: "templates/application-storage/sqLite/html/contract-detail.html",
controller: 'contractDetailCtrl'
}
}
})
.state('app.contractsetting', {
url: "/contractsetting",
cache: false,
views: {
'menuContent': {
templateUrl: "templates/application-storage/sqLite/html/contract-setting.html",
controller: 'contractSettingCtrl'
}
}
})
.state('app.imagedownload', {
url: "/imagedownload",
cache: false,
params:{
isAnimated:(ionic.Platform.isAndroid()==false)
},
views: {
'menuContent': {
templateUrl: "templates/imagedownload/html/imagedownload.html",
controller: 'imageDownloadCtrl'
}
}
})
.state('app.contractUs', {
url: "/contractUs",
views: {
'menuContent': {
templateUrl: "templates/share-application-content/email-message/html/contract-us.html",
controller: 'contractUsCtrl'
}
}
})
.state('app.deviceInformation', {
url: "/deviceInformation",
views: {
'menuContent': {
templateUrl: "templates/hardware-connect/device-information/html/device-information.html",
controller: 'deviceInformationCtrl'
}
}
})
.state('app.mobileContractList', {
url: "/mobileContractList",
cache: false,
views: {
'menuContent': {
templateUrl: "templates/hardware-connect/mobile-contract/html/mobile-contract-list.html",
controller: 'mobileContractListCtrl'
}
}
})
.state('app.mobileContractDetail', {
url: "/mobileContractDetail",
params: {
contractDetail: null,
actionDelete: false
},
views: {
'menuContent': {
templateUrl: "templates/hardware-connect/mobile-contract/html/mobile-contract-detail.html",
controller: 'mobileContractDetailCtrl'
}
}
})
.state('app.flashLight', {
url: "/flashLight",
views: {
'menuContent': {
templateUrl: "templates/hardware-connect/flash-light/html/flash-light.html",
controller: 'flashLightCtrl'
}
}
})
.state('app.vibration', {
url: "/vibration",
views: {
'menuContent': {
templateUrl: "templates/hardware-connect/vibration/html/vibration.html",
controller: 'vibrationCtrl'
}
}
})
.state('app.googleAdmob', {
url: "/googleAdmob",
views: {
'menuContent': {
templateUrl: "templates/advertising-application/googleAdmob/html/googleAdmob.html",
controller: 'googleAdmobCtrl'
}
}
})
.state('app.imagePicker', {
url: "/imagePicker",
cache: false,
views: {
'menuContent': {
templateUrl: "templates/hardware-connect/image-picker/html/image-picker.html",
controller: 'imagePickerCtrl'
}
}
})
.state('app.defaultUI', {
url: "/defaultUI",
cache: false,
views: {
'menuContent': {
templateUrl: "templates/material-user-interface/default-user-interface/html/default-user-interface.html",
controller: 'defaultUserInterfaceCtrl'
}
}
})
.state('app.tryApp', {
url: "/tryApp",
cache: false,
views: {
'menuContent': {
templateUrl: "templates/themes/try-app/html/try-app.html"
}
}
})
.state('app.tryAppNoBackBtn', {
url: "/tryAppNoBackBtn",
cache: false,
views: {
'menuContent': {
templateUrl: "templates/themes/try-app/html/try-app-no-back-btn.html"
}
}
})
.state('app.pricing', {
url: "/pricing",
views: {
'menuContent': {
templateUrl: "templates/themes/pricing/html/pricing.html"
}
}
})
.state('app.menuDashboard', {
url: "/menuDashboard",
views: {
'menuContent': {
templateUrl: "templates/themes/menu-dashboard/html/menu-dashboard.html",
controller: "menuDashboardCtrl"
}
}
})
.state('app.expense', {
url: "/expense",
params:{
isAnimated:true
},
views: {
'menuContent': {
templateUrl: "templates/themes/expense-dashboard/html/expense-dashboard.html",
controller: "expenseDashboardCtrl"
}
}
})
.state('app.expenseSetting', {
url: "/expenseSetting",
views: {
'menuContent': {
templateUrl: "templates/themes/expense-dashboard/html/expense-dashboard-setting.html",
controller: "expenseDashboardSettingCtrl"
}
}
})
.state('app.newsFeed', {
url: "/newsFeed",
views: {
'menuContent': {
templateUrl: "templates/themes/news-feed/html/news-feed.html"
}
}
})
.state('app.clothShop', {
url: "/clothShop",
views: {
'menuContent': {
templateUrl: "templates/themes/cloth-shop/html/cloth-shop.html"
}
}
})
.state('app.onlineCourse', {
url: "/onlineCourse",
views: {
'menuContent': {
templateUrl: "templates/themes/online-course/html/online-course.html"
}
}
})
.state('app.catalog', {
url: "/catalog",
views: {
'menuContent': {
templateUrl: "templates/themes/catalog/html/catalog.html",
controller: "catalogCtrl"
}
}
})
.state('app.locationFeed', {
url: "/locationFeed",
views: {
'menuContent': {
templateUrl: "templates/themes/location-feed/html/location-feed.html"
}
}
})
.state('app.cubeFeed', {
url: "/cubeFeed",
views: {
'menuContent': {
templateUrl: "templates/themes/cube-feed/html/cube-feed.html"
}
}
})
.state('app.restaurant', {
url: "/restaurant",
views: {
'menuContent': {
templateUrl: "templates/themes/restaurant/html/restaurant.html"
}
}
})
.state('app.singlePushNotification', {
url: "/singlePushNotification",
views: {
'menuContent': {
templateUrl: "templates/push-notification/single-push-notification/html/single-push-notification.html",
controller: "singlePushNotificationCtrl"
}
}
})
.state('app.schedulePushNotification', {
url: "/schedulePushNotification",
views: {
'menuContent': {
templateUrl: "templates/push-notification/schedule-push-notification/html/schedule-push-notification.html",
controller: "schedulePushNotificationCtrl"
}
}
})
.state('app.iosMapConnect', {
url: "/iosMapConnect",
views: {
'menuContent': {
templateUrl: "templates/map-and-location/ios-map-connect/html/ios-map-connect.html",
controller: "iosMapConnectCtrl"
}
}
})
.state('app.androidMapConnect', {
url: "/androidMapConnect",
views: {
'menuContent': {
templateUrl: "templates/map-and-location/android-map-connect/html/android-map-connect.html",
controller: "androidMapConnectCtrl"
}
}
});// End $stateProvider
//Use $urlRouterProvider.otherwise(Url);
$urlRouterProvider.otherwise(window.globalVariable.startPage.url);
});

View File

@@ -1,267 +1,2 @@
angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database, $timeout,$rootScope, $cordovaFileTransfer,$cordovaFile,$ionicLoading,$state,$filter,$ionicModal,$ionicPlatform,$location) {
$scope.resetdb = function() {
$database.setInitialRun(0);
}
// Open our new task modal
$scope.downloadImages = function() {
$state.go('imagedownload');
};
})
.controller('ChatsCtrl', function($scope,$ionicPopup,$http, $database,$window, $timeout,$rootScope, $cordovaFileTransfer,$cordovaFile,$ionicLoading,$state,$filter,$ionicModal,$ionicFilterBar) {
var filterBarInstance;
//View wird zum ersten mal geladen
$scope.$on( "$ionicView.loaded", function( scopes, states ) {
$scope.items=[];
});
$scope.$on( "$ionicView.enter", function( scopes, states ) {
if ($scope.items.length===0){
$scope.show($ionicLoading);
$timeout(fill_list, 1000);
}
});
$scope.showFilterBar = function () {
filterBarInstance = $ionicFilterBar.show({
items: $scope.items,
update: function (filteredItems, filterText) {
$scope.items = filteredItems;
if (filterText) {
console.log(filterText);
}
}
});
};
$scope.refreshItems = function () {
if (filterBarInstance) {
filterBarInstance();
filterBarInstance = null;
}
$timeout(function () {
fill_list();
$scope.$broadcast('scroll.refreshComplete');
}, 1000);
};
function fill_list(){
$database.getAllPokemon().then(function (result) {
if(result.length>0){
for(i=0;i<result.length;i++){
$scope.items.push(result[i]);
}
}
else {
$scope.items=[];
}
});
$scope.hide($ionicLoading);
}
$scope.show = function() {
$ionicLoading.show({
template: '<p>Lade...</p><ion-spinner></ion-spinner>'
});
};
$scope.hide = function(){
$ionicLoading.hide();
};
})
.controller('InitCtrl', function($scope, $ionicPlatform, $database,$state) {
$ionicPlatform.ready(function() {
$database.isInitialRun().then(function (result) {
if (result==1) {
$state.go('tab.dash');
}
else{
$state.go('firstrun');
}
});
});
})
.controller('FirstRunCtrl', function($scope,$ionicSlideBoxDelegate,$database,$state) {
$scope.options = {
loop: false,
effect: 'fade',
speed: 500,
}
$scope.$on("$ionicSlides.sliderInitialized", function(event, data){
// data.slider is the instance of Swiper
$scope.slider = data.slider;
});
$scope.$on("$ionicSlides.slideChangeStart", function(event, data){
console.log('Slide change is beginning');
});
$scope.$on("$ionicSlides.slideChangeEnd", function(event, data){
// note: the indexes are 0-based
$scope.activeIndex = data.activeIndex;
$scope.previousIndex = data.previousIndex;
});
$scope.firstruncomplete = function() {
$database.setInitialRun(1);
$state.go('tab.dash');
};
})
.controller('ImageDownloadCtrl', function($scope, $database, $timeout, $cordovaFileTransfer,$cordovaFile,$state,$ionicPlatform) {
$scope.progressval = 0;
$scope.currentfile = '';
$scope.progressprozent = 0;
$scope.DownloadisVisible=true;
$scope.AbbrechenisVisible=false;
$scope.startdownloadtimer=false;
// Open our new task modal
$scope.downloadImages = function() {
$scope.startdownloadtimer=true;
$scope.DownloadisVisible=false;
$scope.AbbrechenisVisible=true;
//$ionicPlatform.ready(function() {
//$scope.taskModal.show();
var baseurl = "http://assets.pokemon.com/assets/cms2/img/pokedex/full/";
var url="";
var filename="";
var targetPath = "";
var downloadprogress = 0;
var pokedexid=1;
var downloadinprogress=false;
//Ordner erstellen auf SD-Karte
$cordovaFile.createDir(cordova.file.externalRootDirectory, "PokedexHelperBilder", false)
.then(function (success) {
// success
console.log('Erfolg bei Ordnererstellung. ' + success);
}, function (error) {
// error
console.log('Error bei Ordnererstellung. ' + error);
});
function downloadimage(){
downloadinprogress=true;
filename=pokedexid + ".png";
if (filename.length==5){
filename='00' + filename;
}
if (filename.length==6){
filename='0' + filename;
}
url=baseurl;
url=encodeURI(url + filename);
targetPath = cordova.file.externalRootDirectory + "/PokedexHelperBilder/" + filename;
//Bild Download
$cordovaFileTransfer.download(url, targetPath, {Connection: "close"}, true).then(function (result) {
$scope.currentfile=filename;
$database.setPokemonImage(targetPath,pokedexid);
console.log(filename + ' heruntergeladen.' + result);
pokedexid=pokedexid + 1;
console.log(result);
downloadinprogress=false;
}, function (error) {
console.log('Error. ' + error.code + ' ' + error.constant);
}, function (progress) {
//downloadprogress=(progress.loaded / progress.total) * 100;
$scope.progressprozent = Math.round(pokedexid / 721 * 100);
$scope.progressval = pokedexid;
$scope.currentfile=filename; //+ downloadprogress;
});
console.log(pokedexid);
if (pokedexid<721){
downloadtimer();
}
else{
$scope.progressprozent = 'Download abgeschlossen! ' + $scope.progressprozent;
$scope.DownloadisVisible=true;
$scope.AbbrechenisVisible=false;
}
if ( $scope.startdownloadtimer==false){
$scope.progressprozent = 'Download Abgebrochen! ' + $scope.progressprozent;
}
}
//});
function downloadtimer(){
if ($scope.startdownloadtimer==true){
$timeout(function(){
if (downloadinprogress==false){
downloadimage();
console.log("downinprogress ist false");
}else{
console.log("downinprogress ist true");
downloadtimer();
}
}, 500);
}
}
downloadtimer();
};
$scope.downloadabbrechen = function() {
$scope.DownloadisVisible=true;
$scope.AbbrechenisVisible=false;
$scope.startdownloadtimer=false;
};
})
.controller('Dummy', function($scope) {
});
var appControllers = angular.module('starter.controllers', []); // Use for all controller of application.
var appServices = angular.module('starter.services', []);// Use for all service of application.

File diff suppressed because one or more lines are too long

View File

@@ -1,117 +0,0 @@
angular.module('starter.services', [])
.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({name:"pokedex.db", iosDatabaseLocation:'default'});
} else {
self.db = window.openDatabase('pokedex.db','1','my',800*1024); // only available when WebSQL is available in Browser
}
console.log('Database opened');
return self.db;
},
setBuys: function(itemName,itemBild,itemBildtext,itemKaufdatum,itemappimgpath,itemappimgpublicpath) {
query="INSERT INTO buys (Name, Bild, Bildtext, Kaufdatum, appimgpath, appimgpublicpath) VALUES (?,?,?,?,?,?);";
return $cordovaSQLite.execute(self.db,query,[itemName,itemBild,itemBildtext,itemKaufdatum,itemappimgpath,itemappimgpublicpath]).
then(function(result) {
console.log("Gespeichert");
query=null;
}, function(error) {
console.error(error);
});
},
deleteBuy: function(id) {
query="DELETE FROM buys WHERE ID = ?;";
return $cordovaSQLite.execute(self.db,query,[id]).
then(function(result) {
console.log("Gelöscht");
query=null;
}, function(error) {
console.error(error);
});
},
isInitialRun: function(){
var InitilaRun;
query="SELECT InitialRun FROM InitialRun";
return $cordovaSQLite.execute(self.db,query).
then(function(result) {
for(j=0;j<result.rows.length;j++){
InitilaRun=result.rows.item(j).InitialRun;
}
console.log('isInitialRun aufgerufen wert : ' + InitilaRun);
return InitilaRun;
},function(e){
console.error(e);
return e;
});
},
setInitialRun: function(InitilaRunBool) {
query="UPDATE InitialRun Set InitialRun = ?;";
return $cordovaSQLite.execute(self.db,query,[InitilaRunBool]).
then(function(result) {
console.log("Update erfolge auf " + InitilaRunBool);
query=null;
}, function(error) {
console.error(error);
});
},
setPokemonImage: function(Image,Pokedexid) {
query="UPDATE tblPokemon Set POKEMONIMAGE = ? WHERE POKEDEXID = ?;";
return $cordovaSQLite.execute(self.db,query,[Image,Pokedexid]).
then(function(result) {
console.log("Update erfolge auf " + Pokedexid + ' mit ' + Image);
query=null;
}, function(error) {
console.error(error);
});
},
getAllPokemon: function(){
var ArrayQ=[];
query="SELECT * FROM tblPokemon order by POKEDEXID ASC";
return $cordovaSQLite.execute(self.db,query).
then(function(result) {
for(j=0;j<result.rows.length;j++){
var List={};
List.ID=result.rows.item(j).ID;
List.POKEDEXID=result.rows.item(j).POKEDEXID;
List.POKEMONNAME=result.rows.item(j).POKEMONNAME;
List.POKEMONTYPA=result.rows.item(j).POKEMONTYPA;
List.POKEMONTYPB=result.rows.item(j).POKEMONTYPB;
List.POKEMONIMAGE=result.rows.item(j).POKEMONIMAGE;
ArrayQ.push(List);
}
//console.log(ArrayQ);
return ArrayQ;
},function(e){
console.error(error);
return error;
});
}
};
}]);

View File

@@ -0,0 +1,34 @@
//This is Controller for Dialog box.
appControllers.controller('DialogController', function ($scope, $mdDialog, displayOption) {
//This variable for display wording of dialog.
//object schema:
//displayOption: {
// title: "Confirm to remove all data?",
// content: "All data will remove from local storage.",
// ok: "Confirm",
// cancel: "Close"
//}
$scope.displayOption = displayOption;
$scope.cancel = function () {
$mdDialog.cancel(); //close dialog.
};
$scope.ok = function () {
$mdDialog.hide();//hide dialog.
};
});// End Controller for Dialog box.
//Controller for Toast.
appControllers.controller('toastController', function ($scope, displayOption) {
//this variable for display wording of toast.
//object schema:
// displayOption: {
// title: "Data Saved !"
//}
$scope.displayOption = displayOption;
});// End Controller for Toast.

View File

@@ -0,0 +1,25 @@
//Directive numbersOnly :
//Use for change input to have ability accept only number.
//Example : <input ng-model="contract.age" numbers-only type="tel">
//
appControllers.directive('numbersOnly', function () {
return {
require: 'ngModel',
link: function (scope, element, attr, ngModelCtrl) {
function fromUser(text) {
if (text) {
var transformedInput = text.replace(/[^0-9]/g, '');
if (transformedInput !== text) {
ngModelCtrl.$setViewValue(transformedInput);
ngModelCtrl.$render();
}
return transformedInput;
}
return undefined;
}
ngModelCtrl.$parsers.push(fromUser);
}
};
});// End Directive numbersOnly.

33
www/js/shared/filter.js Normal file
View File

@@ -0,0 +1,33 @@
//Filter epochToDate :
//Use for convert epoch date format to default date format.
//Example :
//<p>{{item.createdAt |epochToDate | date:"short"}}</p>
appControllers.filter('epochToDate', function ($filter) {
return function (input) {
return new Date(Date(input));
};
});// End Filter epochToDate.
//Filter numberSuffix :
//Use for convert number to have suffix 1,000 to 1K.
//Example :
//{{item.likes.summary.total_count | numberSuffix}}
//
appControllers.filter('numberSuffix', function () {
return function (input) {
var exp;
var suffixes = ['k', 'M', 'G', 'T', 'P', 'E'];
if (window.isNaN(input)) {
return 0;
}
if (input < 1000) {
return input;
}
exp = Math.floor(Math.log(input) / Math.log(1000));
return (input / Math.pow(1000, exp)).toFixed(1) + suffixes[exp - 1];
}
});// End Filter numberSuffix.