Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pavan71198 committed Jan 29, 2018
0 parents commit 71bcaf4
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bootstrap.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions css/bootstrap.min.css

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body{
min-width : 400px;
min-height : 300px;
}
4 changes: 4 additions & 0 deletions jquery-3.2.1.slim.min.js

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"manifest_version": 2,
"name": "Deep Player",
"description": "Deep Player Chrome Extension",
"version": "1.0.0",
"browser_action": {
"default_popup": "popup.html"
},

"permissions": [
"activeTab",
"cookies",
"tabs",
"http://localhost:8000/",
"webNavigation"
]
}
52 changes: 52 additions & 0 deletions popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!doctype html>
<html>
<head>
<title>Recothem</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div id="not-logged-in" class="d-none container">
<br><br><br><br><br><br>
<div class="row align-items-center text-center">
<div class="col">
You are not logged in, please login to <br>
<a target="_blank" href="http://localhost:8000/accounts/login/">Deep Player</a>
</div>
</div>
<br><br><br>
</div>
<div id="youtube" class="d-none container">
<br><br><br><br><br>
<div id="upload-form" class="row align-items-center text-center">
<div class="col-2"></div>
<div class="col-8">
<input class="form-control" placeholder="Enter a name for this video" id="video-name">
<br>
<button class="btn btn-default" id="upload-button">Upload this video</button>
</div>
<div class="col-2"></div>
</div>
<div id="upload-success" class="row align-items-center text-center d-none">
<div class="col">
Video upload request successfully sent to <br> <a target="_blank" href="http://localhost:8000/">Deep Player</a>
</div>
</div>
<br><br><br>

</div>
<div id="not-youtube" class="d-none container">
<br><br><br><br><br><br>
<div class="row align-items-center text-center">
<div class="col">
Open a YouTube video to upload it.
</div>
</div>
<br><br><br>
</div>
<script src="jquery-3.2.1.slim.min.js"></script>
<script src="bootstrap.min.js"></script>
<script src="popup.js" type="text/javascript"></script>
</body>
70 changes: 70 additions & 0 deletions popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
$(document).ready(function(){
$("#not-logged-in").addClass("d-none");
$("#youtube").addClass("d-none");
$("#not-youtube").addClass("d-none");

var csrftoken = "";
var sessionid = "";

chrome.cookies.get({url: 'http://localhost:8000/', name: 'csrftoken'},
function (cookie) {
console.log(cookie);
csrftoken = cookie.value;
}
);

chrome.cookies.get({url: 'http://localhost:8000/', name: 'sessionid'},
function (cookie) {
console.log(cookie);
if (cookie){
sessionid = cookie;
var userid = sessionid.user_id;
var username = sessionid.username;
$("#notlogin").removeClass("d-none");
chrome.tabs.query({active: true, currentWindow: true},
function(tabs){
var tabURL = new URL(tabs[0].url);
if (tabURL.host == "www.youtube.com"){
console.log(tabURL);
$('#youtube').removeClass('d-none');
var videoid = tabURL.searchParams.get("v");
console.log(videoid);
$('#upload-button').onclick(function(){
var videoname = $('#video-name').value();
$.ajax({
url: "http://localhost:8000/uploadvideo",
type: "POST",
data: {
videoname: videoname,
source: "youtube",
videoid: videoid,
csrfmiddlewaretoken: csrftoken
},
success: function () {
$('#upload-success').removeClass("d-none");
$('#upload-form').addClass("d-none");
console.log("Upload request successfull");
},
error:function(){
console.log("Upload error");
}
});
});
}
else{
console.log(tabURL);
$('#not-youtube').removeClass('d-none');
$("#youtube").addClass("d-none");
}
}
)
}
else{
$('#not-logged-in').removeClass('d-none');
$("#youtube").addClass("d-none");
$("#not-youtube").addClass("d-none");
}
}
);

});

0 comments on commit 71bcaf4

Please sign in to comment.