home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / AIMP2 / aimp_2.61.583.exe / $TEMP / YandexPackSetup.msi / filB29E1DA6B9A8A7E8960D5369106DEA8A < prev    next >
Text File  |  2010-07-12  |  4KB  |  107 lines

  1. var YaFeeds = {
  2.   nsIYa: Components.classes["@yandex.ru/yasearch;1"].getService(Components.interfaces.nsIYaSearch).wrappedJSObject,
  3.   
  4.   get _list() {
  5.     return document.getElementsByTagName("menulist")[0];
  6.   },
  7.   
  8.   init: function() {
  9.     this.stringBundleSet = document.getElementById("yasearch-string-bundle-feeds");
  10.     
  11.     this.loader = document.getElementById("yasearch-feeds-select-group").cloneNode(true);
  12.     
  13.     this.enableAcceptButton();
  14.     
  15.     this.nsIYa.getFeedsGroups(this.refreshFeedsGroups);
  16.     
  17.     var items = document.getElementById("yasearch-feed-label-name-replace");
  18.     window.arguments[0].id = "yasearch-feed-label-name-replace";
  19.     this.nsIYa.DOMUtils.replaceNode(window.arguments[0], items);
  20.     
  21.     document.getElementById("yasearch-feed-label-page").value = window.arguments[1];
  22.   },
  23.   
  24.   enableAcceptButton: function() {
  25.     document.documentElement.getButton("accept").disabled =
  26.         !!(document.getElementById("yasearch-feeds-select-group").disabled &&
  27.            document.getElementById("yasearch-feeds-add-group").value == "");
  28.   },
  29.   
  30.   getFeedUrl: function() {
  31.     return this._list.selectedItem.getAttribute("tooltiptext");
  32.   },
  33.   
  34.   getFeedGroupId: function() {
  35.     return document.getElementById("yasearch-feeds-select-group").selectedItem.getAttribute("group-id");
  36.   },
  37.   
  38.   getString: function(aStringName) {
  39.     return this.stringBundleSet.getString(aStringName);
  40.   },
  41.   
  42.   insertFeedCallback: function(error) {
  43.     switch (error) {
  44.       case "errorNewGroup1":
  45.         YaFeeds.nsIYa.promptService.alert(window,
  46.             YaFeeds.getString("ErrorAddGroupTitle"),
  47.             YaFeeds.getString("ErrorAddGroup") + " " +
  48.             YaFeeds.getString("ErrorAddFeedNoConnection"));
  49.         break;
  50.       case "errorNewGroup2":
  51.         YaFeeds.nsIYa.promptService.alert(window,
  52.             YaFeeds.getString("ErrorAddGroupTitle"),
  53.             YaFeeds.getString("ErrorAddGroup"));
  54.         break;
  55.       case "errorNewItem1":
  56.         YaFeeds.nsIYa.promptService.alert(window,
  57.             YaFeeds.getString("ErrorAddFeedTitle"),
  58.             YaFeeds.getString("ErrorAddFeed") + " " +
  59.             YaFeeds.getString("ErrorAddFeedNoConnection"));
  60.         break;
  61.       case "errorNewItem2":
  62.         YaFeeds.nsIYa.promptService.alert(window,
  63.             YaFeeds.getString("ErrorAddFeedTitle"),
  64.             YaFeeds.getString("ErrorAddFeed"));
  65.     }
  66.     setTimeout(function(){document.documentElement.cancelDialog()},2);
  67.   },
  68.   
  69.   onDialogAccept: function() {
  70.     document.documentElement.getButton("accept").disabled = true;
  71.     
  72.     var data = {url: this.getFeedUrl(), callback: this.insertFeedCallback};
  73.     var newGroup = document.getElementById("yasearch-feeds-add-group").value;
  74.     
  75.     if (newGroup != "")
  76.       data.title = newGroup;
  77.     else
  78.       data.group_id = this.getFeedGroupId();
  79.     
  80.     this.nsIYa.feedsInsertNewItem(data);
  81.     
  82.     return false;
  83.   },
  84.   
  85.   refreshFeedsGroups: function(data) {
  86.     if (!data) {
  87.       if (YaFeeds) {
  88.         YaFeeds.nsIYa.promptService.alert(window,
  89.                                           YaFeeds.getString("ErrorFeedGroupsRefreshTitle"),
  90.                                           YaFeeds.getString("ErrorFeedGroupsRefresh"));
  91.         setTimeout(function(){document.documentElement.cancelDialog()},2);
  92.       }
  93.       return false;
  94.     }
  95.     
  96.     var menuList = document.getElementById("yasearch-feeds-select-group");
  97.     
  98.     YaFeeds.nsIYa.DOMUtils.replaceNode(data, menuList);
  99.     
  100.     YaFeeds.enableAcceptButton();
  101.     
  102.     document.getElementById("yasearch-feeds-add-group").disabled = false;
  103.     
  104.     return true;
  105.   }
  106.   
  107. };