From bc9e2266be5323a314e7a587ec7f7c4428aef656 Mon Sep 17 00:00:00 2001 From: Siteshwar Vashisht Date: Sun, 20 Oct 2013 14:28:40 +0530 Subject: [PATCH] Added current scheme in list of color schemes --- share/tools/web_config/js/colorutils.js | 2 ++ share/tools/web_config/js/controllers.js | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/share/tools/web_config/js/colorutils.js b/share/tools/web_config/js/colorutils.js index 941e94523..2328e11fc 100644 --- a/share/tools/web_config/js/colorutils.js +++ b/share/tools/web_config/js/colorutils.js @@ -1,3 +1,5 @@ +/* TODO: Write an angularjs service to wrap these methods */ + term_256_colors = [ //247 "ffd7d7", "d7afaf", diff --git a/share/tools/web_config/js/controllers.js b/share/tools/web_config/js/controllers.js index 5337bed35..a85d5677c 100644 --- a/share/tools/web_config/js/controllers.js +++ b/share/tools/web_config/js/controllers.js @@ -28,7 +28,7 @@ controllers.controller("colorsController", function($scope, $http) { $scope.getColorArraysArray = function() { var result = null; - if ($scope.selectedColorScheme.colors.length > 0) + if ( $scope.selectedColorScheme.colors && $scope.selectedColorScheme.colors.length > 0) result = get_colors_as_nested_array($scope.selectedColorScheme.colors, 32); else result = get_colors_as_nested_array(term_256_colors, 32); @@ -50,7 +50,16 @@ controllers.controller("colorsController", function($scope, $http) { for (var i=0; i < additional_color_schemes.length; i++) $scope.colorSchemes.push(additional_color_schemes[i]) - $scope.changeSelectedColorScheme($scope.colorSchemes[0]); + + $scope.getCurrentTheme = function() { + $http.get("/colors/").success(function(data, status, headers, config) { + var currentScheme = { "name": "Current", "colors":[], "preferred_background": "" }; + for (var i in data) { + currentScheme[data[i].name] = data[i].color; + } + $scope.colorSchemes.splice(0, 0, currentScheme); + $scope.changeSelectedColorScheme(currentScheme); + })}; $scope.setTheme = function() { var settingNames = ["autosuggestion", "command", "param", "redirection", "comment", "error", "quote", "end"]; @@ -61,6 +70,8 @@ controllers.controller("colorsController", function($scope, $http) { }) } }; + + $scope.getCurrentTheme(); }); controllers.controller("promptController", function($scope, $http) { @@ -170,9 +181,9 @@ controllers.controller("historyController", function($scope, $http, $timeout) { return; } - var to_load = $scope.remainingItems.splice(0, 100); - for (i in to_load) { - $scope.historyItems.push(to_load[i]); + var toLoad = $scope.remainingItems.splice(0, 100); + for (i in toLoad) { + $scope.historyItems.push(toLoad[i]); } $scope.loadingText = "Loading " + $scope.historyItems.length + "/" + $scope.historySize;