-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
101 lines (78 loc) · 4.05 KB
/
main.js
File metadata and controls
101 lines (78 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
define(function(require, exports, module) {
"use strict";
var CommandManager = brackets.getModule("command/CommandManager");
var Menus = brackets.getModule("command/Menus");
var EditorManager = brackets.getModule("editor/EditorManager");
var right_click_search_goolge = "RightClickExtended.SearchGoogle";
var right_click_search_Wiki = "RightClickExtended.SearchWiki";
var right_click_search_youtube = "RightClickExtended.Searchyoutube";
var right_click_search_stackoverflow = "RightClickExtended.Searchstackoverflow";
var AppInit = brackets.getModule("utils/AppInit");
var strings = require("strings");
/**
Logs into System Console
@param
@Input: String represnts the message to be printed to console
@return None
*/
function log(msg) {
console.log('GoogleExt:' + msg);
}
/**
Handle the Right Click Event
@param
@Input: None
@return None
*/
function handleRightClickSearchGoolge() {
var thisEditor = EditorManager.getCurrentFullEditor();
var keyword = thisEditor._codeMirror.getSelection();
console.log(keyword);
if ((keyword.length > 0)) { // if the user has selected (highlited) something; the plugin accepts the blank strings to open blank tabs
var url = "https://www.google.com.au/search?q=" + keyword;
brackets.app.openURLInDefaultBrowser(url);
}
}
function handleRightClickSearchWiki() {
var thisEditor = EditorManager.getCurrentFullEditor();
var keyword = thisEditor._codeMirror.getSelection();
console.log(keyword);
if ((keyword.length > 0)) { // if the user has selected (highlited) something; the plugin accepts the blank strings to open blank tabs
var url = "https://en.wikipedia.org/wiki/" + keyword;
brackets.app.openURLInDefaultBrowser(url);
}
}
function handleRightClickSearchYoutube() {
var thisEditor = EditorManager.getCurrentFullEditor();
var keyword = thisEditor._codeMirror.getSelection();
console.log(keyword);
if ((keyword.length > 0)) { // if the user has selected (highlited) something; the plugin accepts the blank strings to open blank tabs
var url = "https://www.youtube.com/results?search_query=" + keyword;
brackets.app.openURLInDefaultBrowser(url);
}
}
function handleRightClickSearchStackOverFlow() {
var thisEditor = EditorManager.getCurrentFullEditor();
var keyword = thisEditor._codeMirror.getSelection();
console.log(keyword);
if ((keyword.length > 0)) { // if the user has selected (highlited) something; the plugin accepts the blank strings to open blank tabs
var url = "http://stackoverflow.com/search?q=" + keyword;
brackets.app.openURLInDefaultBrowser(url);
}
}
/**
System Initialization, Command Registratios, and event handlers
*/
AppInit.appReady(function() {
log(strings);
CommandManager.register(strings.RIGHT_CLICK_SEARCH_TITLE_GOOGLE, right_click_search_goolge, handleRightClickSearchGoolge);
CommandManager.register(strings.RIGHT_CLICK_SEARCH_TITLE_WIKI, right_click_search_Wiki, handleRightClickSearchWiki);
CommandManager.register(strings.RIGHT_CLICK_SEARCH_TITLE_YOUTUBE, right_click_search_youtube, handleRightClickSearchYoutube);
CommandManager.register(strings.RIGHT_CLICK_SEARCH_TITLE_STACKOVERFLOW, right_click_search_stackoverflow, handleRightClickSearchStackOverFlow);
Menus.getContextMenu(Menus.ContextMenuIds.EDITOR_MENU).addMenuDivider();
Menus.getContextMenu(Menus.ContextMenuIds.EDITOR_MENU).addMenuItem(right_click_search_goolge);
Menus.getContextMenu(Menus.ContextMenuIds.EDITOR_MENU).addMenuItem(right_click_search_Wiki);
Menus.getContextMenu(Menus.ContextMenuIds.EDITOR_MENU).addMenuItem(right_click_search_youtube);
Menus.getContextMenu(Menus.ContextMenuIds.EDITOR_MENU).addMenuItem(right_click_search_stackoverflow);
});
});