mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
merged
This commit is contained in:
@@ -386,7 +386,7 @@ li.disabled span {
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.import-spotify-auth, .import-youtube, .export-spotify-auth, .export-youtube, .exported-playlist, .import-zoff, .import-soundcloud{
|
||||
.import-spotify-auth, .import-youtube, .export-spotify-auth, .export-youtube, .exported-playlist, .import-zoff, .import-soundcloud, .export-soundcloud{
|
||||
color:white !important;
|
||||
height:40px !important;
|
||||
line-height: 40px !important;
|
||||
@@ -394,11 +394,11 @@ li.disabled span {
|
||||
width: 76%;
|
||||
}
|
||||
|
||||
.import-soundcloud, .import-soundcloud:active, .import-soundcloud:visited {
|
||||
.import-soundcloud, .import-soundcloud:active, .import-soundcloud:visited, .export-soundcloud:visited {
|
||||
background: #f96200;
|
||||
}
|
||||
|
||||
.import-soundcloud:hover {
|
||||
.import-soundcloud:hover, .export-soundcloud:hover {
|
||||
background: #f97f30;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Zoff OAuth Callback</title>
|
||||
<script src="https://connect.soundcloud.com/sdk/sdk-3.3.0.js"></script>
|
||||
<script type="text/javascript" src="/assets/dist/callback.min.js"></script>
|
||||
<meta charset="UTF-8"/>
|
||||
<style>
|
||||
|
||||
@@ -20,8 +20,38 @@ window.addEventListener("load", function() {
|
||||
|
||||
//window.opener.callback(query);
|
||||
window.location.href = "https://accounts.google.com/o/oauth2/v2/auth?client_id=" + client_id + "&response_type=" + response + "&state=" + state + "&redirect_uri=" + redirect + "&scope=" + scope;
|
||||
} else if(query.soundcloud) {
|
||||
/*
|
||||
SC.initialize({
|
||||
client_id: api_key.soundcloud,
|
||||
redirect_uri: 'https://zoff.me/api/oauth'
|
||||
});
|
||||
|
||||
// initiate auth popup
|
||||
console.log("asd ok", api_key.soundcloud);
|
||||
SC.connect().then(function() {
|
||||
return SC.get('/me');
|
||||
}).then(function(me) {
|
||||
console.log(me);
|
||||
//alert('Hello, ' + me.username);
|
||||
}).catch(function(e) {
|
||||
console.log(e);
|
||||
});*/
|
||||
|
||||
var redirect_uri = encodeURIComponent("https://zoff.me/api/oauth");
|
||||
var response_type = "code";
|
||||
var scope = "non-expiring";
|
||||
var state = query.nonce;
|
||||
var url = "https://soundcloud.com/connect?client_id=" + api_key.soundcloud + "&redirect_uri=" + redirect_uri + "&state=" + state + "&display=page&response_type=code&scope=" + scope;
|
||||
//console.log(url);
|
||||
window.location.href = url;
|
||||
} else {
|
||||
var query_parameters = getQueryHash(window.location.hash);
|
||||
var query_parameters;
|
||||
if(window.location.search.length > 0) {
|
||||
query_parameters = getQueryHash(window.location.search);
|
||||
} else {
|
||||
query_parameters = getQueryHash(window.location.hash);
|
||||
}
|
||||
try {
|
||||
window.opener.callback(query_parameters);
|
||||
} catch(e) {}
|
||||
@@ -29,14 +59,30 @@ window.addEventListener("load", function() {
|
||||
});
|
||||
|
||||
function getQueryHash(url) {
|
||||
var temp_arr = url.substring(1).split("&");
|
||||
var done_obj = {};
|
||||
var splitted;
|
||||
for(var i in temp_arr) {
|
||||
splitted = temp_arr[i].split("=");
|
||||
if(splitted.length == 2) {
|
||||
done_obj[splitted[0]] = splitted[1];
|
||||
if(window.location.search.length > 0) {
|
||||
if(url.substring(url.length - 1) == "#") {
|
||||
url = url.substring(0, url.length - 1);
|
||||
}
|
||||
var temp_arr = url.substring(1).split("&");
|
||||
var done_obj = {};
|
||||
var splitted;
|
||||
for(var i in temp_arr) {
|
||||
splitted = temp_arr[i].split("=");
|
||||
if(splitted.length == 2) {
|
||||
done_obj[splitted[0]] = splitted[1];
|
||||
}
|
||||
}
|
||||
return done_obj;
|
||||
} else {
|
||||
var temp_arr = url.substring(1).split("&");
|
||||
var done_obj = {};
|
||||
var splitted;
|
||||
for(var i in temp_arr) {
|
||||
splitted = temp_arr[i].split("=");
|
||||
if(splitted.length == 2) {
|
||||
done_obj[splitted[0]] = splitted[1];
|
||||
}
|
||||
}
|
||||
return done_obj;
|
||||
}
|
||||
return done_obj;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,8 @@ var chat_active = false;
|
||||
var chat_unseen = false;
|
||||
var blinking = false;
|
||||
var from_frontpage = false;
|
||||
var access_token_data_soundcloud = {};
|
||||
var soundcloud_window;
|
||||
var access_token_data = {};
|
||||
var spotify_authenticated = false;
|
||||
var not_import_html = "";
|
||||
@@ -950,6 +952,29 @@ function addDynamicListeners() {
|
||||
}
|
||||
});
|
||||
|
||||
addListener("click", ".export-soundcloud", function(event) {
|
||||
this.preventDefault();
|
||||
var nonce = Helper.randomString(29);
|
||||
Helper.removeClass("#playlist_loader_export", "hide");
|
||||
Helper.addClass(".soundcloud_export_button", "hide");
|
||||
window.callback = function(data) {
|
||||
access_token_data_soundcloud = data;
|
||||
if(access_token_data_soundcloud.state == nonce){
|
||||
soundcloud_authenticated = true;
|
||||
Helper.removeClass("#playlist_loader_export", "hide");
|
||||
Helper.addClass(".soundcloud_export_button", "hide");
|
||||
} else {
|
||||
access_token_data_soundcloud = {};
|
||||
console.error("States doesn't match");
|
||||
Helper.addClass("#playlist_loader_export", "hide");
|
||||
Helper.removeClass(".soundcloud_export_button", "hide");
|
||||
}
|
||||
soundcloud_window.close();
|
||||
window.callback = "";
|
||||
};
|
||||
soundcloud_window = window.open("/api/oauth#soundcloud=true&nonce=" + nonce, "", "width=600, height=600");
|
||||
})
|
||||
|
||||
addListener("click", ".export-spotify-auth", function(event){
|
||||
this.preventDefault();
|
||||
var nonce = Helper.randomString(29);
|
||||
@@ -1017,7 +1042,7 @@ function addDynamicListeners() {
|
||||
document.querySelector("#import_soundcloud").focus();
|
||||
});
|
||||
|
||||
addListener("submit", "#listImportSoundCloud", function(event) {
|
||||
/*addListener("submit", "#listImportSoundCloud", function(event) {
|
||||
this.preventDefault();
|
||||
Helper.removeClass(".playlist_loader_soundcloud", "hide");
|
||||
Helper.addClass("#listImportSoundCloud", "hide");
|
||||
@@ -1081,9 +1106,12 @@ function addDynamicListeners() {
|
||||
},
|
||||
error: function(data) {
|
||||
console.log(data);
|
||||
Helper.addClass(".playlist_loader_soundcloud", "hide");
|
||||
Helper.removeClass("#listImportSoundCloud", "hide");
|
||||
toast("If the list is private, you have to add the secret code at the end");
|
||||
}
|
||||
});
|
||||
});
|
||||
});*/
|
||||
|
||||
addListener("submit", "#listImportSpotify", function(event){
|
||||
this.preventDefault();
|
||||
|
||||
@@ -203,7 +203,7 @@
|
||||
<form action="#" id="listImportSoundCloud">
|
||||
<i class="material-icons import-icon">playlist_add</i>
|
||||
<input title="Input SoundCloud-playlist url here!" placeholder="Enter SoundCloud-list url" id="import_soundcloud" type="text" class="validate" autocomplete="off" />
|
||||
<p class="soundcloud-disclaimer">Private lists won't work with imports yet, due to our API-key being limited at the time being. Sorry for any inconvinience.</p>
|
||||
<p class="soundcloud-disclaimer">If you want to add a private list, remember to add the secret token at the end!</p>
|
||||
</form>
|
||||
<div id="playlist_loader_soundcloud" class="valign playlist_loader_padding hide">
|
||||
<div class="preloader-wrapper small active">
|
||||
@@ -266,6 +266,11 @@
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="white-bg">
|
||||
<div class="input-field field-settings">
|
||||
<p class="soundcloud-disclaimer">Exporting to SoundCloud is in the works.</p>
|
||||
</div>
|
||||
</li>
|
||||
<li class="exported-list-container white-bg hide">
|
||||
<div class="valign playlist_loader_padding">
|
||||
<div class="row">
|
||||
|
||||
Reference in New Issue
Block a user