- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / subscribe_page_action / common.js
1 // Copyright (c) 2010 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 // Whether we can modify the list of readers.
6 var storageEnabled = window.localStorage != null;
7
8 /**
9 *  Returns the default list of feed readers.
10 */
11 function defaultReaderList() {
12   // This is the default list, unless replaced by what was saved previously.
13   return [
14     { 'url': 'http://www.bloglines.com/login?r=/sub/%s',
15       'description': 'Bloglines'
16     },
17     { 'url': 'http://add.my.yahoo.com/rss?url=%s',
18       'description': 'My Yahoo'
19     }
20   ];
21 }
22
23 /**
24 * Check to see if the current item is set as default reader.
25 */
26 function isDefaultReader(url) {
27   defaultReader = window.localStorage.defaultReader ?
28                       window.localStorage.defaultReader : "";
29   return url == defaultReader;
30 }
31
32 /**
33 * Find an element with |id| and replace the text of it with i18n message with
34 * |msg| key.
35 */
36 function i18nReplaceImpl(id, msg, attribute) {
37   var element = document.getElementById(id);
38   if (element) {
39     if (attribute)
40       element.setAttribute(attribute, chrome.i18n.getMessage(msg));
41     else
42       element.innerText = chrome.i18n.getMessage(msg);
43   }
44 }
45
46 /**
47 * Same as i18nReplaceImpl but provided for convenience for elements that have
48 * the same id as the i18n message id.
49 */
50 function i18nReplace(msg) {
51   i18nReplaceImpl(msg, msg, '');
52 }