Skip to content

Commit dad76f2

Browse files
committed
- Cleanup before submission (removed commented code and unused pages)
1 parent 441393a commit dad76f2

File tree

6 files changed

+2
-101
lines changed

6 files changed

+2
-101
lines changed

background.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,31 @@
1-
2-
const CSS = "body { border: 20px solid red; }";
3-
41
// Production Regex
52
var playerRegex = /^https?\:\/\/app\.pluralsight\.com\/player\?.*course=([^&]*)(&|$)/ig;
63
// Local Mock Regex (IIS can't easily serve static files with no extension).
74
//var playerRegex = /^https?\:\/\/app\.pluralsight\.com\/player.html\?.*course=([^&]*)(&|$)/ig;
85

9-
106
/*
117
Define callback function that will lookup the active course popup in our list and
128
Update the DOM to highlight the current line of the transcript.
139
Also define a second callback that will call updateTranscriptTIme
1410
*/
15-
16-
//var transcriptPort = undefined;
1711
function updateTranscriptTime(m) {
1812
if (m.source == "content")
1913
{
2014
console.log("In background script, received message from content script");
2115
console.log("MODULE: " + m.module);
2216
console.log("CLIP: " + m.clip);
2317
console.log("TIME: " + m.time);
24-
/*if (transcriptPort != undefined)
25-
{
26-
transcriptPort.postMessage(
27-
{
28-
source: "background",
29-
module: m.module,
30-
clip: m.clip,
31-
time: m.time
32-
})
33-
}*/
3418
}
3519
else if (m.source == "transcript")
3620
{
3721
console.log("In background script, received message from transcript");
3822
console.log("TabID: " + m.tabid);
3923
console.log("Title: " + m.title);
40-
4124
}
4225
}
4326

4427
function onCreated(windowInfo, tab, active_course) {
4528
console.log(`Created window: ${windowInfo.id}`);
46-
//transcriptPort = browser.tabs.connect(windowInfo.tabs[0].id, {name: "bg-to-transcript"});
4729
}
4830

4931
function onError(error) {
@@ -60,11 +42,8 @@ function showTranscript(tab) {
6042
console.log("Course: " + active_course);
6143
// Returns 404 if can't find course.
6244
// What if can't find transcript but course exists?
63-
6445
var transcriptURL = "transcript.html";
6546
transcriptURL += "?course=" + active_course;
66-
67-
6847
browser.tabs.executeScript(tab.id, { file: "content.js" });
6948
var creating = browser.windows.create(
7049
{
@@ -73,7 +52,6 @@ function showTranscript(tab) {
7352
});
7453
creating.then(function(windowInfo) { onCreated(windowInfo, tab, active_course); }, onError);
7554
}
76-
7755
/* Register an event handler for the pageClick event to open a pop-up window
7856
with the active course's transcript. */
7957
browser.pageAction.onClicked.addListener(showTranscript);
@@ -84,7 +62,3 @@ browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
8462
browser.pageAction.show(tab.id);
8563
}
8664
});
87-
/* Register event handler to capture injected client script communication back
88-
to the background tab. */
89-
//browser.runtime.onConnect.addListener(function(p) { p.onMessage.addListener(updateTranscriptTime); });
90-
//browser.runtime.onDisconnect.addListener(function(p) { p.}

content.js

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
1-
// http://app.pluralsight.com/player.html?course=ionic2-angular2-typescript-mobile-apps&author=steve-michelotti&name=ionic2-angular2-typescript-mobile-apps-m0&clip=0&mode=live
2-
3-
//var myPort = browser.runtime.connect({name:"port-from-cs"});
4-
/*
5-
myPort.postMessage({greeting: "hello from content script"});
6-
7-
myPort.onMessage.addListener(function(m) {
8-
console.log("In content script, received message from background script: ");
9-
console.log(m.greeting);
10-
});
11-
document.body.addEventListener("click", function() {
12-
myPort.postMessage({greeting: "they clicked the page!"});
13-
});
14-
15-
*/
161
var currentModule = -1;
172
var currentClip = -1;
183
var currentTime = -1;
19-
204
var transcriptData = undefined;
215

226
/* Get JSON from pluralsight and parse it into DOM elements.
@@ -48,8 +32,6 @@ function renderTranscript(course)
4832
};
4933
}
5034

51-
52-
5335
urlParams = parseQuery(window.location.href);
5436
var course = urlParams["course"];
5537
renderTranscript(course);
@@ -103,11 +85,10 @@ function parseQuery(url) {
10385
return query;
10486
}
10587

106-
10788
function updateData()
10889
{
10990
var data_changed = false;
110-
91+
11192
var urlParams = parseQuery(window.location.href);
11293
var nameComponents = urlParams["name"].split('-');
11394
var targetModule = nameComponents[nameComponents.length - 1].substring(1);
@@ -142,12 +123,3 @@ function updateData()
142123
// Invoke updateData immediately upon definition so we don't have any lag time
143124
// from the first time the button is clicked.
144125
updateData();
145-
146-
/*
147-
(function() {
148-
var script = document.createElement('script');
149-
script.type = 'text/javascript';
150-
script.src = 'alert("hi")';
151-
document.body.appendChild(script);
152-
})();
153-
*/

manifest.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
{
2-
32
"manifest_version": 2,
43
"name": "Pluralsight-Transcript",
54
"version": "1.0",
6-
7-
"description": "Creates a popup window with transcript along with live highlighting on Pluralsight videos",
8-
5+
"description": "Add a Page Action to every Pluralsight video player. Clicking the Page Action will create a new popup window with a transcript (if available) along with live highlighting and automatic scrolling in time with the video playback.",
96
"permissions": [
107
"activeTab",
118
"tabs"
@@ -17,7 +14,6 @@
1714
"background": {
1815
"scripts": ["background.js"]
1916
},
20-
2117
"page_action": {
2218
"browser_style": true,
2319
"default_icon": {
@@ -26,7 +22,4 @@
2622
},
2723
"default_title": "Show Transcript"
2824
}
29-
30-
31-
3225
}

popup/pageAction.html

Whitespace-only changes.

transcript.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@
3131
padding: 15px;
3232
margin: 0px 30px;
3333
}
34-
3534
.segment.selected {
3635
background-color: rgba(248, 255, 81, 0.61);
37-
3836
}
3937
</style>
4038
<title>Transcript</title>

transcript.js

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//var myPort = browser.runtime.connect({name:"port-from-transcript"});
21
var title = "";
32
var currentTab = -1;
43
var currentModuleAndClip = "";
@@ -20,9 +19,6 @@ function parseQuery(url) {
2019
return query;
2120
}
2221

23-
/*function updateTranscriptTime(m) {
24-
console.log("In transcript script, received message from background script");
25-
}*/
2622
function updateTitle(tab)
2723
{
2824
currentTab = tab.id;
@@ -78,7 +74,6 @@ function renderTranscript()
7874
}
7975
text += "</div>";
8076
}
81-
//var text = JSON.stringify(transcriptData);
8277
document.body.innerHTML = text;
8378
}
8479

@@ -90,7 +85,6 @@ function updateTranscript(module, clip, time)
9085
}
9186
document.getElementById('module'+module).classList.add('selected');
9287
document.getElementById('module' + module + 'clip' + clip).classList.add('selected');
93-
9488
// If clip/module has changed, scroll to new clip.
9589
var newModuleAndClip = 'm' + module + 'c' + clip;
9690
if (currentModuleAndClip != newModuleAndClip)
@@ -123,36 +117,6 @@ function handleMessage(request, sender, sendResponse) {
123117
renderTranscript();
124118
}
125119
updateTranscript(request.module, request.clip, request.time);
126-
/*
127-
console.log("TODO: Update transcript to: ");
128-
console.log();
129-
console.log(request.module);
130-
console.log(request.clip);
131-
console.log(request.time);*/
132120
}
133-
134-
//sendResponse({response: "Response from background script"});
135121
}
136122
browser.runtime.onMessage.addListener(handleMessage);
137-
138-
139-
140-
141-
//browser.runtime.onConnect.addListener(function(p) { p.onMessage.addListener(updateTranscriptTime); });
142-
143-
//var myId = tab.id;
144-
/*
145-
function dataChanged() {
146-
if (currentTab != -1)
147-
{
148-
myPort.postMessage(
149-
{
150-
source: "transcript",
151-
tabid: currentTab,
152-
title: title
153-
});
154-
}
155-
window.setTimeout(dataChanged, 1000);
156-
}
157-
dataChanged();
158-
*/

0 commit comments

Comments
 (0)