Add a device selector on the launching page

This commit is contained in:
Gaël Métais
2015-04-27 15:40:46 +02:00
parent 9cad9ad2f9
commit cae23d61e2
8 changed files with 105 additions and 3 deletions
+3 -1
View File
@@ -12,8 +12,10 @@ var yltApp = angular.module('YellowLabTools', [
'resultsFactory',
'apiService',
'menuService',
'settingsService',
'gradeDirective',
'offendersDirectives'
'offendersDirectives',
'LocalStorageModule'
]);
yltApp.run(['$rootScope', '$location', function($rootScope, $location) {
+6 -1
View File
@@ -1,8 +1,13 @@
var indexCtrl = angular.module('indexCtrl', []);
indexCtrl.controller('IndexCtrl', ['$scope', '$location', 'API', function($scope, $location, API) {
indexCtrl.controller('IndexCtrl', ['$scope', 'Settings', 'API', function($scope, Settings, API) {
$scope.settings = Settings.getMergedSettings();
console.log($scope.settings);
$scope.launchTest = function() {
if ($scope.url) {
Settings.saveSettings($scope.settings);
API.launchTest($scope.url);
}
};
+23
View File
@@ -0,0 +1,23 @@
var settingsService = angular.module('settingsService', []);
settingsService.factory('Settings', ['localStorageService', function(localStorageService) {
return {
getMergedSettings: function() {
var defaultSettings = {
device: 'desktop'
};
var savedValues = localStorageService.get('settings');
return angular.extend(defaultSettings, savedValues);
},
saveSettings: function(settings) {
localStorageService.set('settings', settings);
}
};
}]);