Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(432)

Side by Side Diff: ui/accessibility/extensions/colorenhancer/src/popup.js

Issue 984833004: Add color enhancer as a chromium accessibility extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add docs and TODOs. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var site;
6
7
8 /**
9 * Update the popup controls based on settings for this site or the default.
10 */
11 function update() {
12 if (site) {
13 console.log('updated site ' + site + ' to ' +
14 getSiteDelta(site) + ',' + getSiteSeverity(site));
kevers 2015/03/10 14:07:51 Please wrap console.log output so that it only app
Peter Wen 2015/03/10 19:00:55 I changed it so we automatically enable logging fo
15 $('delta').value = getSiteDelta(site);
16 $('severity').value = getSiteSeverity(site);
17 } else {
18 console.log('updated site ' + site + ' to ' +
19 getDefaultDelta() + ',' + getDefaultSeverity());
20 $('delta').value = getDefaultDelta();
21 $('severity').value = getDefaultSeverity();
22 }
23
24 console.log('updated site ' + site + ' type ' + getDefaultType());
25 $('type').value = getDefaultType();
26
27 // TODO(mustaq): Finish simulate feature.
28 //console.log('updated site ' + site + ' simulate ' + getDefaultSimulate());
29 //$('simulate').checked = getDefaultSimulate();
30
31 chrome.extension.getBackgroundPage().updateTabs();
32 }
33
34
35 /**
36 * Callback for color rotation slider.
kevers 2015/03/10 14:07:51 @param here and below.
Peter Wen 2015/03/10 19:00:56 Done.
37 */
38 function onDeltaChange(value) {
39 console.log('delta changing to ' + value + ' for site ' + site);
40 if (site) {
41 setSiteDelta(site, value);
42 }
43 setDefaultDelta(value);
44 update();
45 }
46
47
48 /**
49 * Callback for severity slider.
50 */
51 function onSeverityChange(value) {
52 console.log('severity changing to ' + value + ' for site ' + site);
53 if (site) {
54 setSiteSeverity(site, value);
55 }
56 setDefaultSeverity(value);
57 update();
58 }
59
60
61 /**
62 * Callback for changing color deficiency type.
63 */
64 function onTypeChange(value) {
65 console.log('type changing to ' + value + ' for site ' + site);
66 setDefaultType(value);
67 update();
68 }
69
70
71 /**
72 * TODO(mustaq): JsDoc.
73 */
74 function onSimulateChange(value) {
75 console.log('simulate changing to ' + value + ' for site ' + site);
76 setDefaultSimulate(value);
77 update();
78 }
79
80
81 /**
82 * Reset all stored per-site and default values.
83 */
84 function onReset() {
85 console.log('resetting sites');
86 resetSiteDeltas();
87 resetSiteSeverities();
88 update();
89 }
90
91
92 /**
93 * Attach event handlers to controls and update the filter config values for the
94 * currently visible tab.
95 */
96 function initialize() {
97 $('delta').addEventListener('input', function() {
98 onDeltaChange(parseFloat(this.value));
99 });
100 $('severity').addEventListener('input', function() {
101 onSeverityChange(parseFloat(this.value));
102 });
103 $('type').addEventListener('input', function() {
104 onTypeChange(this.value);
105 });
106 // TODO(mustaq): Finish simulate feature.
kevers 2015/03/10 14:07:51 Do we want the simulate feature in the color enhan
Peter Wen 2015/03/10 19:00:55 Originally yes, but we thought it would be benefic
107 //$('simulate').addEventListener('change', function() {
108 // onSimulateChange(!this.checked);
109 //});
110 $('resetall').addEventListener('click', function() {
111 onReset();
112 });
113
114 chrome.windows.getLastFocused({'populate': true}, function(window) {
115 for (var i = 0; i < window.tabs.length; i++) {
116 var tab = window.tabs[i];
117 if (tab.active) {
118 site = siteFromUrl(tab.url);
119 console.log('active tab update ' + site);
120 update();
121 return;
122 }
123 }
124 site = 'unknown site';
125 update();
126 });
127 }
128
129 // TODO(wnwen): Use Promise instead, more reliable.
130 window.addEventListener('load', initialize, false);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698