-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
98 lines (85 loc) · 2.79 KB
/
Copy pathscript.js
File metadata and controls
98 lines (85 loc) · 2.79 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
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if( request.message === "clicked_browser_action" ) {
$(document).ready(function() {
$( function() {
$( "#dialog" ).dialog({
autoOpen: false,
show: {
effect: "drop",
duration: 100
},
hide: {
effect: "drop",
duration: 100
},
width: "50%",
maxWidth: "768px"
});
} );
$( function() {
$( "#eventType" ).selectmenu();
} );
var dialog= '<div id="dialog" title="Event Details"> ' +
'<div id="users-contain" class="ui-widget"> ' +
' <table id="eventDetails" class="ui-widget ui-widget-content"> ' +
' <thead> ' +
' <tr class="ui-widget-header "> ' +
' <th>Item</th> ' +
' <th>Type</th> ' +
' </tr> ' +
' </thead> ' +
' <tbody> ' +
' </tbody> ' +
' </table> ' +
'</div>' +
'<div class="widget">' +
'<button id="btnContinue">Continue</button> ' +
'<button id="btnStore" class="myButton">Store Event</button>' +
'</div>';
$("body").prepend(dialog);
var selectMenu = '<select name="eventType" id="eventType"> ' +
'<option selected="selected" value="title">Title</option> ' +
'<option value="description">Description</option> ' +
'<option value="time">Time & Date</option> ' +
'<option value="venue">Venue</option> ' +
'</select>';
$("body").mouseup(function() {
if ($('#dialog').dialog('isOpen') === false) {
var sel = window.getSelection().toString();
if(sel.length) {
$( "#eventDetails tbody" ).append( "<tr>" +
"<td class='truncate'>" + sel + "</td>" +
"<td class='truncate'>" + selectMenu + "</td>" +
"</tr>" );
$( "#dialog" ).dialog( "open" );
}
}
});
$( "#btnContinue" ).click(function() {
$( "#dialog" ).dialog( "close" );
});
$( "#btnStore" ).click(function() {
var tbl = $('table#eventDetails tr').get().map(function(row) {
return $(row).find('td').get().map(function(cell) {
var tagName = $(cell)[0].lastChild.tagName;
if (typeof tagName != 'undefined') {
return $(cell)[0].lastChild.value;
} else {
return $(cell).html();
}
});
});
chrome.runtime.sendMessage({ message: "store", data: tbl});
$( "#dialog" ).dialog( "close" );
});
var link1=chrome.extension.getURL("icon.png");
$("body").css('cursor','url('+link1+'),auto');
});
}
if( request.message === "event_stored" ) {
$("body").unbind('mouseup');
$("body").css('cursor', 'default');
}
}
);