aboutsummaryrefslogtreecommitdiffhomepage
path: root/share
diff options
context:
space:
mode:
authorGravatar Siteshwar Vashisht <siteshwar@gmail.com>2013-08-18 19:48:32 +0530
committerGravatar Siteshwar Vashisht <siteshwar@gmail.com>2013-10-17 19:47:03 +0530
commitb8deb49007d9ef4fe2ab06fda6c97c2941de685f (patch)
tree85acb7e18ef7e92dfd9c7252b0369fa7c372fb6e /share
parent6b34f19396533c8a6d0a4f34c0e0e0bf87f0536b (diff)
Fixed code for changing prompt
Diffstat (limited to 'share')
-rw-r--r--share/tools/web_config/partials/prompt.html10
-rw-r--r--share/tools/web_config/webconfig.js24
2 files changed, 27 insertions, 7 deletions
diff --git a/share/tools/web_config/partials/prompt.html b/share/tools/web_config/partials/prompt.html
index 05aaceca..d962a428 100644
--- a/share/tools/web_config/partials/prompt.html
+++ b/share/tools/web_config/partials/prompt.html
@@ -1,19 +1,19 @@
<div id="master_detail_table" style="display: table;">
<div id="master">
<div ng-repeat="prompt in samplePrompts">
- <div id="master_{{prompt.name}}" ng-class="{'master_element': true, 'selected_master_elem': selectedPrompt == prompt}" ng-style="selectedPrompt == prompt && {color: '#6666ff'} || {color: '#aaaaaa' }" ng-click="selectPrompt(prompt)">
- <span ng-class="{master_element_text: selectedPrompt == prompt}" ng-style="selectedPrompt == prompt && {'font-size': '13pt', 'border-bottom-color': rgb(0, 6, 111)} || {'font-size': '13pt'}">{{ prompt.name }}</span>
+ <div id="master_{{prompt.name}}" ng-class="{'master_element': true, 'selected_master_elem': selectedPrompt == prompt}" ng-style="prompt.name=='Current' && {color: '#6666ff'} || {color: '#aaaaaa' }" ng-click="selectPrompt(prompt)">
+ <span ng-class="{master_element_text: selectedPrompt == prompt}" ng-style="prompt.name=='Current' && {'font-size': '13pt', 'border-bottom-color': rgb(0, 6, 111) } || {'font-size': '13pt'}">{{ prompt.name }}</span>
</div>
</div>
</div>
<div id="detail">
<div id="detail_prompt" style="display: block;">
<div class="prompt_demo">
- <div class="prompt_demo_text" style="font-size: 15pt;">
+ <div class="prompt_demo_text" style="font-size: {{ demoTextFontSize }};" ng-bind-html-unsafe="demoText">
</div>
</div>
- <div style="text-align: right">
- <span class="prompt_save_button" onclick="save_current_prompt()" style="display: none;"> use prompt </span>
+ <div style="text-align: right" ng-show="selectedPrompt.name != 'Current'">
+ <span class="prompt_save_button" ng-click="setNewPrompt(selectedPrompt)"> use prompt </span>
</div>
<div class="prompt_function">
<div class="prompt_function_text">
diff --git a/share/tools/web_config/webconfig.js b/share/tools/web_config/webconfig.js
index 9e046ea2..7e6a1f24 100644
--- a/share/tools/web_config/webconfig.js
+++ b/share/tools/web_config/webconfig.js
@@ -94,9 +94,9 @@ webconfig.controller("colorsController", function($scope, $http) {
webconfig.controller("promptController", function($scope, $http) {
$scope.selectedPrompt = null;
- $scope.fetchCurrentPrompt = function(currentPrompt) {
+ $scope.fetchCurrentPrompt = function(currenttPrompt) {
$http.get("/current_prompt/").success(function(data, status, headers, config) {
- currentPrompt.function = data.function;
+ currenttPrompt.function = data.function;
})};
$scope.fetchSamplePrompts= function() {
@@ -106,14 +106,28 @@ webconfig.controller("promptController", function($scope, $http) {
$scope.selectPrompt($scope.samplePrompts[0]);
}
})};
+ $scope.fetchSamplePrompt = function(selectedPrompt) {
+ console.log("Fetcing sample prompt");
+ $http.post("/get_sample_prompt/","what=" + encodeURIComponent(selectedPrompt.function), { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).success(function(data, status, headers, config) {
+ console.log("Data is " + JSON.stringify(data[0]));
+ $scope.demoText= data[0].demo;
+ $scope.demoTextFontSize = data[0].font_size;
+ console.log("Demo text is " + $scope.demoText);
+ })};
$scope.selectPrompt = function(promptt) {
$scope.selectedPrompt= promptt;
if ($scope.selectedPrompt.name == "Current") {
$scope.fetchCurrentPrompt($scope.selectedPrompt);
}
+ $scope.fetchSamplePrompt($scope.selectedPrompt);
}
+ $scope.setNewPrompt = function(selectedPrompt) {
+ console.log("Set new prompt" + selectedPrompt);
+ $http.post("/set_prompt/","what=" + encodeURIComponent(selectedPrompt.function), { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).success(function(data, status, headers, config){
+ console.log("Data is " + JSON.stringify(data));
+ })};
$scope.fetchSamplePrompts();
});
@@ -154,5 +168,11 @@ webconfig.controller("historyController", function($scope, $http) {
$scope.historyItems = data;
})};
+ $scope.deleteHistoryItem = function(item) {
+ index = $scope.historyItems.indexOf(item);
+ $http.post("/delete_history_item/","what=" + encodeURIComponent(item), { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).success(function(data, status, headers, config) {
+ $scope.historyItems.splice(index, 1);
+ })};
+
$scope.fetchHistory();
});