diff --git a/config.xml b/config.xml index 37f931e4b43f0d572c07cfb898706167ece30249..98d932d787169c65e9f43d0ba85800d5e98d4a54 100644 --- a/config.xml +++ b/config.xml @@ -1,96 +1,99 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<?xml version='1.0' encoding='utf-8'?> <widget id="com.jeremyguiselin.betskills" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> - <name>Betskills</name> - <description> + <name>Betskills</name> + <description> Betskills app to see predictions of football and tennis games. </description> - <author email="contact@betskills.com" href=""> + <author email="contact@betskills.com" href=""> Betskills team </author> - <content src="index.html"/> - <access origin="*"/> - <preference name="webviewbounce" value="false"/> - <preference name="UIWebViewBounce" value="false"/> - <preference name="DisallowOverscroll" value="true"/> - <preference name="SplashScreenDelay" value="3000"/> - <preference name="android-minSdkVersion" value="16"/> - <preference name="BackupWebStorage" value="none"/> - <preference name="SplashScreen" value="screen"/> - <preference name="xwalkVersion" value="18+"/> - <preference name="xwalkCommandLine" value="--disable-pull-to-refresh-effect"/> - <preference name="xwalkMode" value="embedded"/> - <preference name="xwalkMultipleApk" value="true"/> - <feature name="StatusBar"> - <param name="ios-package" onload="true" value="CDVStatusBar"/> - </feature> - <plugin name="cordova-plugin-console" spec="~1.0.3"/> - <plugin name="cordova-plugin-whitelist" spec="~1.2.2"/> - <plugin name="cordova-plugin-splashscreen" spec="~3.2.2"/> - <plugin name="cordova-plugin-statusbar" spec="~2.1.3"/> - <plugin name="ionic-plugin-keyboard" spec="~2.2.1"/> - <plugin name="cordova-plugin-firebase" spec="~0.1.18"/> - <plugin name="cordova-plugin-device" spec="~1.1.3"/> - <plugin name="cordova-plugin-file-transfer" spec="~1.6.1"/> - <plugin name="cordova-plugin-inapppurchase" spec="~1.1.0"/> - <platform name="ios"> - <preference name="FadeSplashScreen" value="false"/> - <preference name="FadeSplashScreenDuration" value="1000"/> - <preference name="iosPersistentFileLocation" value="Library"/> - <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640"/> - <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750"/> - <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242"/> - <splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208"/> - <splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048"/> - <splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024"/> - <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536"/> - <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768"/> - <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640"/> - <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320"/> - <icon height="57" src="resources/ios/icon/icon.png" width="57"/> - <icon height="114" src="resources/ios/icon/icon@2x.png" width="114"/> - <icon height="40" src="resources/ios/icon/icon-40.png" width="40"/> - <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80"/> - <icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120"/> - <icon height="50" src="resources/ios/icon/icon-50.png" width="50"/> - <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100"/> - <icon height="60" src="resources/ios/icon/icon-60.png" width="60"/> - <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120"/> - <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180"/> - <icon height="72" src="resources/ios/icon/icon-72.png" width="72"/> - <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144"/> - <icon height="76" src="resources/ios/icon/icon-76.png" width="76"/> - <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152"/> - <icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167"/> - <icon height="29" src="resources/ios/icon/icon-small.png" width="29"/> - <icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58"/> - <icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87"/> - </platform> - <platform name="android"> - <preference name="android-minSdkVersion" value="22"/> - <preference name="android-targetSdkVersion" value="22"/> - <preference name="SplashMaintainAspectRatio" value="true"/> - <preference name="SplashShowOnlyFirstTime" value="false"/> - <preference name="AndroidPersistentFileLocation" value="Compatibility"/> - <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png"/> - <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png"/> - <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png"/> - <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png"/> - <splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png"/> - <splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png"/> - <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png"/> - <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png"/> - <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png"/> - <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png"/> - <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png"/> - <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png"/> - <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png"/> - <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png"/> - <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png"/> - <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png"/> - <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png"/> - <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png"/> - <access origin="cdvfile://*"/> - <allow-intent href="cdvfile://*"/> - </platform> - <icon src="resources/android/icon/drawable-xhdpi-icon.png"/> -</widget> \ No newline at end of file + <content src="index.html" /> + <access origin="*" /> + <preference name="webviewbounce" value="false" /> + <preference name="UIWebViewBounce" value="false" /> + <preference name="DisallowOverscroll" value="true" /> + <preference name="SplashScreenDelay" value="3000" /> + <preference name="android-minSdkVersion" value="16" /> + <preference name="BackupWebStorage" value="none" /> + <preference name="SplashScreen" value="screen" /> + <preference name="xwalkVersion" value="18+" /> + <preference name="xwalkCommandLine" value="--disable-pull-to-refresh-effect" /> + <preference name="xwalkMode" value="embedded" /> + <preference name="xwalkMultipleApk" value="true" /> + <feature name="StatusBar"> + <param name="ios-package" onload="true" value="CDVStatusBar" /> + </feature> + <plugin name="cordova-plugin-console" spec="~1.0.3" /> + <plugin name="cordova-plugin-whitelist" spec="~1.2.2" /> + <plugin name="cordova-plugin-splashscreen" spec="~3.2.2" /> + <plugin name="cordova-plugin-statusbar" spec="~2.1.3" /> + <plugin name="ionic-plugin-keyboard" spec="~2.2.1" /> + <plugin name="cordova-plugin-firebase" spec="~0.1.18" /> + <plugin name="cordova-plugin-device" spec="~1.1.3" /> + <plugin name="cordova-plugin-file-transfer" spec="~1.6.1" /> + <plugin name="cordova-plugin-inapppurchase" spec="~1.1.0" /> + <platform name="ios"> + <preference name="FadeSplashScreen" value="false" /> + <preference name="FadeSplashScreenDuration" value="1000" /> + <preference name="iosPersistentFileLocation" value="Library" /> + <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" /> + <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" /> + <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" /> + <splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" /> + <splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" /> + <splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" /> + <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" /> + <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" /> + <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" /> + <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" /> + <icon height="57" src="resources/ios/icon/icon.png" width="57" /> + <icon height="114" src="resources/ios/icon/icon@2x.png" width="114" /> + <icon height="40" src="resources/ios/icon/icon-40.png" width="40" /> + <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" /> + <icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" /> + <icon height="50" src="resources/ios/icon/icon-50.png" width="50" /> + <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" /> + <icon height="60" src="resources/ios/icon/icon-60.png" width="60" /> + <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" /> + <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" /> + <icon height="72" src="resources/ios/icon/icon-72.png" width="72" /> + <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" /> + <icon height="76" src="resources/ios/icon/icon-76.png" width="76" /> + <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" /> + <icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" /> + <icon height="29" src="resources/ios/icon/icon-small.png" width="29" /> + <icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" /> + <icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" /> + </platform> + <platform name="android"> + <preference name="android-minSdkVersion" value="22" /> + <preference name="android-targetSdkVersion" value="22" /> + <preference name="SplashMaintainAspectRatio" value="true" /> + <preference name="SplashShowOnlyFirstTime" value="false" /> + <preference name="AndroidPersistentFileLocation" value="Compatibility" /> + <preference name="android-build-tool" value="gradle" /> + <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" /> + <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" /> + <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" /> + <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" /> + <splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" /> + <splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" /> + <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" /> + <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" /> + <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" /> + <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" /> + <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" /> + <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" /> + <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" /> + <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" /> + <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" /> + <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" /> + <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" /> + <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" /> + <access origin="cdvfile://*" /> + <allow-intent href="cdvfile://*" /> + </platform> + <icon src="resources/android/icon/drawable-xhdpi-icon.png" /> + <plugin name="cordova-plugin-x-toast" spec="https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git" /> + <plugin name="cordova-plugin-badge" spec="https://github.com/katzer/cordova-plugin-badge.git" /> +</widget> diff --git a/scss/pack.scss b/scss/pack.scss index cf25a6d905a65e2f4a66217e916a8a2a3c260d3b..bcae264a174d0d1fdcb1dec888e8b995e2ee0baa 100644 --- a/scss/pack.scss +++ b/scss/pack.scss @@ -34,12 +34,37 @@ display: flex; justify-content: center; align-items: center; + flex-direction: column; .title { color: $whiteColor; font-family: "OspDin"; font-size: 35px; + padding-bottom: 8px; + } + + .subtitle { + font-family: "SF-UI-Display"; + font-weight: 700; + color: $whiteColor; + font-size: 10px; + margin: -4px; + + &-upper { + text-transform: uppercase; + } } } } } + +.locked { + opacity: 0.7; + + .lock { + position: absolute; + left: 5px; + top: 5px; + width: 25px; + } +} diff --git a/scss/prediction.scss b/scss/prediction.scss index 14b50d7f55aea820f8b3976fd25b9554589bc3f0..085b00a308534e61bb686b64b4260f3c1bfaef3d 100644 --- a/scss/prediction.scss +++ b/scss/prediction.scss @@ -1,79 +1,137 @@ .prediction { border-top: none; background-color: transparent; - display: flex; - flex-direction: row; + border-left: none; + border-right: none; - .center { - text-align: center; - width: 50%; + .overview { + display: flex; + flex-direction: row; - .figures { - padding-top: 10px; - display: flex; - .figure { - width: 33%; - color: #7F7F7E; - font-family: "SF-UI-Display"; - font-size: 12px; + .center { + text-align: center; + width: 50%; + + .figures { + padding-top: 10px; + display: flex; + .figure { + width: 33%; + color: #7F7F7E; + font-family: "SF-UI-Display"; + font-size: 12px; + + &:first-of-type { + } + + &:last-of-type { + } + } + } + + .prediction_figures { + padding-top: 10px; + display: flex; + .prediction_figure { + width: 33%; + color: #7F7F7E; + font-family: "OspDin"; + font-size: 30px; + color: #000; - &:first-of-type { + .percent { + font-family: "Impact"; + font-size: 28px; + } } - &:last-of-type { + .main-prediction { + color: $greenColor; + } + + .second-prediction { + color: $orangeColor; } } - } - .prediction_figures { - padding-top: 10px; - display: flex; - .prediction_figure { - width: 33%; - color: #7F7F7E; - font-family: "OspDin"; - font-size: 30px; - color: #000; + .title { + font-family: 'OspDin'; + font-size: 22px; - .percent { - font-family: "Impact"; - font-size: 28px; + .date { + font-family: "SF-UI-Display"; + font-weight: 100; + font-size: 14px; } } + } - .main-prediction { - color: $greenColor; + .team { + width: 25%; + text-align: center; + + img { + width: 70%; + height: auto; } - .second-prediction { - color: $orangeColor; + .name { + font-family: "OspDin"; + font-size: 16px; + white-space: normal; } } + } + + .score-container { + display: flex; + flex-direction: row; + padding-top: 5px; - .title { - font-family: 'OspDin'; - font-size: 22px; + .tick { + width: 25%; + text-align: center; - .date { - font-family: "SF-UI-Display"; - font-weight: 100; - font-size: 14px; + img { + width: 25%; } } - } - .team { - width: 25%; - text-align: center; + .score { + text-align: center; + width: 50%; + } + + .football-score { + display: flex; + flex-direction: row; - img { - width: 70%; - height: auto; + .element { + width: 33%; + .score-element { + background-color: $greyColor; + font-family: "SF-UI-Display"; + padding: 1px 5px; + border-radius: 5px; + } + } } - .name { - font-family: "OspDin"; - font-size: 16px; + .tennis-score { + display: flex; + justify-content: center; + flex-direction: row; + + .set { + padding: 0 5px; + .score-element { + background-color: $greyColor; + font-family: "SF-UI-Display"; + padding: 1px 5px; + border-radius: 5px; + margin: 0 1px; + } + } } } } diff --git a/scss/variables.scss b/scss/variables.scss index e0b2688a2b3485c8e0858e2f49040b6e5a1f3b6e..db4fc633209eeb03de77155a8fe0ea3adbfa73f1 100644 --- a/scss/variables.scss +++ b/scss/variables.scss @@ -31,3 +31,4 @@ $darkGreyColor: #4c4b4b; $whiteColor: #fff; $greenColor: #15AC72; $orangeColor: #eb7c38; +$greyColor: #c7c6c6; diff --git a/www/img/green-tick.png b/www/img/green-tick.png new file mode 100644 index 0000000000000000000000000000000000000000..96d6c701363775c0e10211b327862b536b833e42 Binary files /dev/null and b/www/img/green-tick.png differ diff --git a/www/img/lock.png b/www/img/lock.png new file mode 100644 index 0000000000000000000000000000000000000000..be31a8743346087a0cf104bf0a49f053a25eb599 Binary files /dev/null and b/www/img/lock.png differ diff --git a/www/img/orange-tick.png b/www/img/orange-tick.png new file mode 100644 index 0000000000000000000000000000000000000000..5dd6ec5b04fba44dc253982ebe0d36ca042c5b5f Binary files /dev/null and b/www/img/orange-tick.png differ diff --git a/www/img/red-cross.png b/www/img/red-cross.png new file mode 100644 index 0000000000000000000000000000000000000000..ed29728dc7f65b8e54dba42036f5b6350a5f11ef Binary files /dev/null and b/www/img/red-cross.png differ diff --git a/www/index.html b/www/index.html index 04fa1072e90113fdfe2f0a3988994a3ee37dc391..866b14433f05ea6bf97689e7ef1567ac08f6ac78 100644 --- a/www/index.html +++ b/www/index.html @@ -19,6 +19,24 @@ <script src="dist/project.js"></script> </head> <body ng-app="starter"> + <script> + window.fbAsyncInit = function() { + FB.init({ + appId : '1830882820517971', + xfbml : true, + version : 'v2.8' + }); + FB.AppEvents.logPageView(); + }; + + (function(d, s, id){ + var js, fjs = d.getElementsByTagName(s)[0]; + if (d.getElementById(id)) {return;} + js = d.createElement(s); js.id = id; + js.src = "//connect.facebook.net/en_US/sdk.js"; + fjs.parentNode.insertBefore(js, fjs); + }(document, 'script', 'facebook-jssdk')); + </script> <ion-nav-bar></ion-nav-bar> <ion-nav-view name="content"></ion-nav-view> </body> diff --git a/www/js/app.js b/www/js/app.js index 7616ebc7485635ca55138c9d5e034b89b8787012..6aa0f46da71f6335e40f7663c363f09ac6bd4ec9 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -22,7 +22,8 @@ "daily_predictions": "Daily Predictions", "all_predictions": "All the predictions", "unlock": "Unlock", - "predictions": "Predictions" + "predictions": "Predictions", + "games": "Game(s)" }, "fr": { "info_title_1": "Comment resté connecté ?", @@ -44,7 +45,8 @@ "daily_predictions": "Prédictions gratuites", "all_predictions": "Toutes les prédictions", "unlock": "Dévérouiller", - "predictions": "Prédictions" + "predictions": "Prédictions", + "games": "Match(s)" } }; diff --git a/www/js/pages/football-details/controller.js b/www/js/pages/football-details/controller.js new file mode 100644 index 0000000000000000000000000000000000000000..4c7d5d6cadcaddfe37dba6d6bd9c520f5c097144 --- /dev/null +++ b/www/js/pages/football-details/controller.js @@ -0,0 +1,173 @@ +/** + * Created by jeremyguiselin on 01/12/2017. + */ + + (function (angular) { + "use strict"; + + /** + * @ngdoc controller + * @name FootballDetailsController + * + * @description + * Controller for all the predictions of a football league. + * + * @ngInject + */ + function FootballDetailsController( + $ionicHistory, + $scope, + $http, + $ionicLoading, + constantConfig + ) { + /** + Scope variables + **/ + + $scope.locale = window.navigator.language.split('-')[0]; + $scope.pictureUrl = constantConfig.imgUrl; + + /** + End Scope variables + **/ + + /** + Static variables + **/ + + var self = this; + var deregistrationCallbackList = []; + + /** + End Static variables + **/ + + /** + Scope functions + **/ + + $scope.myGoBack = function() { + $ionicHistory.goBack(); + }; + + + $scope.getPredictionClass = function (prediction, value) { + var percentages = [ + prediction.prediction_win_first, + prediction.prediction_win_second, + prediction.prediction_draw + ]; + percentages.sort(); + if (percentages.indexOf(value) === 2) { + return "main-prediction"; + } else if (percentages.indexOf(value) === 1) { + return "second-prediction"; + } + + return ''; + } + + $scope.getTick = function (prediction) { + var percentages = [ + prediction.prediction_win_first, + prediction.prediction_win_second, + prediction.prediction_draw + ]; + + var ticks = [ + 'red-cross', + 'orange-tick', + 'green-tick' + ]; + + percentages.sort(); + var predictionWin = null; + if (prediction.winner) { + if (prediction.winner === -1) { + predictionWin = prediction.prediction_draw; + } else { + predictionWin = prediction.prediction_win_second; + if (prediction.first_team.id === prediction.winner) { + predictionWin = prediction.prediction_win_first; + } + } + return ticks[percentages.indexOf(predictionWin)]; + } + + return null; + } + + $scope.parseDate = function (date) { + var locale = window.navigator.language.split('-')[0]; + date = date.split(' ')[0].split('-'); + + if (locale === "fr") { + return date[2] + '/' + date[1] + '/' + date[0].substr(-2); + } else { + return date[1] + '/' + date[2] + '/' + date[0].substr(-2); + } + } + + /** + End Scope functions + **/ + + /** + Controller functions + **/ + + this.parseScore = function (prediction) { + if (prediction.score) { + var score = prediction.score; + var scores = score.split('-'); + prediction.score = scores; + } + } + + /** + End Controller functions + **/ + + /** + Scope events + **/ + + $scope.$on('$destroy', function(){ + angular.forEach(deregistrationCallbackList, function(deregistrationCallback){ + deregistrationCallback(); + }); + deregistrationCallbackList = null; + }); + + + $scope.$on("$ionicView.beforeEnter", function(event, data){ + var leagueId = data.stateParams.leagueId; + + $ionicLoading.show({ + template: '<ion-spinner icon="ripple" class="spinner-assertive"></ion-spinner>', + animation: 'fade-in', + showBackdrop: true, + }); + + $http.get(constantConfig.apiUrl + 'predictions/league/' + leagueId).then(function (data) { + var predictions = []; + data['data'].forEach(function (prediction) { + self.parseScore(prediction); + predictions.push(prediction); + }); + $scope.predictions = predictions; + $scope.league = data['data'][0]['league']; + }).finally(function () { + $ionicLoading.hide(); + }); + }); + + /** + End Scope event + **/ + } + + angular.module('starter') + .controller('FootballDetailsController', FootballDetailsController); + })(angular); diff --git a/www/js/pages/football-details/routes.js b/www/js/pages/football-details/routes.js new file mode 100644 index 0000000000000000000000000000000000000000..8bb6cc25b9fccce1c9afd48e7e81a52824a0ad07 --- /dev/null +++ b/www/js/pages/football-details/routes.js @@ -0,0 +1,28 @@ +/** + * Created by jeremyguiselin on 01/12/2017. + */ + +(function (angular) { + "use strict"; + + /** + * @ngInject + */ + + function setupRoutes($stateProvider) { + $stateProvider + .state('football-details', { + url: '/football/details/:leagueId', + views: { + 'content': { + templateUrl: 'partials/league-details.html', + controller: 'FootballDetailsController as footballDetailsCtrl' + } + } + }); + } + + angular.module('starter') + .config(setupRoutes); + +})(angular); diff --git a/www/js/pages/football/controller.js b/www/js/pages/football/controller.js index 45761810e2a54b2d9c607ab638b80827d2a6ec4d..8d91dda761952975c3a57c6685cbad4d548e886b 100644 --- a/www/js/pages/football/controller.js +++ b/www/js/pages/football/controller.js @@ -27,6 +27,8 @@ **/ var deregistrationCallbackList = []; + var self = this; + var uuid = window.cordova ? ionic.Platform.device().uuid : '7f4a6a40e5c87157'; /** End Controller variables @@ -40,6 +42,7 @@ $scope.locale = window.navigator.language.split('-')[0]; $scope.selected = []; $scope.price = 0; + $scope.predictionsNumber = 0; /** End Scope variables @@ -49,8 +52,15 @@ Scope functions **/ - $scope.isBought = function (id) { - return null; + $scope.isBought = function (league) { + return league.device_status === 'unlock'; + } + + $scope.getLink = function (league) { + if (league.device_status === 'unlock') { + return 'details({leagueId:' + league.id + '})'; + } + return '-'; } $scope.isSelected = function (league) { @@ -58,11 +68,13 @@ } $scope.select = function (league) { - if ($scope.isBought(league.id) === null) { + if (!$scope.isBought(league.id)) { if ($scope.selected.indexOf(league) !== -1) { $scope.selected.splice($scope.selected.indexOf(league), 1); + $scope.predictionsNumber -= league.predictions_number; } else { $scope.selected.push(league); + $scope.predictionsNumber += league.predictions_number; } } } @@ -79,10 +91,67 @@ return ''; } + $scope.getTick = function (prediction) { + var percentages = [ + prediction.prediction_win_first, + prediction.prediction_win_second, + prediction.prediction_draw + ]; + + var ticks = [ + 'red-cross', + 'orange-tick', + 'green-tick' + ]; + + percentages.sort(); + var predictionWin = null; + if (prediction.winner) { + if (prediction.winner === -1) { + predictionWin = prediction.prediction_draw; + } else { + predictionWin = prediction.prediction_win_second; + if (prediction.first_team.id === prediction.winner) { + predictionWin = prediction.prediction_win_first; + } + } + return ticks[percentages.indexOf(predictionWin)]; + } + + return null; + } + + $scope.parseDate = function (date) { + var locale = window.navigator.language.split('-')[0]; + date = date.split(' ')[0].split('-'); + + if (locale === "fr") { + return date[2] + '/' + date[1] + '/' + date[0].substr(-2); + } else { + return date[1] + '/' + date[2] + '/' + date[0].substr(-2); + } + } + /** End Scope functions **/ + /** + Controller functions + **/ + + this.parseScore = function (prediction) { + if (prediction.score) { + var score = prediction.score; + var scores = score.split('-'); + prediction.score = scores; + } + } + + /** + End Controller functions + **/ + /** Scope events **/ @@ -110,10 +179,15 @@ }); var freePredictionsPromise = $http.get(constantConfig.apiUrl + 'predictions/football/free'); - var leaguesPromise = $http.get(constantConfig.apiUrl + 'leagues/football'); + var leaguesPromise = $http.get(constantConfig.apiUrl + uuid + '/leagues/football'); $q.all([freePredictionsPromise, leaguesPromise]).then(function (data) { - $scope.freePredictions = data[0]['data']; + var freePredictions = []; + data[0]['data'].forEach(function (prediction) { + self.parseScore(prediction); + freePredictions.push(prediction); + }); + $scope.freePredictions = freePredictions; $scope.leagues = data[1]['data']; }).finally(function () { $ionicLoading.hide(); diff --git a/www/js/pages/tennis-details/controller.js b/www/js/pages/tennis-details/controller.js new file mode 100644 index 0000000000000000000000000000000000000000..6ce218af862c55d07d2bd85e71489dcdf72224c6 --- /dev/null +++ b/www/js/pages/tennis-details/controller.js @@ -0,0 +1,171 @@ +/** + * Created by jeremyguiselin on 01/12/2017. + */ + + (function (angular) { + "use strict"; + + /** + * @ngdoc controller + * @name TennisDetailsController + * + * @description + * Controller for all the predictions of a tennis league. + * + * @ngInject + */ + function TennisDetailsController( + $ionicHistory, + $scope, + $http, + $ionicLoading, + constantConfig + ) { + + /** + Scope variables + **/ + + $scope.locale = window.navigator.language.split('-')[0]; + $scope.pictureUrl = constantConfig.imgUrl; + + /** + End Scope variables + **/ + + /** + Static variables + **/ + + var self = this; + var deregistrationCallbackList = []; + + /** + End Static variables + **/ + + /** + Scope functions + **/ + + $scope.myGoBack = function() { + $ionicHistory.goBack(); + }; + + + $scope.getPredictionClass = function (prediction, value) { + var percentages = [ + prediction.prediction_win_first, + prediction.prediction_win_second + ]; + percentages.sort(); + if (percentages.indexOf(value) === 1) { + return "main-prediction"; + } + + return ''; + } + + $scope.getTick = function (prediction) { + var percentages = [ + prediction.prediction_win_first, + prediction.prediction_win_second + ]; + + var ticks = [ + 'red-cross', + 'green-tick' + ]; + + percentages.sort(); + var predictionWin = null; + if (prediction.winner) { + predictionWin = prediction.prediction_win_second; + if (prediction.first_team.id === prediction.winner) { + predictionWin = prediction.prediction_win_first; + } + return ticks[percentages.indexOf(predictionWin)]; + } + + return null; + } + + $scope.parseDate = function (date) { + var locale = window.navigator.language.split('-')[0]; + date = date.split(' ')[0].split('-'); + + if (locale === "fr") { + return date[2] + '/' + date[1] + '/' + date[0].substr(-2); + } else { + return date[1] + '/' + date[2] + '/' + date[0].substr(-2); + } + } + + /** + End Scope functions + **/ + + /** + Controller functions + **/ + + this.parseScore = function (prediction) { + if (prediction.score) { + var score = prediction.score; + var sets = score.split(' '); + var scores = []; + sets.forEach(function (set) { + scores.push(set.split('-')); + }) + prediction.score = scores; + } + } + + /** + End Controller functions + **/ + + /** + Scope events + **/ + + $scope.$on('$destroy', function(){ + angular.forEach(deregistrationCallbackList, function(deregistrationCallback){ + deregistrationCallback(); + }); + deregistrationCallbackList = null; + }); + + + $scope.$on("$ionicView.beforeEnter", function(event, data){ + var leagueId = data.stateParams.leagueId; + + $ionicLoading.show({ + template: '<ion-spinner icon="ripple" class="spinner-assertive"></ion-spinner>', + animation: 'fade-in', + showBackdrop: true, + }); + + $http.get(constantConfig.apiUrl + 'predictions/league/' + leagueId).then(function (data) { + var predictions = []; + data['data'].forEach(function (prediction) { + self.parseScore(prediction); + predictions.push(prediction); + }); + $scope.predictions = predictions; + $scope.league = data['data'][0]['league']; + }).finally(function () { + $ionicLoading.hide(); + }); + }); + + /** + End Scope event + **/ + + + } + + angular.module('starter') + .controller('TennisDetailsController', TennisDetailsController); + })(angular); diff --git a/www/js/pages/tennis-details/routes.js b/www/js/pages/tennis-details/routes.js new file mode 100644 index 0000000000000000000000000000000000000000..836f83e701e40913354d3d4d8891b74e72b03d6b --- /dev/null +++ b/www/js/pages/tennis-details/routes.js @@ -0,0 +1,28 @@ +/** + * Created by jeremyguiselin on 01/12/2017. + */ + +(function (angular) { + "use strict"; + + /** + * @ngInject + */ + + function setupRoutes($stateProvider) { + $stateProvider + .state('tennis-details', { + url: '/tennis/details/:leagueId', + views: { + 'content': { + templateUrl: 'partials/league-details.html', + controller: 'TennisDetailsController as tennisDetailsCtrl' + } + } + }); + } + + angular.module('starter') + .config(setupRoutes); + +})(angular); diff --git a/www/js/pages/tennis/controller.js b/www/js/pages/tennis/controller.js index 8732fd9d81bfb0195bae72829fa7578674d9fc90..1890599730e36344d9c45972810451f9bbfbaeb1 100644 --- a/www/js/pages/tennis/controller.js +++ b/www/js/pages/tennis/controller.js @@ -30,6 +30,8 @@ var deregistrationCallbackList = []; var products = PurchaseService.getProducts('tennis'); + var self = this; + var uuid = window.cordova ? ionic.Platform.device().uuid : '7f4a6a40e5c87157'; /** End Controller variables @@ -53,8 +55,16 @@ Scope functions **/ - $scope.isBought = function (id) { - return null; + $scope.isBought = function (league) { + return league.device_status === 'unlock'; + } + + $scope.getLink = function (league) { + if (league.device_status === 'unlock') { + return 'tennis-details({leagueId:' + league.id + '})'; + } + + return '-'; } $scope.isSelected = function (league) { @@ -62,13 +72,13 @@ } $scope.select = function (league) { - if ($scope.isBought(league.id) === null) { + if (!$scope.isBought(league.id)) { if ($scope.selected.indexOf(league) !== -1) { $scope.selected.splice($scope.selected.indexOf(league), 1); - $scope.predictionsNumber -= league.predictionsNumber; + $scope.predictionsNumber -= league.predictions_number; } else { $scope.selected.push(league); - $scope.predictionsNumber += league.predictionsNumber; + $scope.predictionsNumber += league.predictions_number; } } } @@ -76,8 +86,7 @@ $scope.getPredictionClass = function (prediction, value) { var percentages = [ prediction.prediction_win_first, - prediction.prediction_win_second, - prediction.prediction_draw + prediction.prediction_win_second ]; percentages.sort(); if (percentages.indexOf(value) === 1) { @@ -96,10 +105,65 @@ } } + $scope.getTick = function (prediction) { + var percentages = [ + prediction.prediction_win_first, + prediction.prediction_win_second + ]; + + var ticks = [ + 'red-cross', + 'green-tick' + ]; + + percentages.sort(); + var predictionWin = null; + if (prediction.winner) { + predictionWin = prediction.prediction_win_second; + if (prediction.first_team.id === prediction.winner) { + predictionWin = prediction.prediction_win_first; + } + return ticks[percentages.indexOf(predictionWin)]; + } + + return null; + } + + $scope.parseDate = function (date) { + var locale = window.navigator.language.split('-')[0]; + date = date.split(' ')[0].split('-'); + + if (locale === "fr") { + return date[2] + '/' + date[1] + '/' + date[0].substr(-2); + } else { + return date[1] + '/' + date[2] + '/' + date[0].substr(-2); + } + } + /** End Scope functions **/ + /** + Controller functions + **/ + + this.parseScore = function (prediction) { + if (prediction.score) { + var score = prediction.score; + var sets = score.split(' '); + var scores = []; + sets.forEach(function (set) { + scores.push(set.split('-')); + }) + prediction.score = scores; + } + } + + /** + End Controller functions + **/ + /** Scope events **/ @@ -127,10 +191,15 @@ }); var freePredictionsPromise = $http.get(constantConfig.apiUrl + 'predictions/tennis/free'); - var leaguesPromise = $http.get(constantConfig.apiUrl + 'leagues/tennis'); + var leaguesPromise = $http.get(constantConfig.apiUrl + uuid + '/leagues/tennis'); $q.all([freePredictionsPromise, leaguesPromise]).then(function (data) { - $scope.freePredictions = data[0]['data']; + var freePredictions = []; + data[0]['data'].forEach(function (prediction) { + self.parseScore(prediction); + freePredictions.push(prediction); + }); + $scope.freePredictions = freePredictions; $scope.leagues = data[1]['data']; }).finally(function () { $ionicLoading.hide(); diff --git a/www/partials/league-details.html b/www/partials/league-details.html new file mode 100644 index 0000000000000000000000000000000000000000..51647846575595842ebf9501437c7725ce87c2ff --- /dev/null +++ b/www/partials/league-details.html @@ -0,0 +1,12 @@ +<ion-view cache-view="true" can-swipe-back="true" title="{{league.sport}}"> + <ion-nav-buttons side="left"> + <img class="info-icon" ng-click="myGoBack()" src="img/back.png" alt=""> + </ion-nav-buttons> + <ion-content class="has-header info"> + <h3 class="title-section">{{league.name}}</h3> + <ion-list> + <ion-item ng-include src="'partials/prediction.html'" ng-repeat="freePrediction in predictions track by freePrediction.id" class="prediction"> + </ion-item> + </ion-list> + </ion-content> +</ion-view> diff --git a/www/partials/prediction.html b/www/partials/prediction.html index 918ad32c83726be7657ad478c75b7fdd9ca2080a..b7555dad483e30109ff66c85fa7fe7d48f6de99b 100644 --- a/www/partials/prediction.html +++ b/www/partials/prediction.html @@ -1,36 +1,46 @@ -<div class="team"> - <img ion-img-cache ng-src="{{pictureUrl}}team/{{freePrediction.first_team.picture}}" /> - <div class="name">{{freePrediction.first_team.name}}</div> -</div> -<div class="center"> - <div class="title"> - {{ freePrediction.league.name }} - <span class="date">{{locale === 'fr' ? (freePrediction.date | date: "dd/MM/yy") : (notification.date | date: "MM/dd/yy")}}</span> - </div> - <div class="figures"> - <div class="figure">1</div> - <div class="figure">{{freePrediction.league.sport === "football" ? 'N' : '' }}</div> - <div class="figure">2</div> +<div class="overview"> + <div class="team"> + <img ion-img-cache ng-src="{{pictureUrl}}team/{{freePrediction.first_team.picture}}" /> + <div class="name">{{freePrediction.first_team.name}}</div> </div> - <div class="prediction_figures"> - <div - class="prediction_figure" - ng-class="getPredictionClass(freePrediction, freePrediction.prediction_win_first)"> - {{freePrediction.prediction_win_first}}<span class="percent">%</span> + <div class="center"> + <div class="title"> + {{ freePrediction.league.name }} - <span class="date">{{locale === 'fr' ? (freePrediction.date | date: "dd/MM/yy") : (notification.date | date: "MM/dd/yy")}}</span> </div> - <div - class="prediction_figure" - ng-class="getPredictionClass(freePrediction, freePrediction.prediction_draw)" - style="{{!freePrediction.prediction_draw ? 'opacity: 0' : ''}}"> - {{freePrediction.prediction_draw}}<span class="percent">%</span> + <div class="figures"> + <div class="figure">1</div> + <div class="figure">{{freePrediction.league.sport === "football" ? 'N' : '' }}</div> + <div class="figure">2</div> </div> - <div - class="prediction_figure" - ng-class="getPredictionClass(freePrediction, freePrediction.prediction_win_second)"> - {{freePrediction.prediction_win_second}}<span class="percent">%</span> + <div class="prediction_figures"> + <div + class="prediction_figure" + ng-class="getPredictionClass(freePrediction, freePrediction.prediction_win_first)"> + {{freePrediction.prediction_win_first}}<span class="percent">%</span> + </div> + <div + class="prediction_figure" + ng-class="getPredictionClass(freePrediction, freePrediction.prediction_draw)" + style="{{!freePrediction.prediction_draw ? 'opacity: 0' : ''}}"> + {{freePrediction.prediction_draw}}<span class="percent">%</span> + </div> + <div + class="prediction_figure" + ng-class="getPredictionClass(freePrediction, freePrediction.prediction_win_second)"> + {{freePrediction.prediction_win_second}}<span class="percent">%</span> + </div> </div> </div> + <div class="team"> + <img ion-img-cache ng-src="{{pictureUrl}}team/{{freePrediction.second_team.picture}}" /> + <div class="name">{{freePrediction.second_team.name}}</div> + </div> </div> -<div class="team"> - <img ion-img-cache ng-src="{{pictureUrl}}team/{{freePrediction.second_team.picture}}" /> - <div class="name">{{freePrediction.second_team.name}}</div> +<div class="score-container" ng-hide="freePrediction.score === null"> + <div class="tick"></div> + <div ng-if="freePrediction.league.sport === 'football'" ng-include="'/partials/score/football.html'" class="score football-score"></div> + <div ng-if="freePrediction.league.sport === 'tennis'" ng-include="'/partials/score/tennis.html'" class="score tennis-score"></div> + <div class="tick"> + <img src="img/{{getTick(freePrediction)}}.png" alt=""> + </div> </div> diff --git a/www/partials/score/football.html b/www/partials/score/football.html new file mode 100644 index 0000000000000000000000000000000000000000..901ad19b7b002129b970845f89421af13570742f --- /dev/null +++ b/www/partials/score/football.html @@ -0,0 +1,7 @@ +<div class="element"> + <span class="score-element">{{freePrediction.score[0]}}</span> +</div> +<div class="element">-</div> +<div class="element"> + <span class="score-element">{{freePrediction.score[1]}}</span> +</div> diff --git a/www/partials/score/tennis.html b/www/partials/score/tennis.html new file mode 100644 index 0000000000000000000000000000000000000000..a8ffc579e6663378ffb159d70be0d57d63dd8cf6 --- /dev/null +++ b/www/partials/score/tennis.html @@ -0,0 +1,3 @@ +<div class="set" ng-repeat="set in freePrediction.score track by set"> + <span class="score-element" ng-repeat="score in set track by score">{{score}}</span> +</div> diff --git a/www/partials/sport-index.html b/www/partials/sport-index.html index 463fd42299f809565aa4b9984bf30de2cbf9603b..9292be77bbada79265e7af011a45b0bac1ce30b5 100644 --- a/www/partials/sport-index.html +++ b/www/partials/sport-index.html @@ -5,19 +5,26 @@ </ion-list> <h3 class="title-section" translate="all_predictions"></h3> <ion-list> - <ion-item ng-repeat="league in leagues track by league.id" class="pack-item"> - <a ng-click="select(league)"> + <ion-item ng-repeat="league in leagues track by league.id" class="pack-item" ng-class="!isBought(league) ? 'locked' : ''"> + <a ui-sref="{{getLink(league)}}" ng-click="!isBought(league) ? select(league) : ''"> + <img src="img/lock.png" ng-hide="isBought(league)" class="lock" alt=""> <div class="selected-pack" ng-class="{active : isSelected(league)}" > <img src="img/white-check.png" /> </div> <div ion-img-cache-bg class="pack-background" ng-style="{'background-image':'url({{pictureUrl}}league/{{league.picture}})'}"> <div class="title">{{league.name}}</div> + <div class="subtitle subtitle-upper">{{league.predictions_number}} {{"games" | translate}}</div> + <div class="subtitle"> + {{parseDate(league.min_date)}} + - + {{parseDate(league.max_date)}} + </div> </div> </a> </ion-item> </ion-list> <div class="unlock" ng-class="{active : selected.length > 0}"> <a class="content" ng-click="buyContent()"> - {{"unlock" | translate}} {{predictions}} {{"predictions" | translate}} <span>{{price / 100}}€</span> + {{"unlock" | translate}} {{predictionsNumber}} {{"predictions" | translate}} <span>{{price / 100}}€</span> </div> </div>