forked from emoneyx5/PinPoint
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpinpoint-notes-presenter.js
More file actions
65 lines (59 loc) · 2.54 KB
/
pinpoint-notes-presenter.js
File metadata and controls
65 lines (59 loc) · 2.54 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
PinPoint.NotePresenter = function(note, index, url, refreshFunc) {
this.note = note;
this.nodeType = "div";
this.index = index;
this.url = url;
this.refreshFunc = refreshFunc;
// this.rootNodeType = "tr";
// this.childNodeType = "td";
this.buttonNodeType = "button";
this.linkNodeType = "a";
}
PinPoint.NotePresenter.prototype = {
present: function() {
// Creates a 'div' node that represents a note
var noteNode = document.createElement(this.nodeType),
// Creates a 'div' node that represents the time and delete button in the note - when var is included, errors are thrown for some reason.
timeAndDeleteNode = document.createElement(this.nodeType),
// Creates an 'a' node to link to a point in the video - when var is included, errors are thrown for some reason.
timeLink = document.createElement(this.linkNodeType),
//Creates delete link
// deleteNode = document.createElement(this.childNodeType);
deleteLink = document.createElement(this.buttonNodeType),
//Creates content div
contentNode = document.createElement(this.nodeType),
//Creates content link
contentLink = document.createElement(this.linkNodeType);
// Assigns class names
noteNode.className = "pinpoint-note";
timeAndDeleteNode.className = 'pinpoint-time-and-delete';
contentNode.className = 'pinpoint-content';
// Gives the link an id.
timeLink.setAttribute('class', 'pinpoint-timelink');
contentLink.setAttribute('class', 'pinpoint-contentlink')
// Sets the link to a specific time within the video
timeLink.setAttribute('href', this.note.url + "#t=" + this.note.seconds );
contentLink.setAttribute('href', this.note.url + "#t=" + this.note.seconds);
// Creates the text for the link
timeLink.innerHTML = this.note.noteTime;
contentLink.innerHTML = this.note.content;
timeAndDeleteNode.appendChild(deleteLink);
timeAndDeleteNode.appendChild(timeLink);
contentNode.appendChild(contentLink);
noteNode.appendChild(contentNode);
noteNode.appendChild(timeAndDeleteNode);
deleteLink.setAttribute('class', 'pinpoint-delete');
deleteLink.setAttribute('href', '#');
deleteLink.setAttribute('data-seconds', this.note.seconds);
deleteLink.innerHTML = "x";
deleteLink.addEventListener('click', function(){
chrome.runtime.sendMessage({
method: "remove note",
url: this.url,
index: this.index,
seconds: this.note.seconds,
}, this.refreshFunc)
}.bind(this));
return noteNode;
}
};