mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-12-08 20:48:48 +00:00
Material
This commit is contained in:
106
static/js/admin.js
Executable file
106
static/js/admin.js
Executable file
@@ -0,0 +1,106 @@
|
||||
var adminTogg = false;
|
||||
var pass_corr = "";
|
||||
|
||||
function admin()
|
||||
{
|
||||
adminTogg = !adminTogg;
|
||||
if(adminTogg)
|
||||
{
|
||||
if(find)
|
||||
{
|
||||
eH = -10;
|
||||
}else
|
||||
eH = 30;
|
||||
$("#playlist").height($("#player").height()-290+eH); //opening
|
||||
}else if(!adminTogg)
|
||||
{
|
||||
if(find)
|
||||
{
|
||||
eH = -10;
|
||||
}else
|
||||
eH = 30;
|
||||
$("#playlist").height($("#player").height()+eH); //closing
|
||||
}
|
||||
$("#adminPanel").toggleClass("hiddenAdmin");
|
||||
}
|
||||
|
||||
|
||||
function submitAdmin(form)
|
||||
{
|
||||
voting = form.vote.value;
|
||||
addsongs = form.addsongs.value;
|
||||
longsongs = form.longsongs.value;
|
||||
frontpage = form.frontpage.value;
|
||||
allvideos = form.allvideos.value;
|
||||
removeplay = form.removeplay.value;
|
||||
adminpass = form.pass.value;
|
||||
skipping = form.skip.value;
|
||||
shuffling = form.shuffle.value;
|
||||
|
||||
confRes = $.ajax({
|
||||
type: "POST",
|
||||
url: "php/change.php",
|
||||
async: false,
|
||||
data: "conf=start&vote="+voting+"&addsongs="+addsongs+"&longsongs="+longsongs+"&frontpage="+frontpage+
|
||||
"&allvideos="+allvideos+"&removeplay="+removeplay+"&pass="+adminpass+"&skip="+skipping+"&shuffling="+shuffling,
|
||||
|
||||
success: function() {
|
||||
console.log("configurations response: "+response);
|
||||
}
|
||||
}).responseText;
|
||||
|
||||
pass_corr = confRes;
|
||||
|
||||
if(pass_corr=="correct"){
|
||||
//$("#adminPanel").addClass("success");
|
||||
document.getElementById("sBar").innerHTML = "Successfully applied settings.";
|
||||
$("#sBar").addClass("opacityFull");
|
||||
document.getElementById("passbox").value = "";
|
||||
}else{
|
||||
document.getElementById("eBar").innerHTML = "Error: Wrong Admin Password!";
|
||||
$("#eBar").addClass("opacityFull");
|
||||
document.getElementById("passbox").value = "";/*$("#adminPanel").addClass("fadeerror");*/
|
||||
}
|
||||
|
||||
console.log(pass_corr);
|
||||
updateList();
|
||||
setTimeout(function(){
|
||||
$("#adminPanel").removeClass("success");
|
||||
$("#adminPanel").removeClass("fadeerror");
|
||||
$("#eBar").removeClass("opacityFull");
|
||||
$("#sBar").removeClass("opacityFull");
|
||||
},1500);
|
||||
}
|
||||
|
||||
function shuffle(form)
|
||||
{
|
||||
console.log(adminpass);
|
||||
confRes = $.ajax({
|
||||
type: "GET",
|
||||
url: "php/change.php",
|
||||
async: false,
|
||||
data: "shuffle=true&pass="+adminpass,
|
||||
|
||||
success: function() {
|
||||
console.log("configurations response: "+response);
|
||||
}
|
||||
}).responseText;
|
||||
if(confRes == "shuffled")
|
||||
{
|
||||
document.getElementById("sBar").innerHTML = "Successfully shuffled playlist.";
|
||||
$("#sBar").addClass("opacityFull");
|
||||
updateList();
|
||||
}else if(confRes = "wrong!"){
|
||||
document.getElementById("eBar").innerHTML = "Error: Wrong Admin Password!";
|
||||
$("#eBar").addClass("opacityFull");
|
||||
}else if(confRes = "size"){
|
||||
document.getElementById("eBar").innerHTML = "Error: Empty Playlist!";
|
||||
$("#eBar").addClass("opacityFull");
|
||||
}
|
||||
setTimeout(function(){
|
||||
$("#adminPanel").removeClass("success");
|
||||
$("#adminPanel").removeClass("fadeerror");
|
||||
$("#eBar").removeClass("opacityFull");
|
||||
$("#sBar").removeClass("opacityFull");
|
||||
},1500);
|
||||
}
|
||||
64
static/js/jazzscript.js
Executable file
64
static/js/jazzscript.js
Executable file
@@ -0,0 +1,64 @@
|
||||
setup = false;
|
||||
function jazz_setup()
|
||||
{
|
||||
console.log(setup);
|
||||
document.getElementsByClassName("ytplayer")[0].style.display = "none";
|
||||
if(!setup)
|
||||
{
|
||||
jplayer = new YT.Player('jplayer', {
|
||||
height: window.height*0.75,
|
||||
width: window.width*0.6,
|
||||
videoId: response,
|
||||
playerVars: { rel:"0", wmode:"transparent", controls: "0" , iv_load_policy: "3", theme:"light", color:"white"},
|
||||
events: {
|
||||
'onReady': onJazzReady,
|
||||
'onStateChange': onJazzState
|
||||
}
|
||||
});
|
||||
setup = true;
|
||||
}else if(setup)
|
||||
{
|
||||
console.log(1234567890);
|
||||
jplayer.playVideo();
|
||||
}
|
||||
document.getElementsByClassName("jp")[0].style.display = "inline";
|
||||
|
||||
}
|
||||
|
||||
function pauseJazz()
|
||||
{
|
||||
jplayer.pauseVideo();
|
||||
}
|
||||
|
||||
function onJazzState(state)
|
||||
{
|
||||
if(state.data == 0)
|
||||
{
|
||||
jplayer.loadVideoById("0fYL_qiDYf0");
|
||||
jplayer.playVideo();
|
||||
}
|
||||
}
|
||||
|
||||
function onJazzReady(event) {
|
||||
//ytplayer = document.getElementById("myytplayer");
|
||||
// ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
|
||||
//ytplayer.addEventListener("onError", "errorHandler");
|
||||
getTime();
|
||||
if(!window.mobilecheck())
|
||||
{
|
||||
$("#jplayer").css("opacity", "1");
|
||||
$("#controls").css("opacity", "1");
|
||||
$(".playlist").css("opacity", "1");
|
||||
//$("#player").fadeIn();
|
||||
jplayer.loadVideoById("0fYL_qiDYf0");
|
||||
jplayer.playVideo();
|
||||
}
|
||||
readyLooks();
|
||||
initSlider();
|
||||
//durationFixer = setInterval(durationSetter, 1000);
|
||||
}
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
jazz_setup();
|
||||
});
|
||||
17
static/js/lib/blur.min.js
vendored
Executable file
17
static/js/lib/blur.min.js
vendored
Executable file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Blur.js
|
||||
* Copyright Jacob Kelley
|
||||
* MIT License
|
||||
*/
|
||||
// Stackblur, courtesy of Mario Klingemann: http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html
|
||||
(function(l){l.fn.blurjs=function(e){function O(){this.a=this.b=this.g=this.r=0;this.next=null}var y=document.createElement("canvas"),P=!1,H=l(this).selector.replace(/[^a-zA-Z0-9]/g,"");if(y.getContext){var e=l.extend({source:"body",radius:5,overlay:"",offset:{x:0,y:0},optClass:"",cache:!1,cacheKeyPrefix:"blurjs-",draggable:!1,debug:!1},e),R=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,
|
||||
328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,
|
||||
305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],S=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,
|
||||
20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
|
||||
24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];return this.each(function(){var A=l(this),I=l(e.source),B=I.css("backgroundImage").replace(/"/g,"").replace(/url\(|\)$/ig,"");ctx=y.getContext("2d");tempImg=new Image;tempImg.onload=function(){if(P)j=tempImg.src;else{y.style.display="none";y.width=tempImg.width;y.height=tempImg.height;ctx.drawImage(tempImg,0,0);var j=y.width,q=y.height,k=e.radius;if(!(isNaN(k)||1>k)){var k=
|
||||
k|0,M=y.getContext("2d"),l;try{try{l=M.getImageData(0,0,j,q)}catch(L){try{netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"),l=M.getImageData(0,0,j,q)}catch(T){throw alert("Cannot access local image"),Error("unable to access local image data: "+T);}}}catch(U){throw alert("Cannot access image"),Error("unable to access image data: "+U);}var c=l.data,u,z,a,d,f,J,g,h,i,v,w,x,m,n,o,r,s,t,C;u=k+k+1;var K=j-1,N=q-1,p=k+1,D=p*(p+1)/2,E=new O,b=E;for(a=1;a<u;a++)if(b=b.next=new O,a==
|
||||
p)var Q=b;b.next=E;b=a=null;J=f=0;var F=R[k],G=S[k];for(z=0;z<q;z++){m=n=o=g=h=i=0;v=p*(r=c[f]);w=p*(s=c[f+1]);x=p*(t=c[f+2]);g+=D*r;h+=D*s;i+=D*t;b=E;for(a=0;a<p;a++)b.r=r,b.g=s,b.b=t,b=b.next;for(a=1;a<p;a++)d=f+((K<a?K:a)<<2),g+=(b.r=r=c[d])*(C=p-a),h+=(b.g=s=c[d+1])*C,i+=(b.b=t=c[d+2])*C,m+=r,n+=s,o+=t,b=b.next;a=E;b=Q;for(u=0;u<j;u++)c[f]=g*F>>G,c[f+1]=h*F>>G,c[f+2]=i*F>>G,g-=v,h-=w,i-=x,v-=a.r,w-=a.g,x-=a.b,d=J+((d=u+k+1)<K?d:K)<<2,m+=a.r=c[d],n+=a.g=c[d+1],o+=a.b=c[d+2],g+=m,h+=n,i+=o,a=a.next,
|
||||
v+=r=b.r,w+=s=b.g,x+=t=b.b,m-=r,n-=s,o-=t,b=b.next,f+=4;J+=j}for(u=0;u<j;u++){n=o=m=h=i=g=0;f=u<<2;v=p*(r=c[f]);w=p*(s=c[f+1]);x=p*(t=c[f+2]);g+=D*r;h+=D*s;i+=D*t;b=E;for(a=0;a<p;a++)b.r=r,b.g=s,b.b=t,b=b.next;d=j;for(a=1;a<=k;a++)f=d+u<<2,g+=(b.r=r=c[f])*(C=p-a),h+=(b.g=s=c[f+1])*C,i+=(b.b=t=c[f+2])*C,m+=r,n+=s,o+=t,b=b.next,a<N&&(d+=j);f=u;a=E;b=Q;for(z=0;z<q;z++)d=f<<2,c[d]=g*F>>G,c[d+1]=h*F>>G,c[d+2]=i*F>>G,g-=v,h-=w,i-=x,v-=a.r,w-=a.g,x-=a.b,d=u+((d=z+p)<N?d:N)*j<<2,g+=m+=a.r=c[d],h+=n+=a.g=
|
||||
c[d+1],i+=o+=a.b=c[d+2],a=a.next,v+=r=b.r,w+=s=b.g,x+=t=b.b,m-=r,n-=s,o-=t,b=b.next,f+=j}M.putImageData(l,0,0)}if(!1!=e.overlay)ctx.beginPath(),ctx.rect(0,0,tempImg.width,tempImg.width),ctx.fillStyle=e.overlay,ctx.fill();var j=y.toDataURL();if(e.cache)try{e.debug&&console.log("Cache Set"),localStorage.setItem(e.cacheKeyPrefix+H+"-"+B+"-data-image",j)}catch(V){console.log(V)}}q=I.css("backgroundAttachment");k="fixed"==q?"":"-"+(A.offset().left-I.offset().left-e.offset.x)+"px -"+(A.offset().top-I.offset().top-
|
||||
e.offset.y)+"px";A.css({"background-image":'url("'+j+'")',"background-repeat":I.css("backgroundRepeat"),"background-position":k,"background-attachment":q});!1!=e.optClass&&A.addClass(e.optClass);e.draggable&&(A.css({"background-attachment":"fixed","background-position":"0 0"}),A.draggable())};Storage.prototype.cacheChecksum=function(j){var q="",k;for(k in j)var l=j[k],q="[object Object]"==l.toString()?q+(l.x.toString()+l.y.toString()+",").replace(/[^a-zA-Z0-9]/g,""):q+(l+",").replace(/[^a-zA-Z0-9]/g,
|
||||
"");this.getItem(e.cacheKeyPrefix+H+"-"+B+"-options-cache")!=q&&(this.removeItem(e.cacheKeyPrefix+H+"-"+B+"-options-cache"),this.setItem(e.cacheKeyPrefix+H+"-"+B+"-options-cache",q),e.debug&&console.log("Settings Changed, Cache Emptied"))};var L=null;e.cache&&(localStorage.cacheChecksum(e),L=localStorage.getItem(e.cacheKeyPrefix+H+"-"+B+"-data-image"));null!=L?(e.debug&&console.log("Cache Used"),P=!0,tempImg.src=L):(e.debug&&console.log("Source Used"),tempImg.src=B)})}}})(jQuery);
|
||||
663
static/js/lib/color-thief.min.js
vendored
Executable file
663
static/js/lib/color-thief.min.js
vendored
Executable file
@@ -0,0 +1,663 @@
|
||||
/*
|
||||
* Color Thief v2.0
|
||||
* by Lokesh Dhakar - http://www.lokeshdhakar.com
|
||||
*
|
||||
* License
|
||||
* -------
|
||||
* Creative Commons Attribution 2.5 License:
|
||||
* http://creativecommons.org/licenses/by/2.5/
|
||||
*
|
||||
* Thanks
|
||||
* ------
|
||||
* Nick Rabinowitz - For creating quantize.js.
|
||||
* John Schulz - For clean up and optimization. @JFSIII
|
||||
* Nathan Spady - For adding drag and drop support to the demo page.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
CanvasImage Class
|
||||
Class that wraps the html image element and canvas.
|
||||
It also simplifies some of the canvas context manipulation
|
||||
with a set of helper functions.
|
||||
*/
|
||||
|
||||
var iAmOnNode = false;
|
||||
if (typeof process !== 'undefined' && process.execPath && process.execPath.indexOf('node') !== -1) {
|
||||
iAmOnNode = true;
|
||||
}
|
||||
if (iAmOnNode) {
|
||||
var Canvas = require('canvas');
|
||||
var Image = Canvas.Image;
|
||||
var fs = require('fs');
|
||||
}
|
||||
|
||||
var CanvasImage = function (image) {
|
||||
// in node we use strings as path to an image
|
||||
// whereas in the browser we use an image element
|
||||
if (iAmOnNode) {
|
||||
this.canvas = new Canvas()
|
||||
var img = new Image;
|
||||
|
||||
if(image instanceof Buffer) {
|
||||
img.src = image
|
||||
}else{
|
||||
img.src = fs.readFileSync(image);
|
||||
}
|
||||
|
||||
} else {
|
||||
this.canvas = document.createElement('canvas');
|
||||
document.body.appendChild(this.canvas);
|
||||
var img = image;
|
||||
}
|
||||
|
||||
this.context = this.canvas.getContext('2d');
|
||||
|
||||
this.width = this.canvas.width = img.width;
|
||||
this.height = this.canvas.height = img.height;
|
||||
|
||||
this.context.drawImage(img, 0, 0, this.width, this.height);
|
||||
};
|
||||
|
||||
CanvasImage.prototype.clear = function () {
|
||||
this.context.clearRect(0, 0, this.width, this.height);
|
||||
};
|
||||
|
||||
CanvasImage.prototype.update = function (imageData) {
|
||||
this.context.putImageData(imageData, 0, 0);
|
||||
};
|
||||
|
||||
CanvasImage.prototype.getPixelCount = function () {
|
||||
return this.width * this.height;
|
||||
};
|
||||
|
||||
CanvasImage.prototype.getImageData = function () {
|
||||
return this.context.getImageData(0, 0, this.width, this.height);
|
||||
};
|
||||
|
||||
CanvasImage.prototype.removeCanvas = function () {
|
||||
if (this.canvas.parentNode) {
|
||||
this.canvas.parentNode.removeChild(this.canvas);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var ColorThief = function () {};
|
||||
|
||||
/*
|
||||
* getColor(sourceImage[, quality])
|
||||
* returns {r: num, g: num, b: num}
|
||||
*
|
||||
* Use the median cut algorithm provided by quantize.js to cluster similar
|
||||
* colors and return the base color from the largest cluster.
|
||||
*
|
||||
* Quality is an optional argument. It needs to be an integer. 0 is the highest quality settings.
|
||||
* 10 is the default. There is a trade-off between quality and speed. The bigger the number, the
|
||||
* faster a color will be returned but the greater the likelihood that it will not be the visually
|
||||
* most dominant color.
|
||||
*
|
||||
* */
|
||||
ColorThief.prototype.getColor = function(sourceImage, quality, allowWhite) {
|
||||
// control if second parameter is allowWhite
|
||||
if (quality === true || quality === false) {
|
||||
allowWhite = quality;
|
||||
quality = undefined;
|
||||
}
|
||||
|
||||
var palette = this.getPalette(sourceImage, 5, quality, allowWhite);
|
||||
var dominantColor = palette[0];
|
||||
return dominantColor;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* getPalette(sourceImage[, colorCount, quality])
|
||||
* returns array[ {r: num, g: num, b: num}, {r: num, g: num, b: num}, ...]
|
||||
*
|
||||
* Use the median cut algorithm provided by quantize.js to cluster similar colors.
|
||||
*
|
||||
* colorCount determines the size of the palette; the number of colors returned. If not set, it
|
||||
* defaults to 10.
|
||||
*
|
||||
* BUGGY: Function does not always return the requested amount of colors. It can be +/- 2.
|
||||
*
|
||||
* quality is an optional argument. It needs to be an integer. 0 is the highest quality settings.
|
||||
* 10 is the default. There is a trade-off between quality and speed. The bigger the number, the
|
||||
* faster the palette generation but the greater the likelihood that colors will be missed.
|
||||
*
|
||||
*
|
||||
*/
|
||||
ColorThief.prototype.getPalette = function(sourceImage, colorCount, quality, allowWhite) {
|
||||
|
||||
if (typeof colorCount === 'undefined') {
|
||||
colorCount = 10;
|
||||
};
|
||||
if (typeof quality === 'undefined') {
|
||||
quality = 10;
|
||||
};
|
||||
|
||||
// Create custom CanvasImage object
|
||||
var image = new CanvasImage(sourceImage);
|
||||
var imageData = image.getImageData();
|
||||
var pixels = imageData.data;
|
||||
var pixelCount = image.getPixelCount();
|
||||
var palette = this.getPaletteFromPixels(pixels, pixelCount, colorCount, quality, allowWhite);
|
||||
|
||||
// Clean up
|
||||
image.removeCanvas();
|
||||
|
||||
return palette;
|
||||
};
|
||||
|
||||
/*
|
||||
* getPaletteFromPixels(pixels, pixelCount, colorCount, quality)
|
||||
* returns array[ {r: num, g: num, b: num}, {r: num, g: num, b: num}, ...]
|
||||
*
|
||||
* Low-level function that takes pixels and computes color palette.
|
||||
* Used by getPalette() and getColor()
|
||||
*
|
||||
*/
|
||||
ColorThief.prototype.getPaletteFromPixels = function(pixels, pixelCount, colorCount, quality, allowWhite) {
|
||||
|
||||
// Store the RGB values in an array format suitable for quantize function
|
||||
var pixelArray = [];
|
||||
for (var i = 0, offset, r, g, b, a; i < pixelCount; i = i + quality) {
|
||||
offset = i * 4;
|
||||
r = pixels[offset + 0];
|
||||
g = pixels[offset + 1];
|
||||
b = pixels[offset + 2];
|
||||
a = pixels[offset + 3];
|
||||
// If pixel is mostly opaque and not white
|
||||
if (a >= 125) {
|
||||
if ((!(r > 250 && g > 250 && b > 250) && allowWhite !== true) || (!(r > 255 && g > 255 && b > 255) && allowWhite === true )) {
|
||||
pixelArray.push([r, g, b]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send array to quantize function which clusters values
|
||||
// using median cut algorithm
|
||||
var cmap = MMCQ.quantize(pixelArray, colorCount);
|
||||
var palette = cmap.palette();
|
||||
|
||||
return palette;
|
||||
}
|
||||
|
||||
/*!
|
||||
* quantize.js Copyright 2008 Nick Rabinowitz.
|
||||
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
// fill out a couple protovis dependencies
|
||||
/*!
|
||||
* Block below copied from Protovis: http://mbostock.github.com/protovis/
|
||||
* Copyright 2010 Stanford Visualization Group
|
||||
* Licensed under the BSD License: http://www.opensource.org/licenses/bsd-license.php
|
||||
*/
|
||||
if (!pv) {
|
||||
var pv = {
|
||||
map: function(array, f) {
|
||||
var o = {};
|
||||
return f
|
||||
? array.map(function(d, i) { o.index = i; return f.call(o, d); })
|
||||
: array.slice();
|
||||
},
|
||||
naturalOrder: function(a, b) {
|
||||
return (a < b) ? -1 : ((a > b) ? 1 : 0);
|
||||
},
|
||||
sum: function(array, f) {
|
||||
var o = {};
|
||||
return array.reduce(f
|
||||
? function(p, d, i) { o.index = i; return p + f.call(o, d); }
|
||||
: function(p, d) { return p + d; }, 0);
|
||||
},
|
||||
max: function(array, f) {
|
||||
return Math.max.apply(null, f ? pv.map(array, f) : array);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Basic Javascript port of the MMCQ (modified median cut quantization)
|
||||
* algorithm from the Leptonica library (http://www.leptonica.com/).
|
||||
* Returns a color map you can use to map original pixels to the reduced
|
||||
* palette. Still a work in progress.
|
||||
*
|
||||
* @author Nick Rabinowitz
|
||||
* @example
|
||||
|
||||
// array of pixels as [R,G,B] arrays
|
||||
var myPixels = [[190,197,190], [202,204,200], [207,214,210], [211,214,211], [205,207,207]
|
||||
// etc
|
||||
];
|
||||
var maxColors = 4;
|
||||
|
||||
var cmap = MMCQ.quantize(myPixels, maxColors);
|
||||
var newPalette = cmap.palette();
|
||||
var newPixels = myPixels.map(function(p) {
|
||||
return cmap.map(p);
|
||||
});
|
||||
|
||||
*/
|
||||
var MMCQ = (function() {
|
||||
// private constants
|
||||
var sigbits = 5,
|
||||
rshift = 8 - sigbits,
|
||||
maxIterations = 1000,
|
||||
fractByPopulations = 0.75;
|
||||
|
||||
// get reduced-space color index for a pixel
|
||||
function getColorIndex(r, g, b) {
|
||||
return (r << (2 * sigbits)) + (g << sigbits) + b;
|
||||
}
|
||||
|
||||
// Simple priority queue
|
||||
function PQueue(comparator) {
|
||||
var contents = [],
|
||||
sorted = false;
|
||||
|
||||
function sort() {
|
||||
contents.sort(comparator);
|
||||
sorted = true;
|
||||
}
|
||||
|
||||
return {
|
||||
push: function(o) {
|
||||
contents.push(o);
|
||||
sorted = false;
|
||||
},
|
||||
peek: function(index) {
|
||||
if (!sorted) sort();
|
||||
if (index===undefined) index = contents.length - 1;
|
||||
return contents[index];
|
||||
},
|
||||
pop: function() {
|
||||
if (!sorted) sort();
|
||||
return contents.pop();
|
||||
},
|
||||
size: function() {
|
||||
return contents.length;
|
||||
},
|
||||
map: function(f) {
|
||||
return contents.map(f);
|
||||
},
|
||||
debug: function() {
|
||||
if (!sorted) sort();
|
||||
return contents;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 3d color space box
|
||||
function VBox(r1, r2, g1, g2, b1, b2, histo) {
|
||||
var vbox = this;
|
||||
vbox.r1 = r1;
|
||||
vbox.r2 = r2;
|
||||
vbox.g1 = g1;
|
||||
vbox.g2 = g2;
|
||||
vbox.b1 = b1;
|
||||
vbox.b2 = b2;
|
||||
vbox.histo = histo;
|
||||
}
|
||||
VBox.prototype = {
|
||||
volume: function(force) {
|
||||
var vbox = this;
|
||||
if (!vbox._volume || force) {
|
||||
vbox._volume = ((vbox.r2 - vbox.r1 + 1) * (vbox.g2 - vbox.g1 + 1) * (vbox.b2 - vbox.b1 + 1));
|
||||
}
|
||||
return vbox._volume;
|
||||
},
|
||||
count: function(force) {
|
||||
var vbox = this,
|
||||
histo = vbox.histo;
|
||||
if (!vbox._count_set || force) {
|
||||
var npix = 0,
|
||||
i, j, k;
|
||||
for (i = vbox.r1; i <= vbox.r2; i++) {
|
||||
for (j = vbox.g1; j <= vbox.g2; j++) {
|
||||
for (k = vbox.b1; k <= vbox.b2; k++) {
|
||||
var index = getColorIndex(i,j,k);
|
||||
npix += (histo[index] || 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
vbox._count = npix;
|
||||
vbox._count_set = true;
|
||||
}
|
||||
return vbox._count;
|
||||
},
|
||||
copy: function() {
|
||||
var vbox = this;
|
||||
return new VBox(vbox.r1, vbox.r2, vbox.g1, vbox.g2, vbox.b1, vbox.b2, vbox.histo);
|
||||
},
|
||||
avg: function(force) {
|
||||
var vbox = this,
|
||||
histo = vbox.histo;
|
||||
if (!vbox._avg || force) {
|
||||
var ntot = 0,
|
||||
mult = 1 << (8 - sigbits),
|
||||
rsum = 0,
|
||||
gsum = 0,
|
||||
bsum = 0,
|
||||
hval,
|
||||
i, j, k, histoindex;
|
||||
for (i = vbox.r1; i <= vbox.r2; i++) {
|
||||
for (j = vbox.g1; j <= vbox.g2; j++) {
|
||||
for (k = vbox.b1; k <= vbox.b2; k++) {
|
||||
histoindex = getColorIndex(i,j,k);
|
||||
hval = histo[histoindex] || 0;
|
||||
ntot += hval;
|
||||
rsum += (hval * (i + 0.5) * mult);
|
||||
gsum += (hval * (j + 0.5) * mult);
|
||||
bsum += (hval * (k + 0.5) * mult);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ntot) {
|
||||
vbox._avg = [~~(rsum/ntot), ~~(gsum/ntot), ~~(bsum/ntot)];
|
||||
} else {
|
||||
// console.log('empty box');
|
||||
vbox._avg = [
|
||||
~~(mult * (vbox.r1 + vbox.r2 + 1) / 2),
|
||||
~~(mult * (vbox.g1 + vbox.g2 + 1) / 2),
|
||||
~~(mult * (vbox.b1 + vbox.b2 + 1) / 2)
|
||||
];
|
||||
}
|
||||
}
|
||||
return vbox._avg;
|
||||
},
|
||||
contains: function(pixel) {
|
||||
var vbox = this,
|
||||
rval = pixel[0] >> rshift;
|
||||
gval = pixel[1] >> rshift;
|
||||
bval = pixel[2] >> rshift;
|
||||
return (rval >= vbox.r1 && rval <= vbox.r2 &&
|
||||
gval >= vbox.g1 && gval <= vbox.g2 &&
|
||||
bval >= vbox.b1 && bval <= vbox.b2);
|
||||
}
|
||||
};
|
||||
|
||||
// Color map
|
||||
function CMap() {
|
||||
this.vboxes = new PQueue(function(a,b) {
|
||||
return pv.naturalOrder(
|
||||
a.vbox.count()*a.vbox.volume(),
|
||||
b.vbox.count()*b.vbox.volume()
|
||||
)
|
||||
});;
|
||||
}
|
||||
CMap.prototype = {
|
||||
push: function(vbox) {
|
||||
this.vboxes.push({
|
||||
vbox: vbox,
|
||||
color: vbox.avg()
|
||||
});
|
||||
},
|
||||
palette: function() {
|
||||
return this.vboxes.map(function(vb) { return vb.color });
|
||||
},
|
||||
size: function() {
|
||||
return this.vboxes.size();
|
||||
},
|
||||
map: function(color) {
|
||||
var vboxes = this.vboxes;
|
||||
for (var i=0; i<vboxes.size(); i++) {
|
||||
if (vboxes.peek(i).vbox.contains(color)) {
|
||||
return vboxes.peek(i).color;
|
||||
}
|
||||
}
|
||||
return this.nearest(color);
|
||||
},
|
||||
nearest: function(color) {
|
||||
var vboxes = this.vboxes,
|
||||
d1, d2, pColor;
|
||||
for (var i=0; i<vboxes.size(); i++) {
|
||||
d2 = Math.sqrt(
|
||||
Math.pow(color[0] - vboxes.peek(i).color[0], 2) +
|
||||
Math.pow(color[1] - vboxes.peek(i).color[1], 2) +
|
||||
Math.pow(color[2] - vboxes.peek(i).color[2], 2)
|
||||
);
|
||||
if (d2 < d1 || d1 === undefined) {
|
||||
d1 = d2;
|
||||
pColor = vboxes.peek(i).color;
|
||||
}
|
||||
}
|
||||
return pColor;
|
||||
},
|
||||
forcebw: function() {
|
||||
// XXX: won't work yet
|
||||
var vboxes = this.vboxes;
|
||||
vboxes.sort(function(a,b) { return pv.naturalOrder(pv.sum(a.color), pv.sum(b.color) )});
|
||||
|
||||
// force darkest color to black if everything < 5
|
||||
var lowest = vboxes[0].color;
|
||||
if (lowest[0] < 5 && lowest[1] < 5 && lowest[2] < 5)
|
||||
vboxes[0].color = [0,0,0];
|
||||
|
||||
// force lightest color to white if everything > 251
|
||||
var idx = vboxes.length-1,
|
||||
highest = vboxes[idx].color;
|
||||
if (highest[0] > 251 && highest[1] > 251 && highest[2] > 251)
|
||||
vboxes[idx].color = [255,255,255];
|
||||
}
|
||||
};
|
||||
|
||||
// histo (1-d array, giving the number of pixels in
|
||||
// each quantized region of color space), or null on error
|
||||
function getHisto(pixels) {
|
||||
var histosize = 1 << (3 * sigbits),
|
||||
histo = new Array(histosize),
|
||||
index, rval, gval, bval;
|
||||
pixels.forEach(function(pixel) {
|
||||
rval = pixel[0] >> rshift;
|
||||
gval = pixel[1] >> rshift;
|
||||
bval = pixel[2] >> rshift;
|
||||
index = getColorIndex(rval, gval, bval);
|
||||
histo[index] = (histo[index] || 0) + 1;
|
||||
});
|
||||
return histo;
|
||||
}
|
||||
|
||||
function vboxFromPixels(pixels, histo) {
|
||||
var rmin=1000000, rmax=0,
|
||||
gmin=1000000, gmax=0,
|
||||
bmin=1000000, bmax=0,
|
||||
rval, gval, bval;
|
||||
// find min/max
|
||||
pixels.forEach(function(pixel) {
|
||||
rval = pixel[0] >> rshift;
|
||||
gval = pixel[1] >> rshift;
|
||||
bval = pixel[2] >> rshift;
|
||||
if (rval < rmin) rmin = rval;
|
||||
else if (rval > rmax) rmax = rval;
|
||||
if (gval < gmin) gmin = gval;
|
||||
else if (gval > gmax) gmax = gval;
|
||||
if (bval < bmin) bmin = bval;
|
||||
else if (bval > bmax) bmax = bval;
|
||||
});
|
||||
return new VBox(rmin, rmax, gmin, gmax, bmin, bmax, histo);
|
||||
}
|
||||
|
||||
function medianCutApply(histo, vbox) {
|
||||
if (!vbox.count()) return;
|
||||
|
||||
var rw = vbox.r2 - vbox.r1 + 1,
|
||||
gw = vbox.g2 - vbox.g1 + 1,
|
||||
bw = vbox.b2 - vbox.b1 + 1,
|
||||
maxw = pv.max([rw, gw, bw]);
|
||||
// only one pixel, no split
|
||||
if (vbox.count() == 1) {
|
||||
return [vbox.copy()]
|
||||
}
|
||||
/* Find the partial sum arrays along the selected axis. */
|
||||
var total = 0,
|
||||
partialsum = [],
|
||||
lookaheadsum = [],
|
||||
i, j, k, sum, index;
|
||||
if (maxw == rw) {
|
||||
for (i = vbox.r1; i <= vbox.r2; i++) {
|
||||
sum = 0;
|
||||
for (j = vbox.g1; j <= vbox.g2; j++) {
|
||||
for (k = vbox.b1; k <= vbox.b2; k++) {
|
||||
index = getColorIndex(i,j,k);
|
||||
sum += (histo[index] || 0);
|
||||
}
|
||||
}
|
||||
total += sum;
|
||||
partialsum[i] = total;
|
||||
}
|
||||
}
|
||||
else if (maxw == gw) {
|
||||
for (i = vbox.g1; i <= vbox.g2; i++) {
|
||||
sum = 0;
|
||||
for (j = vbox.r1; j <= vbox.r2; j++) {
|
||||
for (k = vbox.b1; k <= vbox.b2; k++) {
|
||||
index = getColorIndex(j,i,k);
|
||||
sum += (histo[index] || 0);
|
||||
}
|
||||
}
|
||||
total += sum;
|
||||
partialsum[i] = total;
|
||||
}
|
||||
}
|
||||
else { /* maxw == bw */
|
||||
for (i = vbox.b1; i <= vbox.b2; i++) {
|
||||
sum = 0;
|
||||
for (j = vbox.r1; j <= vbox.r2; j++) {
|
||||
for (k = vbox.g1; k <= vbox.g2; k++) {
|
||||
index = getColorIndex(j,k,i);
|
||||
sum += (histo[index] || 0);
|
||||
}
|
||||
}
|
||||
total += sum;
|
||||
partialsum[i] = total;
|
||||
}
|
||||
}
|
||||
partialsum.forEach(function(d,i) {
|
||||
lookaheadsum[i] = total-d
|
||||
});
|
||||
function doCut(color) {
|
||||
var dim1 = color + '1',
|
||||
dim2 = color + '2',
|
||||
left, right, vbox1, vbox2, d2, count2=0;
|
||||
for (i = vbox[dim1]; i <= vbox[dim2]; i++) {
|
||||
if (partialsum[i] > total / 2) {
|
||||
vbox1 = vbox.copy();
|
||||
vbox2 = vbox.copy();
|
||||
left = i - vbox[dim1];
|
||||
right = vbox[dim2] - i;
|
||||
if (left <= right)
|
||||
d2 = Math.min(vbox[dim2] - 1, ~~(i + right / 2));
|
||||
else d2 = Math.max(vbox[dim1], ~~(i - 1 - left / 2));
|
||||
// avoid 0-count boxes
|
||||
while (!partialsum[d2]) d2++;
|
||||
count2 = lookaheadsum[d2];
|
||||
while (!count2 && partialsum[d2-1]) count2 = lookaheadsum[--d2];
|
||||
// set dimensions
|
||||
vbox1[dim2] = d2;
|
||||
vbox2[dim1] = vbox1[dim2] + 1;
|
||||
// console.log('vbox counts:', vbox.count(), vbox1.count(), vbox2.count());
|
||||
return [vbox1, vbox2];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// determine the cut planes
|
||||
return maxw == rw ? doCut('r') :
|
||||
maxw == gw ? doCut('g') :
|
||||
doCut('b');
|
||||
}
|
||||
|
||||
function quantize(pixels, maxcolors) {
|
||||
// short-circuit
|
||||
if (!pixels.length || maxcolors < 2 || maxcolors > 256) {
|
||||
// console.log('wrong number of maxcolors');
|
||||
return false;
|
||||
}
|
||||
|
||||
// XXX: check color content and convert to grayscale if insufficient
|
||||
|
||||
var histo = getHisto(pixels),
|
||||
histosize = 1 << (3 * sigbits);
|
||||
|
||||
// check that we aren't below maxcolors already
|
||||
var nColors = 0;
|
||||
histo.forEach(function() { nColors++ });
|
||||
if (nColors <= maxcolors) {
|
||||
// XXX: generate the new colors from the histo and return
|
||||
}
|
||||
|
||||
// get the beginning vbox from the colors
|
||||
var vbox = vboxFromPixels(pixels, histo),
|
||||
pq = new PQueue(function(a,b) { return pv.naturalOrder(a.count(), b.count()) });
|
||||
pq.push(vbox);
|
||||
|
||||
// inner function to do the iteration
|
||||
function iter(lh, target) {
|
||||
var ncolors = 1,
|
||||
niters = 0,
|
||||
vbox;
|
||||
while (niters < maxIterations) {
|
||||
vbox = lh.pop();
|
||||
if (!vbox.count()) { /* just put it back */
|
||||
lh.push(vbox);
|
||||
niters++;
|
||||
continue;
|
||||
}
|
||||
// do the cut
|
||||
var vboxes = medianCutApply(histo, vbox),
|
||||
vbox1 = vboxes[0],
|
||||
vbox2 = vboxes[1];
|
||||
|
||||
if (!vbox1) {
|
||||
// console.log("vbox1 not defined; shouldn't happen!");
|
||||
return;
|
||||
}
|
||||
lh.push(vbox1);
|
||||
if (vbox2) { /* vbox2 can be null */
|
||||
lh.push(vbox2);
|
||||
ncolors++;
|
||||
}
|
||||
if (ncolors >= target) return;
|
||||
if (niters++ > maxIterations) {
|
||||
// console.log("infinite loop; perhaps too few pixels!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// first set of colors, sorted by population
|
||||
iter(pq, fractByPopulations * maxcolors);
|
||||
|
||||
// Re-sort by the product of pixel occupancy times the size in color space.
|
||||
var pq2 = new PQueue(function(a,b) {
|
||||
return pv.naturalOrder(a.count()*a.volume(), b.count()*b.volume())
|
||||
});
|
||||
while (pq.size()) {
|
||||
pq2.push(pq.pop());
|
||||
}
|
||||
|
||||
// next set - generate the median cuts using the (npix * vol) sorting.
|
||||
iter(pq2, maxcolors - pq2.size());
|
||||
|
||||
// calculate the actual colors
|
||||
var cmap = new CMap();
|
||||
while (pq2.size()) {
|
||||
cmap.push(pq2.pop());
|
||||
}
|
||||
|
||||
return cmap;
|
||||
}
|
||||
|
||||
return {
|
||||
quantize: quantize
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = ColorThief;
|
||||
}
|
||||
1
static/js/lib/iscroll-min.js
vendored
Executable file
1
static/js/lib/iscroll-min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
2006
static/js/lib/iscroll.js
Executable file
2006
static/js/lib/iscroll.js
Executable file
File diff suppressed because it is too large
Load Diff
2
static/js/lib/lazyload-min.js
vendored
Executable file
2
static/js/lib/lazyload-min.js
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
/*! Lazy Load 1.9.3 - MIT license - Copyright 2010-2013 Mika Tuupola */
|
||||
!function(a,b,c,d){var e=a(b);a.fn.lazyload=function(f){function g(){var b=0;i.each(function(){var c=a(this);if(!j.skip_invisible||c.is(":visible"))if(a.abovethetop(this,j)||a.leftofbegin(this,j));else if(a.belowthefold(this,j)||a.rightoffold(this,j)){if(++b>j.failure_limit)return!1}else c.trigger("appear"),b=0})}var h,i=this,j={threshold:0,failure_limit:0,event:"scroll",effect:"show",container:b,data_attribute:"original",skip_invisible:!0,appear:null,load:null,placeholder:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC"};return f&&(d!==f.failurelimit&&(f.failure_limit=f.failurelimit,delete f.failurelimit),d!==f.effectspeed&&(f.effect_speed=f.effectspeed,delete f.effectspeed),a.extend(j,f)),h=j.container===d||j.container===b?e:a(j.container),0===j.event.indexOf("scroll")&&h.bind(j.event,function(){return g()}),this.each(function(){var b=this,c=a(b);b.loaded=!1,(c.attr("src")===d||c.attr("src")===!1)&&c.is("img")&&c.attr("src",j.placeholder),c.one("appear",function(){if(!this.loaded){if(j.appear){var d=i.length;j.appear.call(b,d,j)}a("<img />").bind("load",function(){var d=c.attr("data-"+j.data_attribute);c.hide(),c.is("img")?c.attr("src",d):c.css("background-image","url('"+d+"')"),c[j.effect](j.effect_speed),b.loaded=!0;var e=a.grep(i,function(a){return!a.loaded});if(i=a(e),j.load){var f=i.length;j.load.call(b,f,j)}}).attr("src",c.attr("data-"+j.data_attribute))}}),0!==j.event.indexOf("scroll")&&c.bind(j.event,function(){b.loaded||c.trigger("appear")})}),e.bind("resize",function(){g()}),/(?:iphone|ipod|ipad).*os 5/gi.test(navigator.appVersion)&&e.bind("pageshow",function(b){b.originalEvent&&b.originalEvent.persisted&&i.each(function(){a(this).trigger("appear")})}),a(c).ready(function(){g()}),this},a.belowthefold=function(c,f){var g;return g=f.container===d||f.container===b?(b.innerHeight?b.innerHeight:e.height())+e.scrollTop():a(f.container).offset().top+a(f.container).height(),g<=a(c).offset().top-f.threshold},a.rightoffold=function(c,f){var g;return g=f.container===d||f.container===b?e.width()+e.scrollLeft():a(f.container).offset().left+a(f.container).width(),g<=a(c).offset().left-f.threshold},a.abovethetop=function(c,f){var g;return g=f.container===d||f.container===b?e.scrollTop():a(f.container).offset().top,g>=a(c).offset().top+f.threshold+a(c).height()},a.leftofbegin=function(c,f){var g;return g=f.container===d||f.container===b?e.scrollLeft():a(f.container).offset().left,g>=a(c).offset().left+f.threshold+a(c).width()},a.inviewport=function(b,c){return!(a.rightoffold(b,c)||a.leftofbegin(b,c)||a.belowthefold(b,c)||a.abovethetop(b,c))},a.extend(a.expr[":"],{"below-the-fold":function(b){return a.belowthefold(b,{threshold:0})},"above-the-top":function(b){return!a.belowthefold(b,{threshold:0})},"right-of-screen":function(b){return a.rightoffold(b,{threshold:0})},"left-of-screen":function(b){return!a.rightoffold(b,{threshold:0})},"in-viewport":function(b){return a.inviewport(b,{threshold:0})},"above-the-fold":function(b){return!a.belowthefold(b,{threshold:0})},"right-of-fold":function(b){return a.rightoffold(b,{threshold:0})},"left-of-fold":function(b){return!a.rightoffold(b,{threshold:0})}})}(jQuery,window,document);
|
||||
6003
static/js/lib/materialize.js
vendored
Executable file
6003
static/js/lib/materialize.js
vendored
Executable file
File diff suppressed because one or more lines are too long
10
static/js/lib/materialize.min.js
vendored
Executable file
10
static/js/lib/materialize.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
217
static/js/list.js
Executable file
217
static/js/list.js
Executable file
@@ -0,0 +1,217 @@
|
||||
var list;
|
||||
var toSend = "";
|
||||
var sendURL;
|
||||
var myScroll;
|
||||
var scroller = false;
|
||||
var showToggle =true;
|
||||
var chan = $("#chan").html();
|
||||
var hasadmin=0;
|
||||
|
||||
function updateList()
|
||||
{
|
||||
console.log("updating list");
|
||||
list = $.ajax({ type: "GET",
|
||||
url: "php/change.php",
|
||||
async: false
|
||||
}).responseText;
|
||||
list = $.parseJSON(list);
|
||||
conf = list.conf;
|
||||
if(conf.hasOwnProperty("addsongs") && conf.addsongs == "true") adminadd = 1;
|
||||
else adminadd = 0;
|
||||
if(conf.hasOwnProperty("allvideos") && conf.allvideos == "true") music = 1;
|
||||
else music = 0;
|
||||
if(conf.hasOwnProperty("longsongs") && conf.longsongs == "true") longS = 1;
|
||||
else longS = 0;
|
||||
if(conf.hasOwnProperty("vote") && conf.vote == "true") adminvote = 1;
|
||||
else adminvote = 0;
|
||||
if(conf.hasOwnProperty("adminpass") && conf.adminpass !== '') hasadmin = 1;
|
||||
else hasadmin = 0;
|
||||
/*list[0].shift();
|
||||
list[3].shift();
|
||||
list[2].shift();*/
|
||||
|
||||
setTimeout(function()
|
||||
{
|
||||
|
||||
$("#wrapper").empty();
|
||||
|
||||
$.each(list.songs, function(j, listeID){
|
||||
var video_title=listeID.title.replace(/\\\'/g, "'").replace(/"/g,"'").replace(/&/g,"&");
|
||||
var video_id = listeID.id;
|
||||
if(find && $.inArray(video_id, bright) == -1) brightness = "brightness";
|
||||
else if(find && $.inArray(video_id, bright) != -1) brightness = "brightness fullbrightness";
|
||||
else brightness = "";
|
||||
var video_thumb = "http://i.ytimg.com/vi/"+video_id+"/mqdefault.jpg";
|
||||
var odd = ""; if(j%2===0)odd=" oddlist";
|
||||
var delsong = ""; if(pass_corr=="correct")delsong="<input id='del' title='Remove' type='button' class='button' value='X' onclick=\"vote('"+video_id+"','del')\">";
|
||||
var finalhtml="<div id='result' class='"+video_id+" result "+brightness+" lresult"+odd+"'>"+
|
||||
"<img class='thumb lthumb' src='"+video_thumb+"'>"+
|
||||
"<div class='ltitle'>"+video_title+"</div>"+
|
||||
"<div class='votes'>"+listeID.votes+
|
||||
"<a onclick=\"vote('"+video_id+"','pos');\" id='plus'>+</a>"+
|
||||
"<a onclick=\"vote('"+video_id+"','neg');\" id='minus'>-</a>"+
|
||||
delsong+
|
||||
"</div>"+
|
||||
"</div>";
|
||||
$("#wrapper").append(finalhtml);
|
||||
});
|
||||
if($("#playlist").height() != $("#player").height() || (peis && $("#playlist").height() != $("#jplayer").height()))
|
||||
{
|
||||
if(!window.mobilecheck())
|
||||
{
|
||||
if(peis)
|
||||
{
|
||||
player_name = "#jplayer";
|
||||
}else player_name = "#player";
|
||||
$("#playlist").css({height: $(player_name).height()-$("#adminPanel").outerHeight(true)-$("#findform").outerHeight(true)+30});
|
||||
$("#playlist").css({overflow: "hidden"});
|
||||
if(scroller === false)
|
||||
{
|
||||
myScroll = new IScroll('#playlist', {
|
||||
mouseWheel: true,
|
||||
scrollbars: true,
|
||||
scrollY: true,
|
||||
interactiveScrollbars: true,
|
||||
fadeScrollbars: false
|
||||
});
|
||||
scroller = true;
|
||||
}else
|
||||
{
|
||||
myScroll.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(window.mobilecheck())
|
||||
{
|
||||
//document.getElementById("player").style.display="none";
|
||||
//ytplayer.pauseVideo();
|
||||
}else{
|
||||
myScroll.refresh();
|
||||
}
|
||||
if(!adminTogg)
|
||||
{
|
||||
names=["vote","addsongs","longsongs","frontpage", "allvideos", "removeplay", "skip", "shuffle"];
|
||||
for (var i = 0; i < names.length; i++) {
|
||||
document.getElementsByName(names[i])[0].checked = (conf[names[i]] === "true");
|
||||
document.getElementsByName(names[i])[1].checked = (conf[names[i]] === "false");
|
||||
}
|
||||
|
||||
if(hasadmin)
|
||||
$("#setpass").text("Channel has admin");
|
||||
else
|
||||
$("#setpass").text("Channel has no admin");
|
||||
}
|
||||
$("#settings").css("visibility", "visible");
|
||||
$("#settings").css("opacity", "0.7");
|
||||
$("#wrapper").css("opacity", "1");
|
||||
}, 2500);
|
||||
}
|
||||
|
||||
function vote(id, vote){
|
||||
serverAns = ($.ajax({
|
||||
type: "GET",
|
||||
url: "php/change.php",
|
||||
async: false,
|
||||
data: "vote="+vote+"&id="+id+"&pass="+adminpass,
|
||||
success: function() {
|
||||
console.log("voted "+vote+" on "+id);
|
||||
/*if(vote=="pos"){ $("#playlist").addClass("success");}
|
||||
else{ $("#playlist").addClass("fadeerror");}
|
||||
updateList();*/
|
||||
},
|
||||
}).responseText);
|
||||
|
||||
if(serverAns == "wrong")
|
||||
{
|
||||
//alert("Wrong adminpassword!");
|
||||
$("#eBar").addClass("opacityFull");
|
||||
}else{
|
||||
if(vote=="pos" && serverAns != "many"){ $("."+id).addClass("success");}
|
||||
else{ $("."+id).addClass("fadeerror");}
|
||||
updateList();
|
||||
}
|
||||
|
||||
setTimeout(function(){
|
||||
$("."+id).removeClass("success");
|
||||
$("."+id).removeClass("fadeerror");
|
||||
$("#eBar").removeClass("opacityFull");
|
||||
},1500);
|
||||
}
|
||||
|
||||
function skip(){
|
||||
voteRes = ($.ajax({
|
||||
type: "GET",
|
||||
url: "php/change.php",
|
||||
async: false,
|
||||
data: "skip",
|
||||
success: function() {
|
||||
console.log("voted to skip song");
|
||||
//$("#search").addClass("success");
|
||||
updateList();
|
||||
},
|
||||
}).responseText);
|
||||
|
||||
if(voteRes == "wrong!")
|
||||
{
|
||||
document.getElementById("eBar").innerHTML = "Error: Skipping disabled.";
|
||||
$("#eBar").addClass("opacityFull");
|
||||
}else{
|
||||
skipVotes = voteRes.split("/");
|
||||
if(skipVotes[0]>= skipVotes[1]/2)
|
||||
{
|
||||
document.getElementById("sBar").innerHTML = "Successfully skipped!";
|
||||
$("#sBar").addClass("opacityFull");
|
||||
}else
|
||||
{
|
||||
document.getElementById("pBar").innerHTML = "Vote registrated! "+skipVotes[0]+" of "+skipVotes[1]+" has skipped. "+(Math.ceil(skipVotes[1]/2))+" or more is needed!";
|
||||
$("#pBar").addClass("opacityFull");
|
||||
}
|
||||
}
|
||||
setTimeout(function(){
|
||||
$("#search").removeClass("success");
|
||||
$("#sBar").removeClass("opacityFull");
|
||||
$("#pBar").removeClass("opacityFull");
|
||||
$("#eBar").removeClass("opacityFull");
|
||||
},1500);
|
||||
|
||||
}
|
||||
|
||||
function show(){
|
||||
if(!window.mobilecheck())
|
||||
{
|
||||
if(showToggle){
|
||||
showToggle=false;
|
||||
$("#toptitle").empty();
|
||||
$("#chan").addClass("bigChan");
|
||||
//$("#chan").html("zoff.no/"+encodeURI(chan));
|
||||
$("#chan").html("zoff.no/"+chan);
|
||||
}else{
|
||||
showToggle=true;
|
||||
$("#toptitle").html("Zöff");
|
||||
$("#chan").removeClass("bigChan");
|
||||
$("#chan").html(chan);
|
||||
}
|
||||
fitToScreen();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function ks()
|
||||
{
|
||||
list = $.ajax({ type: "GET",
|
||||
url: "php/change.php",
|
||||
async: false
|
||||
}).responseText;
|
||||
list = $.parseJSON(list);
|
||||
myScroll.destroy();
|
||||
myScroll = null;
|
||||
$("#playlist").css({height: $("#player").height()});
|
||||
$("#playlist").css({overflow: "hidden"});
|
||||
myScroll = new IScroll('#playlist', {
|
||||
mouseWheel: true,
|
||||
scrollbars: false,
|
||||
scrollY: true,
|
||||
interactiveScrollbars: false
|
||||
});
|
||||
scroller = true;
|
||||
}
|
||||
246
static/js/playercontrols.js
Executable file
246
static/js/playercontrols.js
Executable file
@@ -0,0 +1,246 @@
|
||||
function initYoutubeControls(player)
|
||||
{
|
||||
if(player !== undefined)
|
||||
{
|
||||
ytplayer = player;
|
||||
//initSlider();
|
||||
durationFixer = setInterval(durationSetter, 1000);
|
||||
}else
|
||||
{
|
||||
tag = document.createElement('script');
|
||||
tag.src = "https://www.youtube.com/iframe_api";
|
||||
firstScriptTag = document.getElementsByTagName('script')[0];
|
||||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
||||
}
|
||||
elems = Array("volume", "duration", "mute", "fullscreen", "q");
|
||||
//elems = Array("volume", "duration", "fullscreen");
|
||||
var container = document.getElementById("controls");
|
||||
var newElem = document.createElement("div");
|
||||
newElem.id = "playpause";
|
||||
newElem.className = "play";
|
||||
container.appendChild(newElem);
|
||||
for(x = 0; x < elems.length; x++)
|
||||
{
|
||||
var newElemFor = document.createElement("div");
|
||||
newElemFor.id = elems[x];
|
||||
container.appendChild(newElemFor);
|
||||
}
|
||||
elems = Array("medium", "large", "hd1080", "auto");
|
||||
elemName = Array("Low", "Medium", "High", "Auto");
|
||||
newElem = document.createElement("div");
|
||||
newElem.id = "qS";
|
||||
newElem.className = "hide";
|
||||
|
||||
for(x = 0; x < elems.length; x++)
|
||||
{
|
||||
var newChild = document.createElement("div");
|
||||
newChild.className = "qChange";
|
||||
newChild.name = elems[x];
|
||||
newChild.setAttribute("onclick", "changeQuality('"+elems[x]+"');");
|
||||
newChild.innerHTML = elemName[x];
|
||||
newElem.appendChild(newChild);
|
||||
}
|
||||
container.appendChild(newElem);
|
||||
|
||||
newElem = document.createElement("div");
|
||||
newElem.id = "bar";
|
||||
|
||||
container.appendChild(newElem);
|
||||
|
||||
initControls();
|
||||
fitToScreen();
|
||||
$("#mute").hover(function(){hoverMute(true)}, function(){hoverMute(false)});
|
||||
$(window).resize(function(){
|
||||
fitToScreen();
|
||||
});
|
||||
}
|
||||
|
||||
function initControls()
|
||||
{
|
||||
document.getElementById("playpause").addEventListener("click", playPause);
|
||||
document.getElementById("q").addEventListener("click", settings);
|
||||
document.getElementById("mute").addEventListener("click", volumeOptions);
|
||||
document.getElementById("fullscreen").addEventListener("click", function()
|
||||
{
|
||||
document.getElementById("player").webkitRequestFullscreen();
|
||||
});
|
||||
//document.getElementById("controls").style.width= $(window).width()*0.6+"px";
|
||||
var classname = document.getElementsByClassName("qChange");
|
||||
/*for(var i=0; i< classname.length;i++)
|
||||
{
|
||||
classname[i].addEventListener("click", changeQuality);
|
||||
}*/
|
||||
}
|
||||
|
||||
function fitToScreen()
|
||||
{
|
||||
if(peis)
|
||||
{
|
||||
player_name = "#jplayer";
|
||||
}else player_name = "#player";
|
||||
//document.getElementById("controls").style.top = document.getElementById("player").offsetTop + $("#player").height() + "px";
|
||||
document.getElementById("controls").style.top = $(player_name).position()["top"] + $(player_name).height() + "px";
|
||||
//document.getElementById("controls").style.left = document.getElementById("player").offsetLeft + "px";
|
||||
document.getElementById("controls").style.left = $(player_name).position()["left"] + "px";
|
||||
//document.getElementById("controls").style.left = "10px";
|
||||
$("#controls").width($(player_name).width());
|
||||
document.getElementById("qS").style.top = "-80px";
|
||||
document.getElementById("qS").style.left = $("#controls").width()-125+"px";
|
||||
|
||||
}
|
||||
|
||||
function initSlider()
|
||||
{
|
||||
$("#volume").slider({
|
||||
min: 0,
|
||||
max: 100,
|
||||
value: ytplayer.getVolume(),
|
||||
range: "min",
|
||||
animate: true,
|
||||
slide: function(event, ui) {
|
||||
setVolume(ui.value);
|
||||
}
|
||||
});
|
||||
$("#volume").slider("value", ytplayer.getVolume());
|
||||
}
|
||||
|
||||
function settings()
|
||||
{
|
||||
$("#qS").toggleClass("hide");
|
||||
}
|
||||
|
||||
function changeQuality(wantedQ)
|
||||
{
|
||||
//wantedQ = this.getAttribute("name");
|
||||
//console.log("Change quality");
|
||||
//console.log(wantedQ);
|
||||
if(ytplayer.getPlaybackQuality != wantedQ)
|
||||
{
|
||||
ytplayer.setPlaybackQuality(wantedQ);
|
||||
ytplayer.getPlaybackQuality();
|
||||
}
|
||||
$("#qS").toggleClass("hide");
|
||||
}
|
||||
|
||||
function setVolume(vol)
|
||||
{
|
||||
ytplayer.setVolume(vol);
|
||||
//console.log(vol); //NO LOGS FOR U LOL
|
||||
if(ytplayer.isMuted())
|
||||
ytplayer.unMute();
|
||||
if(vol == 0){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -403px");
|
||||
}else if(vol < 33){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -1457px");
|
||||
}else if(vol > 33 && vol < 66){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -806px");
|
||||
}else if(vol > 66){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -1829px");
|
||||
}
|
||||
}
|
||||
|
||||
function playPause()
|
||||
{
|
||||
console.log("playPause");
|
||||
state = ytplayer.getPlayerState();
|
||||
console.log("state: "+state);
|
||||
button = document.getElementById("playpause");
|
||||
if(state == 1)
|
||||
{
|
||||
ytplayer.pauseVideo();
|
||||
//button.innerHTML = "Resume";
|
||||
}else if(state == 2)
|
||||
{
|
||||
ytplayer.playVideo();
|
||||
//button.innerHTML = "Pause";
|
||||
}
|
||||
}
|
||||
|
||||
function durationSetter()
|
||||
{
|
||||
if(ytplayer !== undefined && ytplayer.getDuration() !== undefined)
|
||||
{
|
||||
duration = ytplayer.getDuration();
|
||||
dMinutes = Math.floor(duration / 60);
|
||||
dSeconds = duration - dMinutes * 60;
|
||||
currDurr = ytplayer.getCurrentTime();
|
||||
if(currDurr > duration)
|
||||
currDurr = duration;
|
||||
minutes = Math.floor(currDurr / 60);
|
||||
seconds = currDurr - minutes * 60;
|
||||
document.getElementById("duration").innerHTML = pad(minutes)+":"+pad(seconds)+" <span id='dash'>/</span> "+pad(dMinutes)+":"+pad(dSeconds);
|
||||
per = (100 / duration) * currDurr;
|
||||
if(per >= 100)
|
||||
per = 100;
|
||||
else if(duration == 0)
|
||||
per = 0;
|
||||
$("#bar").width(per+"%");
|
||||
}
|
||||
}
|
||||
|
||||
function pad(n)
|
||||
{
|
||||
return n < 10 ? "0"+Math.floor(n) : Math.floor(n);
|
||||
}
|
||||
|
||||
function volumeOptions()
|
||||
{
|
||||
//console.log("volumeOptions");
|
||||
//button = document.getElementById("volume");
|
||||
if(ytplayer.isMuted())
|
||||
{
|
||||
ytplayer.unMute();
|
||||
vol = ytplayer.getVolume();
|
||||
$("#volume").slider("value", ytplayer.getVolume());
|
||||
if(vol == 0){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -93px");
|
||||
}else if(vol < 33){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -1395px");
|
||||
}else if(vol > 33 && vol < 66){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -1767px");
|
||||
}else if(vol > 66){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -2604px");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ytplayer.mute();
|
||||
$("#volume").slider("value", 0);
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -93px");
|
||||
}
|
||||
}
|
||||
|
||||
function hoverMute(foo)
|
||||
{
|
||||
vol = ytplayer.getVolume();
|
||||
console.log(vol);
|
||||
if(foo)
|
||||
{
|
||||
if(vol == 0 || ytplayer.isMuted()){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -93px");
|
||||
}else if(vol < 33){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -1395px");
|
||||
}else if(vol > 33 && vol < 66){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -1767px");
|
||||
}else if(vol > 66){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -2604px");
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(vol == 0 || ytplayer.isMuted()){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -403px");
|
||||
}else if(vol < 33){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -1457px");
|
||||
}else if(vol > 33 && vol < 66){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -806px");
|
||||
}else if(vol > 66){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -1829px");
|
||||
}
|
||||
}
|
||||
}
|
||||
//url(http://localhost/Kasperrt/static/player.webp) 0px -94px no-repeat
|
||||
|
||||
function logQ()
|
||||
{
|
||||
console.log(ytplayer.getPlaybackQuality());
|
||||
}
|
||||
243
static/js/search.js
Executable file
243
static/js/search.js
Executable file
@@ -0,0 +1,243 @@
|
||||
var old_input="";
|
||||
var timer = 0;
|
||||
/*jshint multistr: true */
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
$( "#results" ).hover( function() { $("div.result").removeClass("hoverResults"); i = 0; }, function() { });
|
||||
|
||||
|
||||
$("#search").focus();
|
||||
|
||||
$('#base').bind("keyup keypress", function(e) {
|
||||
var code = e.keyCode || e.which;
|
||||
if (code == 13) {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$(".search_input").focus();
|
||||
$(".search_input").keyup(function(event) {
|
||||
var search_input = $(this).val();
|
||||
console.log(event.keyCode);
|
||||
if(event.keyCode == 13 && search_input == "fireplace")
|
||||
{
|
||||
if(!peis)
|
||||
{
|
||||
peis = true;
|
||||
loadjsfile("js/jazzscript.js");
|
||||
|
||||
}else
|
||||
{
|
||||
peis = false;
|
||||
document.getElementsByClassName("jp")[0].style.display = "none";
|
||||
document.getElementsByClassName("ytplayer")[0].style.display = "inline";
|
||||
pauseJazz();
|
||||
}
|
||||
}
|
||||
|
||||
if (event.keyCode != 40 && event.keyCode != 38 && event.keyCode != 13 && event.keyCode != 39 && event.keyCode != 37) {
|
||||
if(search_input.length < 3){$("#results").html("");}
|
||||
if(event.keyCode == 13){
|
||||
search(search_input);
|
||||
}else if(event.keyCode == 27){
|
||||
$("#results").html("");
|
||||
$(".main").removeClass("blurT");
|
||||
$("#controls").removeClass("blurT");
|
||||
$(".main").removeClass("clickthrough");
|
||||
}else{
|
||||
i = 0;
|
||||
timer=100;
|
||||
}
|
||||
}else if(event.keyCode == 13)
|
||||
{
|
||||
//console.log(search_input);
|
||||
//console.log(search_input.split("list=")[1]);
|
||||
pId = search_input.split("list=");
|
||||
if(pId.length > 1)
|
||||
{
|
||||
pListUrl = "http://gdata.youtube.com/feeds/api/playlists/"+pId[1]+"/?format=5&max-results=25&v=2&alt=jsonc";
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: pListUrl,
|
||||
dataType:"jsonp",
|
||||
success: function(response)
|
||||
{
|
||||
console.log(response.data.items);
|
||||
$.each(response.data.items, function(i,data)
|
||||
{
|
||||
submit(data.video.id, data.video.title, true);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
setInterval(function(){
|
||||
timer--;
|
||||
if(timer===0){
|
||||
search($(".search_input").val());
|
||||
}
|
||||
}, 1);
|
||||
});
|
||||
|
||||
$(document).keyup(function(e) {
|
||||
if ($("div.result").length > 2){
|
||||
if (e.keyCode == 40) {
|
||||
if(i < $("div.result").length -2)
|
||||
i++;
|
||||
$("div.result:nth-child("+(i-1)+")").removeClass("hoverResults");
|
||||
$("div.result:nth-child("+i+")").addClass("hoverResults");
|
||||
} else if (e.keyCode == 38) {
|
||||
$("div.result:nth-child("+i+")").removeClass("hoverResults");
|
||||
$("div.result:nth-child("+(i-1)+")").addClass("hoverResults");
|
||||
if(i > 1)
|
||||
i--;
|
||||
} else if(e.keyCode == 13) {
|
||||
i = 0;
|
||||
var elem = document.getElementsByClassName("hoverResults")[0];
|
||||
if (typeof elem.onclick == "function") {
|
||||
elem.onclick.apply(elem);
|
||||
}
|
||||
$("div.hoverResults").removeClass("hoverResults");
|
||||
$("#results").html('');
|
||||
document.getElementById("search").value = "";
|
||||
$(".main").removeClass("blurT");
|
||||
$("#controls").removeClass("blurT");
|
||||
$(".main").removeClass("clickthrough");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function search(search_input){
|
||||
|
||||
|
||||
$("#results").html('');
|
||||
if(search_input !== ""){
|
||||
var keyword= encodeURIComponent(search_input);
|
||||
|
||||
var yt_url='http://gdata.youtube.com/feeds/api/videos?q='+keyword+'&format=5&orderby=relevance&max-results=6&v=2&alt=jsonc';
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: yt_url,
|
||||
dataType:"jsonp",
|
||||
success: function(response)
|
||||
{
|
||||
if(response.data.items)
|
||||
{
|
||||
var wrapper = "";
|
||||
$.each(response.data.items, function(i,data)
|
||||
{
|
||||
if(data.duration > 720 && longS === 0){return;}
|
||||
if(data.category == "Music" || music == 1){
|
||||
var video_title=encodeURIComponent(data.title).replace(/'/g, "\\\'");
|
||||
var views=data.viewCount;
|
||||
var video_thumb = "http://i.ytimg.com/vi/"+data.id+"/default.jpg";
|
||||
var length = Math.floor(data.duration/60)+":"+(data.duration-Math.floor(data.duration / 60)*60);
|
||||
var finalhtml="\
|
||||
<div id='result' class='result' onclick=\"submitAndClose('"+data.id+"','"+video_title+"');\">\
|
||||
<img src='"+video_thumb+"' class='thumb'>\
|
||||
<div id='title'>"+data.title+"\
|
||||
<div class='result_info'>"+views+" views • "+length+"</div>\
|
||||
<input id='add' title='Add several songs' type='button' class='button' value='+' onclick=\"submit('"+data.id+"','"+video_title+"', false);\">\
|
||||
</div>\
|
||||
</div>";
|
||||
//+data.uploader+" • "+
|
||||
//$("#results").append(finalhtml);
|
||||
wrapper += finalhtml;
|
||||
}
|
||||
});
|
||||
//console.log(wrapper);
|
||||
//$("#results").append(wrapper).show("slow");
|
||||
if(wrapper.length > 0)
|
||||
{
|
||||
$(".main").addClass("blurT");
|
||||
$("#controls").addClass("blurT");
|
||||
$(".main").addClass("clickthrough");
|
||||
}
|
||||
|
||||
$("<div id='r' style='display:none;'>"+wrapper+"</div>").appendTo('#results').slideDown('slow');
|
||||
|
||||
}
|
||||
else{ $("#video").html("<div id='no'>No Video</div>");}
|
||||
}
|
||||
|
||||
});
|
||||
}else{
|
||||
$(".main").removeClass("blurT");
|
||||
$("#controls").removeClass("blurT");
|
||||
$(".main").removeClass("clickthrough");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function submitAndClose(id,title){
|
||||
submit(id,title, true);
|
||||
$("#results").html('');
|
||||
console.log("sub&closed");
|
||||
|
||||
}
|
||||
|
||||
function submit(id,title,type){
|
||||
|
||||
serverAns = $.ajax({
|
||||
type: "GET",
|
||||
url: "php/change.php",
|
||||
async: false,
|
||||
data: "v="+id+"&n="+title+"&pass="+adminpass,
|
||||
success: function() {
|
||||
if(type){
|
||||
document.getElementById("search").value = "";
|
||||
$("#results").html = "";
|
||||
$(".main").removeClass("blurT");
|
||||
$("#controls").removeClass("blurT");
|
||||
$(".main").removeClass("clickthrough");
|
||||
}
|
||||
//$("#search").addClass("success");
|
||||
},
|
||||
error: function(){
|
||||
|
||||
console.log("error in adding");
|
||||
if(type)
|
||||
{
|
||||
document.getElementById("search").value = "";
|
||||
$("#results").html = "";
|
||||
$(".main").removeClass("blurT");
|
||||
$("#controls").removeClass("blurT");
|
||||
$(".main").removeClass("clickthrough");
|
||||
$("#search").addClass("error");
|
||||
}
|
||||
}
|
||||
}).responseText;
|
||||
|
||||
if(serverAns == "wrong")
|
||||
{
|
||||
//alert("Wrong adminpassword");
|
||||
$("#search").addClass("error");
|
||||
document.getElementById("eBar").innerHTML = "Error: Wrong Admin Password!";
|
||||
$("#eBar").addClass("opacityFull");
|
||||
}else{
|
||||
//$("#search").addClass("success");
|
||||
document.getElementById("sBar").innerHTML = "Successfully added song!";
|
||||
$("#sBar").addClass("opacityFull");
|
||||
}
|
||||
|
||||
$("#search").focus();
|
||||
|
||||
setTimeout(function(){
|
||||
$("#search").removeClass("success");
|
||||
$("#search").removeClass("error");
|
||||
$("#eBar").removeClass("opacityFull");
|
||||
$("#sBar").removeClass("opacityFull");
|
||||
},1500);
|
||||
updateList();
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
// if(reply=="added"){$("#search").removeClass('success'); $("#search").addClass('success');}
|
||||
122
static/js/searchlist.js
Executable file
122
static/js/searchlist.js
Executable file
@@ -0,0 +1,122 @@
|
||||
$(document).ready(function()
|
||||
{
|
||||
found = null;
|
||||
znum = 1;
|
||||
elem = [];
|
||||
bright = [];
|
||||
$.expr[":"].contains = $.expr.createPseudo(function(arg) {
|
||||
return function( elem ) {
|
||||
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
|
||||
};
|
||||
});
|
||||
find = false;
|
||||
$("html").keydown(function(event) {
|
||||
if ((event.keyCode == 27 && find) || (event.ctrlKey && event.keyCode === 70))
|
||||
{
|
||||
find = !find;
|
||||
znum = 1;
|
||||
if(find)
|
||||
$(".lresult").addClass("brightness");
|
||||
else
|
||||
{
|
||||
$(".lresult").removeClass("brightness");
|
||||
$(".lresult").removeClass("fullbrightness");
|
||||
bright.length = 0;
|
||||
}
|
||||
event.preventDefault();
|
||||
$("#findform").toggleClass("display");
|
||||
$("#adminPanel").toggleClass("brightness");
|
||||
$("#findform-input").val("");
|
||||
$("#findform-input").focus();
|
||||
/*
|
||||
if(find) $("#playlist").height($("#player").height()-30+30);
|
||||
if(!find)$("#playlist").height($("#player").height()+30);; //closing
|
||||
*/
|
||||
/*if(adminTogg) extraHeight = -300;
|
||||
else extraHeight = -30;*/
|
||||
|
||||
if(find)
|
||||
{
|
||||
if($("#adminPanel").height() != 0)
|
||||
{
|
||||
extraHeight = $("#adminPanel").height()+30;
|
||||
}else
|
||||
{
|
||||
extraHeight = 10;
|
||||
}
|
||||
$("#playlist").height($("#player").height()-extraHeight); //opening
|
||||
}else if(!find)
|
||||
{
|
||||
if($("#adminPanel").height() != 0)
|
||||
{
|
||||
extraHeight = $("#adminPanel").height()-10;
|
||||
}else
|
||||
{
|
||||
extraHeight = -30;
|
||||
}
|
||||
$("#playlist").height($("#player").height()-extraHeight);; //closing
|
||||
}
|
||||
|
||||
myScroll.refresh();
|
||||
setTimeout(function(){myScroll.refresh();}, 505);
|
||||
}
|
||||
});
|
||||
$("body").keyup(function(event) {
|
||||
var x = event.keyCode;
|
||||
if(find)
|
||||
{
|
||||
if(x == 13)
|
||||
{
|
||||
if(found != "" && $("#findform-input").val() != "")
|
||||
{
|
||||
znum+=1;
|
||||
if(znum > elem.length)
|
||||
{
|
||||
znum = 1;
|
||||
myScroll.scrollToElement(elem[0], 10, 0, 0);
|
||||
}
|
||||
console.log(znum);
|
||||
console.log(elem[znum]);
|
||||
myScroll.scrollToElement(elem[znum-1], 10, 0, 0);
|
||||
document.getElementById("numfound").innerHTML = znum + " av " + bright.length;
|
||||
$("#numfound").css("margin-left", "-"+($("#numfound").width()+8));
|
||||
$("#numfound").css("padding-right", 4);
|
||||
$("#findform-input").css("padding", "0 "+($("#numfound").width()+8)+"px 0 5px");
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(found != null)
|
||||
{
|
||||
last = found[0];
|
||||
if(!(typeof last === "undefined"))
|
||||
$(".lresult").removeClass("fullbrightness");
|
||||
}
|
||||
found = $("#wrapper").find(".lresult:contains('"+$("#findform-input").val()+"')");
|
||||
if(found != "" && $("#findform-input").val() != "")
|
||||
{
|
||||
elem.length = 0;
|
||||
bright.length = 0;
|
||||
znum = 1;
|
||||
for(i = 0; i < found.length; i++)
|
||||
{
|
||||
found[i].className = found[i].className + " fullbrightness";
|
||||
bright.push(found[i].className.split(" ")[0]);
|
||||
elem.push(found[i]);
|
||||
}
|
||||
document.getElementById("numfound").innerHTML = znum + " av " + bright.length;
|
||||
$("#numfound").css("margin-left", "-"+($("#numfound").width()+8));
|
||||
$("#numfound").css("padding-right", 4);
|
||||
$("#findform-input").css("padding", "0 "+($("#numfound").width()+8)+"px 0 5px");
|
||||
myScroll.scrollToElement(found[0], 10, 0, 0);
|
||||
}else
|
||||
{
|
||||
$(".lresult").removeClass("fullbrightness");
|
||||
bright.length = 0;
|
||||
elem.length = 0;
|
||||
znum = 1;
|
||||
}
|
||||
}
|
||||
//console.log($("#wrapper").find(".result:contains('"+$("#findform-input").val()+"')"));
|
||||
}
|
||||
});
|
||||
});
|
||||
452
static/js/youtube.js
Executable file
452
static/js/youtube.js
Executable file
@@ -0,0 +1,452 @@
|
||||
/*
|
||||
This is the youtube player sync and control file.
|
||||
|
||||
Fetcher sangen som spilles fra JSON filen
|
||||
|
||||
*/
|
||||
|
||||
var timeDifference;
|
||||
var wasPaused;
|
||||
var beginning;
|
||||
var diffVideo;
|
||||
var serverTime;
|
||||
var url;
|
||||
var response;
|
||||
var url;
|
||||
var tag;
|
||||
var firstScriptTag;
|
||||
var ytplayer;
|
||||
var syncInterval;
|
||||
var title;
|
||||
var interval;
|
||||
var viewers;
|
||||
var video_id;
|
||||
var changed = false;
|
||||
var conf = [];
|
||||
var adminvote = 0;
|
||||
var adminadd = 0;
|
||||
var adminskip = 0;
|
||||
var music = 0;
|
||||
var longS = 0;
|
||||
var frontpage = 1;
|
||||
var adminpass = "";
|
||||
var notified = false;
|
||||
var peis = false;
|
||||
var filesadded="";
|
||||
var colorThief;
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
colorThief = new ColorThief();
|
||||
window.mobilecheck = function() {
|
||||
var check = false;
|
||||
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))check = true;})(navigator.userAgent||navigator.vendor||window.opera);
|
||||
//(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))check = true})(navigator.userAgent||navigator.vendor||window.opera);
|
||||
return check; };
|
||||
|
||||
if(!window.mobilecheck())
|
||||
{
|
||||
$("#change").css("opacity", "0");
|
||||
$("#wrapper").css("opacity", "0");
|
||||
Notification.requestPermission();
|
||||
}
|
||||
|
||||
updateList();
|
||||
wasPaused = false;
|
||||
beginning = true;
|
||||
diffVideo = false;
|
||||
interval = false;
|
||||
response = $.ajax({ type: "GET",
|
||||
url: "php/change.php",
|
||||
async: false
|
||||
}).responseText;
|
||||
//console.log(response);
|
||||
response = $.parseJSON(response);
|
||||
console.log(response.nowPlaying.length);
|
||||
conf = response.conf;
|
||||
console.log(conf);
|
||||
try{
|
||||
for(var first in response.nowPlaying) break;
|
||||
console.log(first);
|
||||
response = first;
|
||||
}catch(err){
|
||||
response = "1";
|
||||
}
|
||||
|
||||
if(window.mobilecheck()){
|
||||
//syncInterval = setInterval(getTime, 50000);
|
||||
//listInterval = setInterval(updateList, 50000);
|
||||
mobileSync = setInterval(function(){getTime();updateList();}, 10000);
|
||||
//listKillInterval = setInterval(ks, 50000);
|
||||
document.getElementById("search").blur();
|
||||
readyLooks();
|
||||
}else{
|
||||
tag = document.createElement('script');
|
||||
tag.src = "https://www.youtube.com/iframe_api";
|
||||
firstScriptTag = document.getElementsByTagName('script')[0];
|
||||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
||||
if(!syncInterval)
|
||||
syncInterval = setInterval(getTime, 5000);
|
||||
listInterval = setInterval(updateList, 10000);
|
||||
//listKillInterval = setInterval(ks, 50000);
|
||||
|
||||
if($("#chan").html().toLowerCase() == "jazz")
|
||||
{
|
||||
loadjsfile("static/js/jazzscript.js");
|
||||
peis = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function loadjsfile(filename)
|
||||
{
|
||||
if (filesadded.indexOf("["+filename+"]")==-1){
|
||||
var fileref=document.createElement('script');
|
||||
fileref.setAttribute("type","text/javascript");
|
||||
fileref.setAttribute("src", filename);
|
||||
document.getElementsByTagName("head")[0].appendChild(fileref);
|
||||
filesadded+="["+filename+"]";
|
||||
}else jazz_setup();
|
||||
}
|
||||
|
||||
function onYouTubeIframeAPIReady() {
|
||||
$("#change").css("-webkit-transition", "opacity 1s");
|
||||
$("#change").css("opacity", "1");
|
||||
ytplayer = new YT.Player('player', {
|
||||
height: window.height*0.75,
|
||||
width: window.width*0.6,
|
||||
videoId: response,
|
||||
playerVars: { rel:"0", wmode:"transparent", controls: "0" , iv_load_policy: "3", theme:"light", color:"white"},
|
||||
events: {
|
||||
'onReady': onPlayerReady,
|
||||
'onStateChange': onPlayerStateChange,
|
||||
'onError': errorHandler,
|
||||
'onPlaybackQualityChange': logQ
|
||||
}
|
||||
});
|
||||
if(peis)
|
||||
{
|
||||
jazz_setup();
|
||||
}
|
||||
$("#player").css("opacity", "0");
|
||||
}
|
||||
|
||||
function onPlayerStateChange(newState) {
|
||||
console.log("new state: "+newState.data);
|
||||
console.log("beginning: "+beginning);
|
||||
//ytplayer.seekTo(15);
|
||||
if((newState.data === 0 && checkEnd()) || (newState.data == 1 && checkEnd()))
|
||||
{
|
||||
console.log("nummer 1");
|
||||
startNextSong();
|
||||
ytplayer.pauseVideo();
|
||||
wasPaused = false;
|
||||
}else if(newState.data == 1 && (wasPaused && !beginning))
|
||||
{
|
||||
console.log("unpaused");
|
||||
beginning = false;
|
||||
wasPaused = false;
|
||||
if(!syncInterval)
|
||||
syncInterval = setInterval(getTime, 5000);
|
||||
getTime();
|
||||
}else if(newState.data == 2)
|
||||
{
|
||||
//clearInterval(syncInterval);
|
||||
interval = true;
|
||||
wasPaused = true;
|
||||
beginning = false;
|
||||
}
|
||||
if(newState.data == 1 || newState.data == 2)
|
||||
{
|
||||
activeButton = document.getElementById("playpause").className;
|
||||
console.log(activeButton);
|
||||
if((newState.data == 2 && activeButton == "pause") || (newState.data == 1 && activeButton == "play"))
|
||||
{
|
||||
$("#playpause").toggleClass("play");
|
||||
$("#playpause").toggleClass("pause");
|
||||
}
|
||||
}
|
||||
if(newState.data === 0)
|
||||
{
|
||||
quickFixCountdown = setTimeout(function(){
|
||||
console.log("trying quickfix");
|
||||
if(ytplayer.getPlayerState() === 0){
|
||||
console.log("quickfixPlay");
|
||||
startNextSong();
|
||||
wasPaused = false;
|
||||
}
|
||||
},5000);
|
||||
}
|
||||
}
|
||||
|
||||
function checkEnd()
|
||||
{
|
||||
console.log("sjekker om brukeren spolte");
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: 'php/timedifference.php',
|
||||
data: "abcde",
|
||||
async: false,
|
||||
success: function(data) {
|
||||
timeDifference = $.parseJSON(data);
|
||||
}
|
||||
});
|
||||
if(parseInt(timeDifference[0]) > ytplayer.getDuration())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function startNextSong()
|
||||
{
|
||||
|
||||
//console.log(getTime());
|
||||
if(checkEnd() && !changed)
|
||||
{
|
||||
setTimeout(function(){
|
||||
arr = $.ajax({
|
||||
type: "POST",
|
||||
url: "php/change.php",
|
||||
async: false,
|
||||
data: "thisUrl="+response+"&act=save",
|
||||
|
||||
success: function() {
|
||||
console.log("saved song-switch - "+response);
|
||||
}
|
||||
}).responseText;
|
||||
arr = $.parseJSON(arr);
|
||||
response = arr.id;
|
||||
console.log("next video: "+response);
|
||||
getTitle(response);
|
||||
if(!window.mobilecheck())
|
||||
{
|
||||
ytplayer.loadVideoById(response);
|
||||
notifyUser(response, arr.title);
|
||||
}
|
||||
beginning = true;
|
||||
setBGimage(response);
|
||||
|
||||
},2500);
|
||||
updateList();
|
||||
changed = true;
|
||||
|
||||
setTimeout(function() {
|
||||
changed = false;
|
||||
if(!syncInterval)
|
||||
syncInterval = setInterval(getTime, 5000);
|
||||
interval = true;
|
||||
console.log("starter intervallen. Interval: " + interval);
|
||||
}, 2500);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getTime()
|
||||
{
|
||||
console.log("utenfor if test" + wasPaused);
|
||||
if(!window.mobilecheck() && ytplayer.getCurrentTime() > 2 && ytplayer.getPlayerState() == 1) wasPaused = false;
|
||||
if(!wasPaused)
|
||||
{
|
||||
console.log("sjekker om brukeren spolte");
|
||||
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: 'php/timedifference.php',
|
||||
data: "abcde",
|
||||
async: false,
|
||||
success: function(data) {
|
||||
timeDifference = $.parseJSON(data);
|
||||
}
|
||||
});
|
||||
console.log("current song: "+response);
|
||||
console.log("song in database: "+timeDifference[1]);
|
||||
if(!window.mobilecheck()){ //Added so the mobileversion will change banner
|
||||
if(parseInt(timeDifference[2]) + 1> ytplayer.getCurrentTime() + parseInt(timeDifference[3]) && ytplayer.getPlayerState() === 0)
|
||||
{
|
||||
return true;
|
||||
}else if(ytplayer.getCurrentTime() + parseInt(timeDifference[3]) > parseInt(timeDifference[2]) + 5 || (ytplayer.getCurrentTime() + parseInt(timeDifference[3]) < parseInt(timeDifference[2]) - 5 && ytplayer.getPlayerState() !== 0 && ytplayer.getPlayerState() != 3))
|
||||
{
|
||||
if(parseInt(timeDifference[0]) > ytplayer.getDuration())
|
||||
{
|
||||
console.log("burde ikke søke, men hoppe til neste sang");
|
||||
}
|
||||
ytplayer.seekTo(timeDifference[0]);
|
||||
ytplayer.pauseVideo();
|
||||
ytplayer.playVideo();
|
||||
getTitle();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//if(interval){syncInterval = setInterval(getTime, 5000);interval = false;}
|
||||
|
||||
if(response != timeDifference[1])
|
||||
{
|
||||
//clearInterval(syncInterval);
|
||||
wasPaused = true;
|
||||
console.log("forskjellige videoer!!");
|
||||
if(!window.mobilecheck())
|
||||
{
|
||||
ytplayer.pauseVideo();
|
||||
ytplayer.loadVideoById(timeDifference[1]);
|
||||
notifyUser(timeDifference[1], timeDifference[4]);
|
||||
wasPaused = false;
|
||||
if(!syncInterval)
|
||||
syncInterval = setInterval(getTime, 5000);
|
||||
}
|
||||
response = timeDifference[1];
|
||||
getTitle();
|
||||
setBGimage(timeDifference[1]);
|
||||
updateList();
|
||||
/*setTimeout(function(){
|
||||
//console.log(response);
|
||||
diffVideo = true;
|
||||
beginning = true;
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "php/change.php",
|
||||
async: false,
|
||||
data: "thisUrl=123abcprompeprompe&act=save",
|
||||
success: function(data)
|
||||
{
|
||||
response = timeDifference[1];
|
||||
getTitle();
|
||||
}
|
||||
});
|
||||
wasPaused = false;
|
||||
if(!syncInterval)
|
||||
syncInterval = setInterval(getTime, 5000);
|
||||
},2500);*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getTitle()
|
||||
{
|
||||
|
||||
$.ajax({ type: "GET",
|
||||
url: "php/timedifference.php",
|
||||
async: false,
|
||||
success: function(data) {
|
||||
viewers = $.parseJSON(data);
|
||||
var outPutWord = viewers[5].length > 1 ? "viewers" : "viewer";
|
||||
var title= viewers[4].replace(/\\\'/g, "'").replace(/"/g,"'").replace(/&/g,"&");
|
||||
document.title = title + " • Zöff";
|
||||
if(!window.mobilecheck())
|
||||
document.getElementsByName('v')[0].placeholder = title + " • " + viewers[5].length + " " + outPutWord;
|
||||
else
|
||||
{
|
||||
document.getElementById("mobileTitle").innerHTML = title;
|
||||
document.getElementsByName('v')[0].placeholder = "Search • " + viewers[5].length + " " + outPutWord;
|
||||
//document.getElementById("viewers").innerHTML = viewers[5].length + " " + outPutWord;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function errorHandler(newState)
|
||||
{
|
||||
setTimeout(function(){
|
||||
arr = $.ajax({
|
||||
type: "POST",
|
||||
url: "php/change.php",
|
||||
async: false,
|
||||
data: "thisUrl="+response+"&act=empty",
|
||||
|
||||
success: function() {
|
||||
console.log("error! deleted video");
|
||||
}
|
||||
}).responseText;
|
||||
arr = $.parseJSON(arr);
|
||||
response = arr.id;
|
||||
if(!window.mobilecheck())
|
||||
{
|
||||
ytplayer.loadVideoById(response);
|
||||
notifyUser(response);
|
||||
}
|
||||
setBGimage(response);
|
||||
},2500);
|
||||
/*
|
||||
setTimeout(function(){
|
||||
response = $.ajax({ type: "GET",
|
||||
url: "change.php",
|
||||
async: false
|
||||
}).responseText;
|
||||
var url = $.parseJSON(response);
|
||||
response = url[0][0];
|
||||
|
||||
ytplayer.loadVideoById(response);
|
||||
},2500);*/
|
||||
}
|
||||
function onPlayerReady(event) {
|
||||
//ytplayer = document.getElementById("myytplayer");
|
||||
// ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
|
||||
//ytplayer.addEventListener("onError", "errorHandler");
|
||||
getTime();
|
||||
if(!window.mobilecheck())
|
||||
{
|
||||
$("#player").css("opacity", "1");
|
||||
$("#controls").css("opacity", "1");
|
||||
$(".playlist").css("opacity", "1");
|
||||
//$("#player").fadeIn();
|
||||
ytplayer.playVideo();
|
||||
initYoutubeControls(ytplayer);
|
||||
}
|
||||
readyLooks();
|
||||
initSlider();
|
||||
//durationFixer = setInterval(durationSetter, 1000);
|
||||
}
|
||||
|
||||
function readyLooks()
|
||||
{
|
||||
getTitle();
|
||||
setBGimage(response);
|
||||
}
|
||||
|
||||
function setBGimage(id){
|
||||
if(!window.mobilecheck()){
|
||||
var bg = $(".thumb.lthumb")[0]; //new Image();
|
||||
//bg.src = "http://i.ytimg.com/vi/"+id+"/mqdefault.jpg";
|
||||
var color = colorThief.getColor(bg, 10);
|
||||
var hsl = rgbToHsl(color);
|
||||
var colorTxt = "hsla("+hsl[0]+", "+hsl[1]+"%, 22%, 0.5);";
|
||||
$("#controls").css("background-color", colorTxt);
|
||||
$("#search").css("background-color", colortxt);
|
||||
}else if(window.mobilecheck()){
|
||||
$("#mobile-banner").css("background-image", "url(http://img.youtube.com/vi/"+id+"/hqdefault.jpg)");
|
||||
$("#mobile-banner").css("width",$(window).width());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function notifyUser(id, title) {
|
||||
title= title.replace(/\\\'/g, "'").replace(/"/g,"'").replace(/&/g,"&");
|
||||
if (Notification.permission === "granted" && !notified && document.hidden && id != "30H2Z8Lr-4c" && !window.mobilecheck()) {
|
||||
var notification = new Notification("Now Playing", {body: title, icon: "http://i.ytimg.com/vi/"+id+"/mqdefault.jpg", iconUrl: "http://i.ytimg.com/vi/"+id+"/mqdefault.jpg"});
|
||||
setTimeout(function(){
|
||||
notification.close();
|
||||
},5000);
|
||||
}
|
||||
}
|
||||
|
||||
function rgbToHsl(r, g, b){
|
||||
r /= 255, g /= 255, b /= 255;
|
||||
var max = Math.max(r, g, b), min = Math.min(r, g, b);
|
||||
var h, s, l = (max + min) / 2;
|
||||
|
||||
if(max == min){
|
||||
h = s = 0; // achromatic
|
||||
}else{
|
||||
var d = max - min;
|
||||
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
||||
switch(max){
|
||||
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
||||
case g: h = (b - r) / d + 2; break;
|
||||
case b: h = (r - g) / d + 4; break;
|
||||
}
|
||||
h /= 6;
|
||||
}
|
||||
|
||||
return [h*360, s*100, l*100];
|
||||
}
|
||||
Reference in New Issue
Block a user