Guest User

FBPHOTOZOOM context.js

a guest
Oct 21st, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1.  
  2. var context = {
  3.  
  4. init: function () {
  5.  
  6. this.add({
  7. title: localStorage["isEnabled"] == null ? "Disabled" : ((localStorage["isEnabled"] == "1") ? "Disabled" : "Enabled"),
  8. urlPatterns: ["http://*.facebook.com/*", "http://facebook.com/*", "https://*.facebook.com/*", "https://facebook.com/*", "http://*.flickr.com/*", "http://flickr.com/*", "https://*.flickr.com/*", "https://flickr.com/*"],
  9. checked: localStorage["isEnabled"] == null ? true : ((localStorage["isEnabled"] == "1") ? true : false)
  10. }, "setEnabled");
  11.  
  12.  
  13. this.add({
  14. title: "Search Images for %s",
  15. contexts: ["selection"]
  16. }, "SrchImgByTxt");
  17.  
  18. this.add({
  19. title: "Search for similar Images",
  20. contexts: ["image"]
  21. }, "SrchImg");
  22.  
  23. },
  24.  
  25. add: function (params, event) {
  26.  
  27. var contextInfo = {
  28. type: params.type || "normal",
  29. title: params.title || "",
  30. documentUrlPatterns: params.urlPatterns || ["http://*/*", "https://*/*"],
  31. contexts: params.contexts || ["all"]
  32. }
  33.  
  34. if (params.type == "checkbox") {
  35. contextInfo.checked = typeof (params.checked) == "boolean" ? params.checked : false;
  36. }
  37.  
  38. contextInfo.onclick = this.contextClicks[event];
  39.  
  40. if (this.contextItems[event]) {
  41. chrome.contextMenus.update(this.contextItems[event], contextInfo, function () { });
  42. } else {
  43. this.contextItems[event] = chrome.contextMenus.create(contextInfo, function () { });
  44. }
  45.  
  46. },
  47.  
  48. contextItems: {},
  49.  
  50. contextClicks: {
  51.  
  52. setEnabled: function () {
  53.  
  54. var isEnabled;
  55. var ttlText;
  56.  
  57. if (localStorage["isEnabled"] == "1") {
  58. localStorage["isEnabled"] = "0";
  59. isEnabled = false;
  60. ttlText = "Enabled";
  61. _gaq.push(["_trackEvent", "UserInfo", "Functionality", "Disabled | " + localStorage["install"] + " | Chrome"]);
  62. } else {
  63. localStorage["isEnabled"] = "1";
  64. isEnabled = true;
  65. ttlText = "Disabled";
  66. _gaq.push(["_trackEvent", "UserInfo", "Functionality", "Enabled | " + localStorage["install"] + " | Chrome"]);
  67. }
  68.  
  69. if (context.contextItems["setEnabled"]) {
  70. chrome.contextMenus.update(context.contextItems["setEnabled"], { title: ttlText }, function () { });
  71. }
  72.  
  73. chrome.tabs.getSelected(null, function (tab) {
  74. chrome.tabs.sendRequest(tab.id, { 'name': 'setStatus', 'data': isEnabled });
  75. });
  76.  
  77. },
  78.  
  79. SrchImgByTxt: function (info) {
  80. var url = "http://www.gophoto.it/result.php?type=1&src=fbz&q=" + info.selectionText;
  81. chrome.tabs.create({ 'url': url }, function (tab) { });
  82. },
  83.  
  84. SrchImg: function (info) {
  85. var url = "http://www.gophoto.it/result.php?type=2&src=fbz&q=" + escape(info.srcUrl);
  86. chrome.tabs.create({ 'url': url }, function (tab) { });
  87. }
  88. }
  89.  
  90. };
  91.  
  92. try { context.init(); } catch(e) {};
Advertisement
Add Comment
Please, Sign In to add comment