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

Side by Side Diff: chrome/browser/resources/translate_internals/translate_internals.js

Issue 1903593002: Allows to manually change the stored permanent country in Variations from the translate-internals d… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: UI polishing Created 4 years, 8 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function() { 5 (function() {
6 'use strict'; 6 'use strict';
7 7
8 cr.define('cr.translateInternals', function() { 8 cr.define('cr.translateInternals', function() {
9 9
10 var detectionLogs_ = null; 10 var detectionLogs_ = null;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 245
246 var text = formatLanguageCode(language); 246 var text = formatLanguageCode(language);
247 if (details['alpha_languages'].indexOf(language) != -1) 247 if (details['alpha_languages'].indexOf(language) != -1)
248 text += ' - alpha'; 248 text += ' - alpha';
249 li.innerText = text; 249 li.innerText = text;
250 250
251 ul.appendChild(li); 251 ul.appendChild(li);
252 } 252 }
253 } 253 }
254 254
255
Alexei Svitkine (slow) 2016/04/20 20:30:23 Nit: Remove extra line.
hamelphi 2016/04/20 21:39:46 Done.
256 /**
257 * Handles the message of 'countryUpdated' from the browser.
258 *
259 * @param {Object} details the object containing the country
260 * information.
261 */
262 function onCountryUpdated(details) {
263 var p;
264 p = $('country-override');
265
266 p.innerHTML = '';
267
268 if ('country' in details) {
269 var country = details['country'];
270
271 var input = document.createElement('textarea');
272 // FIXME: what is the max length of a country code?
Alexei Svitkine (slow) 2016/04/20 20:30:23 We can probably just not set this.
hamelphi 2016/04/20 21:39:46 Done.
273 input.maxLength = '20';
274 input.cols = '20';
275 input.rows = '1';
276 input.value = country;
277
278 var button = document.createElement('button');
279 button.textContent = 'update';
280 button.classList.add('override_country');
281 button.addEventListener('click', function() {
282 chrome.send('overrideCountry', [input.value]);
283 }, false);
284 p.appendChild(input);
285 p.appendChild(document.createElement('br'));
286 p.appendChild(button);
287
288 if ('update' in details && details['update']) {
289 var div1 = document.createElement('div');
290 div1.textContent = 'Permanent stored country updated.';
291 var div2 = document.createElement('div');
292 div2.textContent = ('You will need to restart your browser ' +
293 'for the changes to take effect.');
294 p.appendChild(div1);
295 p.appendChild(div2);
296 }
297 } else {
298 p.textContent = 'Could not load country info from Variations.';
299 }
300 }
301
255 /** 302 /**
256 * Addes '0's to |number| as a string. |width| is length of the string 303 * Adds '0's to |number| as a string. |width| is length of the string
257 * including '0's. 304 * including '0's.
258 * 305 *
259 * @param {string} number The number to be converted into a string. 306 * @param {string} number The number to be converted into a string.
260 * @param {number} width The width of the returned string. 307 * @param {number} width The width of the returned string.
261 * @return {string} The formatted string. 308 * @return {string} The formatted string.
262 */ 309 */
263 function padWithZeros(number, width) { 310 function padWithZeros(number, width) {
264 var numberStr = number.toString(); 311 var numberStr = number.toString();
265 var restWidth = width - numberStr.length; 312 var restWidth = width - numberStr.length;
266 if (restWidth <= 0) 313 if (restWidth <= 0)
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 switch (message) { 445 switch (message) {
399 case 'languageDetectionInfoAdded': 446 case 'languageDetectionInfoAdded':
400 onLanguageDetectionInfoAdded(details); 447 onLanguageDetectionInfoAdded(details);
401 break; 448 break;
402 case 'prefsUpdated': 449 case 'prefsUpdated':
403 onPrefsUpdated(details); 450 onPrefsUpdated(details);
404 break; 451 break;
405 case 'supportedLanguagesUpdated': 452 case 'supportedLanguagesUpdated':
406 onSupportedLanguagesUpdated(details); 453 onSupportedLanguagesUpdated(details);
407 break; 454 break;
455 case 'countryUpdated':
456 onCountryUpdated(details);
457 break;
408 case 'translateErrorDetailsAdded': 458 case 'translateErrorDetailsAdded':
409 onTranslateErrorDetailsAdded(details); 459 onTranslateErrorDetailsAdded(details);
410 break; 460 break;
411 case 'translateEventDetailsAdded': 461 case 'translateEventDetailsAdded':
412 onTranslateEventDetailsAdded(details); 462 onTranslateEventDetailsAdded(details);
413 break; 463 break;
414 default: 464 default:
415 console.error('Unknown message:', message); 465 console.error('Unknown message:', message);
416 break; 466 break;
417 } 467 }
(...skipping 28 matching lines...) Expand all
446 /** 496 /**
447 * The entry point of the UI. 497 * The entry point of the UI.
448 */ 498 */
449 function main() { 499 function main() {
450 cr.doc.addEventListener('DOMContentLoaded', 500 cr.doc.addEventListener('DOMContentLoaded',
451 cr.translateInternals.initialize); 501 cr.translateInternals.initialize);
452 } 502 }
453 503
454 main(); 504 main();
455 })(); 505 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698