diff --git a/gulpfile.js b/gulpfile.js
index f28d14d1..1ed3afd2 100755
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -1,120 +1,198 @@
-var gulp    = require('gulp'),
-	gutil   = require('gulp-util'),
-	uglify  = require('gulp-uglify'),
-    //sourcemaps = require('gulp-sourcemaps'),
-    gutil = require('gulp-util'),
-	concat  = require('gulp-concat'),
-    cssnano = require('gulp-cssnano');
+var gulp = require("gulp"),
+  gutil = require("gulp-util"),
+  uglify = require("gulp-uglify"),
+  //sourcemaps = require('gulp-sourcemaps'),
+  gutil = require("gulp-util"),
+  concat = require("gulp-concat"),
+  cleanCSS = require("gulp-clean-css");
 
-gulp.task('css', function() {
-    return gulp.src('server/public/assets/css/style.css')
-        .pipe(cssnano({
-            preset: ['default', {
-                discardComments: {
-                    removeAll: true,
-                },
-            }]
-        }))
-        .pipe(gulp.dest('server/public/assets/dist'));
+gulp.task("css", function() {
+  return gulp
+    .src("server/public/assets/css/style.css")
+    .pipe(cleanCSS({ compatibility: "ie8" }))
+    .pipe(gulp.dest("server/public/assets/dist"));
 });
 
-gulp.task('css-embed', function() {
-    return gulp.src('server/public/assets/css/embed.css')
-        .pipe(cssnano({
-            preset: ['default', {
-                discardComments: {
-                    removeAll: true,
-                },
-            }]
-        }))
-        .pipe(gulp.dest('server/public/assets/dist'));
+gulp.task("css-embed", function() {
+  return gulp
+    .src("server/public/assets/css/embed.css")
+    .pipe(cleanCSS({ compatibility: "ie8" }))
+    .pipe(gulp.dest("server/public/assets/dist"));
 });
 
-gulp.task('js', function () {
-    return gulp.src(['server/VERSION.js', 'server/config/api_key.js', 'server/public/assets/js/*.js', '!server/public/assets/js/embed*', '!server/public/assets/js/token*', '!server/public/assets/js/remotecontroller.js', '!server/public/assets/js/callback.js'])
-    //.pipe(sourcemaps.init())
-    .pipe(concat('main.min.js'))
-        .pipe(uglify({
-        	mangle: true,
-            compress: true,
-        	enclose: true,
-        }))
-        .on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); })
-        //.pipe(sourcemaps.write('maps'))
-        .pipe(gulp.dest('server/public/assets/dist'));
+gulp.task("js", function() {
+  return (
+    gulp
+      .src([
+        "server/VERSION.js",
+        "server/config/api_key.js",
+        "server/public/assets/js/*.js",
+        "!server/public/assets/js/embed*",
+        "!server/public/assets/js/token*",
+        "!server/public/assets/js/remotecontroller.js",
+        "!server/public/assets/js/callback.js"
+      ])
+      //.pipe(sourcemaps.init())
+      .pipe(concat("main.min.js"))
+      .pipe(
+        uglify({
+          mangle: true,
+          compress: true,
+          enclose: true
+        })
+      )
+      .on("error", function(err) {
+        gutil.log(gutil.colors.red("[Error]"), err.toString());
+      })
+      //.pipe(sourcemaps.write('maps'))
+      .pipe(gulp.dest("server/public/assets/dist"))
+  );
 });
 
-gulp.task('embed', function () {
-    return gulp.src(['server/VERSION.js', 'server/config/api_key.js', 'server/public/assets/js/player.js', 'server/public/assets/js/functions.js', 'server/public/assets/js/helpers.js', 'server/public/assets/js/playercontrols.js', 'server/public/assets/js/list.js', 'server/public/assets/js/embed.js', '!server/public/assets/js/frontpage*', '!server/public/assets/js/remotecontroller.js', 'server/public/assets/js/hostcontroller.js'])
-    //.pipe(sourcemaps.init())
-    .pipe(concat('embed.min.js'))
-        .pipe(uglify({
-            mangle: true,
-            compress: true,
-            enclose: true
-        }))
-        .on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); })
-        //.pipe(sourcemaps.write('maps'))
-        .pipe(gulp.dest('server/public/assets/dist'));
+gulp.task("embed", function() {
+  return (
+    gulp
+      .src([
+        "server/VERSION.js",
+        "server/config/api_key.js",
+        "server/public/assets/js/player.js",
+        "server/public/assets/js/functions.js",
+        "server/public/assets/js/helpers.js",
+        "server/public/assets/js/playercontrols.js",
+        "server/public/assets/js/list.js",
+        "server/public/assets/js/embed.js",
+        "!server/public/assets/js/frontpage*",
+        "!server/public/assets/js/remotecontroller.js",
+        "server/public/assets/js/hostcontroller.js"
+      ])
+      //.pipe(sourcemaps.init())
+      .pipe(concat("embed.min.js"))
+      .pipe(
+        uglify({
+          mangle: true,
+          compress: true,
+          enclose: true
+        })
+      )
+      .on("error", function(err) {
+        gutil.log(gutil.colors.red("[Error]"), err.toString());
+      })
+      //.pipe(sourcemaps.write('maps'))
+      .pipe(gulp.dest("server/public/assets/dist"))
+  );
 });
 
-gulp.task('token', function() {
-    return gulp.src(['server/public/assets/js/token*', 'server/public/assets/js/helpers.js'])
-    //.pipe(sourcemaps.init())
-    .pipe(concat('token.min.js'))
-        .pipe(uglify({
-            mangle: true,
-            compress: true,
-            enclose: true
-        }))
-        .on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); })
+gulp.task("token", function() {
+  return (
+    gulp
+      .src([
+        "server/public/assets/js/token*",
+        "server/public/assets/js/helpers.js"
+      ])
+      //.pipe(sourcemaps.init())
+      .pipe(concat("token.min.js"))
+      .pipe(
+        uglify({
+          mangle: true,
+          compress: true,
+          enclose: true
+        })
+      )
+      .on("error", function(err) {
+        gutil.log(gutil.colors.red("[Error]"), err.toString());
+      })
 
-        //.pipe(sourcemaps.write('maps'))
-        .pipe(gulp.dest('server/public/assets/dist'));
-})
-
-gulp.task('callback', function () {
-    return gulp.src(['server/VERSION.js', 'server/config/api_key.js', 'server/public/assets/js/callback.js'])
-    //.pipe(sourcemaps.init())
-    .pipe(concat('callback.min.js'))
-        .pipe(uglify({
-            mangle: true,
-            compress: true,
-            enclose: true
-        }))
-        .on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); })
-
-        //.pipe(sourcemaps.write('maps'))
-        .pipe(gulp.dest('server/public/assets/dist'));
+      //.pipe(sourcemaps.write('maps'))
+      .pipe(gulp.dest("server/public/assets/dist"))
+  );
 });
 
-gulp.task('build', done => {
-    gulp.series('css', 'css-embed', 'js', 'embed', 'remotecontroller', 'callback', 'token')();
-    done();
+gulp.task("callback", function() {
+  return (
+    gulp
+      .src([
+        "server/VERSION.js",
+        "server/config/api_key.js",
+        "server/public/assets/js/callback.js"
+      ])
+      //.pipe(sourcemaps.init())
+      .pipe(concat("callback.min.js"))
+      .pipe(
+        uglify({
+          mangle: true,
+          compress: true,
+          enclose: true
+        })
+      )
+      .on("error", function(err) {
+        gutil.log(gutil.colors.red("[Error]"), err.toString());
+      })
+
+      //.pipe(sourcemaps.write('maps'))
+      .pipe(gulp.dest("server/public/assets/dist"))
+  );
 });
 
-gulp.task('remotecontroller', function () {
-    return gulp.src(['server/VERSION.js', 'server/config/api_key.js', 'server/public/assets/js/remotecontroller.js', 'server/public/assets/js/helpers.js'])
-    ////.pipe(sourcemaps.init())
-    .pipe(concat('remote.min.js'))
-        .pipe(uglify({
-            mangle: true,
-            compress: true,
-            enclose: true
-        }))
-        .on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); })
-
-        //.pipe(sourcemaps.write('maps'))
-        .pipe(gulp.dest('server/public/assets/dist'));
+gulp.task("build", done => {
+  gulp.series(
+    "css",
+    "css-embed",
+    "js",
+    "embed",
+    "remotecontroller",
+    "callback",
+    "token"
+  )();
+  done();
 });
 
-gulp.task('default', function(){
-    gulp.watch(['server/VERSION.js', 'server/public/assets/js/*.js'], ['js']);
-    gulp.watch(['server/public/assets/css/*.css'], ['css']);
-    gulp.watch(['server/public/assets/css/*.css'], ['css-embed']);
-    gulp.watch(['server/public/assets/js/token*.js', 'server/public/assets/js/helpers.js'], ['token']);
-    gulp.watch(['server/VERSION.js', 'server/public/assets/js/*.js'], ['embed']);
-    gulp.watch(['server/VERSION.js', 'server/public/assets/js/callback.js', 'server/public/assets/js/helpers.js'], ['callback']);
-    //gulp.watch('server/public/assets/js/*.js', ['nochan']);
-    gulp.watch(['server/VERSION.js', 'server/public/assets/js/remotecontroller.js'], ['remotecontroller']);
+gulp.task("remotecontroller", function() {
+  return (
+    gulp
+      .src([
+        "server/VERSION.js",
+        "server/config/api_key.js",
+        "server/public/assets/js/remotecontroller.js",
+        "server/public/assets/js/helpers.js"
+      ])
+      ////.pipe(sourcemaps.init())
+      .pipe(concat("remote.min.js"))
+      .pipe(
+        uglify({
+          mangle: true,
+          compress: true,
+          enclose: true
+        })
+      )
+      .on("error", function(err) {
+        gutil.log(gutil.colors.red("[Error]"), err.toString());
+      })
+
+      //.pipe(sourcemaps.write('maps'))
+      .pipe(gulp.dest("server/public/assets/dist"))
+  );
+});
+
+gulp.task("default", function() {
+  gulp.watch(["server/VERSION.js", "server/public/assets/js/*.js"], ["js"]);
+  gulp.watch(["server/public/assets/css/*.css"], ["css"]);
+  gulp.watch(["server/public/assets/css/*.css"], ["css-embed"]);
+  gulp.watch(
+    ["server/public/assets/js/token*.js", "server/public/assets/js/helpers.js"],
+    ["token"]
+  );
+  gulp.watch(["server/VERSION.js", "server/public/assets/js/*.js"], ["embed"]);
+  gulp.watch(
+    [
+      "server/VERSION.js",
+      "server/public/assets/js/callback.js",
+      "server/public/assets/js/helpers.js"
+    ],
+    ["callback"]
+  );
+  //gulp.watch('server/public/assets/js/*.js', ['nochan']);
+  gulp.watch(
+    ["server/VERSION.js", "server/public/assets/js/remotecontroller.js"],
+    ["remotecontroller"]
+  );
 });
diff --git a/package-lock.json b/package-lock.json
index d75b50c5..f867e7c2 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -750,6 +750,14 @@
         }
       }
     },
+    "clean-css": {
+      "version": "4.2.1",
+      "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.1.tgz",
+      "integrity": "sha512-4ZxI6dy4lrY6FHzfiy1aEOXgu4LIsW2MhwG0VBKdcoGoH/XLFgaHSdLTGr4O8Be6A8r3MOphEiI8Gc1n0ecf3g==",
+      "requires": {
+        "source-map": "~0.6.0"
+      }
+    },
     "cliui": {
       "version": "3.2.0",
       "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz",
@@ -2899,6 +2907,45 @@
         }
       }
     },
+    "gulp-clean-css": {
+      "version": "4.2.0",
+      "resolved": "https://registry.npmjs.org/gulp-clean-css/-/gulp-clean-css-4.2.0.tgz",
+      "integrity": "sha512-r4zQsSOAK2UYUL/ipkAVCTRg/2CLZ2A+oPVORopBximRksJ6qy3EX1KGrIWT4ZrHxz3Hlobb1yyJtqiut7DNjA==",
+      "requires": {
+        "clean-css": "4.2.1",
+        "plugin-error": "1.0.1",
+        "through2": "3.0.1",
+        "vinyl-sourcemaps-apply": "0.2.1"
+      },
+      "dependencies": {
+        "readable-stream": {
+          "version": "3.4.0",
+          "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz",
+          "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==",
+          "requires": {
+            "inherits": "^2.0.3",
+            "string_decoder": "^1.1.1",
+            "util-deprecate": "^1.0.1"
+          }
+        },
+        "string_decoder": {
+          "version": "1.2.0",
+          "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz",
+          "integrity": "sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w==",
+          "requires": {
+            "safe-buffer": "~5.1.0"
+          }
+        },
+        "through2": {
+          "version": "3.0.1",
+          "resolved": "https://registry.npmjs.org/through2/-/through2-3.0.1.tgz",
+          "integrity": "sha512-M96dvTalPT3YbYLaKaCuwu+j06D/8Jfib0o/PxbVt6Amhv3dUAtW6rTV1jPgJSBG83I/e04Y6xkVdVhSRhi0ww==",
+          "requires": {
+            "readable-stream": "2 || 3"
+          }
+        }
+      }
+    },
     "gulp-concat": {
       "version": "2.6.1",
       "resolved": "https://registry.npmjs.org/gulp-concat/-/gulp-concat-2.6.1.tgz",
@@ -3850,6 +3897,11 @@
         "strip-bom": "^2.0.0"
       }
     },
+    "lodash": {
+      "version": "4.17.15",
+      "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
+      "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
+    },
     "lodash._basecopy": {
       "version": "3.0.1",
       "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz",
@@ -4150,9 +4202,9 @@
       "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8="
     },
     "mixin-deep": {
-      "version": "1.3.1",
-      "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz",
-      "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==",
+      "version": "1.3.2",
+      "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz",
+      "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==",
       "dev": true,
       "requires": {
         "for-in": "^1.0.2",
@@ -4324,11 +4376,6 @@
           "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.1.tgz",
           "integrity": "sha512-jCGVYLoYMHDkOsbwJZBCqwMHyH4c+wzgI9hG7Z6SZJRXWr+x58pdIbm2i9a/jFGCkRJqRUr8eoI7lDWa0hTkxg=="
         },
-        "lodash": {
-          "version": "4.17.11",
-          "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
-          "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg=="
-        },
         "mongodb": {
           "version": "3.1.13",
           "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.1.13.tgz",
@@ -5835,9 +5882,9 @@
       "dev": true
     },
     "set-value": {
-      "version": "2.0.0",
-      "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz",
-      "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==",
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz",
+      "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==",
       "dev": true,
       "requires": {
         "extend-shallow": "^2.0.1",
@@ -6647,38 +6694,15 @@
       "dev": true
     },
     "union-value": {
-      "version": "1.0.0",
-      "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz",
-      "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=",
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
+      "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==",
       "dev": true,
       "requires": {
         "arr-union": "^3.1.0",
         "get-value": "^2.0.6",
         "is-extendable": "^0.1.1",
-        "set-value": "^0.4.3"
-      },
-      "dependencies": {
-        "extend-shallow": {
-          "version": "2.0.1",
-          "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
-          "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
-          "dev": true,
-          "requires": {
-            "is-extendable": "^0.1.0"
-          }
-        },
-        "set-value": {
-          "version": "0.4.3",
-          "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz",
-          "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=",
-          "dev": true,
-          "requires": {
-            "extend-shallow": "^2.0.1",
-            "is-extendable": "^0.1.1",
-            "is-plain-object": "^2.0.1",
-            "to-object-path": "^0.3.0"
-          }
-        }
+        "set-value": "^2.0.1"
       }
     },
     "uniq": {
diff --git a/package.json b/package.json
index c128f80b..532ee0d8 100644
--- a/package.json
+++ b/package.json
@@ -41,6 +41,7 @@
     "express-recaptcha": "^3.0.1",
     "express-session": "^1.15.6",
     "feature-policy": "^0.2.0",
+    "gulp-clean-css": "^4.2.0",
     "gulp-sourcemaps": "^2.6.5",
     "gulp-uglify-es": "^1.0.4",
     "helmet": "^3.16.0",
diff --git a/server/handlers/io.js b/server/handlers/io.js
index 32b18ff4..a1b6bccb 100644
--- a/server/handlers/io.js
+++ b/server/handlers/io.js
@@ -1,734 +1,924 @@
 var cookieParser = require("cookie-parser");
 var cookie = require("cookie");
 
-var Functions = require(pathThumbnails + '/handlers/functions.js');
-var ListChange = require(pathThumbnails + '/handlers/list_change.js');
-var Chat = require(pathThumbnails + '/handlers/chat.js');
-var List = require(pathThumbnails + '/handlers/list.js');
-var Suggestions = require(pathThumbnails + '/handlers/suggestions.js');
-var ListSettings = require(pathThumbnails + '/handlers/list_settings.js');
-var Frontpage = require(pathThumbnails + '/handlers/frontpage.js');
-var Search = require(pathThumbnails + '/handlers/search.js');
-var crypto = require('crypto');
-var Filter = require('bad-words');
-var filter = new Filter({ placeHolder: 'x'});
+var Functions = require(pathThumbnails + "/handlers/functions.js");
+var ListChange = require(pathThumbnails + "/handlers/list_change.js");
+var Chat = require(pathThumbnails + "/handlers/chat.js");
+var List = require(pathThumbnails + "/handlers/list.js");
+var Suggestions = require(pathThumbnails + "/handlers/suggestions.js");
+var ListSettings = require(pathThumbnails + "/handlers/list_settings.js");
+var Frontpage = require(pathThumbnails + "/handlers/frontpage.js");
+var Search = require(pathThumbnails + "/handlers/search.js");
+var crypto = require("crypto");
+var Filter = require("bad-words");
+var filter = new Filter({ placeHolder: "x" });
 /*var filter = {
     clean: function(str) {
         return str;
     }
 }*/
-var db = require(pathThumbnails + '/handlers/db.js');
+var db = require(pathThumbnails + "/handlers/db.js");
 
 module.exports = function() {
-    io.on('connection', function(socket){
-        try {
-            var parsedCookies = cookie.parse(socket.handshake.headers.cookie);
-            socket.cookie_id = parsedCookies["_uI"];
-            //return socket.guid;
-        } catch(e) {
-            socket.cookie_id = "empty";
-        }
-        socket.zoff_id = socket.id;
-        socket.emit("get_list");
+  io.on("connection", function(socket) {
+    try {
+      var parsedCookies = cookie.parse(socket.handshake.headers.cookie);
+      socket.cookie_id = parsedCookies["_uI"];
+      //return socket.guid;
+    } catch (e) {
+      socket.cookie_id = "empty";
+    }
+    socket.zoff_id = socket.id;
+    socket.emit("get_list");
+    var guid = socket.cookie_id;
+    if (guid == "empty" || guid == null || guid == undefined)
+      guid = Functions.hash_pass(
+        socket.handshake.headers["user-agent"] +
+          socket.handshake.address +
+          socket.handshake.headers["accept-language"]
+      );
 
-        var guid = socket.cookie_id;
-        if(guid == "empty" || guid == null || guid == undefined) guid = Functions.hash_pass(socket.handshake.headers["user-agent"] + socket.handshake.address + socket.handshake.headers["accept-language"]);
-
-        socket.guid = guid;
-        socket.on('close', function() {
-        });
-
-        socket.on('pinging', function() {
-            socket.emit("ok");
-        });
-
-        var ping_timeout;
-        var socketid = socket.zoff_id;
-        var coll;
-        var in_list = false;
-        var name = "";
-        var short_id;
-        Chat.get_name(guid, {announce: false, socket: socket});
-        var offline = false;
-        var chromecast_object = false;
-
-        socket.emit("guid", guid);
-
-        socket.on('self_ping', function(msg) {
-
-            var channel = msg.channel;
-            if(channel.indexOf("?") > -1){
-                channel = channel.substring(0, channel.indexOf("?"));
-            }
-            if(msg.hasOwnProperty("channel")) {
-                msg.channel = Functions.encodeChannelName(msg.channel);
-            }
-            //channel = channel.replace(/ /g,'');
-            if(offline) {
-                db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, {upsert: true}, function(err, docs){});
-            } else {
-                db.collection("connected_users").update({"_id": channel}, {$addToSet: {users: guid}}, {upsert: true}, function(err, docs){
-                    db.collection("frontpage_lists").update({"_id": channel}, {$inc: {viewers: 1}}, {upsert: true}, function(){});
-                });
-            }
-            if(channel != "" && channel != undefined) {
-                db.collection("connected_users").update({"_id": "total_users"}, {$addToSet: {total_users: guid + channel}}, {upsert: true}, function(err, docs){});
-            }
-        });
-
-        socket.on("logout", function() {
-            Functions.removeSessionAdminPass(Functions.getSession(socket), coll, function() {})
-        });
-
-        socket.on('next_song', function(obj) {
-            if(obj == undefined || !obj.hasOwnProperty("channel")) return;
-            db.collection(obj.channel + "_settings").find(function(e, docs) {
-                if(docs.length == 0) return;
-                var pass = "";
-                if(obj.hasOwnProperty("pass")) {
-                    pass = crypto.createHash('sha256').update(Functions.decrypt_string(obj.pass)).digest("base64");
-                }
-                if((docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || docs[0].userpass == pass))) {
-                    List.getNextSong(obj.channel, socket);
-                }
-            });
-        });
-
-        socket.on('chromecast', function(msg) {
-            try {
-                if(typeof(msg) == "object" && msg.hasOwnProperty("guid") &&
-                msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel") && typeof(msg.guid) == "string" &&
-                typeof(msg.channel) == "string" && typeof(msg.socket_id) == "string" && msg.channel != "") {
-                    if(msg.hasOwnProperty("channel")) {
-                        msg.channel = Functions.encodeChannelName(msg.channel);
-                    }
-                    db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) {
-                        if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) {
-                            coll = msg.channel.toLowerCase();//.replace(/ /g,'');
-                            coll = Functions.removeEmojis(coll).toLowerCase();
-                            //coll = filter.clean(coll);
-                            if(coll.indexOf("?") > -1){
-                                coll = coll.substring(0, coll.indexOf("?"));
-                            }
-                            Functions.setChromecastHost(socket.cookie_id, msg.socket_id, msg.channel, function(results) {
-                            });
-                            //socket.cookie_id = msg.guid;
-                            guid = msg.guid;
-                            socketid = msg.socket_id;
-                            socket.zoff_id = socketid;
-
-                            in_list = true;
-                            chromecast_object = true;
-                            socket.join(coll);
-                        }
-                    });
-                }
-            } catch(e) {
-                return;
-            }
-        });
-
-        socket.on("get_id", function() {
-            socket.emit("id_chromecast", {cookie_id: Functions.getSession(socket), guid: guid});
-        });
-
-        socket.on("error_video", function(msg) {
-            try {
-                msg.channel = Functions.encodeChannelName(msg.channel);
-                var _list = msg.channel;//.replace(/ /g,'');
-                if(_list.length == 0) return;
-                if(_list.indexOf("?") > -1){
-                    _list = _list.substring(0, _list.indexOf("?"));
-                    msg.channel = _list;
-                }
-                coll = Functions.removeEmojis(_list).toLowerCase();
-                //coll = coll.replace(/_/g, "");
-
-                //coll = filter.clean(coll);
-            } catch(e) {
-                return;
-            }
-            if(msg.hasOwnProperty("channel")) {
-                msg.channel = Functions.encodeChannelName(msg.channel);
-            }
-            Search.check_error_video(msg, coll);
-        });
-
-        socket.on("get_spread", function(){
-            db.collection("connected_users").find({"_id": "total_users"}, function(err, tot) {
-                db.collection("connected_users").find({"_id": "offline_users"}, function(err, off) {
-                    db.collection("connected_users").find({"_id": {$ne: "total_users"}, "_id": {$ne: "offline_users"}}, function(err, users_list) {
-                        if(tot.length > 0 && off.length == 0) {
-                            socket.emit("spread_listeners", {offline: 0, total: tot[0].total_users.length, online_users: users_list});
-                        } else if(tot.length > 0 && off.length > 0){
-                            socket.emit("spread_listeners", {offline: off[0].users.length, total: tot[0].total_users.length, online_users: users_list});
-                        }
-                    });
-                });
-            });
-        });
-
-        socket.on('suggest_thumbnail', function(msg){
-            if(msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1){
-                var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
-                msg.channel = _list;
-            }
-            if(msg.hasOwnProperty("channel")) {
-                msg.channel = Functions.encodeChannelName(msg.channel);
-            }
-            Suggestions.thumbnail(msg, coll, guid, offline, socket);
-        });
-
-        socket.on('suggest_description', function(msg){
-            if(msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1){
-                var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
-                msg.channel = _list;
-            }
-            if(msg.hasOwnProperty("channel")) {
-                msg.channel = Functions.encodeChannelName(msg.channel);
-            }
-            Suggestions.description(msg, coll, guid, offline, socket);
-        });
-
-        socket.on('suggest_rules', function(msg){
-            if(msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1){
-                var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
-                msg.channel = _list;
-            }
-            if(msg.hasOwnProperty("channel")) {
-                msg.channel = Functions.encodeChannelName(msg.channel);
-            }
-            Suggestions.rules(msg, coll, guid, offline, socket);
-        });
-
-        socket.on("namechange", function(msg) {
-            if(msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1){
-                var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
-                msg.channel = _list;
-            }
-            if(msg.hasOwnProperty("channel")) {
-                msg.channel = Functions.encodeChannelName(msg.channel);
-            }
-            Chat.namechange(msg, guid, socket);
-        });
-
-        socket.on("removename", function(msg) {
-            if(msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1){
-                var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
-                msg.channel = _list;
-            }
-            if(msg.hasOwnProperty("channel")) {
-                msg.channel = Functions.encodeChannelName(msg.channel);
-            }
-            if(typeof(msg) != "object" || !msg.hasOwnProperty("channel")) {
-                var result = {
-                    channel: {
-                        expected: "string",
-                        got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
-                    }
-                };
-                socket.emit('update_required', result);
-                return;
-            }
-            Chat.removename(guid, msg.channel, socket);
-        });
-
-        socket.on("offline", function(msg){
-            if(msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1){
-                var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
-                msg.channel = _list;
-            }
-            if(msg.hasOwnProperty("channel")) {
-                msg.channel = Functions.encodeChannelName(msg.channel);
-            }
-            if(!msg.hasOwnProperty('status') || !msg.hasOwnProperty('channel') ||
-            typeof(msg.status) != "boolean" || typeof(msg.channel) != "string") {
-                var result = {
-                    status: {
-                        expected: "boolean",
-                        got: msg.hasOwnProperty("status") ? typeof(msg.status) : undefined,
-                    },
-                    channel: {
-                        expected: "string",
-                        got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined
-                    }
-                };
-                socket.emit('update_required', result);
-                return;
-            }
-            var status = msg.status;
-            var channel = Functions.encodeChannelName(msg.channel);//.replace(/ /g,'');
-            if(status){
-                in_list = false;
-                offline = true;
-                if(channel != "") coll = channel;
-                if(coll !== undefined) {
-                    coll = Functions.removeEmojis(coll).toLowerCase();
-                    //coll = filter.clean(coll);
-                    db.collection("connected_users").findAndModify({
-                        query: {"_id": coll},
-                        update: {$pull: {users: guid}},
-                        upsert: true,
-                    }, function(err, updated, d) {
-                        if(d.n == 1) {
-                            var num = 0;
-                            if(updated && updated.users) {
-                                num = updated.users.length;
-                            }
-                            io.to(coll).emit("viewers", num);
-                            db.collection("frontpage_lists").update({"_id": coll, "viewers": {$gt: 0}}, {$inc: {viewers: -1}}, function(err, docs) { });
-                            db.collection("connected_users").update({"_id": "total_users"}, {$pull: {total_users: guid + coll}}, function(err, docs){
-                                db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, {upsert: true}, function(err, docs) {
-                                    if(docs.nModified == 1 && (coll != undefined && coll != "")) {
-                                        db.collection("connected_users").update({"_id": "total_users"}, {$addToSet: {total_users: guid + coll}}, function(err, docs) {});
-                                    }
-                                });
-                            });
-                        }
-                        Functions.remove_name_from_db(guid, coll);
-                    });
-                }
-
-                Functions.remove_unique_id(short_id);
-            } else {
-                offline = false;
-                db.collection("connected_users").update({"_id": "offline_users"}, {$pull: {users: guid}}, function(err, docs) {
-                    Functions.check_inlist(coll, guid, socket, offline, undefined, "place 3");
-                });
-            }
-        });
-
-        socket.on('get_history', function(msg) {
-            if(msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1){
-                var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
-                msg.channel = _list;
-            }
-            if(msg.hasOwnProperty("channel")) {
-                msg.channel = Functions.encodeChannelName(msg.channel);
-            }
-            if(!msg.hasOwnProperty("channel") || !msg.hasOwnProperty("all") ||
-            typeof(msg.channel) != "string" || typeof(msg.all) != "boolean") {
-                var result = {
-                    all: {
-                        expected: "boolean",
-                        got: msg.hasOwnProperty("all") ? typeof(msg.all) : undefined,
-                    },
-                    channel: {
-                        expected: "string",
-                        got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
-                    },
-                    pass: {
-                        expected: "string",
-                        got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined,
-                    }
-                };
-                socket.emit('update_required', result);
-                return;
-            }
-            Chat.get_history(msg.channel, msg.all, socket);
-        });
-
-        socket.on('chat', function (msg) {
-            if(msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1){
-                var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
-                msg.channel = _list;
-            }
-            if(msg.hasOwnProperty("channel")) {
-                msg.channel = Functions.encodeChannelName(msg.channel);
-            }
-            Chat.chat(msg, guid, offline, socket);
-        });
-
-        socket.on("all,chat", function(data)
-        {
-            if(data.hasOwnProperty("channel") && data.channel.indexOf("?") > -1){
-                var _list = data.channel.substring(0, data.channel.indexOf("?"));
-                data.channel = _list;
-            }
-            if(data.hasOwnProperty("channel")) {
-                data.channel = Functions.encodeChannelName(data.channel);
-            }
-            Chat.all_chat(data, guid, offline, socket);
-        });
-
-        socket.on('frontpage_lists', function(msg)
-        {
-            if(msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1){
-                var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
-                msg.channel = _list;
-            }
-            if(msg.hasOwnProperty("channel")) {
-                msg.channel = Functions.encodeChannelName(msg.channel);
-            }
-            Frontpage.frontpage_lists(msg, socket);
-        });
-
-        socket.on('import_zoff', function(msg) {
-            if(msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1){
-                var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
-                msg.channel = _list;
-            }
-            if(msg.hasOwnProperty("channel")) {
-                msg.channel = Functions.encodeChannelName(msg.channel);
-            }
-            ListChange.addFromOtherList(msg, guid, offline, socket);
-        })
-
-        socket.on('now_playing', function(list, fn)
-        {
-            List.now_playing(list, fn, socket);
-        });
-
-        socket.on('id', function(arr)
-        {
-            if(arr.hasOwnProperty("channel") && arr.channel.indexOf("?") > -1){
-                var _list = arr.channel.substring(0, arr.channel.indexOf("?"));
-                arr.channel = _list;
-            }
-            if(arr.hasOwnProperty("channel")) {
-                arr.channel = Functions.encodeChannelName(arr.channel);
-            }
-            if(typeof(arr) == 'object')
-            io.to(arr.id).emit(arr.id.toLowerCase(), {type: arr.type, value: arr.value});
-        });
-
-        socket.on('list', function(msg)
-        {
-            if(msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1){
-                var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
-                msg.channel = _list;
-            }
-            if(msg.hasOwnProperty("channel")) {
-                msg.channel = Functions.encodeChannelName(msg.channel);
-            }
-            try {
-                //var _list = msg.channel.replace(/ /g,'');
-                var _list = msg.channel;
-                if(_list.length == 0) return;
-                if(_list.indexOf("?") > -1){
-                    _list = _list.substring(0, _list.indexOf("?"));
-                    msg.channel = _list;
-                }
-                coll = Functions.removeEmojis(_list).toLowerCase();
-                //coll = coll.replace(/_/g, "");
-                //
-                //coll = filter.clean(coll);
-            } catch(e) {
-                return;
-            }
-
-            if(msg.hasOwnProperty("offline") && msg.offline) {
-                offline = true;
-            }
-            List.list(msg, guid, coll, offline, socket);
-            Functions.get_short_id(socket);
-        });
-
-        socket.on('end', function(obj)
-        {
-            if(obj.hasOwnProperty("channel") && obj.channel.indexOf("?") > -1){
-                var _list = obj.channel.substring(0, obj.channel.indexOf("?"));
-                obj.channel = _list;
-            }
-            if(obj.hasOwnProperty("channel")) {
-                obj.channel = Functions.encodeChannelName(obj.channel);
-                try {
-                    coll = obj.channel.toLowerCase();//.replace(/ /g,'');
-                    if(coll.length == 0) return;
-                    coll = Functions.removeEmojis(coll).toLowerCase();
-                    //coll = coll.replace(/_/g, "");
-
-                    //coll = filter.clean(coll);
-                } catch(e) {
-                    return;
-                }
-            }
-
-            List.end(obj, coll, guid, offline, socket);
-        });
-
-        socket.on('addPlaylist', function(arr) {
-            if(arr.hasOwnProperty("channel") && arr.channel.indexOf("?") > -1){
-                var _list = arr.channel.substring(0, arr.channel.indexOf("?"));
-                arr.channel = _list;
-            }
-            if(arr.hasOwnProperty("channel")) {
-                arr.channel = Functions.encodeChannelName(arr.channel);
-            }
-            ListChange.addPlaylist(arr, guid, offline, socket);
-        })
-
-        socket.on('add', function(arr)
-        {
-            if(arr.hasOwnProperty("list") && arr.list.indexOf("?") > -1){
-                var _list = arr.list.substring(0, arr.list.indexOf("?"));
-                arr.list = _list;
-            }
-            if(arr.hasOwnProperty("list")) {
-                arr.list = Functions.encodeChannelName(arr.list);
-            }
-            if(coll !== undefined && ((arr.hasOwnProperty("offsiteAdd") && !arr.offsiteAdd) || !arr.hasOwnProperty("offsiteAdd"))) {
-                try {
-                    coll = arr.list;//.replace(/ /g,'');
-                    if(coll.length == 0) return;
-                    coll = Functions.removeEmojis(coll).toLowerCase();
-                    //coll = coll.replace(/_/g, "");
-
-                    //coll = filter.clean(coll);
-                } catch(e) {
-                    return;
-                }
-            } else if(arr.hasOwnProperty("offsiteAdd") && arr.offsiteAdd) {
-                arr.list = Functions.removeEmojis(arr.list).toLowerCase();
-            }
-            ListChange.add_function(arr, coll, guid, offline, socket);
-        });
-
-        socket.on('delete_all', function(msg) {
-            try {
-                if(msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1){
-                    var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
-                    msg.channel = _list;
-                }
-                if(msg.hasOwnProperty("channel")) {
-                    msg.channel = Functions.encodeChannelName(msg.channel);
-                }
-                coll = msg.channel.toLowerCase();//.replace(/ /g,'');
-                if(coll.length == 0) return;
-                coll = Functions.removeEmojis(coll).toLowerCase();
-                //coll = coll.replace(/_/g, "");
-
-                //coll = filter.clean(coll);
-            } catch(e) {
-                return;
-            }
-
-            ListChange.delete_all(msg, coll, guid, offline, socket);
-        });
-
-        socket.on('vote', function(msg)
-        {
-            if(msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1){
-                var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
-                msg.channel = _list;
-            }
-            if(msg.hasOwnProperty("channel")) {
-                msg.channel = Functions.encodeChannelName(msg.channel);
-            }
-            if(coll !== undefined) {
-                try {
-                    coll = msg.channel.toLowerCase();//.replace(/ /g,'');
-                    if(coll.length == 0) return;
-                    coll = Functions.removeEmojis(coll).toLowerCase();
-                    //coll = coll.replace(/_/g, "");
-
-                    //coll = filter.clean(coll);
-                } catch(e) {
-                    return;
-                }
-            }
-            ListChange.voteUndecided(msg, coll, guid, offline, socket);
-        });
-
-        socket.on('password', function(inp)
-        {
-            if(inp.hasOwnProperty("channel") && inp.channel.indexOf("?") > -1){
-                var _list = inp.channel.substring(0, inp.channel.indexOf("?"));
-                inp.channel = _list;
-            }
-            if(inp.hasOwnProperty("channel")) {
-                inp.channel = Functions.encodeChannelName(inp.channel);
-            }
-            //if(coll != undefined) coll.replace(/ /g,'');
-            ListSettings.password(inp, coll, guid, offline, socket);
-        });
-
-        socket.on('skip', function(list)
-        {
-            if(list.hasOwnProperty("channel") && list.channel.indexOf("?") > -1){
-                var _list = list.channel.substring(0, list.channel.indexOf("?"));
-                list.channel = _list;
-                coll = list.channel;
-            }
-            if(list.hasOwnProperty("channel")) {
-                list.channel = Functions.encodeChannelName(list.channel);
-            }
-            //if(coll != undefined) coll.replace(/ /g,'');
-            List.skip(list, guid, coll, offline, socket);
-        });
-
-        socket.on('conf', function(conf)
-        {
-            if(conf.hasOwnProperty("channel") && conf.channel.indexOf("?") > -1){
-                var _list = conf.channel.substring(0, conf.channel.indexOf("?"));
-                conf.channel = _list;
-                coll = conf.channel;
-            }
-            if(conf.hasOwnProperty("channel")) {
-                conf.channel = Functions.encodeChannelName(conf.channel);
-                coll = conf.channel;
-            }
-            //if(coll != undefined) coll.replace(/ /g,'');
-            ListSettings.conf_function(conf, coll, guid, offline, socket);
-        });
-
-        socket.on('shuffle', function(msg)
-        {
-            if(msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1){
-                var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
-                msg.channel = _list;
-            }
-            if(msg.hasOwnProperty("channel")) {
-                msg.channel = Functions.encodeChannelName(msg.channel);
-            }
-            try {
-                coll = msg.channel.toLowerCase();//.replace(/ /g,'');
-                if(coll.length == 0) return;
-                coll = Functions.removeEmojis(coll).toLowerCase();
-                //coll = coll.replace(/_/g, "");
-
-                //coll = filter.clean(coll);
-            } catch(e) {
-                return;
-            }
-
-            ListChange.shuffle(msg, coll, guid, offline, socket);
-        });
-
-        socket.on('change_channel', function(obj)
-        {
-            if(obj == undefined && coll != undefined) {
-                obj = {};
-                obj.channel = coll;
-            } else if(obj != undefined && obj.hasOwnProperty("channel") && obj.channel.indexOf("?") > -1){
-                var _list = obj.channel.substring(0, obj.channel.indexOf("?"));
-                obj.channel = _list;
-            }
-            if(obj == undefined && coll == undefined) {
-                return;
-            }
-            if(obj.hasOwnProperty("channel")) {
-                obj.channel = Functions.encodeChannelName(obj.channel);
-            }
-            if(coll === undefined && obj !== undefined && obj.channel !== undefined){
-                try {
-                    coll = obj.channel.toLowerCase();//.replace(/ /g,'');
-                    if(coll.length == 0) return;
-                    coll = Functions.removeEmojis(coll).toLowerCase();
-                    //coll = coll.replace(/_/g, "");
-
-                    //coll = filter.clean(coll);
-                } catch(e) {
-                    return;
-                }
-            }
-            Functions.left_channel(coll, guid, short_id, in_list, socket, true, "left 1");
-            in_list = false;
-        });
-
-        socket.on('disconnect', function()
-        {
-            Functions.left_channel(coll, guid, short_id, in_list, socket, false, "left 2");
-        });
-
-        socket.on('disconnected', function()
-        {
-            Functions.left_channel(coll, guid, short_id, in_list, socket, false, "left 3");
-        });
-
-        socket.on("left_channel", function(msg) {
-            if(msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1){
-                var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
-                msg.channel = _list;
-            }
-            if(msg.hasOwnProperty("channel")) {
-                msg.channel = Functions.encodeChannelName(msg.channel);
-            }
-            if(msg.hasOwnProperty("channel") && msg.channel != "" && typeof(msg.channel) == "string") {
-                coll = msg.channel;//.replace(/ /g,'');
-                coll = Functions.removeEmojis(coll).toLowerCase();
-                //coll = filter.clean(coll);
-                Functions.left_channel(coll, guid, short_id, in_list, socket, false, "left 4");
-            }
-        })
-
-        socket.on('reconnect_failed', function()
-        {
-            Functions.left_channel(coll, guid, short_id, in_list, socket, false, "left 5");
-        });
-
-        socket.on('connect_timeout', function()
-        {
-            Functions.left_channel(coll, guid, short_id, in_list, socket, false, "left 6");
-        });
-
-        socket.on('error', function()
-        {
-            Functions.left_channel(coll, guid, short_id, in_list, socket, false, "left 7");
-        });
-
-        socket.on('pos', function(obj)
-        {
-            if(obj != undefined && obj.hasOwnProperty("channel") && obj.channel.indexOf("?") > -1){
-                var _list = obj.channel.substring(0, obj.channel.indexOf("?"));
-                obj.channel = _list;
-            }
-            if(obj != undefined && obj.hasOwnProperty("channel")) {
-                obj.channel = Functions.encodeChannelName(obj.channel);
-            }
-            if(obj == undefined && coll == undefined) {
-                return;
-            }
-            if(coll !== undefined) {
-                try {
-                    coll = obj.channel.toLowerCase();//.replace(/ /g,'');
-                    if(coll.length == 0) return;
-                    coll = Functions.removeEmojis(coll).toLowerCase();
-                    //coll = coll.replace(/_/g, "");
-
-                    //coll = filter.clean(coll);
-                } catch(e) {
-                    return;
-                }
-            }
-
-            if(!obj.hasOwnProperty("channel") || typeof(obj.channel) != "string") {
-                var result = {
-                    channel: {
-                        expected: "string",
-                        got: obj.hasOwnProperty("channel") ? typeof(obj.channel) : undefined
-                    },
-                    pass: {
-                        expected: "string",
-                        got: obj.hasOwnProperty("pass") ? typeof(obj.pass) : undefined
-                    }
-                };
-                socket.emit('update_required', result);
-                return;
-            }
-            if(coll == undefined) return;
-            db.collection(coll + "_settings").find(function(err, docs) {
-                Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
-                    if(userpass != "" || obj.pass == undefined) {
-                        obj.pass = userpass;
-                    } else {
-                        obj.pass = crypto.createHash('sha256').update(Functions.decrypt_string(obj.pass)).digest("base64")
-                    }
-                    if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (obj.hasOwnProperty('pass') && docs[0].userpass == obj.pass))) {
-                        Functions.check_inlist(coll, guid, socket, offline, undefined, "place 4");
-                        List.send_play(coll, socket);
-                    } else {
-                        socket.emit("auth_required");
-                    }
-                });
-            });
-        });
+    socket.guid = guid;
+    socket.on("close", function() {});
 
+    socket.on("pinging", function() {
+      socket.emit("ok");
     });
 
-    //send_ping();
-}
+    var ping_timeout;
+    var socketid = socket.zoff_id;
+    var coll;
+    var in_list = false;
+    var name = "";
+    var short_id;
+    Chat.get_name(guid, { announce: false, socket: socket });
+    var offline = false;
+    var chromecast_object = false;
 
+    socket.emit("guid", guid);
+
+    socket.on("self_ping", function(msg) {
+      var channel = msg.channel;
+      if (channel.indexOf("?") > -1) {
+        channel = channel.substring(0, channel.indexOf("?"));
+      }
+      if (msg.hasOwnProperty("channel")) {
+        msg.channel = Functions.encodeChannelName(msg.channel);
+      }
+      //channel = channel.replace(/ /g,'');
+      if (offline) {
+        db.collection("connected_users").update(
+          { _id: "offline_users" },
+          { $addToSet: { users: guid } },
+          { upsert: true },
+          function(err, docs) {}
+        );
+      } else {
+        db.collection("connected_users").update(
+          { _id: channel },
+          { $addToSet: { users: guid } },
+          { upsert: true },
+          function(err, docs) {
+            db.collection("frontpage_lists").update(
+              { _id: channel },
+              { $inc: { viewers: 1 } },
+              { upsert: true },
+              function() {}
+            );
+          }
+        );
+      }
+      if (channel != "" && channel != undefined) {
+        db.collection("connected_users").update(
+          { _id: "total_users" },
+          { $addToSet: { total_users: guid + channel } },
+          { upsert: true },
+          function(err, docs) {}
+        );
+      }
+    });
+
+    socket.on("logout", function() {
+      Functions.removeSessionAdminPass(
+        Functions.getSession(socket),
+        coll,
+        function() {}
+      );
+    });
+
+    socket.on("next_song", function(obj) {
+      if (obj == undefined || !obj.hasOwnProperty("channel")) return;
+      db.collection(obj.channel + "_settings").find(function(e, docs) {
+        if (docs.length == 0) return;
+        var pass = "";
+        if (obj.hasOwnProperty("pass")) {
+          pass = crypto
+            .createHash("sha256")
+            .update(Functions.decrypt_string(obj.pass))
+            .digest("base64");
+        }
+        if (
+          docs.length > 0 &&
+          (docs[0].userpass == undefined ||
+            docs[0].userpass == "" ||
+            docs[0].userpass == pass)
+        ) {
+          List.getNextSong(obj.channel, socket);
+        }
+      });
+    });
+
+    socket.on("chromecast", function(msg) {
+      try {
+        if (
+          typeof msg == "object" &&
+          msg.hasOwnProperty("guid") &&
+          msg.hasOwnProperty("socket_id") &&
+          msg.hasOwnProperty("channel") &&
+          typeof msg.guid == "string" &&
+          typeof msg.channel == "string" &&
+          typeof msg.socket_id == "string" &&
+          msg.channel != ""
+        ) {
+          if (msg.hasOwnProperty("channel")) {
+            msg.channel = Functions.encodeChannelName(msg.channel);
+          }
+          db.collection("connected_users").find({ _id: msg.channel }, function(
+            err,
+            connected_users_channel
+          ) {
+            if (
+              connected_users_channel.length > 0 &&
+              connected_users_channel[0].users.indexOf(msg.guid) > -1
+            ) {
+              coll = msg.channel.toLowerCase(); //.replace(/ /g,'');
+              coll = Functions.removeEmojis(coll).toLowerCase();
+              //coll = filter.clean(coll);
+              if (coll.indexOf("?") > -1) {
+                coll = coll.substring(0, coll.indexOf("?"));
+              }
+              Functions.setChromecastHost(
+                socket.cookie_id,
+                msg.socket_id,
+                msg.channel,
+                function(results) {}
+              );
+              //socket.cookie_id = msg.guid;
+              guid = msg.guid;
+              socketid = msg.socket_id;
+              socket.zoff_id = socketid;
+
+              in_list = true;
+              chromecast_object = true;
+              socket.join(coll);
+            }
+          });
+        }
+      } catch (e) {
+        return;
+      }
+    });
+
+    socket.on("get_id", function() {
+      socket.emit("id_chromecast", {
+        cookie_id: Functions.getSession(socket),
+        guid: guid
+      });
+    });
+
+    socket.on("error_video", function(msg) {
+      try {
+        msg.channel = Functions.encodeChannelName(msg.channel);
+        var _list = msg.channel; //.replace(/ /g,'');
+        if (_list.length == 0) return;
+        if (_list.indexOf("?") > -1) {
+          _list = _list.substring(0, _list.indexOf("?"));
+          msg.channel = _list;
+        }
+        coll = Functions.removeEmojis(_list).toLowerCase();
+        //coll = coll.replace(/_/g, "");
+
+        //coll = filter.clean(coll);
+      } catch (e) {
+        return;
+      }
+      if (msg.hasOwnProperty("channel")) {
+        msg.channel = Functions.encodeChannelName(msg.channel);
+      }
+      Search.check_error_video(msg, coll);
+    });
+
+    socket.on("get_spread", function() {
+      db.collection("connected_users").find({ _id: "total_users" }, function(
+        err,
+        tot
+      ) {
+        db.collection("connected_users").find(
+          { _id: "offline_users" },
+          function(err, off) {
+            db.collection("connected_users").find(
+              { _id: { $ne: "total_users" }, _id: { $ne: "offline_users" } },
+              function(err, users_list) {
+                if (tot.length > 0 && off.length == 0) {
+                  socket.emit("spread_listeners", {
+                    offline: 0,
+                    total: tot[0].total_users.length,
+                    online_users: users_list
+                  });
+                } else if (tot.length > 0 && off.length > 0) {
+                  socket.emit("spread_listeners", {
+                    offline: off[0].users.length,
+                    total: tot[0].total_users.length,
+                    online_users: users_list
+                  });
+                }
+              }
+            );
+          }
+        );
+      });
+    });
+
+    socket.on("suggest_thumbnail", function(msg) {
+      if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
+        var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
+        msg.channel = _list;
+      }
+      if (msg.hasOwnProperty("channel")) {
+        msg.channel = Functions.encodeChannelName(msg.channel);
+      }
+      Suggestions.thumbnail(msg, coll, guid, offline, socket);
+    });
+
+    socket.on("suggest_description", function(msg) {
+      if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
+        var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
+        msg.channel = _list;
+      }
+      if (msg.hasOwnProperty("channel")) {
+        msg.channel = Functions.encodeChannelName(msg.channel);
+      }
+      Suggestions.description(msg, coll, guid, offline, socket);
+    });
+
+    socket.on("suggest_rules", function(msg) {
+      if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
+        var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
+        msg.channel = _list;
+      }
+      if (msg.hasOwnProperty("channel")) {
+        msg.channel = Functions.encodeChannelName(msg.channel);
+      }
+      Suggestions.rules(msg, coll, guid, offline, socket);
+    });
+
+    socket.on("namechange", function(msg) {
+      if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
+        var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
+        msg.channel = _list;
+      }
+      if (msg.hasOwnProperty("channel")) {
+        msg.channel = Functions.encodeChannelName(msg.channel);
+      }
+      Chat.namechange(msg, guid, socket);
+    });
+
+    socket.on("removename", function(msg) {
+      if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
+        var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
+        msg.channel = _list;
+      }
+      if (msg.hasOwnProperty("channel")) {
+        msg.channel = Functions.encodeChannelName(msg.channel);
+      }
+      if (typeof msg != "object" || !msg.hasOwnProperty("channel")) {
+        var result = {
+          channel: {
+            expected: "string",
+            got: msg.hasOwnProperty("channel") ? typeof msg.channel : undefined
+          }
+        };
+        socket.emit("update_required", result);
+        return;
+      }
+      Chat.removename(guid, msg.channel, socket);
+    });
+
+    socket.on("offline", function(msg) {
+      if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
+        var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
+        msg.channel = _list;
+      }
+      if (msg.hasOwnProperty("channel")) {
+        msg.channel = Functions.encodeChannelName(msg.channel);
+      }
+      if (
+        !msg.hasOwnProperty("status") ||
+        !msg.hasOwnProperty("channel") ||
+        typeof msg.status != "boolean" ||
+        typeof msg.channel != "string"
+      ) {
+        var result = {
+          status: {
+            expected: "boolean",
+            got: msg.hasOwnProperty("status") ? typeof msg.status : undefined
+          },
+          channel: {
+            expected: "string",
+            got: msg.hasOwnProperty("channel") ? typeof msg.channel : undefined
+          }
+        };
+        socket.emit("update_required", result);
+        return;
+      }
+      var status = msg.status;
+      var channel = Functions.encodeChannelName(msg.channel); //.replace(/ /g,'');
+      if (status) {
+        in_list = false;
+        offline = true;
+        if (channel != "") coll = channel;
+        if (coll !== undefined) {
+          coll = Functions.removeEmojis(coll).toLowerCase();
+          //coll = filter.clean(coll);
+          db.collection("connected_users").findAndModify(
+            {
+              query: { _id: coll },
+              update: { $pull: { users: guid } },
+              upsert: true
+            },
+            function(err, updated, d) {
+              if (d.n == 1) {
+                var num = 0;
+                if (updated && updated.users) {
+                  num = updated.users.length;
+                }
+                io.to(coll).emit("viewers", num);
+                db.collection("frontpage_lists").update(
+                  { _id: coll, viewers: { $gt: 0 } },
+                  { $inc: { viewers: -1 } },
+                  function(err, docs) {}
+                );
+                db.collection("connected_users").update(
+                  { _id: "total_users" },
+                  { $pull: { total_users: guid + coll } },
+                  function(err, docs) {
+                    db.collection("connected_users").update(
+                      { _id: "offline_users" },
+                      { $addToSet: { users: guid } },
+                      { upsert: true },
+                      function(err, docs) {
+                        if (
+                          docs.nModified == 1 &&
+                          (coll != undefined && coll != "")
+                        ) {
+                          db.collection("connected_users").update(
+                            { _id: "total_users" },
+                            { $addToSet: { total_users: guid + coll } },
+                            function(err, docs) {}
+                          );
+                        }
+                      }
+                    );
+                  }
+                );
+              }
+              Functions.remove_name_from_db(guid, coll);
+            }
+          );
+        }
+
+        Functions.remove_unique_id(short_id);
+      } else {
+        offline = false;
+        db.collection("connected_users").update(
+          { _id: "offline_users" },
+          { $pull: { users: guid } },
+          function(err, docs) {
+            Functions.check_inlist(
+              coll,
+              guid,
+              socket,
+              offline,
+              undefined,
+              "place 3"
+            );
+          }
+        );
+      }
+    });
+
+    socket.on("get_history", function(msg) {
+      if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
+        var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
+        msg.channel = _list;
+      }
+      if (msg.hasOwnProperty("channel")) {
+        msg.channel = Functions.encodeChannelName(msg.channel);
+      }
+      if (
+        !msg.hasOwnProperty("channel") ||
+        !msg.hasOwnProperty("all") ||
+        typeof msg.channel != "string" ||
+        typeof msg.all != "boolean"
+      ) {
+        var result = {
+          all: {
+            expected: "boolean",
+            got: msg.hasOwnProperty("all") ? typeof msg.all : undefined
+          },
+          channel: {
+            expected: "string",
+            got: msg.hasOwnProperty("channel") ? typeof msg.channel : undefined
+          },
+          pass: {
+            expected: "string",
+            got: msg.hasOwnProperty("pass") ? typeof msg.pass : undefined
+          }
+        };
+        socket.emit("update_required", result);
+        return;
+      }
+      Chat.get_history(msg.channel, msg.all, socket);
+    });
+
+    socket.on("chat", function(msg) {
+      if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
+        var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
+        msg.channel = _list;
+      }
+      if (msg.hasOwnProperty("channel")) {
+        msg.channel = Functions.encodeChannelName(msg.channel);
+      }
+      Chat.chat(msg, guid, offline, socket);
+    });
+
+    socket.on("all,chat", function(data) {
+      if (data.hasOwnProperty("channel") && data.channel.indexOf("?") > -1) {
+        var _list = data.channel.substring(0, data.channel.indexOf("?"));
+        data.channel = _list;
+      }
+      if (data.hasOwnProperty("channel")) {
+        data.channel = Functions.encodeChannelName(data.channel);
+      }
+      Chat.all_chat(data, guid, offline, socket);
+    });
+
+    socket.on("frontpage_lists", function(msg) {
+      if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
+        var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
+        msg.channel = _list;
+      }
+      if (msg.hasOwnProperty("channel")) {
+        msg.channel = Functions.encodeChannelName(msg.channel);
+      }
+      Frontpage.frontpage_lists(msg, socket);
+    });
+
+    socket.on("import_zoff", function(msg) {
+      if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
+        var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
+        msg.channel = _list;
+      }
+      if (msg.hasOwnProperty("channel")) {
+        msg.channel = Functions.encodeChannelName(msg.channel);
+      }
+      ListChange.addFromOtherList(msg, guid, offline, socket);
+    });
+
+    socket.on("now_playing", function(list, fn) {
+      List.now_playing(list, fn, socket);
+    });
+
+    socket.on("id", function(arr) {
+      if (arr.hasOwnProperty("channel") && arr.channel.indexOf("?") > -1) {
+        var _list = arr.channel.substring(0, arr.channel.indexOf("?"));
+        arr.channel = _list;
+      }
+      if (arr.hasOwnProperty("channel")) {
+        arr.channel = Functions.encodeChannelName(arr.channel);
+      }
+      if (typeof arr == "object")
+        io.to(arr.id).emit(arr.id.toLowerCase(), {
+          type: arr.type,
+          value: arr.value
+        });
+    });
+
+    socket.on("list", function(msg) {
+      if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
+        var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
+        msg.channel = _list;
+      }
+      if (msg.hasOwnProperty("channel")) {
+        msg.channel = Functions.encodeChannelName(msg.channel);
+      }
+      try {
+        //var _list = msg.channel.replace(/ /g,'');
+        var _list = msg.channel;
+        if (_list.length == 0) return;
+        if (_list.indexOf("?") > -1) {
+          _list = _list.substring(0, _list.indexOf("?"));
+          msg.channel = _list;
+        }
+        coll = Functions.removeEmojis(_list).toLowerCase();
+        //coll = coll.replace(/_/g, "");
+        //
+        //coll = filter.clean(coll);
+      } catch (e) {
+        return;
+      }
+
+      if (msg.hasOwnProperty("offline") && msg.offline) {
+        offline = true;
+      }
+      List.list(msg, guid, coll, offline, socket);
+      Functions.get_short_id(socket);
+    });
+
+    socket.on("end", function(obj) {
+      if (obj.hasOwnProperty("channel") && obj.channel.indexOf("?") > -1) {
+        var _list = obj.channel.substring(0, obj.channel.indexOf("?"));
+        obj.channel = _list;
+      }
+      if (obj.hasOwnProperty("channel")) {
+        obj.channel = Functions.encodeChannelName(obj.channel);
+        try {
+          coll = obj.channel.toLowerCase(); //.replace(/ /g,'');
+          if (coll.length == 0) return;
+          coll = Functions.removeEmojis(coll).toLowerCase();
+          //coll = coll.replace(/_/g, "");
+
+          //coll = filter.clean(coll);
+        } catch (e) {
+          return;
+        }
+      }
+
+      List.end(obj, coll, guid, offline, socket);
+    });
+
+    socket.on("addPlaylist", function(arr) {
+      if (arr.hasOwnProperty("channel") && arr.channel.indexOf("?") > -1) {
+        var _list = arr.channel.substring(0, arr.channel.indexOf("?"));
+        arr.channel = _list;
+      }
+      if (arr.hasOwnProperty("channel")) {
+        arr.channel = Functions.encodeChannelName(arr.channel);
+      }
+      ListChange.addPlaylist(arr, guid, offline, socket);
+    });
+
+    socket.on("add", function(arr) {
+      if (arr.hasOwnProperty("list") && arr.list.indexOf("?") > -1) {
+        var _list = arr.list.substring(0, arr.list.indexOf("?"));
+        arr.list = _list;
+      }
+      if (arr.hasOwnProperty("list")) {
+        arr.list = Functions.encodeChannelName(arr.list);
+      }
+      if (
+        coll !== undefined &&
+        ((arr.hasOwnProperty("offsiteAdd") && !arr.offsiteAdd) ||
+          !arr.hasOwnProperty("offsiteAdd"))
+      ) {
+        try {
+          coll = arr.list; //.replace(/ /g,'');
+          if (coll.length == 0) return;
+          coll = Functions.removeEmojis(coll).toLowerCase();
+          //coll = coll.replace(/_/g, "");
+
+          //coll = filter.clean(coll);
+        } catch (e) {
+          return;
+        }
+      } else if (arr.hasOwnProperty("offsiteAdd") && arr.offsiteAdd) {
+        arr.list = Functions.removeEmojis(arr.list).toLowerCase();
+      }
+      ListChange.add_function(arr, coll, guid, offline, socket);
+    });
+
+    socket.on("delete_all", function(msg) {
+      try {
+        if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
+          var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
+          msg.channel = _list;
+        }
+        if (msg.hasOwnProperty("channel")) {
+          msg.channel = Functions.encodeChannelName(msg.channel);
+        }
+        coll = msg.channel.toLowerCase(); //.replace(/ /g,'');
+        if (coll.length == 0) return;
+        coll = Functions.removeEmojis(coll).toLowerCase();
+        //coll = coll.replace(/_/g, "");
+
+        //coll = filter.clean(coll);
+      } catch (e) {
+        return;
+      }
+
+      ListChange.delete_all(msg, coll, guid, offline, socket);
+    });
+
+    socket.on("vote", function(msg) {
+      if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
+        var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
+        msg.channel = _list;
+      }
+      if (msg.hasOwnProperty("channel")) {
+        msg.channel = Functions.encodeChannelName(msg.channel);
+      }
+      if (coll !== undefined) {
+        try {
+          coll = msg.channel.toLowerCase(); //.replace(/ /g,'');
+          if (coll.length == 0) return;
+          coll = Functions.removeEmojis(coll).toLowerCase();
+          //coll = coll.replace(/_/g, "");
+
+          //coll = filter.clean(coll);
+        } catch (e) {
+          return;
+        }
+      }
+      ListChange.voteUndecided(msg, coll, guid, offline, socket);
+    });
+
+    socket.on("password", function(inp) {
+      if (inp.hasOwnProperty("channel") && inp.channel.indexOf("?") > -1) {
+        var _list = inp.channel.substring(0, inp.channel.indexOf("?"));
+        inp.channel = _list;
+      }
+      if (inp.hasOwnProperty("channel")) {
+        inp.channel = Functions.encodeChannelName(inp.channel);
+      }
+      //if(coll != undefined) coll.replace(/ /g,'');
+      ListSettings.password(inp, coll, guid, offline, socket);
+    });
+
+    socket.on("skip", function(list) {
+      if (list.hasOwnProperty("channel") && list.channel.indexOf("?") > -1) {
+        var _list = list.channel.substring(0, list.channel.indexOf("?"));
+        list.channel = _list;
+        coll = list.channel;
+      }
+      if (list.hasOwnProperty("channel")) {
+        list.channel = Functions.encodeChannelName(list.channel);
+      }
+      //if(coll != undefined) coll.replace(/ /g,'');
+      List.skip(list, guid, coll, offline, socket);
+    });
+
+    socket.on("conf", function(conf) {
+      if (conf.hasOwnProperty("channel") && conf.channel.indexOf("?") > -1) {
+        var _list = conf.channel.substring(0, conf.channel.indexOf("?"));
+        conf.channel = _list;
+        coll = conf.channel;
+      }
+      if (conf.hasOwnProperty("channel")) {
+        conf.channel = Functions.encodeChannelName(conf.channel);
+        coll = conf.channel;
+      }
+      //if(coll != undefined) coll.replace(/ /g,'');
+      ListSettings.conf_function(conf, coll, guid, offline, socket);
+    });
+
+    socket.on("shuffle", function(msg) {
+      if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
+        var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
+        msg.channel = _list;
+      }
+      if (msg.hasOwnProperty("channel")) {
+        msg.channel = Functions.encodeChannelName(msg.channel);
+      }
+      try {
+        coll = msg.channel.toLowerCase(); //.replace(/ /g,'');
+        if (coll.length == 0) return;
+        coll = Functions.removeEmojis(coll).toLowerCase();
+        //coll = coll.replace(/_/g, "");
+
+        //coll = filter.clean(coll);
+      } catch (e) {
+        return;
+      }
+
+      ListChange.shuffle(msg, coll, guid, offline, socket);
+    });
+
+    socket.on("change_channel", function(obj) {
+      if (obj == undefined && coll != undefined) {
+        obj = {};
+        obj.channel = coll;
+      } else if (
+        obj != undefined &&
+        obj.hasOwnProperty("channel") &&
+        obj.channel.indexOf("?") > -1
+      ) {
+        var _list = obj.channel.substring(0, obj.channel.indexOf("?"));
+        obj.channel = _list;
+      }
+      if (obj == undefined && coll == undefined) {
+        return;
+      }
+      if (obj.hasOwnProperty("channel")) {
+        obj.channel = Functions.encodeChannelName(obj.channel);
+      }
+      if (
+        coll === undefined &&
+        obj !== undefined &&
+        obj.channel !== undefined
+      ) {
+        try {
+          coll = obj.channel.toLowerCase(); //.replace(/ /g,'');
+          if (coll.length == 0) return;
+          coll = Functions.removeEmojis(coll).toLowerCase();
+          //coll = coll.replace(/_/g, "");
+
+          //coll = filter.clean(coll);
+        } catch (e) {
+          return;
+        }
+      }
+      Functions.left_channel(
+        coll,
+        guid,
+        short_id,
+        in_list,
+        socket,
+        true,
+        "left 1"
+      );
+      in_list = false;
+    });
+
+    socket.on("disconnect", function() {
+      Functions.left_channel(
+        coll,
+        guid,
+        short_id,
+        in_list,
+        socket,
+        false,
+        "left 2"
+      );
+    });
+
+    socket.on("disconnected", function() {
+      Functions.left_channel(
+        coll,
+        guid,
+        short_id,
+        in_list,
+        socket,
+        false,
+        "left 3"
+      );
+    });
+
+    socket.on("left_channel", function(msg) {
+      if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) {
+        var _list = msg.channel.substring(0, msg.channel.indexOf("?"));
+        msg.channel = _list;
+      }
+      if (msg.hasOwnProperty("channel")) {
+        msg.channel = Functions.encodeChannelName(msg.channel);
+      }
+      if (
+        msg.hasOwnProperty("channel") &&
+        msg.channel != "" &&
+        typeof msg.channel == "string"
+      ) {
+        coll = msg.channel; //.replace(/ /g,'');
+        coll = Functions.removeEmojis(coll).toLowerCase();
+        //coll = filter.clean(coll);
+        Functions.left_channel(
+          coll,
+          guid,
+          short_id,
+          in_list,
+          socket,
+          false,
+          "left 4"
+        );
+      }
+    });
+
+    socket.on("reconnect_failed", function() {
+      Functions.left_channel(
+        coll,
+        guid,
+        short_id,
+        in_list,
+        socket,
+        false,
+        "left 5"
+      );
+    });
+
+    socket.on("connect_timeout", function() {
+      Functions.left_channel(
+        coll,
+        guid,
+        short_id,
+        in_list,
+        socket,
+        false,
+        "left 6"
+      );
+    });
+
+    socket.on("error", function() {
+      Functions.left_channel(
+        coll,
+        guid,
+        short_id,
+        in_list,
+        socket,
+        false,
+        "left 7"
+      );
+    });
+
+    socket.on("pos", function(obj) {
+      if (
+        obj != undefined &&
+        obj.hasOwnProperty("channel") &&
+        obj.channel.indexOf("?") > -1
+      ) {
+        var _list = obj.channel.substring(0, obj.channel.indexOf("?"));
+        obj.channel = _list;
+      }
+      if (obj != undefined && obj.hasOwnProperty("channel")) {
+        obj.channel = Functions.encodeChannelName(obj.channel);
+      }
+      if (obj == undefined && coll == undefined) {
+        return;
+      }
+      if (coll !== undefined) {
+        try {
+          coll = obj.channel.toLowerCase(); //.replace(/ /g,'');
+          if (coll.length == 0) return;
+          coll = Functions.removeEmojis(coll).toLowerCase();
+          //coll = coll.replace(/_/g, "");
+
+          //coll = filter.clean(coll);
+        } catch (e) {
+          return;
+        }
+      }
+
+      if (!obj.hasOwnProperty("channel") || typeof obj.channel != "string") {
+        var result = {
+          channel: {
+            expected: "string",
+            got: obj.hasOwnProperty("channel") ? typeof obj.channel : undefined
+          },
+          pass: {
+            expected: "string",
+            got: obj.hasOwnProperty("pass") ? typeof obj.pass : undefined
+          }
+        };
+        socket.emit("update_required", result);
+        return;
+      }
+      if (coll == undefined) return;
+      db.collection(coll + "_settings").find(function(err, docs) {
+        Functions.getSessionAdminUser(
+          Functions.getSession(socket),
+          coll,
+          function(userpass, adminpass) {
+            if (userpass != "" || obj.pass == undefined) {
+              obj.pass = userpass;
+            } else {
+              obj.pass = crypto
+                .createHash("sha256")
+                .update(Functions.decrypt_string(obj.pass))
+                .digest("base64");
+            }
+            if (
+              docs.length > 0 &&
+              (docs[0].userpass == undefined ||
+                docs[0].userpass == "" ||
+                (obj.hasOwnProperty("pass") && docs[0].userpass == obj.pass))
+            ) {
+              Functions.check_inlist(
+                coll,
+                guid,
+                socket,
+                offline,
+                undefined,
+                "place 4"
+              );
+              List.send_play(coll, socket);
+            } else {
+              socket.emit("auth_required");
+            }
+          }
+        );
+      });
+    });
+  });
+
+  //send_ping();
+};
 
 /*
 function send_ping() {
diff --git a/server/handlers/list.js b/server/handlers/list.js
index a8b7db77..d8fbded2 100644
--- a/server/handlers/list.js
+++ b/server/handlers/list.js
@@ -1,772 +1,1248 @@
-var ColorThief = require('color-thief-jimp');
-var Jimp = require('jimp');
-var Functions = require(pathThumbnails + '/handlers/functions.js');
-var Frontpage = require(pathThumbnails + '/handlers/frontpage.js');
+var ColorThief = require("color-thief-jimp");
+var Jimp = require("jimp");
+var Functions = require(pathThumbnails + "/handlers/functions.js");
+var Frontpage = require(pathThumbnails + "/handlers/frontpage.js");
 var projects = require(pathThumbnails + "/handlers/aggregates.js");
-var crypto = require('crypto');
-var Filter = require('bad-words');
-var Search = require(pathThumbnails + '/handlers/search.js');
-var filter = new Filter({ placeHolder: 'x'});
+var crypto = require("crypto");
+var Filter = require("bad-words");
+var Search = require(pathThumbnails + "/handlers/search.js");
+var filter = new Filter({ placeHolder: "x" });
 /*var filter = {
     clean: function(str) {
         return str;
     }
 }*/
-var request = require('request');
-var db = require(pathThumbnails + '/handlers/db.js');
+var request = require("request");
+var db = require(pathThumbnails + "/handlers/db.js");
 
 function now_playing(list, fn, socket) {
-    if(typeof(list) !== 'string' || typeof(fn) !== 'function') {
-        socket.emit('update_required');
-        return;
+  if (typeof list !== "string" || typeof fn !== "function") {
+    socket.emit("update_required");
+    return;
+  }
+  db.collection(list).find({ now_playing: true }, function(err, docs) {
+    if (docs.length === 0) {
+      fn("No song currently playing");
+      return;
     }
-    db.collection(list).find({now_playing:true}, function(err, docs){
-        if(docs.length === 0){
-            fn("No song currently playing");
-            return;
-        }
-        var title = docs[0].title;
-        if(title === undefined) fn("No song currently playing");
-        else fn(title);
-    });
+    var title = docs[0].title;
+    if (title === undefined) fn("No song currently playing");
+    else fn(title);
+  });
 }
 
 function list(msg, guid, coll, offline, socket) {
-    var socketid = socket.zoff_id;
-
-    if(typeof(msg) === 'object' && msg !== undefined && msg !== null)
-    {
-        Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass, gotten) {
-            if(gotten && userpass != "" && !msg.hasOwnProperty("pass")) {
-                msg.pass = userpass;
-            } else {
-                msg.pass = crypto.createHash('sha256').update(Functions.decrypt_string(msg.pass)).digest("base64");
-            }
-            adminpass = Functions.hash_pass(adminpass);
-            if(!msg.hasOwnProperty('version') || !msg.hasOwnProperty("channel") ||
-             msg.version != VERSION || msg.version == undefined ||
-            typeof(msg.channel) != "string") {
-                var result = {
-                    channel: {
-                        expected: "string",
-                        got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined,
-                    },
-                    version: {
-                        expected: VERSION,
-                        got: msg.version,
-                    },
-                    pass: {
-                        expected: "string",
-                        got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined,
-                    },
-                };
-                socket.emit('update_required', result);
-                return;
-            }
-            coll = msg.channel.toLowerCase(); //.replace(/ /g,'');
-            coll = Functions.removeEmojis(coll).toLowerCase();
-            //coll = filter.clean(coll);
-            var pass = msg.pass;
-            db.collection('frontpage_lists').find({"_id": coll}, function(err, frontpage_lists){
-                if(frontpage_lists.length == 1) {
-                    db.collection(coll + "_settings").find(function(err, docs) {
-                        if(docs.length == 0 || (docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || docs[0].userpass == pass))) {
-                            if(docs.length > 0 && docs[0].hasOwnProperty('userpass') && docs[0].userpass != "" && docs[0].userpass == pass) {
-                                Functions.setSessionUserPass(Functions.getSession(socket), msg.pass, coll, function(){})
-                                socket.emit("auth_accepted", {value: true});
-                            }
-                            if(docs.length > 0 && docs[0].userpass != pass) {
-                                Functions.setSessionUserPass(Functions.getSession(socket), "", coll, function(){})
-                            }
-                            if(docs.length > 0 && docs[0].hasOwnProperty("adminpass") && docs[0].adminpass != "" && docs[0].adminpass == adminpass) {
-                                socket.emit("pw", true);
-                            }
-                            in_list = true;
-                            socket.join(coll);
-                            Functions.check_inlist(coll, guid, socket, offline, undefined, "place 10");
-
-                            if(frontpage_lists[0].viewers != undefined){
-                                io.to(coll).emit("viewers", frontpage_lists[0].viewers);
-                            } else {
-                                io.to(coll).emit("viewers", 1);
-                            }
-
-                            send_list(coll, socket, true, false, true);
-
-                        } else {
-                            socket.emit("auth_required");
-                        }
-                    });
-                } else {
-                    db.createCollection(coll, function(err, docs){
-                        db.collection(coll).createIndex({ id: 1}, {unique: true}, function(e, d) {
-                            var configs = {"addsongs":false, "adminpass":"", "allvideos":true, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":Functions.get_time(), "views": [], "vote": false, "description": "", "thumbnail": "", "rules": "", userpass: "", id: "config", "toggleChat": true};
-                            db.collection(coll + "_settings").insert(configs, function(err, docs){
-                                socket.join(coll);
-                                send_list(coll, socket, true, false, true);
-                                db.collection("frontpage_lists").insert({"_id": coll, "count" : 0, "frontpage": true, "accessed": Functions.get_time(), "viewers": 1}, function(e,d){
-                                });
-                                Functions.check_inlist(coll, guid, socket, offline, undefined, "place 11");
-                            });
-                        });
-                    });
-                }
-            });
-        });
-    } else {
+  var socketid = socket.zoff_id;
+  if (typeof msg === "object" && msg !== undefined && msg !== null) {
+    Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(
+      userpass,
+      adminpass,
+      gotten
+    ) {
+      if (gotten && userpass != "" && !msg.hasOwnProperty("pass")) {
+        msg.pass = userpass;
+      } else {
+        msg.pass = crypto
+          .createHash("sha256")
+          .update(Functions.decrypt_string(msg.pass))
+          .digest("base64");
+      }
+      adminpass = Functions.hash_pass(adminpass);
+      if (
+        !msg.hasOwnProperty("version") ||
+        !msg.hasOwnProperty("channel") ||
+        msg.version != VERSION ||
+        msg.version == undefined ||
+        typeof msg.channel != "string"
+      ) {
         var result = {
-            msg: {
-                expected: "object",
-                got: typeof(msg)
-            },
+          channel: {
+            expected: "string",
+            got: msg.hasOwnProperty("channel") ? typeof msg.channel : undefined
+          },
+          version: {
+            expected: VERSION,
+            got: msg.version
+          },
+          pass: {
+            expected: "string",
+            got: msg.hasOwnProperty("pass") ? typeof msg.pass : undefined
+          }
         };
-        socket.emit('update_required', result);
-    }
+        socket.emit("update_required", result);
+        return;
+      }
+      coll = msg.channel.toLowerCase(); //.replace(/ /g,'');
+      coll = Functions.removeEmojis(coll).toLowerCase();
+      //coll = filter.clean(coll);
+      var pass = msg.pass;
+      db.collection("frontpage_lists").find({ _id: coll }, function(
+        err,
+        frontpage_lists
+      ) {
+        if (frontpage_lists.length == 1) {
+          db.collection(coll + "_settings").find(function(err, docs) {
+            if (
+              docs.length == 0 ||
+              (docs.length > 0 &&
+                (docs[0].userpass == undefined ||
+                  docs[0].userpass == "" ||
+                  docs[0].userpass == pass))
+            ) {
+              if (
+                docs.length > 0 &&
+                docs[0].hasOwnProperty("userpass") &&
+                docs[0].userpass != "" &&
+                docs[0].userpass == pass
+              ) {
+                Functions.setSessionUserPass(
+                  Functions.getSession(socket),
+                  msg.pass,
+                  coll,
+                  function() {}
+                );
+                socket.emit("auth_accepted", { value: true });
+              }
+              if (docs.length > 0 && docs[0].userpass != pass) {
+                Functions.setSessionUserPass(
+                  Functions.getSession(socket),
+                  "",
+                  coll,
+                  function() {}
+                );
+              }
+              if (
+                docs.length > 0 &&
+                docs[0].hasOwnProperty("adminpass") &&
+                docs[0].adminpass != "" &&
+                docs[0].adminpass == adminpass
+              ) {
+                socket.emit("pw", true);
+              }
+              in_list = true;
+              socket.join(coll);
+              Functions.check_inlist(
+                coll,
+                guid,
+                socket,
+                offline,
+                undefined,
+                "place 10"
+              );
+
+              if (frontpage_lists[0].viewers != undefined) {
+                io.to(coll).emit("viewers", frontpage_lists[0].viewers);
+              } else {
+                io.to(coll).emit("viewers", 1);
+              }
+
+              send_list(coll, socket, true, false, true);
+            } else {
+              socket.emit("auth_required");
+            }
+          });
+        } else {
+          db.createCollection(coll, function(err, docs) {
+            db.collection(coll).createIndex(
+              { id: 1 },
+              { unique: true },
+              function(e, d) {
+                var configs = {
+                  addsongs: false,
+                  adminpass: "",
+                  allvideos: true,
+                  frontpage: true,
+                  longsongs: false,
+                  removeplay: false,
+                  shuffle: true,
+                  skip: false,
+                  skips: [],
+                  startTime: Functions.get_time(),
+                  views: [],
+                  vote: false,
+                  description: "",
+                  thumbnail: "",
+                  rules: "",
+                  userpass: "",
+                  id: "config",
+                  toggleChat: true
+                };
+                db.collection(coll + "_settings").insert(configs, function(
+                  err,
+                  docs
+                ) {
+                  socket.join(coll);
+                  send_list(coll, socket, true, false, true);
+                  db.collection("frontpage_lists").insert(
+                    {
+                      _id: coll,
+                      count: 0,
+                      frontpage: true,
+                      accessed: Functions.get_time(),
+                      viewers: 1
+                    },
+                    function(e, d) {}
+                  );
+                  Functions.check_inlist(
+                    coll,
+                    guid,
+                    socket,
+                    offline,
+                    undefined,
+                    "place 11"
+                  );
+                });
+              }
+            );
+          });
+        }
+      });
+    });
+  } else {
+    var result = {
+      msg: {
+        expected: "object",
+        got: typeof msg
+      }
+    };
+    socket.emit("update_required", result);
+  }
 }
 
 function skip(list, guid, coll, offline, socket, callback) {
-    var socketid = socket.zoff_id;
+  var socketid = socket.zoff_id;
 
-    if(list !== undefined && list !== null && list !== "")
-    {
-        if(coll == undefined && list.hasOwnProperty('channel')) coll = list.channel.toLowerCase();
-        if(coll !== undefined) {
-            try {
-                coll = list.channel.toLowerCase();//.replace(/ /g,'');
-                if(coll.length == 0) return;
-                coll = Functions.removeEmojis(coll).toLowerCase();
-                //coll = coll.replace(/_/g, "");
+  if (list !== undefined && list !== null && list !== "") {
+    if (coll == undefined && list.hasOwnProperty("channel"))
+      coll = list.channel.toLowerCase();
+    if (coll !== undefined) {
+      try {
+        coll = list.channel.toLowerCase(); //.replace(/ /g,'');
+        if (coll.length == 0) return;
+        coll = Functions.removeEmojis(coll).toLowerCase();
+        //coll = coll.replace(/_/g, "");
 
-                //coll = filter.clean(coll);
-            } catch(e) {
-                return;
-            }
-        }
-        if(!list.hasOwnProperty("id") || list.id == undefined) {
-            socket.emit('toast', "The list is empty.");
-            return;
-        }
-        if(!list.hasOwnProperty("id") || !list.hasOwnProperty("channel") ||
-            (typeof(list.id) != "string" && typeof(list.id) != "number") || typeof(list.channel) != "string") {
-                var result = {
-                    channel: {
-                        expected: "string",
-                        got: list.hasOwnProperty("channel") ? typeof(list.channel) : undefined,
-                    },
-                    pass: {
-                        expected: "string",
-                        got: list.hasOwnProperty("pass") ? typeof(list.pass) : undefined,
-                    },
-                    userpass: {
-                        expected: "string",
-                        got: list.hasOwnProperty("userpass") ? typeof(list.userpass) : undefined,
-                    },
-                    id: {
-                        expected: "string",
-                        got: list.hasOwnProperty("id") ? typeof(list.id) : undefined,
-                    },
-                };
-                socket.emit('update_required', result);
-                return;
-            }
-        list.id = list.id + "";
-        Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
-            if(adminpass != "" || list.pass == undefined) {
-                list.pass = Functions.hash_pass(adminpass);
-            } else if(list.pass != "") {
-                list.pass = Functions.hash_pass(Functions.hash_pass(Functions.decrypt_string(list.pass),true));;
-            } else {
-                list.pass = "";
-            }
-            if(userpass != "" || list.userpass == undefined) {
-                list.userpass = userpass;
-            } else {
-                list.userpass = crypto.createHash('sha256').update(Functions.decrypt_string(list.userpass)).digest("base64");
-            }
-
-            db.collection(coll + "_settings").find(function(_err, docs){
-                if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (list.hasOwnProperty('userpass') && docs[0].userpass == list.userpass))) {
-                    Functions.check_inlist(coll, guid, socket, offline, undefined, "place 12");
-
-                    var video_id;
-                    adminpass = "";
-                    video_id  = list.id;
-                    var err       = list.error;
-                    Search.check_if_error_or_blocked(video_id, coll, err == "5" || err == "100" || err == "101" || err == "150" || err == 5 || err == 100 || err == 101 || err == 150, function(trueError) {
-                        var error = false;
-                        if (!trueError) {
-                            adminpass = list.pass;
-                        } else if(trueError) {
-                            error = true;
-                        }
-                        hash = adminpass;
-                        //db.collection(coll + "_settings").find(function(err, docs){
-                        var strictSkip = false;
-                        var strictSkipNumber = 10;
-                        if(docs[0].strictSkip) strictSkip = docs[0].strictSkip;
-                        if(docs[0].strictSkipNumber) strictSkipNumber = docs[0].strictSkipNumber;
-                        if(docs !== null && docs.length !== 0)
-                        {
-                            if(!docs[0].skip || (docs[0].adminpass == hash && docs[0].adminpass !== "") || error)
-                            {
-                                db.collection("frontpage_lists").find({"_id": coll}, function(err, frontpage_viewers){
-                                    if(error ||
-                                        ((strictSkip && ((docs[0].adminpass == hash && docs[0].adminpass !== "") || (docs[0].skips.length+1 >= strictSkipNumber))) ||
-                                        (!strictSkip && ((frontpage_viewers[0].viewers/2 <= docs[0].skips.length+1 && !Functions.contains(docs[0].skips, guid) && frontpage_viewers[0].viewers != 2) ||
-                                            (frontpage_viewers[0].viewers == 2 && docs[0].skips.length+1 == 2 && !Functions.contains(docs[0].skips, guid)) ||
-                                            (docs[0].adminpass == hash && docs[0].adminpass !== "" && docs[0].skip)))))
-                                    {
-                                        Functions.checkTimeout("skip", 1, coll, coll, error, true, socket, function() {
-                                            change_song(coll, error, video_id, docs);
-                                            socket.emit("toast", "skip");
-                                            db.collection("user_names").find({"guid": guid}, function(err, docs) {
-                                                if(docs.length == 1) {
-                                                    db.collection("registered_users").find({"_id": docs[0].name}, function(err, n) {
-                                                        var icon = false;
-                                                        if(n.length > 0 && n[0].icon) {
-                                                            icon = n[0].icon;
-                                                        }
-                                                        io.to(coll).emit('chat', {from: docs[0].name, icon: icon, msg: " skipped"});
-                                                    });
-                                                }
-                                            });
-                                        }, "The channel is skipping too often, please wait ");
-                                    } else if(!Functions.contains(docs[0].skips, guid)){
-                                        db.collection(coll + "_settings").update({ id: "config" }, {$push:{skips:guid}}, function(err, d){
-                                            if(frontpage_viewers[0].viewers == 2 && !strictSkip) {
-                                                to_skip = 1;
-                                            } else if(strictSkip) {
-                                                to_skip = (strictSkipNumber) - docs[0].skips.length-1;
-                                            } else {
-                                                to_skip = (Math.ceil(frontpage_viewers[0].viewers/2) - docs[0].skips.length-1);
-                                            }
-                                            socket.emit("toast", to_skip + " more are needed to skip!");
-                                            db.collection("user_names").find({"guid": guid}, function(err, docs) {
-                                                if(docs.length == 1) {
-                                                    db.collection("registered_users").find({"_id": docs[0].name}, function(err, n) {
-                                                        var icon = false;
-                                                        if(n.length > 0 && n[0].icon) {
-                                                            icon = n[0].icon;
-                                                        }
-                                                        socket.to(coll).emit('chat', {from: docs[0].name, msg: " voted to skip"});
-                                                    })
-                                                }
-                                            });
-                                        });
-                                    }else{
-                                        socket.emit("toast", "alreadyskip");
-                                    }
-                                });
-                            }else
-                            socket.emit("toast", "noskip");
-                        }
-                    });
-                    //});
-                } else {
-                    socket.emit("auth_required");
-                }
-            });
-        });
-    } else {
-        var result = {
-            msg: {
-                expected: "object",
-                got: typeof(list),
-            },
-        };
-        socket.emit("update_required", result);
+        //coll = filter.clean(coll);
+      } catch (e) {
+        return;
+      }
     }
+    if (!list.hasOwnProperty("id") || list.id == undefined) {
+      socket.emit("toast", "The list is empty.");
+      return;
+    }
+    if (
+      !list.hasOwnProperty("id") ||
+      !list.hasOwnProperty("channel") ||
+      (typeof list.id != "string" && typeof list.id != "number") ||
+      typeof list.channel != "string"
+    ) {
+      var result = {
+        channel: {
+          expected: "string",
+          got: list.hasOwnProperty("channel") ? typeof list.channel : undefined
+        },
+        pass: {
+          expected: "string",
+          got: list.hasOwnProperty("pass") ? typeof list.pass : undefined
+        },
+        userpass: {
+          expected: "string",
+          got: list.hasOwnProperty("userpass")
+            ? typeof list.userpass
+            : undefined
+        },
+        id: {
+          expected: "string",
+          got: list.hasOwnProperty("id") ? typeof list.id : undefined
+        }
+      };
+      socket.emit("update_required", result);
+      return;
+    }
+    list.id = list.id + "";
+    Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(
+      userpass,
+      adminpass
+    ) {
+      if (adminpass != "" || list.pass == undefined) {
+        list.pass = Functions.hash_pass(adminpass);
+      } else if (list.pass != "") {
+        list.pass = Functions.hash_pass(
+          Functions.hash_pass(Functions.decrypt_string(list.pass), true)
+        );
+      } else {
+        list.pass = "";
+      }
+      if (userpass != "" || list.userpass == undefined) {
+        list.userpass = userpass;
+      } else {
+        list.userpass = crypto
+          .createHash("sha256")
+          .update(Functions.decrypt_string(list.userpass))
+          .digest("base64");
+      }
+
+      db.collection(coll + "_settings").find(function(_err, docs) {
+        if (
+          docs.length > 0 &&
+          (docs[0].userpass == undefined ||
+            docs[0].userpass == "" ||
+            (list.hasOwnProperty("userpass") &&
+              docs[0].userpass == list.userpass))
+        ) {
+          Functions.check_inlist(
+            coll,
+            guid,
+            socket,
+            offline,
+            undefined,
+            "place 12"
+          );
+
+          var video_id;
+          adminpass = "";
+          video_id = list.id;
+          var err = list.error;
+          Search.check_if_error_or_blocked(
+            video_id,
+            coll,
+            err == "5" ||
+              err == "100" ||
+              err == "101" ||
+              err == "150" ||
+              err == 5 ||
+              err == 100 ||
+              err == 101 ||
+              err == 150,
+            function(trueError) {
+              var error = false;
+              if (!trueError) {
+                adminpass = list.pass;
+              } else if (trueError) {
+                error = true;
+              }
+              hash = adminpass;
+              //db.collection(coll + "_settings").find(function(err, docs){
+              var strictSkip = false;
+              var strictSkipNumber = 10;
+              if (docs[0].strictSkip) strictSkip = docs[0].strictSkip;
+              if (docs[0].strictSkipNumber)
+                strictSkipNumber = docs[0].strictSkipNumber;
+              if (docs !== null && docs.length !== 0) {
+                if (
+                  !docs[0].skip ||
+                  (docs[0].adminpass == hash && docs[0].adminpass !== "") ||
+                  error
+                ) {
+                  db.collection("frontpage_lists").find({ _id: coll }, function(
+                    err,
+                    frontpage_viewers
+                  ) {
+                    if (
+                      error ||
+                      ((strictSkip &&
+                        ((docs[0].adminpass == hash &&
+                          docs[0].adminpass !== "") ||
+                          docs[0].skips.length + 1 >= strictSkipNumber)) ||
+                        (!strictSkip &&
+                          ((frontpage_viewers[0].viewers / 2 <=
+                            docs[0].skips.length + 1 &&
+                            !Functions.contains(docs[0].skips, guid) &&
+                            frontpage_viewers[0].viewers != 2) ||
+                            (frontpage_viewers[0].viewers == 2 &&
+                              docs[0].skips.length + 1 == 2 &&
+                              !Functions.contains(docs[0].skips, guid)) ||
+                            (docs[0].adminpass == hash &&
+                              docs[0].adminpass !== "" &&
+                              docs[0].skip))))
+                    ) {
+                      Functions.checkTimeout(
+                        "skip",
+                        1,
+                        coll,
+                        coll,
+                        error,
+                        true,
+                        socket,
+                        function() {
+                          change_song(coll, error, video_id, docs);
+                          socket.emit("toast", "skip");
+                          db.collection("user_names").find(
+                            { guid: guid },
+                            function(err, docs) {
+                              if (docs.length == 1) {
+                                db.collection("registered_users").find(
+                                  { _id: docs[0].name },
+                                  function(err, n) {
+                                    var icon = false;
+                                    if (n.length > 0 && n[0].icon) {
+                                      icon = n[0].icon;
+                                    }
+                                    io.to(coll).emit("chat", {
+                                      from: docs[0].name,
+                                      icon: icon,
+                                      msg: " skipped"
+                                    });
+                                  }
+                                );
+                              }
+                            }
+                          );
+                        },
+                        "The channel is skipping too often, please wait "
+                      );
+                    } else if (!Functions.contains(docs[0].skips, guid)) {
+                      db.collection(coll + "_settings").update(
+                        { id: "config" },
+                        { $push: { skips: guid } },
+                        function(err, d) {
+                          if (
+                            frontpage_viewers[0].viewers == 2 &&
+                            !strictSkip
+                          ) {
+                            to_skip = 1;
+                          } else if (strictSkip) {
+                            to_skip =
+                              strictSkipNumber - docs[0].skips.length - 1;
+                          } else {
+                            to_skip =
+                              Math.ceil(frontpage_viewers[0].viewers / 2) -
+                              docs[0].skips.length -
+                              1;
+                          }
+                          socket.emit(
+                            "toast",
+                            to_skip + " more are needed to skip!"
+                          );
+                          db.collection("user_names").find(
+                            { guid: guid },
+                            function(err, docs) {
+                              if (docs.length == 1) {
+                                db.collection("registered_users").find(
+                                  { _id: docs[0].name },
+                                  function(err, n) {
+                                    var icon = false;
+                                    if (n.length > 0 && n[0].icon) {
+                                      icon = n[0].icon;
+                                    }
+                                    socket.to(coll).emit("chat", {
+                                      from: docs[0].name,
+                                      msg: " voted to skip"
+                                    });
+                                  }
+                                );
+                              }
+                            }
+                          );
+                        }
+                      );
+                    } else {
+                      socket.emit("toast", "alreadyskip");
+                    }
+                  });
+                } else socket.emit("toast", "noskip");
+              }
+            }
+          );
+          //});
+        } else {
+          socket.emit("auth_required");
+        }
+      });
+    });
+  } else {
+    var result = {
+      msg: {
+        expected: "object",
+        got: typeof list
+      }
+    };
+    socket.emit("update_required", result);
+  }
 }
 
 function change_song(coll, error, id, conf, callback, socket) {
-    //coll = coll.replace(/ /g,'');
-    //db.collection(coll + "_settings").find(function(err, docs){
-        var startTime = conf[0].startTime;
-        if(conf !== null && conf.length !== 0)
+  //coll = coll.replace(/ /g,'');
+  //db.collection(coll + "_settings").find(function(err, docs){
+  var startTime = conf[0].startTime;
+  if (conf !== null && conf.length !== 0) {
+    db.collection(coll).aggregate(
+      [
         {
-            db.collection(coll).aggregate([{
-                $match:{
-                    views:{
-                        $exists: false
-                    },
-                    type:{
-                        $ne: "suggested"
-                    }
-                }
-            }, {
-                $sort:{
-                    now_playing: -1,
-                    votes:-1,
-                    added:1,
-                    title: 1
-                }
-            }, {
-                $limit:2
-            }], function(err, now_playing_doc){
-                if(now_playing_doc.length == 0) {
-                    console.log("empty list", coll, callback, id, conf);
-                }
-                if(now_playing_doc.length > 0 && ((id && id == now_playing_doc[0].id) || !id)) {
-                    if(error){
-                            db.collection(coll).remove({now_playing:true, id:id}, function(err, docs){
-                                var next_song;
-                                if(now_playing_doc.length == 2) next_song = now_playing_doc[1].id;
-                                change_song_post(coll, next_song, conf, callback, socket, error);
-                                if(!callback) {
-                                    io.to(coll).emit("channel", {type: "deleted", value: now_playing_doc[0].id, removed: true});
-                                }
-                                if(docs.deletedCount == 1) {
-                                    db.collection("frontpage_lists").update({_id: coll, count: {$gt: 0}}, {$inc: {count: -1}, $set:{accessed: Functions.get_time()}}, {upsert: true}, function(err, docs){});
-                                }
-                            });
-                    } else if(conf[0].removeplay === true){
-                        db.collection(coll).remove({now_playing:true, id:id}, function(err, docs){
-                            var next_song;
-                            if(now_playing_doc.length == 2) next_song = now_playing_doc[1].id;
-                            change_song_post(coll, next_song, conf, callback, socket, error);
-                            if(!callback) {
-                                io.to(coll).emit("channel", {type: "deleted", value: now_playing_doc[0].id, removed: true});
-                            }
-                            if(docs.deletedCount == 1) {
-                                db.collection("frontpage_lists").update({_id: coll, count: {$gt: 0}}, {$inc: {count: -1}, $set:{accessed: Functions.get_time()}}, {upsert: true}, function(err, docs){});
-                            }
-                        });
-                    } else {
-                        if((conf[0].skipped_time != undefined && conf[0].skipped_time != Functions.get_time()) ||conf[0].skipped_time == undefined) {
-                            db.collection(coll).update({now_playing:true, id:id}, {
-                                $set:{
-                                    now_playing:false,
-                                    votes:0,
-                                    guids:[]
-                                }
-                            },{multi:true}, function(err, docs){
-                                var next_song;
-                                if(now_playing_doc.length == 2) next_song = now_playing_doc[1].id;
-                                change_song_post(coll, next_song, conf, callback, socket, error);
-                            });
-                        }
-                    }
-                } else {
-                    if(now_playing_doc.length > 0 && now_playing_doc[0].now_playing == true && now_playing_doc.length > 1 && now_playing_doc[1].id == id) {
-                        db.collection(coll).update({id: now_playing_doc[0].id}, {$set: {now_playing: false}}, function(e, d) {
-                            change_song(coll, error, id, conf, callback, socket, error);
-                        })
-                    } else {
-                        return;
-                    }
-                }
-            });
+          $match: {
+            views: {
+              $exists: false
+            },
+            type: {
+              $ne: "suggested"
+            }
+          }
+        },
+        {
+          $sort: {
+            now_playing: -1,
+            votes: -1,
+            added: 1,
+            title: 1
+          }
+        },
+        {
+          $limit: 2
         }
-    //});
+      ],
+      function(err, now_playing_doc) {
+        if (now_playing_doc.length == 0) {
+          console.log("empty list", coll, callback, id, conf);
+        }
+        if (
+          now_playing_doc.length > 0 &&
+          ((id && id == now_playing_doc[0].id) || !id)
+        ) {
+          if (error) {
+            db.collection(coll).remove({ now_playing: true, id: id }, function(
+              err,
+              docs
+            ) {
+              var next_song;
+              if (now_playing_doc.length == 2)
+                next_song = now_playing_doc[1].id;
+              change_song_post(coll, next_song, conf, callback, socket, error);
+              if (!callback) {
+                io.to(coll).emit("channel", {
+                  type: "deleted",
+                  value: now_playing_doc[0].id,
+                  removed: true
+                });
+              }
+              if (docs.deletedCount == 1) {
+                db.collection("frontpage_lists").update(
+                  { _id: coll, count: { $gt: 0 } },
+                  {
+                    $inc: { count: -1 },
+                    $set: { accessed: Functions.get_time() }
+                  },
+                  { upsert: true },
+                  function(err, docs) {}
+                );
+              }
+            });
+          } else if (conf[0].removeplay === true) {
+            db.collection(coll).remove({ now_playing: true, id: id }, function(
+              err,
+              docs
+            ) {
+              var next_song;
+              if (now_playing_doc.length == 2)
+                next_song = now_playing_doc[1].id;
+              change_song_post(coll, next_song, conf, callback, socket, error);
+              if (!callback) {
+                io.to(coll).emit("channel", {
+                  type: "deleted",
+                  value: now_playing_doc[0].id,
+                  removed: true
+                });
+              }
+              if (docs.deletedCount == 1) {
+                db.collection("frontpage_lists").update(
+                  { _id: coll, count: { $gt: 0 } },
+                  {
+                    $inc: { count: -1 },
+                    $set: { accessed: Functions.get_time() }
+                  },
+                  { upsert: true },
+                  function(err, docs) {}
+                );
+              }
+            });
+          } else {
+            if (
+              (conf[0].skipped_time != undefined &&
+                conf[0].skipped_time != Functions.get_time()) ||
+              conf[0].skipped_time == undefined
+            ) {
+              db.collection(coll).update(
+                { now_playing: true, id: id },
+                {
+                  $set: {
+                    now_playing: false,
+                    votes: 0,
+                    guids: []
+                  }
+                },
+                { multi: true },
+                function(err, docs) {
+                  var next_song;
+                  if (now_playing_doc.length == 2)
+                    next_song = now_playing_doc[1].id;
+                  change_song_post(
+                    coll,
+                    next_song,
+                    conf,
+                    callback,
+                    socket,
+                    error
+                  );
+                }
+              );
+            }
+          }
+        } else {
+          if (
+            now_playing_doc.length > 0 &&
+            now_playing_doc[0].now_playing == true &&
+            now_playing_doc.length > 1 &&
+            now_playing_doc[1].id == id
+          ) {
+            db.collection(coll).update(
+              { id: now_playing_doc[0].id },
+              { $set: { now_playing: false } },
+              function(e, d) {
+                change_song(coll, error, id, conf, callback, socket, error);
+              }
+            );
+          } else {
+            return;
+          }
+        }
+      }
+    );
+  }
+  //});
 }
 
 function change_song_post(coll, next_song, conf, callback, socket, removed) {
-    //coll = coll.replace(/ /g,'');
-    db.collection(coll).aggregate([{
-        $match:{
-            now_playing:false,
-            type:{
-                $ne: "suggested"
+  //coll = coll.replace(/ /g,'');
+  db.collection(coll).aggregate(
+    [
+      {
+        $match: {
+          now_playing: false,
+          type: {
+            $ne: "suggested"
+          }
+        }
+      },
+      {
+        $sort: {
+          votes: -1,
+          added: 1,
+          title: 1
+        }
+      },
+      {
+        $limit: 2
+      }
+    ],
+    function(err, docs) {
+      if (docs !== null && docs.length > 0) {
+        var id = docs[0].id;
+        if (next_song && next_song != id) {
+          if (docs.length == 2 && next_song == docs[1].id) {
+            id = docs[1].id;
+          } else {
+            return;
+          }
+        }
+        db.collection(coll).update(
+          { id: id, now_playing: false },
+          {
+            $set: {
+              now_playing: true,
+              votes: 0,
+              guids: [],
+              added: Functions.get_time()
             }
-        }
-    }, {
-        $sort:{
-            votes:-1,
-            added:1,
-            title: 1
-        }
-    }, {
-        $limit:2
-    }], function(err, docs){
-        if(docs !== null && docs.length > 0){
-            var id = docs[0].id;
-            if(next_song && next_song != id) {
-                if((docs.length == 2 && next_song == docs[1].id)) {
-                    id = docs[1].id;
+          },
+          function(err, returnDocs) {
+            if (
+              (returnDocs.hasOwnProperty("nModified") &&
+                returnDocs.nModified == 0) ||
+              (returnDocs.hasOwnProperty("n") && returnDocs.n == 0)
+            ) {
+              if (!callback) return;
+              callback();
+              return;
+            }
+            db.collection(coll + "_settings").update(
+              { id: "config" },
+              {
+                $set: {
+                  startTime: Functions.get_time(),
+                  skips: []
+                }
+              },
+              function(err, returnDocs) {
+                //db.collection(coll + "_settings").find({id: "config"}, function(err, conf){
+                if (!callback) {
+                  io.to(coll).emit("channel", {
+                    type: "song_change",
+                    time: Functions.get_time(),
+                    remove: conf[0].removeplay || removed,
+                    id: id
+                  });
+                  send_play(coll);
                 } else {
-                    return;
+                  if (socket == undefined) {
+                    io.to(coll).emit("channel", {
+                      type: "song_change",
+                      time: Functions.get_time(),
+                      remove: conf[0].removeplay || removed,
+                      id: id
+                    });
+                  } else {
+                    socket.to(coll).emit("channel", {
+                      type: "song_change",
+                      time: Functions.get_time(),
+                      remove: conf[0].removeplay || removed,
+                      id: id
+                    });
+                  }
+                  send_play(coll, socket, true);
+                  callback();
                 }
-            }
-            db.collection(coll).update({id:id, now_playing: false},{
-                $set:{
-                    now_playing:true,
-                    votes:0,
-                    guids:[],
-                    added:Functions.get_time()
-                }
-            }, function(err, returnDocs){
-                if((returnDocs.hasOwnProperty("nModified") && returnDocs.nModified == 0) || (returnDocs.hasOwnProperty("n") && returnDocs.n == 0)) {
-                    if(!callback) return;
-                    callback();
-                    return;
-                }
-                db.collection(coll + "_settings").update({id: "config"}, {
-                    $set:{
-                        startTime:Functions.get_time(),
-                        skips:[]
-                    }
-                }, function(err, returnDocs){
-                    //db.collection(coll + "_settings").find({id: "config"}, function(err, conf){
-                        if(!callback) {
-                            io.to(coll).emit("channel", {type: "song_change", time: Functions.get_time(), remove: conf[0].removeplay || removed, id: id});
-                            send_play(coll);
-                        } else {
-                            if(socket == undefined) {
-                                io.to(coll).emit("channel", {type: "song_change", time: Functions.get_time(), remove: conf[0].removeplay || removed, id: id});
-                            } else {
-                                socket.to(coll).emit("channel", {type: "song_change", time: Functions.get_time(), remove: conf[0].removeplay || removed, id: id});
-                            }
-                            send_play(coll, socket, true);
-                            callback();
-                        }
-                        Frontpage.update_frontpage(coll, docs[0].id, docs[0].title, docs[0].thumbnail, docs[0].source);
-                    //});
-                });
-            });
-        }
-    });
+                Frontpage.update_frontpage(
+                  coll,
+                  docs[0].id,
+                  docs[0].title,
+                  docs[0].thumbnail,
+                  docs[0].source
+                );
+                //});
+              }
+            );
+          }
+        );
+      }
+    }
+  );
 }
 
-function send_list(coll, socket, send, list_send, configs, shuffled)
-{
-    //coll = coll.replace(/ /g,'');
-    db.collection(coll + "_settings").aggregate([
-        {
-            "$match": {
-                id: "config"
-            }
-        },
-        {
-            "$project": projects.toShowConfig
-        },
-    ], function(err, _conf){
-        var conf = _conf;
-        if(conf.length == 0) {
-            var conf = {"id": "config", "addsongs":false, "adminpass":"", "allvideos":true, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":Functions.get_time(), "views": [], "vote": false, "description": "", "thumbnail": "", "rules": "", "toggleChat": true, userpass: ""};
-            db.collection(coll + "_settings").update({id: "config"}, conf, {upsert: true}, function(err, docs) {
-                send_list(coll, socket, send, list_send, configs, shuffled);
-            });
-        } else {
-            db.collection(coll).aggregate([
-                {
-                    "$match": {type: {$ne: "suggested"}}
-                },
-                {
-                    "$project": projects.project_object
-                },
-                { "$sort" : { "now_playing" : -1, "votes": -1, "added": 1 } }
-            ], function(err, docs)
-            //db.collection(coll).find({type: {$ne: "suggested"}}, function(err, docs)
-            {
-                if(docs.length > 0) {
-                    db.collection(coll).find({now_playing: true}, function(err, np_docs) {
-                        if(np_docs.length == 0) {
-                            db.collection(coll).aggregate([{
-                                $match:{
-                                    views:{
-                                        $exists: false
-                                    },
-                                    type:{
-                                        $ne: "suggested"
-                                    }
-                                }
-                            }, {
-                                $sort:{
-                                    now_playing: -1,
-                                    votes:-1,
-                                    added:1,
-                                    title: 1
-                                }
-                            }, {
-                                $limit:1
-                            }], function(err, now_playing_doc){
-                                if(now_playing_doc[0].now_playing == false) {
-                                    db.collection(coll).update({id:now_playing_doc[0].id, now_playing: false}, {
-                                        $set:{
-                                            now_playing:true,
-                                            votes:0,
-                                            guids:[],
-                                            added:Functions.get_time()
-                                        }
-                                    }, function(err, returnDocs){
-                                        db.collection(coll + "_settings").update({ id: "config" }, {
-                                            $set:{
-                                                startTime: Functions.get_time(),
-                                                skips:[]
-                                            }
-                                        }, function(err, returnDocs){
-                                            Frontpage.update_frontpage(coll, now_playing_doc[0].id, now_playing_doc[0].title, now_playing_doc[0].thumbnail, now_playing_doc[0].source);
-                                            send_list(coll, socket, send, list_send, configs, shuffled);
-                                        });
-                                    });
-                                }
-                            });
-                        } else if(np_docs.length > 1) {
-                            db.collection(coll).aggregate([{
-                                $match:{
-                                    now_playing: true
-                                }
-                            }, {
-                                $sort:{
-                                    now_playing: -1,
-                                    votes:-1,
-                                    added:1,
-                                    title: 1
-                                }
-                            }], function(e, docs) {
-                                var real_now_playing = docs[docs.length - 1];
-                                db.collection(coll).update({now_playing: true, id: {$ne: real_now_playing.id}}, {$set: {now_playing: false}}, {multi: true}, function(e, d) {
-                                    send_list(coll, socket, send, list_send, configs, shuffled);
-                                })
-                            })
-                        } else {
-                            if(Functions.get_time()-conf[0].startTime > np_docs[0].duration){
-                                change_song(coll, false, np_docs[0].id, conf, function() {
-                                    send_list(coll, socket, send, list_send, configs, shuffled);
-                                }, socket);
-                            } else {
-                                if(list_send) {
-                                    io.to(coll).emit("channel", {type: "list", playlist: docs, shuffled: shuffled});
-                                } else if(!list_send) {
-                                    socket.emit("channel", {type: "list", playlist: docs, shuffled: shuffled});
-                                }
-                                if(socket === undefined && send) {
-                                    send_play(coll);
-                                } else if(send) {
-                                    send_play(coll, socket);
-                                }
-                            }
-                        }
-                    });
-                } else {
-                    if(list_send) {
-                        io.to(coll).emit("channel", {type: "list", playlist: docs, shuffled: shuffled});
-                    } else if(!list_send) {
-                        socket.emit("channel", {type: "list", playlist: docs, shuffled: shuffled});
-                    }
-                    if(socket === undefined && send) {
-                        send_play(coll);
-                    } else if(send) {
-                        send_play(coll, socket);
-                    }
-                }
-            });
-            if(configs)
-            {
-                if(conf.length > 0) {
-                    if(conf[0].adminpass !== "") conf[0].adminpass = true;
-                    if(conf[0].hasOwnProperty("userpass") && conf[0].userpass != "") conf[0].userpass = true;
-                    else conf[0].userpass = false;
-                    io.to(coll).emit("conf", conf);
-                } else if(conf.length == 0 && docs.length > 0) {
-                    var conf = {"id": "config", "addsongs":false, "adminpass":"", "allvideos":true, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":Functions.get_time(), "views": [], "vote": false, "desc": "", userpass: ""};
-                    db.collection(coll + "_settings").update({id: "config"}, conf, {upsert: true}, function(err, docs) {
-                        io.to(coll).emit("conf", conf);
-                    });
-                }
-            }
+function send_list(coll, socket, send, list_send, configs, shuffled) {
+  //coll = coll.replace(/ /g,'');
+  db.collection(coll + "_settings").aggregate(
+    [
+      {
+        $match: {
+          id: "config"
         }
-    });
-    if(socket){
-        db.collection(coll).find({type:"suggested"}).sort({added: 1}, function(err, sugg){
-            socket.emit("suggested", sugg);
-        });
+      },
+      {
+        $project: projects.toShowConfig
+      }
+    ],
+    function(err, _conf) {
+      var conf = _conf;
+      if (conf.length == 0) {
+        var conf = {
+          id: "config",
+          addsongs: false,
+          adminpass: "",
+          allvideos: true,
+          frontpage: true,
+          longsongs: false,
+          removeplay: false,
+          shuffle: true,
+          skip: false,
+          skips: [],
+          startTime: Functions.get_time(),
+          views: [],
+          vote: false,
+          description: "",
+          thumbnail: "",
+          rules: "",
+          toggleChat: true,
+          userpass: ""
+        };
+        db.collection(coll + "_settings").update(
+          { id: "config" },
+          conf,
+          { upsert: true },
+          function(err, docs) {
+            send_list(coll, socket, send, list_send, configs, shuffled);
+          }
+        );
+      } else {
+        db.collection(coll).aggregate(
+          [
+            {
+              $match: { type: { $ne: "suggested" } }
+            },
+            {
+              $project: projects.project_object
+            },
+            { $sort: { now_playing: -1, votes: -1, added: 1 } }
+          ],
+          function(
+            err,
+            docs //db.collection(coll).find({type: {$ne: "suggested"}}, function(err, docs)
+          ) {
+            if (docs.length > 0) {
+              db.collection(coll).find({ now_playing: true }, function(
+                err,
+                np_docs
+              ) {
+                if (np_docs.length == 0) {
+                  db.collection(coll).aggregate(
+                    [
+                      {
+                        $match: {
+                          views: {
+                            $exists: false
+                          },
+                          type: {
+                            $ne: "suggested"
+                          }
+                        }
+                      },
+                      {
+                        $sort: {
+                          now_playing: -1,
+                          votes: -1,
+                          added: 1,
+                          title: 1
+                        }
+                      },
+                      {
+                        $limit: 1
+                      }
+                    ],
+                    function(err, now_playing_doc) {
+                      if (now_playing_doc[0].now_playing == false) {
+                        db.collection(coll).update(
+                          { id: now_playing_doc[0].id, now_playing: false },
+                          {
+                            $set: {
+                              now_playing: true,
+                              votes: 0,
+                              guids: [],
+                              added: Functions.get_time()
+                            }
+                          },
+                          function(err, returnDocs) {
+                            db.collection(coll + "_settings").update(
+                              { id: "config" },
+                              {
+                                $set: {
+                                  startTime: Functions.get_time(),
+                                  skips: []
+                                }
+                              },
+                              function(err, returnDocs) {
+                                Frontpage.update_frontpage(
+                                  coll,
+                                  now_playing_doc[0].id,
+                                  now_playing_doc[0].title,
+                                  now_playing_doc[0].thumbnail,
+                                  now_playing_doc[0].source
+                                );
+                                send_list(
+                                  coll,
+                                  socket,
+                                  send,
+                                  list_send,
+                                  configs,
+                                  shuffled
+                                );
+                              }
+                            );
+                          }
+                        );
+                      }
+                    }
+                  );
+                } else if (np_docs.length > 1) {
+                  db.collection(coll).aggregate(
+                    [
+                      {
+                        $match: {
+                          now_playing: true
+                        }
+                      },
+                      {
+                        $sort: {
+                          now_playing: -1,
+                          votes: -1,
+                          added: 1,
+                          title: 1
+                        }
+                      }
+                    ],
+                    function(e, docs) {
+                      var real_now_playing = docs[docs.length - 1];
+                      db.collection(coll).update(
+                        { now_playing: true, id: { $ne: real_now_playing.id } },
+                        { $set: { now_playing: false } },
+                        { multi: true },
+                        function(e, d) {
+                          send_list(
+                            coll,
+                            socket,
+                            send,
+                            list_send,
+                            configs,
+                            shuffled
+                          );
+                        }
+                      );
+                    }
+                  );
+                } else {
+                  if (
+                    Functions.get_time() - conf[0].startTime >
+                    np_docs[0].duration
+                  ) {
+                    change_song(
+                      coll,
+                      false,
+                      np_docs[0].id,
+                      conf,
+                      function() {
+                        send_list(
+                          coll,
+                          socket,
+                          send,
+                          list_send,
+                          configs,
+                          shuffled
+                        );
+                      },
+                      socket
+                    );
+                  } else {
+                    if (list_send) {
+                      io.to(coll).emit("channel", {
+                        type: "list",
+                        playlist: docs,
+                        shuffled: shuffled
+                      });
+                    } else if (!list_send) {
+                      socket.emit("channel", {
+                        type: "list",
+                        playlist: docs,
+                        shuffled: shuffled
+                      });
+                    }
+                    if (socket === undefined && send) {
+                      send_play(coll);
+                    } else if (send) {
+                      send_play(coll, socket);
+                    }
+                  }
+                }
+              });
+            } else {
+              if (list_send) {
+                io.to(coll).emit("channel", {
+                  type: "list",
+                  playlist: docs,
+                  shuffled: shuffled
+                });
+              } else if (!list_send) {
+                socket.emit("channel", {
+                  type: "list",
+                  playlist: docs,
+                  shuffled: shuffled
+                });
+              }
+              if (socket === undefined && send) {
+                send_play(coll);
+              } else if (send) {
+                send_play(coll, socket);
+              }
+            }
+          }
+        );
+        if (configs) {
+          if (conf.length > 0) {
+            if (conf[0].adminpass !== "") conf[0].adminpass = true;
+            if (conf[0].hasOwnProperty("userpass") && conf[0].userpass != "")
+              conf[0].userpass = true;
+            else conf[0].userpass = false;
+            io.to(coll).emit("conf", conf);
+          } else if (conf.length == 0 && docs.length > 0) {
+            var conf = {
+              id: "config",
+              addsongs: false,
+              adminpass: "",
+              allvideos: true,
+              frontpage: true,
+              longsongs: false,
+              removeplay: false,
+              shuffle: true,
+              skip: false,
+              skips: [],
+              startTime: Functions.get_time(),
+              views: [],
+              vote: false,
+              desc: "",
+              userpass: ""
+            };
+            db.collection(coll + "_settings").update(
+              { id: "config" },
+              conf,
+              { upsert: true },
+              function(err, docs) {
+                io.to(coll).emit("conf", conf);
+              }
+            );
+          }
+        }
+      }
     }
+  );
+  if (socket) {
+    db.collection(coll)
+      .find({ type: "suggested" })
+      .sort({ added: 1 }, function(err, sugg) {
+        socket.emit("suggested", sugg);
+      });
+  }
 }
 
 function end(obj, coll, guid, offline, socket) {
-    var socketid = socket.zoff_id;
-    if(typeof(obj) !== 'object') {
-        return;
-    }
-    id = obj.id;
+  var socketid = socket.zoff_id;
+  if (typeof obj !== "object") {
+    return;
+  }
+  id = obj.id;
 
-    if(id !== undefined && id !== null && id !== "") {
-
-        if(!obj.hasOwnProperty("id") || !obj.hasOwnProperty("channel") ||
-            (typeof(obj.id) != "string" && typeof(obj.id) != "number") || typeof(obj.channel) != "string") {
-                var result = {
-                    channel: {
-                        expected: "string",
-                        got: obj.hasOwnProperty("channel") ? typeof(obj.channel) : undefined,
-                    },
-                    pass: {
-                        expected: "string",
-                        got: obj.hasOwnProperty("pass") ? typeof(obj.pass) : undefined,
-                    },
-                    id: {
-                        expected: "string || number",
-                        got: obj.hasOwnProperty("id") ? typeof(obj.id) : undefined,
-                    },
-                };
-                socket.emit("update_required", result);
-            return;
+  if (id !== undefined && id !== null && id !== "") {
+    if (
+      !obj.hasOwnProperty("id") ||
+      !obj.hasOwnProperty("channel") ||
+      (typeof obj.id != "string" && typeof obj.id != "number") ||
+      typeof obj.channel != "string"
+    ) {
+      var result = {
+        channel: {
+          expected: "string",
+          got: obj.hasOwnProperty("channel") ? typeof obj.channel : undefined
+        },
+        pass: {
+          expected: "string",
+          got: obj.hasOwnProperty("pass") ? typeof obj.pass : undefined
+        },
+        id: {
+          expected: "string || number",
+          got: obj.hasOwnProperty("id") ? typeof obj.id : undefined
         }
-        obj.id = obj.id + "";
-        id = id + "";
-        var callback_function = function() {
-            for(var i = 0; i < arguments.length; i++) {
-                if(typeof(arguments[i]) == "function") {
-                    arguments[i]();
-                }
-            }
-        }
-        db.collection(coll + "_settings").find(function(err, docs){
-            var authentication_needed = false;
-            if(docs.length > 0 && (docs[0].userpass != undefined && docs[0].userpass != "")) {
-                callback_function = Functions.getSessionAdminUser;
-                authentication_needed = true;
-            }
-            callback_function(Functions.getSession(socket), coll, function(userpass) {
-                if(userpass != "" || obj.pass == undefined) {
-                    obj.pass = userpass;
-                } else {
-                    obj.pass = crypto.createHash('sha256').update(Functions.decrypt_string(obj.pass)).digest("base64");
-                }
-                if(!authentication_needed || (authentication_needed && obj.hasOwnProperty('pass') && docs[0].userpass == obj.pass)) {
-                    Functions.check_inlist(coll, guid, socket, offline, undefined, "place 13");
-                    db.collection(coll).find({now_playing:true}, function(err, np){
-                        if(err !== null) console.log(err);
-                        if(np !== null && np !== undefined && np.length == 1 && np[0].id == id){
-                            var startTime = docs[0].startTime;
-                            if(startTime+parseInt(np[0].duration)<=Functions.get_time()+5) {
-                                change_song(coll, false, id, docs);
-                            }
-                        }
-                    });
-                } else {
-                    socket.emit("auth_required");
-                }
-            })
-        });
-    } else {
-        var result = {
-            msg: {
-                expected: "object",
-                got: typeof(obj)
-            },
-        };
-        socket.emit("update_required", result);
+      };
+      socket.emit("update_required", result);
+      return;
     }
+    obj.id = obj.id + "";
+    id = id + "";
+    var callback_function = function() {
+      for (var i = 0; i < arguments.length; i++) {
+        if (typeof arguments[i] == "function") {
+          arguments[i]();
+        }
+      }
+    };
+    db.collection(coll + "_settings").find(function(err, docs) {
+      var authentication_needed = false;
+      if (
+        docs.length > 0 &&
+        (docs[0].userpass != undefined && docs[0].userpass != "")
+      ) {
+        callback_function = Functions.getSessionAdminUser;
+        authentication_needed = true;
+      }
+      callback_function(Functions.getSession(socket), coll, function(userpass) {
+        if (userpass != "" || obj.pass == undefined) {
+          obj.pass = userpass;
+        } else {
+          obj.pass = crypto
+            .createHash("sha256")
+            .update(Functions.decrypt_string(obj.pass))
+            .digest("base64");
+        }
+        if (
+          !authentication_needed ||
+          (authentication_needed &&
+            obj.hasOwnProperty("pass") &&
+            docs[0].userpass == obj.pass)
+        ) {
+          Functions.check_inlist(
+            coll,
+            guid,
+            socket,
+            offline,
+            undefined,
+            "place 13"
+          );
+          db.collection(coll).find({ now_playing: true }, function(err, np) {
+            if (err !== null) console.log(err);
+            if (
+              np !== null &&
+              np !== undefined &&
+              np.length == 1 &&
+              np[0].id == id
+            ) {
+              var startTime = docs[0].startTime;
+              if (
+                startTime + parseInt(np[0].duration) <=
+                Functions.get_time() + 5
+              ) {
+                change_song(coll, false, id, docs);
+              }
+            }
+          });
+        } else {
+          socket.emit("auth_required");
+        }
+      });
+    });
+  } else {
+    var result = {
+      msg: {
+        expected: "object",
+        got: typeof obj
+      }
+    };
+    socket.emit("update_required", result);
+  }
 }
 
 function send_play(coll, socket, broadcast) {
-    //coll = coll.replace(/ /g,'');
-    db.collection(coll).find({now_playing:true}, function(err, np){
-        db.collection(coll + "_settings").find(function(err, conf){
-            if(err !== null) console.log(err);
-            try{
-                if(Functions.get_time()-conf[0].startTime > np[0].duration){
-                    change_song(coll, false, np[0].id, conf);
-                } else if(conf !== null && conf !== undefined && conf.length !== 0)
-                {
-                    if(conf[0].adminpass !== "") conf[0].adminpass = true;
-                    if(conf[0].hasOwnProperty("userpass") && conf[0].userpass != "") conf[0].userpass = true;
-                    else conf[0].userpass = false;
-                    if(!np.hasOwnProperty("start")) np.start = 0;
-                    if(!np.hasOwnProperty("end")) np.end = np.duration;
-                    toSend = {np: np, conf: conf, time: Functions.get_time()};
-                    if(socket === undefined) {
-                        io.to(coll).emit("np", toSend);
-                        //
-                        getNextSong(coll, undefined)
-                        var url = 'https://img.youtube.com/vi/'+np[0].id+'/mqdefault.jpg';
-                        if(np[0].source == "soundcloud") url = np[0].thumbnail;
-                        sendColor(coll, false, url);
-                    } else {
-                        var url = 'https://img.youtube.com/vi/'+np[0].id+'/mqdefault.jpg';
-                        if(np[0].source == "soundcloud") url = np[0].thumbnail;
-                        sendColor(coll, socket, url);
-                        if(broadcast) {
-                            socket.to(coll).emit("np", toSend);
-                            return;
-                        }
-                        socket.emit("np", toSend);
-                    }
-                }
-            } catch(e){
-                if(socket) {
-                    if(broadcast) {
-                        socket.to(coll).emit("np", {});
-                        return;
-                    }
-                    socket.emit("np", {});
-                } else {
-                    io.to(coll).emit("np", {});
-                }
+  //coll = coll.replace(/ /g,'');
+  db.collection(coll).find({ now_playing: true }, function(err, np) {
+    db.collection(coll + "_settings").find(function(err, conf) {
+      if (err !== null) console.log(err);
+      try {
+        if (Functions.get_time() - conf[0].startTime > np[0].duration) {
+          change_song(coll, false, np[0].id, conf);
+        } else if (conf !== null && conf !== undefined && conf.length !== 0) {
+          if (conf[0].adminpass !== "") conf[0].adminpass = true;
+          if (conf[0].hasOwnProperty("userpass") && conf[0].userpass != "")
+            conf[0].userpass = true;
+          else conf[0].userpass = false;
+          if (!np.hasOwnProperty("start")) np.start = 0;
+          if (!np.hasOwnProperty("end")) np.end = np.duration;
+          toSend = { np: np, conf: conf, time: Functions.get_time() };
+          if (socket === undefined) {
+            io.to(coll).emit("np", toSend);
+            //
+            getNextSong(coll, undefined);
+            var url =
+              "https://img.youtube.com/vi/" + np[0].id + "/mqdefault.jpg";
+            if (np[0].source == "soundcloud") url = np[0].thumbnail;
+            sendColor(coll, false, url);
+          } else {
+            var url =
+              "https://img.youtube.com/vi/" + np[0].id + "/mqdefault.jpg";
+            if (np[0].source == "soundcloud") url = np[0].thumbnail;
+            sendColor(coll, socket, url);
+            if (broadcast) {
+              socket.to(coll).emit("np", toSend);
+              return;
             }
-        });
+            socket.emit("np", toSend);
+          }
+        }
+      } catch (e) {
+        if (socket) {
+          if (broadcast) {
+            socket.to(coll).emit("np", {});
+            return;
+          }
+          socket.emit("np", {});
+        } else {
+          io.to(coll).emit("np", {});
+        }
+      }
     });
+  });
 }
 
 function sendColor(coll, socket, url, ajax, res) {
-    if(coll != undefined && typeof(coll) == "string") {
-        //coll = coll.replace(/ /g,'');
-    }
-    if(url.indexOf("://") == -1) url = 'https://img.youtube.com/vi/'+url+'/mqdefault.jpg';
-    //var url = 'https://img.youtube.com/vi/'+id+'/mqdefault.jpg';
+  if (coll != undefined && typeof coll == "string") {
+    //coll = coll.replace(/ /g,'');
+  }
+  if (url.indexOf("://") == -1)
+    url = "https://img.youtube.com/vi/" + url + "/mqdefault.jpg";
+  //var url = 'https://img.youtube.com/vi/'+id+'/mqdefault.jpg';
 
-    Jimp.read(url).then(function (image) {
-
-        var c = ColorThief.getColor(image);
-        if(ajax) {
-            res.header({"Content-Type": "application/json"});
-            res.status(200).send(c);
-            return;
+  Jimp.read(url)
+    .then(function(image) {
+      var c = ColorThief.getColor(image);
+      if (ajax) {
+        res.header({ "Content-Type": "application/json" });
+        res.status(200).send(c);
+        return;
+      } else {
+        if (socket) {
+          socket.emit("color", { color: c, only: true });
         } else {
-            if(socket) {
-                socket.emit("color", {color: c, only: true});
-            } else {
-                io.to(coll).emit("color", {color: c, only: false});
-            }
-        }
-    }).catch(function(err) {
-        console.log("Crashed on fetching image, url is " + url);
-        console.log("Is ajax: " + ajax);
-        if(ajax) {
-            res.header({"Content-Type": "application/json"});
-            res.status(404);
-            return;
+          io.to(coll).emit("color", { color: c, only: false });
         }
+      }
+    })
+    .catch(function(err) {
+      console.log("Crashed on fetching image, url is " + url);
+      console.log("Is ajax: " + ajax);
+      if (ajax) {
+        res.header({ "Content-Type": "application/json" });
+        res.status(404);
+        return;
+      }
     });
 }
 
 function getNextSong(coll, socket, callback) {
-    //coll = coll.replace(/ /g,'');
-    db.collection(coll).aggregate([{
-        $match:{
-            views:{
-                $exists: false
-            },
-            type:{
-                $ne: "suggested"
-            }
+  //coll = coll.replace(/ /g,'');
+  db.collection(coll).aggregate(
+    [
+      {
+        $match: {
+          views: {
+            $exists: false
+          },
+          type: {
+            $ne: "suggested"
+          }
         }
-    }, {
-        $sort:{
-            now_playing: 1,
-            votes:-1,
-            added:1,
-            title: 1
+      },
+      {
+        $sort: {
+          now_playing: 1,
+          votes: -1,
+          added: 1,
+          title: 1
         }
-    }, {
-        $limit:1
-    }], function(err, doc) {
-        if(doc.length == 1) {
-            var thumbnail = "";
-            var source = "youtube";
-            if(doc[0].source && doc[0].source == "soundcloud") {
-                source = "soundcloud";
-                thumbnail = doc[0].thumbnail;
-            }
-            if(socket != undefined) {
-                socket.emit("next_song", {videoId: doc[0].id, title: doc[0].title, source: source, thumbnail: thumbnail});
-            } else {
-                io.to(coll).emit("next_song", {videoId: doc[0].id, title: doc[0].title, source: source, thumbnail: thumbnail});
-            }
+      },
+      {
+        $limit: 1
+      }
+    ],
+    function(err, doc) {
+      if (doc.length == 1) {
+        var thumbnail = "";
+        var source = "youtube";
+        if (doc[0].source && doc[0].source == "soundcloud") {
+          source = "soundcloud";
+          thumbnail = doc[0].thumbnail;
         }
-        if(typeof(callback) == "function") callback();
-    });
+        if (socket != undefined) {
+          socket.emit("next_song", {
+            videoId: doc[0].id,
+            title: doc[0].title,
+            source: source,
+            thumbnail: thumbnail
+          });
+        } else {
+          io.to(coll).emit("next_song", {
+            videoId: doc[0].id,
+            title: doc[0].title,
+            source: source,
+            thumbnail: thumbnail
+          });
+        }
+      }
+      if (typeof callback == "function") callback();
+    }
+  );
 }
 
 module.exports.sendColor = sendColor;
diff --git a/server/public/assets/js/channel.js b/server/public/assets/js/channel.js
index b43b8444..81e9e8ae 100644
--- a/server/public/assets/js/channel.js
+++ b/server/public/assets/js/channel.js
@@ -1,245 +1,321 @@
 var Channel = {
-    init: function() {
-        if(window.location.hash == "#small" || inIframe()) {
-            small_player = true;
-            document.querySelector("footer").style.display = "none";
-            //addJoinBox();
-            //hideAllExtra();
-            //document.querySelectorAll(".tab.col.s3")[1].remove();
-            //document.querySelectorAll(".tab.col.s3")[1].remove();
-        }
-        if(client) {
-            Helper.addClass(".tabs", "hide");
-            Helper.removeClass("#wrapper", "tabs_height");
-            Helper.addClass("#wrapper", "client-wrapper");
-            if(!Helper.mobilecheck()) {
-                Helper.tooltip(".skip_next_client", {
-                    delay: 5,
-                    position: "bottom",
-                    html: "Skip"
-                });
-            }
-            Helper.addClass("#chan", "chan-client");
-            Helper.addClass("#results", "client-results-height");
-            Helper.addClass(".pagination-results", "client-pagination-height");
-            Helper.addClass(".control-list", "client-control-list");
-        } else {
-            if(!api_key.hasOwnProperty("soundcloud")) soundcloud_enabled = false;
-            else {
-                /*SC.initialize({
+  init: function() {
+    if (window.location.hash == "#small" || inIframe()) {
+      small_player = true;
+      document.querySelector("footer").style.display = "none";
+      //addJoinBox();
+      //hideAllExtra();
+      //document.querySelectorAll(".tab.col.s3")[1].remove();
+      //document.querySelectorAll(".tab.col.s3")[1].remove();
+    }
+    if (client) {
+      Helper.addClass(".tabs", "hide");
+      Helper.removeClass("#wrapper", "tabs_height");
+      Helper.addClass("#wrapper", "client-wrapper");
+      if (!Helper.mobilecheck()) {
+        Helper.tooltip(".skip_next_client", {
+          delay: 5,
+          position: "bottom",
+          html: "Skip"
+        });
+      }
+      Helper.addClass("#chan", "chan-client");
+      Helper.addClass("#results", "client-results-height");
+      Helper.addClass(".pagination-results", "client-pagination-height");
+      Helper.addClass(".control-list", "client-control-list");
+    } else {
+      if (!api_key.hasOwnProperty("soundcloud")) soundcloud_enabled = false;
+      else {
+        /*SC.initialize({
                   client_id: api_key.soundcloud
                 }, function() {
                 });*/
-            }
-            if(cast_ready_connect || chromecastAvailable || chromecastReady) {
-                Helper.addClass(".volume-container", "volume-container-cast");
-            }
-    	    if(!embed) {
-    	    	document.querySelector("#main-container").insertAdjacentHTML("beforeend", "keyboard_arrow_right");
-    	          document.querySelector("#hide-playlist").style.left = (document.querySelector("#video-container").offsetWidth - document.querySelector("#hide-playlist").offsetWidth) + "px";
-    	    }
-            //Player.soundcloud_player = document.querySelector("#soundcloud_player");
+      }
+      if (cast_ready_connect || chromecastAvailable || chromecastReady) {
+        Helper.addClass(".volume-container", "volume-container-cast");
+      }
+      if (!embed) {
+        document
+          .querySelector("#main-container")
+          .insertAdjacentHTML(
+            "beforeend",
+            "keyboard_arrow_right"
+          );
+        document.querySelector("#hide-playlist").style.left =
+          document.querySelector("#video-container").offsetWidth -
+          document.querySelector("#hide-playlist").offsetWidth +
+          "px";
+      }
+      //Player.soundcloud_player = document.querySelector("#soundcloud_player");
+    }
+    List.calculate_song_heights();
+    Admin.logged_in = false;
+    Admin.display_logged_out();
+    number_suggested = 0;
+    var no_socket = true;
+
+    //chan = Helper.decodeChannelName(Helper.html("#chan"));
+    var _p = window.location.pathname;
+    if (_p.substring(0, 1) == "/") _p = _p.substring(1);
+    if (_p.substring(_p.length - 1) == "/") _p = _p.substring(0, _p.length - 1);
+    chan = Helper.decodeChannelName(_p);
+
+    mobile_beginning = Helper.mobilecheck();
+    var side = Helper.mobilecheck() ? "left" : "right";
+
+    if (window.location.hostname != "localhost") {
+      var page = window.location.pathname;
+      if (page.substring(page.length - 1) != "/") page += "/";
+      ga("send", "pageview", page);
+    }
+
+    window.onpopstate = function(e) {
+      Channel.onepage_load();
+    };
+
+    if (window.location.hostname == "fb.zoff.me") {
+      Helper.addClass("footer", "hide");
+    }
+
+    if (window.location.hostname != "fb.zoff.me") Channel.share_link_modifier();
+    if (
+      window.location.hostname == "zoff.me" ||
+      window.location.hostname == "fb.zoff.me"
+    )
+      add = "https://zoff.me";
+    else add = window.location.hostname;
+
+    if (Player !== undefined && !client) {
+      Player.stopInterval = false;
+    }
+
+    if (!client) {
+      //Helper.tabs('.playlist-tabs');
+      Helper.tabs(".playlist-tabs-loggedIn", {
+        onShow: function(e) {
+          if (this.index == 2) {
+            document.getElementById("text-chat-input").focus();
+            Chat.channel_received = 0;
+            Chat.all_received = 0;
+            Helper.addClass(
+              document.querySelector(".chat-link span.badge.new.white"),
+              "hide"
+            );
+            document
+              .getElementById("favicon")
+              .setAttribute("href", "/assets/images/favicon.png");
+
+            chat_active = true;
+            unseen = false;
+            chat_unseen = false;
+            document
+              .getElementsByClassName("chat-link")[0]
+              .setAttribute("style", "color: white !important;");
+            blinking = false;
+            //Helper.css("#chat-container", "display", "block");
+            //Helper.css("#wrapper", "display", "none");
+            //Helper.css("#suggestions", "display", "none");
+            document.getElementById("text-chat-input").focus();
+            Helper.css("#pageButtons", "display", "none");
+            scrollChat();
+            window.scrollTo(0, 0);
+          }
         }
-        List.calculate_song_heights();
-        Admin.logged_in = false;
-        Admin.display_logged_out();
-        number_suggested = 0;
-        var no_socket = true;
+      });
 
-        //chan = Helper.decodeChannelName(Helper.html("#chan"));
-        var _p = window.location.pathname;
-        if(_p.substring(0,1) == "/") _p = _p.substring(1);
-        if(_p.substring(_p.length - 1) == "/") _p = _p.substring(0, _p.length - 1);
-        chan = Helper.decodeChannelName(_p);
+      if (window.location.hash == "#chat-container") {
+        M.Tabs.getInstance(
+          document.querySelector(".playlist-tabs-loggedIn")
+        ).select("chat-container");
+      } else if (window.location.hash == "#suggestions") {
+        M.Tabs.getInstance(
+          document.querySelector(".playlist-tabs-loggedIn")
+        ).select("suggestions");
+      } else if (window.location.hash == "#wrapper") {
+        M.Tabs.getInstance(
+          document.querySelector(".playlist-tabs-loggedIn")
+        ).select("wrapper");
+      }
 
-        mobile_beginning = Helper.mobilecheck();
-        var side = Helper.mobilecheck() ? "left" : "right";
+      Helper.tabs(".chatTabs");
+    }
+    Helper.tabs(".results-tabs");
+    var sidenavElem = document.getElementsByClassName("sidenav")[0];
+    M.Sidenav.init(sidenavElem, {
+      menuWidth: 310,
+      edge: side,
+      closeOnClick: false,
+      draggable: Helper.mobilecheck(),
+      onOpenStart: function(el) {
+        Helper.addClass(".hamburger-sidenav", "open");
+      },
+      onCloseStart: function(el) {
+        Helper.removeClass(".hamburger-sidenav", "open");
+      }
+    });
+    M.Collapsible.init(
+      document.getElementsByClassName("settings-collapsible")[0],
+      {
+        accordion: true
+      }
+    );
 
-        if(window.location.hostname != "localhost") {
-            var page = window.location.pathname;
-            if(page.substring(page.length - 1) != "/") page += "/";
-            ga('send', 'pageview', page);
+    if (!client) {
+      M.Modal.init(document.getElementById("embed"), {
+        onCloseStart: function() {
+          document.querySelector(".embed-preview").innerHTML = "";
         }
+      });
+    } else {
+      Helper.removeElement("#embed");
+      Helper.removeElement(".embed-button-footer");
+      Helper.removeElement(".tabs");
+    }
+    M.Modal.init(document.getElementById("advanced_filter"), {
+      onCloseEnd: function() {
+        document.querySelector(".filter-results").innerHTML = "";
+        document.getElementById("filtersearch_input").value = "";
+        document.getElementById("filtersearch_input").blur();
+      },
+      onOpenEnd: function() {
+        document.getElementById("filtersearch_input").focus();
+      }
+    });
 
-        window.onpopstate = function(e){
-            Channel.onepage_load();
-        };
+    M.FormSelect.init(document.querySelector(".category-advanced-select"));
+    M.Modal.init(document.getElementById("help"));
+    M.Modal.init(document.getElementById("contact"));
+    M.Modal.init(document.getElementById("channel-share-modal"));
+    M.Modal.init(document.getElementById("delete_song_alert"), {
+      dismissible: false
+    });
+    M.Modal.init(document.getElementById("user_password"), {
+      dismissible: false
+    });
 
-        if(window.location.hostname == "fb.zoff.me") {
-            Helper.addClass("footer", "hide");
+    Channel.spotify_is_authenticated(spotify_authenticated);
+
+    result_html = document.getElementById("temp-results-container");
+    pagination_buttons_html =
+      "";
+    empty_results_html = Helper.html("#empty-results-container");
+    not_import_html = Helper.html(".not-imported-container");
+    not_export_html = Helper.html(".not-exported-container");
+    Helper.setHtml(".not-imported-container", "");
+    Helper.setHtml(".not-exported-container", "");
+
+    if (socket === undefined) {
+      no_socket = false;
+      if (window.location.port != "") {
+        add = add + ":" + window.location.port + "/";
+      }
+      socket = io.connect(
+        "" + add,
+        connection_options
+      );
+      socket.on("update_required", function(msg) {
+        if (window.location.hostname == "localhost") {
+          console.error(msg);
+          return;
         }
+        window.location.reload(true);
+      });
+    }
 
-        if(window.location.hostname != "fb.zoff.me") Channel.share_link_modifier();
-        if(window.location.hostname == "zoff.me" || window.location.hostname == "fb.zoff.me") add = "https://zoff.me";
-        else add = window.location.hostname;
+    Crypt.init();
 
-        if(Player !== undefined && !client) {
-            Player.stopInterval = false;
+    setup_auth_listener();
+
+    if (Crypt.get_offline()) {
+      document.getElementsByClassName("offline_switch_class")[0].checked = true;
+      change_offline(true, offline);
+    }
+    if (
+      !Helper.mobilecheck() &&
+      (document.querySelectorAll("#alreadychannel").length === 0 ||
+        !Hostcontroller.old_id ||
+        document.getElementById("code-text").innerText.toUpperCase() ==
+          "ABBADUR")
+    )
+      setup_host_initialization();
+    setup_suggested_listener();
+    if (!Helper.mobilecheck()) {
+      showOnSmallNotMobile();
+    }
+    if (
+      document.querySelectorAll("#alreadychannel").length === 0 ||
+      Helper.mobilecheck()
+    ) {
+      setup_now_playing_listener();
+      get_list_listener();
+
+      if (!client) {
+        setup_viewers_listener();
+      }
+    } else {
+      Helper.css("#channel-load", "display", "none");
+      Helper.css("#player", "opacity", "1");
+      Helper.css("#controls", "opacity", "1");
+      Helper.css(".playlist", "opacity", "1");
+      if (!client) {
+        Player.readyLooks();
+        Playercontrols.initYoutubeControls(Player.player);
+        Playercontrols.initSlider();
+        if (player_ready) {
+          try {
+            Player.player.setVolume(Crypt.get_volume());
+          } catch (e) {}
+          try {
+            if (scUsingWidget)
+              Player.soundcloud_player.setVolume(
+                embed ? 1 : Crypt.get_volume()
+              );
+            else
+              Player.soundcloud_player.setVolume(
+                embed ? 1 : Crypt.get_volume() / 100
+              );
+          } catch (e) {}
         }
+        Helper.removeClass(".video-container", "no-opacity");
+        var codeURL = "https://remote." + window.location.hostname + "/" + id;
+        Helper.setHtml("#code-text", id);
+        document
+          .getElementById("code-qr")
+          .setAttribute(
+            "src",
+            "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl=" +
+              codeURL
+          );
+        document.getElementById("code-link").setAttribute("href", codeURL);
+      }
+    }
 
-        if(!client) {
-            //Helper.tabs('.playlist-tabs');
-            Helper.tabs('.playlist-tabs-loggedIn', {
-                onShow: function(e) {
-                    if(this.index == 2) {
-                        document.getElementById("text-chat-input").focus();
-                        Chat.channel_received = 0;
-                        Chat.all_received = 0;
-                        Helper.addClass(document.querySelector(".chat-link span.badge.new.white"), "hide");
-                        document.getElementById("favicon").setAttribute("href", "/assets/images/favicon.png");
-
-                        chat_active = true;
-                        unseen = false;
-                        chat_unseen = false;
-                        document.getElementsByClassName("chat-link")[0].setAttribute("style", "color: white !important;");
-                        blinking = false;
-                        //Helper.css("#chat-container", "display", "block");
-                        //Helper.css("#wrapper", "display", "none");
-                        //Helper.css("#suggestions", "display", "none");
-                        document.getElementById("text-chat-input").focus();
-                        Helper.css("#pageButtons", "display", "none");
-                        scrollChat();
-                        window.scrollTo(0, 0);
-                    }
-                }
-            });
-
-            if(window.location.hash == "#chat-container") {
-                M.Tabs.getInstance(document.querySelector('.playlist-tabs-loggedIn')).select("chat-container");
-            } else if(window.location.hash == "#suggestions") {
-                M.Tabs.getInstance(document.querySelector('.playlist-tabs-loggedIn')).select("suggestions");
-            } else if(window.location.hash == "#wrapper") {
-                M.Tabs.getInstance(document.querySelector('.playlist-tabs-loggedIn')).select("wrapper");
-            }
-
-            Helper.tabs('.chatTabs');
-        }
-        Helper.tabs('.results-tabs');
-        var sidenavElem = document.getElementsByClassName("sidenav")[0];
-        M.Sidenav.init(sidenavElem, {
-            menuWidth: 310,
-            edge: side,
-            closeOnClick: false,
-            draggable: Helper.mobilecheck(),
-            onOpenStart: function(el) {
-                Helper.addClass(".hamburger-sidenav", "open");
-            },
-            onCloseStart: function(el) {
-                Helper.removeClass(".hamburger-sidenav", "open");
-            },
-        });
-        M.Collapsible.init(document.getElementsByClassName("settings-collapsible")[0], {
-            accordion : true
-        });
-
-        if(!client) {
-            M.Modal.init(document.getElementById("embed"), {
-                onCloseStart: function() {
-                    document.querySelector(".embed-preview").innerHTML = "";
-                }
-            });
-        } else {
-            Helper.removeElement("#embed");
-            Helper.removeElement(".embed-button-footer");
-            Helper.removeElement(".tabs");
-        }
-        M.Modal.init(document.getElementById("advanced_filter"), {
-            onCloseEnd: function() {
-                document.querySelector(".filter-results").innerHTML = "";
-                document.getElementById("filtersearch_input").value = "";
-                document.getElementById("filtersearch_input").blur();
-            },
-            onOpenEnd: function() {
-                document.getElementById("filtersearch_input").focus();
-            }
-        });
-
-        M.FormSelect.init(document.querySelector('.category-advanced-select'));
-        M.Modal.init(document.getElementById("help"));
-        M.Modal.init(document.getElementById("contact"));
-        M.Modal.init(document.getElementById("channel-share-modal"));
-        M.Modal.init(document.getElementById("delete_song_alert"), {
-            dismissible: false
-        });
-        M.Modal.init(document.getElementById("user_password"), {
-            dismissible: false,
-        });
-
-        Channel.spotify_is_authenticated(spotify_authenticated);
-
-        result_html 	   	  = document.getElementById("temp-results-container");
-        pagination_buttons_html = "";
-        empty_results_html 	  = Helper.html("#empty-results-container");
-        not_import_html       = Helper.html(".not-imported-container");
-        not_export_html       = Helper.html(".not-exported-container");
-        Helper.setHtml(".not-imported-container", "");
-        Helper.setHtml(".not-exported-container", "");
-
-        if(socket === undefined){
-            no_socket = false;
-            socket = io.connect(''+add, connection_options);
-            socket.on('update_required', function(msg) {
-                if(window.location.hostname == "localhost") {
-                    console.error(msg);
-                    return;
-                }
-                window.location.reload(true);
-            });
-        }
-
-        Crypt.init();
-
-        setup_auth_listener();
-
-        if(Crypt.get_offline()){
-            document.getElementsByClassName("offline_switch_class")[0].checked = true;
-            change_offline(true, offline);
-        }
-        if(!Helper.mobilecheck() && (document.querySelectorAll("#alreadychannel").length === 0 || !Hostcontroller.old_id || document.getElementById("code-text").innerText.toUpperCase() == "ABBADUR")) setup_host_initialization();
-        setup_suggested_listener();
-        if(!Helper.mobilecheck()) {
-            showOnSmallNotMobile();
-        }
-        if(document.querySelectorAll("#alreadychannel").length === 0 || Helper.mobilecheck()){
-            setup_now_playing_listener();
-            get_list_listener();
-
-            if(!client) {
-                setup_viewers_listener();
-            }
-        } else {
-            Helper.css("#channel-load", "display", "none");
-            Helper.css("#player", "opacity", "1");
-            Helper.css("#controls", "opacity", "1");
-            Helper.css(".playlist", "opacity", "1");
-            if(!client) {
-                Player.readyLooks();
-                Playercontrols.initYoutubeControls(Player.player);
-                Playercontrols.initSlider();
-                if(player_ready) {
-                    try {
-                        Player.player.setVolume(Crypt.get_volume());
-                    } catch(e){}
-                    try {
-                        if(scUsingWidget) Player.soundcloud_player.setVolume(embed ? 1 : Crypt.get_volume());
-                        else Player.soundcloud_player.setVolume(embed ? 1 : Crypt.get_volume() / 100);
-                    } catch(e){}
-                }
-                Helper.removeClass(".video-container", "no-opacity");
-                var codeURL = "https://remote."+window.location.hostname+"/"+id;
-                Helper.setHtml("#code-text", id);
-                document.getElementById("code-qr").setAttribute("src", "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+codeURL);
-                document.getElementById("code-link").setAttribute("href", codeURL);
-            }
-        }
-
-
-        if(!client) {
-            if(!Helper.mobilecheck()) {
-                var shareCodeUrl = window.location.protocol + "//client."+window.location.hostname+"/r/"+btoa(encodeURIComponent(chan.toLowerCase()));
-                document.getElementById("share-join-qr").setAttribute("src", "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+shareCodeUrl);
-                Helper.setHtml("#channel-name-join", "client." + window.location.hostname + "/" + encodeURIComponent(chan.toLowerCase()));
-            } /*else if(small_player) {
+    if (!client) {
+      if (!Helper.mobilecheck()) {
+        var shareCodeUrl =
+          window.location.protocol +
+          "//client." +
+          window.location.hostname +
+          "/r/" +
+          btoa(encodeURIComponent(chan.toLowerCase()));
+        document
+          .getElementById("share-join-qr")
+          .setAttribute(
+            "src",
+            "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl=" +
+              shareCodeUrl
+          );
+        Helper.setHtml(
+          "#channel-name-join",
+          "client." +
+            window.location.hostname +
+            "/" +
+            encodeURIComponent(chan.toLowerCase())
+        );
+      } /*else if(small_player) {
                 document.querySelector("#channel-share-modal .modal-content").innerHTML = "To listen to this channel with more features, go to
https://zoff.me/" + encodeURIComponent(chan.toLowerCase()) + "
 ";
                 //M.Modal.getInstance(document.getElementById("channel-share-modal")).open();
                 if(!Helper.mobilecheck()) {
@@ -248,110 +324,119 @@ var Channel = {
                     }, 10000);
                 }
             }*/
-        } else {
-            Helper.removeElement(".video-container");
-            Helper.removeElement(".offline-panel");
-            Helper.removeElement(".remote-panel");
-            Helper.removeElement(".mobile-remote-panel");
-            Helper.removeElement(".import-panel");
-            Helper.removeElement(".export-panel");
-        }
-        if(no_socket || Helper.mobilecheck()){
-            emit_list();
-        }
+    } else {
+      Helper.removeElement(".video-container");
+      Helper.removeElement(".offline-panel");
+      Helper.removeElement(".remote-panel");
+      Helper.removeElement(".mobile-remote-panel");
+      Helper.removeElement(".import-panel");
+      Helper.removeElement(".export-panel");
+    }
+    if (no_socket || Helper.mobilecheck()) {
+      emit_list();
+    }
 
-        if(!Helper.mobilecheck()) {
-            if(!client) {
-                Helper.tooltip("#chan", {
-                    delay: 5,
-                    position: "bottom",
-                    html: "Show join URL",
-                });
-            }
+    if (!Helper.mobilecheck()) {
+      if (!client) {
+        Helper.tooltip("#chan", {
+          delay: 5,
+          position: "bottom",
+          html: "Show join URL"
+        });
+      }
 
-            Helper.tooltip("#viewers", {
-                delay: 5,
-                position: "top",
-                html: "Viewers"
-            });
+      Helper.tooltip("#viewers", {
+        delay: 5,
+        position: "top",
+        html: "Viewers"
+      });
 
-            Helper.tooltip("#addToOtherList", {
-                delay: 5,
-                position: "top",
-                html: "Add to other playlist"
-            });
+      Helper.tooltip("#addToOtherList", {
+        delay: 5,
+        position: "top",
+        html: "Add to other playlist"
+      });
 
-            Helper.tooltip("#fullscreen", {
-                delay: 5,
-                position: "top",
-                html: "Fullscreen"
-            });
+      Helper.tooltip("#fullscreen", {
+        delay: 5,
+        position: "top",
+        html: "Fullscreen"
+      });
 
-            Helper.tooltip(".search-btn-container", {
-                delay: 5,
-                position: "bottom",
-                html: "Search"
-            });
+      Helper.tooltip(".search-btn-container", {
+        delay: 5,
+        position: "bottom",
+        html: "Search"
+      });
 
+      Helper.tooltip(".shuffle-btn-container", {
+        delay: 5,
+        position: "bottom",
+        html: "Shuffle"
+      });
 
-            Helper.tooltip(".shuffle-btn-container", {
-                delay: 5,
-                position: "bottom",
-                html: "Shuffle",
-            });
+      Helper.tooltip("#settings", {
+        delay: 5,
+        position: "bottom",
+        html: "Settings"
+      });
+    }
 
-            Helper.tooltip("#settings", {
-                delay: 5,
-                position: "bottom",
-                html: "Settings",
-            });
-        }
+    if (!client) {
+      window.onYouTubeIframeAPIReady = Player.onYouTubeIframeAPIReady;
+      if (
+        Player.player === "" ||
+        Player.player === undefined ||
+        Helper.mobilecheck()
+      )
+        Player.loadPlayer();
+    } else {
+      Player.loadSoundCloudPlayer();
+    }
+    //}
 
-        if(!client) {
-            window.onYouTubeIframeAPIReady = Player.onYouTubeIframeAPIReady;
-            if(Player.player === "" || Player.player === undefined || Helper.mobilecheck()) Player.loadPlayer();
-        } else {
-            Player.loadSoundCloudPlayer();
-        }
-        //}
+    if (Helper.mobilecheck()) {
+      if (!client) {
+        Mobile_remote.initiate_volume();
+      }
+      Helper.addClass(".close-settings", "hide");
+    } else {
+      if (!client) {
+        Channel.window_width_volume_slider();
+      }
+    }
 
-        if(Helper.mobilecheck()) {
-            if(!client) {
-                Mobile_remote.initiate_volume();
-            }
-                Helper.addClass(".close-settings", "hide");
-        } else {
-            if(!client) {
-                Channel.window_width_volume_slider();
-            }
-        }
+    setup_admin_listener();
+    setup_list_listener();
+    if (!client) {
+      setup_chat_listener();
+      get_history();
+    }
+    if (client || Helper.mobilecheck()) {
+      get_list_ajax();
+      get_np_ajax();
+    }
 
-        setup_admin_listener();
-        setup_list_listener();
-        if(!client) {
-            setup_chat_listener();
-            get_history();
-        }
-        if(client || Helper.mobilecheck()){
-            get_list_ajax();
-            get_np_ajax();
+    try {
+      if (
+        !Helper.msieversion() &&
+        !Helper.mobilecheck() &&
+        !client &&
+        Notification != undefined
+      )
+        Notification.requestPermission();
+    } catch (e) {}
+    document.getElementsByClassName("search_input")[0].focus();
 
-        }
+    Helper.sample();
+    if (!Helper.mobilecheck() && !client) {
+      Helper.tooltip(".castButton", {
+        delay: 5,
+        position: "top",
+        html: "Cast Zoff to TV"
+      });
 
-	try {
-        	if(!Helper.msieversion() && !Helper.mobilecheck() && !client && Notification != undefined) Notification.requestPermission();
-	}catch(e){}
-        document.getElementsByClassName("search_input")[0].focus();
-
-        Helper.sample();
-        if(!Helper.mobilecheck() && !client) {
-            Helper.tooltip('.castButton', {
-                delay: 5,
-                position: "top",
-                html: "Cast Zoff to TV"
-            });
-
-            /*$("#color_embed").spectrum({
+      /*$("#color_embed").spectrum({
                 color: "#808080",
                 change: function(c) {
                     color = c.toHexString().substring(1); // #ff0000
@@ -363,383 +448,513 @@ var Channel = {
                 },
             });*/
 
-            /*Helper.addClass(".sp-choose", "hide");
+      /*Helper.addClass(".sp-choose", "hide");
             Helper.addClass(".sp-cancel", "btn-flat waves-effect waves-red");
             Helper.removeClass(".sp-cancel", "sp-cancel");
             document.getElementsByClassName("sp-button-container")[0].insertAdjacentHTML("beforeend", "CHOOSE");
             */
-        }
+    }
 
-        addListener("click", ".sp-choose-link", function(e) {
-            event.preventDefault();
-            document.getElementsByClassName("sp-choose")[0].click();
-        });
+    addListener("click", ".sp-choose-link", function(e) {
+      event.preventDefault();
+      document.getElementsByClassName("sp-choose")[0].click();
+    });
 
-        //$("#results" ).hover( function() { Helper.removeClass(".result", "hoverResults"); i = 0; }, function(){ });
-        document.getElementById("search").focus();
-        Helper.css("#embed-button", "display", "inline-block");
-        document.getElementById("search").setAttribute("placeholder", "Search...");
+    //$("#results" ).hover( function() { Helper.removeClass(".result", "hoverResults"); i = 0; }, function(){ });
+    document.getElementById("search").focus();
+    Helper.css("#embed-button", "display", "inline-block");
+    document.getElementById("search").setAttribute("placeholder", "Search...");
 
-        if(!client) {
-            Helper.addClass("footer", "padding-bottom-novideo");
-            document.getElementById("embed-area").value = embed_code(embed_autoplay, embed_width, embed_height, color, embed_videoonly, embed_localmode);
-        }
+    if (!client) {
+      Helper.addClass("footer", "padding-bottom-novideo");
+      document.getElementById("embed-area").value = embed_code(
+        embed_autoplay,
+        embed_width,
+        embed_height,
+        color,
+        embed_videoonly,
+        embed_localmode
+      );
+    }
 
-        if(!/chrom(e|ium)/.test(navigator.userAgent.toLowerCase()) && !Helper.mobilecheck() && !client){
-            Helper.css(".castButton", "display", "none");
-        }
+    if (
+      !/chrom(e|ium)/.test(navigator.userAgent.toLowerCase()) &&
+      !Helper.mobilecheck() &&
+      !client
+    ) {
+      Helper.css(".castButton", "display", "none");
+    }
 
-        Helper.log(["chromecastAvailable " + chromecastAvailable, "chromecastReady " + chromecastReady]);
+    Helper.log([
+      "chromecastAvailable " + chromecastAvailable,
+      "chromecastReady " + chromecastReady
+    ]);
 
-        if(chromecastAvailable && !client){
-            hide_native(1);
-        } else if(chromecastReady && !client) {
+    if (chromecastAvailable && !client) {
+      hide_native(1);
+    } else if (chromecastReady && !client) {
+      initializeCastApi();
+    } else if (!client) {
+      window["__onGCastApiAvailable"] = function(loaded, errorInfo) {
+        if (loaded) {
+          setTimeout(function() {
+            chromecastReady = true;
             initializeCastApi();
-        } else if(!client){
-            window['__onGCastApiAvailable'] = function(loaded, errorInfo) {
-                if (loaded) {
-                    setTimeout(function(){
-                        chromecastReady = true;
-                        initializeCastApi();
-                    }, 1000);
-                } else {
-                    chromecastReady = true;
-                }
-            }
-        }
-        Channel.listeners(true);
-        Channel.add_context_menu();
-
-        if(!Helper.mobilecheck() && navigator.userAgent.match(/iPad/i) == null){
-            setTimeout(function(){Channel.set_title_width();}, 100);
-        }
-    },
-
-    set_title_width: function(start){
-        if(window.innerWidth > 600){
-            var add_width = document.getElementsByClassName("brand-logo")[0].offsetWidth
-            if(start){
-                add_width = window.innerWidth * 0.15;
-            }
-            var test_against_width = window.innerWidth - document.getElementsByClassName("control-list")[0].offsetWidth - add_width - 11;
-            title_width = test_against_width;
-            document.getElementsByClassName("title-container")[0].style.width = title_width + "px";
+          }, 1000);
         } else {
-            document.getElementsByClassName("title-container")[0].style.width = "100%";
+          chromecastReady = true;
         }
-    },
+      };
+    }
+    Channel.listeners(true);
+    Channel.add_context_menu();
 
-    spotify_is_authenticated: function(bool){
-        if(bool){
-            Helper.log([
-                "Spotify is authenticated",
-                "access_token: " + access_token_data.access_token,
-                "token_type:" + access_token_data.token_type,
-                "expires_in: " + access_token_data.expires_in
-            ]);
+    if (!Helper.mobilecheck() && navigator.userAgent.match(/iPad/i) == null) {
+      setTimeout(function() {
+        Channel.set_title_width();
+      }, 100);
+    }
+  },
 
-            Helper.css(".spotify_authenticated", "display", "block");
-            Helper.css(".spotify_unauthenticated", "display", "none");
-        } else {
-            Helper.log(["Spotify is not authenticated"]);
-            Helper.css(".spotify_authenticated", "display", "none");
-            Helper.css(".spotify_unauthenticated", "display", "flex");
+  set_title_width: function(start) {
+    if (window.innerWidth > 600) {
+      var add_width = document.getElementsByClassName("brand-logo")[0]
+        .offsetWidth;
+      if (start) {
+        add_width = window.innerWidth * 0.15;
+      }
+      var test_against_width =
+        window.innerWidth -
+        document.getElementsByClassName("control-list")[0].offsetWidth -
+        add_width -
+        11;
+      title_width = test_against_width;
+      document.getElementsByClassName("title-container")[0].style.width =
+        title_width + "px";
+    } else {
+      document.getElementsByClassName("title-container")[0].style.width =
+        "100%";
+    }
+  },
+
+  spotify_is_authenticated: function(bool) {
+    if (bool) {
+      Helper.log([
+        "Spotify is authenticated",
+        "access_token: " + access_token_data.access_token,
+        "token_type:" + access_token_data.token_type,
+        "expires_in: " + access_token_data.expires_in
+      ]);
+
+      Helper.css(".spotify_authenticated", "display", "block");
+      Helper.css(".spotify_unauthenticated", "display", "none");
+    } else {
+      Helper.log(["Spotify is not authenticated"]);
+      Helper.css(".spotify_authenticated", "display", "none");
+      Helper.css(".spotify_unauthenticated", "display", "flex");
+    }
+  },
+
+  add_context_menu: function() {
+    addListener("contextmenu", ".vote-container", function(e) {
+      if (hostMode) {
+        return;
+      }
+      this.preventDefault();
+      this.preventDefault();
+      var that = this;
+      contextListener(e, that);
+    });
+
+    addListener("contextmenu", ".add-suggested", function(e) {
+      this.preventDefault();
+      var that = this;
+      contextListener(e, that);
+    });
+
+    addListener("click", ".list-remove", function(e) {
+      this.preventDefault();
+      var that = this;
+      contextListener(e, that);
+    });
+  },
+
+  share_link_modifier: function() {
+    document
+      .getElementById("facebook-code-link")
+      .setAttribute(
+        "href",
+        "https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/" +
+          chan.toLowerCase()
+      );
+    document
+      .getElementById("facebook-code-link")
+      .setAttribute(
+        "onclick",
+        "window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/" +
+          chan.toLowerCase() +
+          "', 'Share Playlist','width=600,height=300'); return false;"
+      );
+    document
+      .getElementById("twitter-code-link")
+      .setAttribute(
+        "href",
+        "https://twitter.com/intent/tweet?url=https://zoff.me/" +
+          chan.toLowerCase() +
+          "&text=Check%20out%20this%20playlist%20" +
+          chan.toLowerCase() +
+          "%20on%20Zoff!&via=zoffmusic"
+      );
+    document
+      .getElementById("twitter-code-link")
+      .setAttribute(
+        "onclick",
+        "window.open('https://twitter.com/intent/tweet?url=https://zoff.me/" +
+          chan.toLowerCase() +
+          "/&text=Check%20out%20this%20playlist%20" +
+          chan.toLowerCase() +
+          "%20on%20Zoff!&via=zoffmusic','Share Playlist','width=600,height=300'); return false;"
+      );
+  },
+
+  window_width_volume_slider: function() {
+    if (window.innerWidth <= 600 && slider_type == "horizontal") {
+      slider_type = "vertical";
+      Playercontrols.initSlider();
+    } else if (window.innerWidth > 600 && slider_type == "vertical") {
+      slider_type = "horizontal";
+      Playercontrols.initSlider();
+      Helper.removeClass(".volume-container", "hide");
+    }
+  },
+
+  listeners: function(on) {
+    var scrollListener = function(e) {
+      if (!programscroll) {
+        userscroll = true;
+        if (
+          document.getElementById("chatchannel").scrollTop +
+            document.getElementById("chatchannel").offsetHeight >=
+          document.getElementById("chatchannel").scrollHeight
+        ) {
+          userscroll = false;
         }
-    },
-
-    add_context_menu: function() {
-        addListener("contextmenu", ".vote-container", function(e) {
-            if(hostMode) {
-                return;
-            }
-            this.preventDefault();
-            this.preventDefault();
-            var that = this;
-            contextListener(e, that);
-        });
-
-        addListener("contextmenu", ".add-suggested", function(e) {
-            this.preventDefault();
-            var that = this;
-            contextListener(e, that);
-        });
-
-        addListener("click", ".list-remove", function(e) {
-            this.preventDefault();
-            var that = this;
-            contextListener(e, that);
-        });
-    },
-
-    share_link_modifier: function(){
-        document.getElementById("facebook-code-link").setAttribute("href", "https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/" + chan.toLowerCase());
-        document.getElementById("facebook-code-link").setAttribute("onclick", "window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/" + chan.toLowerCase() + "', 'Share Playlist','width=600,height=300'); return false;");
-        document.getElementById("twitter-code-link").setAttribute("href", "https://twitter.com/intent/tweet?url=https://zoff.me/" + chan.toLowerCase() + "&text=Check%20out%20this%20playlist%20" + chan.toLowerCase() + "%20on%20Zoff!&via=zoffmusic");
-        document.getElementById("twitter-code-link").setAttribute("onclick", "window.open('https://twitter.com/intent/tweet?url=https://zoff.me/" + chan.toLowerCase() + "/&text=Check%20out%20this%20playlist%20" + chan.toLowerCase() + "%20on%20Zoff!&via=zoffmusic','Share Playlist','width=600,height=300'); return false;");
-    },
-
-    window_width_volume_slider: function() {
-        if(window.innerWidth <= 600 && slider_type == "horizontal") {
-            slider_type = "vertical";
-            Playercontrols.initSlider();
-        } else if(window.innerWidth > 600 && slider_type == "vertical") {
-            slider_type = "horizontal";
-            Playercontrols.initSlider();
-            Helper.removeClass(".volume-container", "hide");
+      }
+    };
+    var scrollAllListener = function(e) {
+      if (!programscroll) {
+        userscroll = true;
+        if (
+          document.getElementById("chatall").scrollTop +
+            document.getElementById("chatall").offsetHeight >=
+          document.getElementById("chatall").scrollHeight
+        ) {
+          userscroll = false;
         }
-    },
+      }
+    };
+    if (!client) {
+      if (on) {
+        document
+          .getElementById("chatchannel")
+          .addEventListener("scroll", scrollListener);
+        document
+          .getElementById("chatall")
+          .addEventListener("scroll", scrollListener);
+      } else {
+        document
+          .getElementById("chatchannel")
+          .removeEventListener("scroll", scrollListener);
+        document
+          .getElementById("chatall")
+          .removeEventListener("scroll", scrollAllListener);
+      }
+    }
+  },
 
-    listeners: function(on) {
-        var scrollListener = function(e) {
-            if(!programscroll) {
-                userscroll = true;
-                if(document.getElementById("chatchannel").scrollTop + document.getElementById("chatchannel").offsetHeight >= document.getElementById("chatchannel").scrollHeight) {
-                    userscroll = false;
-                }
-            }
-        }
-        var scrollAllListener = function(e) {
-            if(!programscroll) {
-                userscroll = true;
-                if(document.getElementById("chatall").scrollTop+ document.getElementById("chatall").offsetHeight >= document.getElementById("chatall").scrollHeight) {
-                    userscroll = false;
-                }
-            }
-        }
-        if(!client) {
-            if(on) {
-                document.getElementById("chatchannel").addEventListener("scroll", scrollListener);
-                document.getElementById("chatall").addEventListener("scroll", scrollListener);
-            } else {
-                document.getElementById("chatchannel").removeEventListener("scroll", scrollListener);
-                document.getElementById("chatall").removeEventListener("scroll", scrollAllListener);
-            }
-        }
-    },
+  onepage_load: function() {
+    if (changing_to_frontpage) return;
+    if (user_auth_started) {
+      clearTimeout(durationTimeout);
+      Player.stopInterval = true;
+      user_auth_avoid = true;
+      if (!Helper.mobilecheck()) {
+        Helper.tooltip(".castButton", "destroy");
+        Helper.tooltip("#viewers", "destroy");
+        Helper.tooltip("#addToOtherList", "destroy");
+        //$('.castButton-unactive').tooltip("destroy");
+        Helper.tooltip("#offline-mode", "destroy");
+        Helper.tooltip("#admin-lock", "destroy");
+      }
+    }
+    var url_split = window.location.href.split("/");
+    if (
+      url_split[3].substr(0, 1) != "#!" &&
+      url_split[3] !== "" &&
+      !(url_split.length == 5 && url_split[4].substr(0, 1) == "#")
+    ) {
+      socket.emit("change_channel", {
+        channel: channel_before_move
+      });
+      Admin.beginning = true;
 
-    onepage_load: function(){
-        if(changing_to_frontpage) return;
-        if(user_auth_started) {
-            clearTimeout(durationTimeout);
-            Player.stopInterval = true;
-            user_auth_avoid = true;
-            if(!Helper.mobilecheck()) {
-                Helper.tooltip('.castButton', "destroy");
-                Helper.tooltip("#viewers", "destroy");
-                Helper.tooltip('#addToOtherList', 'destroy');
-                //$('.castButton-unactive').tooltip("destroy");
-                Helper.tooltip("#offline-mode", "destroy");
-                Helper.tooltip('#admin-lock', "destroy");
-            }
-        }
-        var url_split = window.location.href.split("/");
-        if(url_split[3].substr(0,1) != "#!" && url_split[3] !== "" && !(url_split.length == 5 && url_split[4].substr(0,1) == "#")){
-            socket.emit("change_channel", {
-                channel: channel_before_move
-            });
-            Admin.beginning = true;
-
-            chan = url_split[3].replace("#", "");
-            document.getElementById("chan").innerHTML = Helper.upperFirst(chan);
-            var add = "";
-            w_p = true;
-            //if(private_channel) add = Crypt.getCookie("_uI") + "_";
-
-            socket.emit("list", {version: parseInt(_VERSION), channel: add + chan.toLowerCase()});
-        } else if(url_split[3] === "") {
-            /*if(client) {
+      chan = url_split[3].replace("#", "");
+      document.getElementById("chan").innerHTML = Helper.upperFirst(chan);
+      var add = "";
+      w_p = true;
+      //if(private_channel) add = Crypt.getCookie("_uI") + "_";
+      socket.emit("list", {
+        version: parseInt(_VERSION),
+        channel: add + chan.toLowerCase()
+      });
+    } else if (url_split[3] === "") {
+      /*if(client) {
                 var host = window.location.hostname.split(".");
                 window.location.hostname = host[host.length -1];
             }*/
-            Admin.display_logged_out();
-            if(hostMode) {
-                Helper.removeClass("#main-row", "fullscreened");
-                document.querySelector(".host_switch_class").checked = false
-                enable_host_mode(false);
-            }
-            var channel_before_move = chan.toLowerCase();
-            clearTimeout(timed_remove_check);
-            changing_to_frontpage = true;
-            user_change_password = false;
-            clearTimeout(width_timeout);
-            if(fireplace_initiated){
-                fireplace_initiated = false;
-                Player.fireplace.destroy();
-                Helper.css("#fireplace_player", "display", "none");
-            }
-            Helper.css("#channel-load", "display", "block");
-            window.scrollTo(0, 0);
+      Admin.display_logged_out();
+      if (hostMode) {
+        Helper.removeClass("#main-row", "fullscreened");
+        document.querySelector(".host_switch_class").checked = false;
+        enable_host_mode(false);
+      }
+      var channel_before_move = chan.toLowerCase();
+      clearTimeout(timed_remove_check);
+      changing_to_frontpage = true;
+      user_change_password = false;
+      clearTimeout(width_timeout);
+      if (fireplace_initiated) {
+        fireplace_initiated = false;
+        Player.fireplace.destroy();
+        Helper.css("#fireplace_player", "display", "none");
+      }
+      Helper.css("#channel-load", "display", "block");
+      window.scrollTo(0, 0);
 
-            //Player.stopInterval = true;
-            Admin.beginning 	 = true;
-            began 				 = false;
-            durationBegun  		 = false;
+      //Player.stopInterval = true;
+      Admin.beginning = true;
+      began = false;
+      durationBegun = false;
 
-            Helper.css("#embed-button", "display", "none");
-            if(!Helper.mobilecheck()) {
-                Helper.tooltip(".castButton", "destroy");
-                Helper.tooltip('#addToOtherList', 'destroy');
-                Helper.tooltip("#viewers", "destroy");
-                Helper.tooltip("#offline-mode", "destroy");
-                Helper.tooltip("search-btn", "destroy");
-                Helper.tooltip('#fullscreen', "destroy");
-                if(M.Tooltip.getInstance(document.getElementById("admin-lock")) != undefined) {
-                    Helper.tooltip('#admin-lock', "destroy");
-                }
-                Helper.tooltip(".search-btn-container", "destroy");
-                Helper.tooltip(".shuffle-btn-container", "destroy");
-                Helper.tooltip("#settings", "destroy");
-            }
-            Helper.removeElement("#seekToDuration");
-
-            M.Sidenav.getInstance(document.getElementsByClassName("sidenav")[0]).destroy();
-            if(!client) {
-                if(!Helper.mobilecheck()) {
-                    Helper.tooltip("#chan", "destroy");
-                }
-                var tap_1 = document.querySelectorAll(".tap-target")
-                if(tap_1.length > 0 && M.TapTarget.getInstance(tap_1[0])) {
-                    M.TapTarget.getInstance(tap_1[0]).close();
-                }
-            }
-            clearTimeout(tap_target_timeout);
-            //before_toast();
-            if(Helper.mobilecheck() || user_auth_avoid || client) {
-                Helper.log(["Removing all listeners"]);
-                //socket.emit("change_channel");
-                //removeAllListeners();
-                //socket.removeEventListener(id);
-                socket.emit("left_channel", {
-                    channel: channel_before_move
-                });
-                socket.emit("change_channel", {
-                    channel: channel_before_move
-                });
-                chan = "";
-                socket.removeEventListener("np");
-                socket.removeEventListener("id");
-                socket.removeEventListener(id);
-                //socket.disconnect();
-            }
-            socket.removeEventListener("chat.all");
-            socket.removeEventListener("chat");
-            socket.removeEventListener("conf");
-            socket.removeEventListener("pw");
-            socket.removeEventListener("toast");
-            //socket.removeEventListener("id");
-            socket.removeEventListener("channel");
-            socket.removeEventListener("auth_required");
-            socket.removeEventListener("auth_accepted");
-            socket.removeEventListener("suggested");
-            socket.removeEventListener("color");
-            socket.removeEventListener("chat_history");
-            Helper.ajax({
-                url: "/",
-                method: "GET",
-                success: function(e){
-
-                    if(!client) {
-                	document.querySelector("#hide-playlist").remove();
-			if(hiddenPlaylist) document.querySelector("main").style.maxWidth = "";
-			hiddenPlaylist = false;
-		        document.getElementById("volume-button").removeEventListener("click", Playercontrols.mute_video);
-                        document.getElementById("playpause").removeEventListener("click", Playercontrols.play_pause);
-                        document.getElementById("fullscreen").removeEventListener("click", Playercontrols.fullscreen);
-                    }
-                    Channel.listeners(false);
-                    if(Helper.mobilecheck() || user_auth_avoid) {
-                        video_id   = "";
-                        song_title = "";
-                    }
-
-                    document.querySelectorAll("meta[name=theme-color]")[0].setAttribute("content", "#2D2D2D");
-
-                    if(!Helper.mobilecheck() && !user_auth_avoid){
-                        Helper.removeElement("#playbar");
-                        Helper.removeElement("#main_components");
-                        Helper.addClass("#player_overlay", "player_bottom");
-                        Helper.addClass("#player", "player_bottom");
-                        Helper.addClass(".video-container", "frontpage-player");
-                        Helper.addClass("#main-row", "frontpage_modified_heights");
-                        Helper.css("#player", "opacity", "1");
-                        Helper.removeClass("#video-container", "no-opacity");
-                        document.getElementById("main-row").insertAdjacentHTML("afterbegin", "
";
                 //M.Modal.getInstance(document.getElementById("channel-share-modal")).open();
                 if(!Helper.mobilecheck()) {
@@ -248,110 +324,119 @@ var Channel = {
                     }, 10000);
                 }
             }*/
-        } else {
-            Helper.removeElement(".video-container");
-            Helper.removeElement(".offline-panel");
-            Helper.removeElement(".remote-panel");
-            Helper.removeElement(".mobile-remote-panel");
-            Helper.removeElement(".import-panel");
-            Helper.removeElement(".export-panel");
-        }
-        if(no_socket || Helper.mobilecheck()){
-            emit_list();
-        }
+    } else {
+      Helper.removeElement(".video-container");
+      Helper.removeElement(".offline-panel");
+      Helper.removeElement(".remote-panel");
+      Helper.removeElement(".mobile-remote-panel");
+      Helper.removeElement(".import-panel");
+      Helper.removeElement(".export-panel");
+    }
+    if (no_socket || Helper.mobilecheck()) {
+      emit_list();
+    }
 
-        if(!Helper.mobilecheck()) {
-            if(!client) {
-                Helper.tooltip("#chan", {
-                    delay: 5,
-                    position: "bottom",
-                    html: "Show join URL",
-                });
-            }
+    if (!Helper.mobilecheck()) {
+      if (!client) {
+        Helper.tooltip("#chan", {
+          delay: 5,
+          position: "bottom",
+          html: "Show join URL"
+        });
+      }
 
-            Helper.tooltip("#viewers", {
-                delay: 5,
-                position: "top",
-                html: "Viewers"
-            });
+      Helper.tooltip("#viewers", {
+        delay: 5,
+        position: "top",
+        html: "Viewers"
+      });
 
-            Helper.tooltip("#addToOtherList", {
-                delay: 5,
-                position: "top",
-                html: "Add to other playlist"
-            });
+      Helper.tooltip("#addToOtherList", {
+        delay: 5,
+        position: "top",
+        html: "Add to other playlist"
+      });
 
-            Helper.tooltip("#fullscreen", {
-                delay: 5,
-                position: "top",
-                html: "Fullscreen"
-            });
+      Helper.tooltip("#fullscreen", {
+        delay: 5,
+        position: "top",
+        html: "Fullscreen"
+      });
 
-            Helper.tooltip(".search-btn-container", {
-                delay: 5,
-                position: "bottom",
-                html: "Search"
-            });
+      Helper.tooltip(".search-btn-container", {
+        delay: 5,
+        position: "bottom",
+        html: "Search"
+      });
 
+      Helper.tooltip(".shuffle-btn-container", {
+        delay: 5,
+        position: "bottom",
+        html: "Shuffle"
+      });
 
-            Helper.tooltip(".shuffle-btn-container", {
-                delay: 5,
-                position: "bottom",
-                html: "Shuffle",
-            });
+      Helper.tooltip("#settings", {
+        delay: 5,
+        position: "bottom",
+        html: "Settings"
+      });
+    }
 
-            Helper.tooltip("#settings", {
-                delay: 5,
-                position: "bottom",
-                html: "Settings",
-            });
-        }
+    if (!client) {
+      window.onYouTubeIframeAPIReady = Player.onYouTubeIframeAPIReady;
+      if (
+        Player.player === "" ||
+        Player.player === undefined ||
+        Helper.mobilecheck()
+      )
+        Player.loadPlayer();
+    } else {
+      Player.loadSoundCloudPlayer();
+    }
+    //}
 
-        if(!client) {
-            window.onYouTubeIframeAPIReady = Player.onYouTubeIframeAPIReady;
-            if(Player.player === "" || Player.player === undefined || Helper.mobilecheck()) Player.loadPlayer();
-        } else {
-            Player.loadSoundCloudPlayer();
-        }
-        //}
+    if (Helper.mobilecheck()) {
+      if (!client) {
+        Mobile_remote.initiate_volume();
+      }
+      Helper.addClass(".close-settings", "hide");
+    } else {
+      if (!client) {
+        Channel.window_width_volume_slider();
+      }
+    }
 
-        if(Helper.mobilecheck()) {
-            if(!client) {
-                Mobile_remote.initiate_volume();
-            }
-                Helper.addClass(".close-settings", "hide");
-        } else {
-            if(!client) {
-                Channel.window_width_volume_slider();
-            }
-        }
+    setup_admin_listener();
+    setup_list_listener();
+    if (!client) {
+      setup_chat_listener();
+      get_history();
+    }
+    if (client || Helper.mobilecheck()) {
+      get_list_ajax();
+      get_np_ajax();
+    }
 
-        setup_admin_listener();
-        setup_list_listener();
-        if(!client) {
-            setup_chat_listener();
-            get_history();
-        }
-        if(client || Helper.mobilecheck()){
-            get_list_ajax();
-            get_np_ajax();
+    try {
+      if (
+        !Helper.msieversion() &&
+        !Helper.mobilecheck() &&
+        !client &&
+        Notification != undefined
+      )
+        Notification.requestPermission();
+    } catch (e) {}
+    document.getElementsByClassName("search_input")[0].focus();
 
-        }
+    Helper.sample();
+    if (!Helper.mobilecheck() && !client) {
+      Helper.tooltip(".castButton", {
+        delay: 5,
+        position: "top",
+        html: "Cast Zoff to TV"
+      });
 
-	try {
-        	if(!Helper.msieversion() && !Helper.mobilecheck() && !client && Notification != undefined) Notification.requestPermission();
-	}catch(e){}
-        document.getElementsByClassName("search_input")[0].focus();
-
-        Helper.sample();
-        if(!Helper.mobilecheck() && !client) {
-            Helper.tooltip('.castButton', {
-                delay: 5,
-                position: "top",
-                html: "Cast Zoff to TV"
-            });
-
-            /*$("#color_embed").spectrum({
+      /*$("#color_embed").spectrum({
                 color: "#808080",
                 change: function(c) {
                     color = c.toHexString().substring(1); // #ff0000
@@ -363,383 +448,513 @@ var Channel = {
                 },
             });*/
 
-            /*Helper.addClass(".sp-choose", "hide");
+      /*Helper.addClass(".sp-choose", "hide");
             Helper.addClass(".sp-cancel", "btn-flat waves-effect waves-red");
             Helper.removeClass(".sp-cancel", "sp-cancel");
             document.getElementsByClassName("sp-button-container")[0].insertAdjacentHTML("beforeend", "CHOOSE");
             */
-        }
+    }
 
-        addListener("click", ".sp-choose-link", function(e) {
-            event.preventDefault();
-            document.getElementsByClassName("sp-choose")[0].click();
-        });
+    addListener("click", ".sp-choose-link", function(e) {
+      event.preventDefault();
+      document.getElementsByClassName("sp-choose")[0].click();
+    });
 
-        //$("#results" ).hover( function() { Helper.removeClass(".result", "hoverResults"); i = 0; }, function(){ });
-        document.getElementById("search").focus();
-        Helper.css("#embed-button", "display", "inline-block");
-        document.getElementById("search").setAttribute("placeholder", "Search...");
+    //$("#results" ).hover( function() { Helper.removeClass(".result", "hoverResults"); i = 0; }, function(){ });
+    document.getElementById("search").focus();
+    Helper.css("#embed-button", "display", "inline-block");
+    document.getElementById("search").setAttribute("placeholder", "Search...");
 
-        if(!client) {
-            Helper.addClass("footer", "padding-bottom-novideo");
-            document.getElementById("embed-area").value = embed_code(embed_autoplay, embed_width, embed_height, color, embed_videoonly, embed_localmode);
-        }
+    if (!client) {
+      Helper.addClass("footer", "padding-bottom-novideo");
+      document.getElementById("embed-area").value = embed_code(
+        embed_autoplay,
+        embed_width,
+        embed_height,
+        color,
+        embed_videoonly,
+        embed_localmode
+      );
+    }
 
-        if(!/chrom(e|ium)/.test(navigator.userAgent.toLowerCase()) && !Helper.mobilecheck() && !client){
-            Helper.css(".castButton", "display", "none");
-        }
+    if (
+      !/chrom(e|ium)/.test(navigator.userAgent.toLowerCase()) &&
+      !Helper.mobilecheck() &&
+      !client
+    ) {
+      Helper.css(".castButton", "display", "none");
+    }
 
-        Helper.log(["chromecastAvailable " + chromecastAvailable, "chromecastReady " + chromecastReady]);
+    Helper.log([
+      "chromecastAvailable " + chromecastAvailable,
+      "chromecastReady " + chromecastReady
+    ]);
 
-        if(chromecastAvailable && !client){
-            hide_native(1);
-        } else if(chromecastReady && !client) {
+    if (chromecastAvailable && !client) {
+      hide_native(1);
+    } else if (chromecastReady && !client) {
+      initializeCastApi();
+    } else if (!client) {
+      window["__onGCastApiAvailable"] = function(loaded, errorInfo) {
+        if (loaded) {
+          setTimeout(function() {
+            chromecastReady = true;
             initializeCastApi();
-        } else if(!client){
-            window['__onGCastApiAvailable'] = function(loaded, errorInfo) {
-                if (loaded) {
-                    setTimeout(function(){
-                        chromecastReady = true;
-                        initializeCastApi();
-                    }, 1000);
-                } else {
-                    chromecastReady = true;
-                }
-            }
-        }
-        Channel.listeners(true);
-        Channel.add_context_menu();
-
-        if(!Helper.mobilecheck() && navigator.userAgent.match(/iPad/i) == null){
-            setTimeout(function(){Channel.set_title_width();}, 100);
-        }
-    },
-
-    set_title_width: function(start){
-        if(window.innerWidth > 600){
-            var add_width = document.getElementsByClassName("brand-logo")[0].offsetWidth
-            if(start){
-                add_width = window.innerWidth * 0.15;
-            }
-            var test_against_width = window.innerWidth - document.getElementsByClassName("control-list")[0].offsetWidth - add_width - 11;
-            title_width = test_against_width;
-            document.getElementsByClassName("title-container")[0].style.width = title_width + "px";
+          }, 1000);
         } else {
-            document.getElementsByClassName("title-container")[0].style.width = "100%";
+          chromecastReady = true;
         }
-    },
+      };
+    }
+    Channel.listeners(true);
+    Channel.add_context_menu();
 
-    spotify_is_authenticated: function(bool){
-        if(bool){
-            Helper.log([
-                "Spotify is authenticated",
-                "access_token: " + access_token_data.access_token,
-                "token_type:" + access_token_data.token_type,
-                "expires_in: " + access_token_data.expires_in
-            ]);
+    if (!Helper.mobilecheck() && navigator.userAgent.match(/iPad/i) == null) {
+      setTimeout(function() {
+        Channel.set_title_width();
+      }, 100);
+    }
+  },
 
-            Helper.css(".spotify_authenticated", "display", "block");
-            Helper.css(".spotify_unauthenticated", "display", "none");
-        } else {
-            Helper.log(["Spotify is not authenticated"]);
-            Helper.css(".spotify_authenticated", "display", "none");
-            Helper.css(".spotify_unauthenticated", "display", "flex");
+  set_title_width: function(start) {
+    if (window.innerWidth > 600) {
+      var add_width = document.getElementsByClassName("brand-logo")[0]
+        .offsetWidth;
+      if (start) {
+        add_width = window.innerWidth * 0.15;
+      }
+      var test_against_width =
+        window.innerWidth -
+        document.getElementsByClassName("control-list")[0].offsetWidth -
+        add_width -
+        11;
+      title_width = test_against_width;
+      document.getElementsByClassName("title-container")[0].style.width =
+        title_width + "px";
+    } else {
+      document.getElementsByClassName("title-container")[0].style.width =
+        "100%";
+    }
+  },
+
+  spotify_is_authenticated: function(bool) {
+    if (bool) {
+      Helper.log([
+        "Spotify is authenticated",
+        "access_token: " + access_token_data.access_token,
+        "token_type:" + access_token_data.token_type,
+        "expires_in: " + access_token_data.expires_in
+      ]);
+
+      Helper.css(".spotify_authenticated", "display", "block");
+      Helper.css(".spotify_unauthenticated", "display", "none");
+    } else {
+      Helper.log(["Spotify is not authenticated"]);
+      Helper.css(".spotify_authenticated", "display", "none");
+      Helper.css(".spotify_unauthenticated", "display", "flex");
+    }
+  },
+
+  add_context_menu: function() {
+    addListener("contextmenu", ".vote-container", function(e) {
+      if (hostMode) {
+        return;
+      }
+      this.preventDefault();
+      this.preventDefault();
+      var that = this;
+      contextListener(e, that);
+    });
+
+    addListener("contextmenu", ".add-suggested", function(e) {
+      this.preventDefault();
+      var that = this;
+      contextListener(e, that);
+    });
+
+    addListener("click", ".list-remove", function(e) {
+      this.preventDefault();
+      var that = this;
+      contextListener(e, that);
+    });
+  },
+
+  share_link_modifier: function() {
+    document
+      .getElementById("facebook-code-link")
+      .setAttribute(
+        "href",
+        "https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/" +
+          chan.toLowerCase()
+      );
+    document
+      .getElementById("facebook-code-link")
+      .setAttribute(
+        "onclick",
+        "window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/" +
+          chan.toLowerCase() +
+          "', 'Share Playlist','width=600,height=300'); return false;"
+      );
+    document
+      .getElementById("twitter-code-link")
+      .setAttribute(
+        "href",
+        "https://twitter.com/intent/tweet?url=https://zoff.me/" +
+          chan.toLowerCase() +
+          "&text=Check%20out%20this%20playlist%20" +
+          chan.toLowerCase() +
+          "%20on%20Zoff!&via=zoffmusic"
+      );
+    document
+      .getElementById("twitter-code-link")
+      .setAttribute(
+        "onclick",
+        "window.open('https://twitter.com/intent/tweet?url=https://zoff.me/" +
+          chan.toLowerCase() +
+          "/&text=Check%20out%20this%20playlist%20" +
+          chan.toLowerCase() +
+          "%20on%20Zoff!&via=zoffmusic','Share Playlist','width=600,height=300'); return false;"
+      );
+  },
+
+  window_width_volume_slider: function() {
+    if (window.innerWidth <= 600 && slider_type == "horizontal") {
+      slider_type = "vertical";
+      Playercontrols.initSlider();
+    } else if (window.innerWidth > 600 && slider_type == "vertical") {
+      slider_type = "horizontal";
+      Playercontrols.initSlider();
+      Helper.removeClass(".volume-container", "hide");
+    }
+  },
+
+  listeners: function(on) {
+    var scrollListener = function(e) {
+      if (!programscroll) {
+        userscroll = true;
+        if (
+          document.getElementById("chatchannel").scrollTop +
+            document.getElementById("chatchannel").offsetHeight >=
+          document.getElementById("chatchannel").scrollHeight
+        ) {
+          userscroll = false;
         }
-    },
-
-    add_context_menu: function() {
-        addListener("contextmenu", ".vote-container", function(e) {
-            if(hostMode) {
-                return;
-            }
-            this.preventDefault();
-            this.preventDefault();
-            var that = this;
-            contextListener(e, that);
-        });
-
-        addListener("contextmenu", ".add-suggested", function(e) {
-            this.preventDefault();
-            var that = this;
-            contextListener(e, that);
-        });
-
-        addListener("click", ".list-remove", function(e) {
-            this.preventDefault();
-            var that = this;
-            contextListener(e, that);
-        });
-    },
-
-    share_link_modifier: function(){
-        document.getElementById("facebook-code-link").setAttribute("href", "https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/" + chan.toLowerCase());
-        document.getElementById("facebook-code-link").setAttribute("onclick", "window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/" + chan.toLowerCase() + "', 'Share Playlist','width=600,height=300'); return false;");
-        document.getElementById("twitter-code-link").setAttribute("href", "https://twitter.com/intent/tweet?url=https://zoff.me/" + chan.toLowerCase() + "&text=Check%20out%20this%20playlist%20" + chan.toLowerCase() + "%20on%20Zoff!&via=zoffmusic");
-        document.getElementById("twitter-code-link").setAttribute("onclick", "window.open('https://twitter.com/intent/tweet?url=https://zoff.me/" + chan.toLowerCase() + "/&text=Check%20out%20this%20playlist%20" + chan.toLowerCase() + "%20on%20Zoff!&via=zoffmusic','Share Playlist','width=600,height=300'); return false;");
-    },
-
-    window_width_volume_slider: function() {
-        if(window.innerWidth <= 600 && slider_type == "horizontal") {
-            slider_type = "vertical";
-            Playercontrols.initSlider();
-        } else if(window.innerWidth > 600 && slider_type == "vertical") {
-            slider_type = "horizontal";
-            Playercontrols.initSlider();
-            Helper.removeClass(".volume-container", "hide");
+      }
+    };
+    var scrollAllListener = function(e) {
+      if (!programscroll) {
+        userscroll = true;
+        if (
+          document.getElementById("chatall").scrollTop +
+            document.getElementById("chatall").offsetHeight >=
+          document.getElementById("chatall").scrollHeight
+        ) {
+          userscroll = false;
         }
-    },
+      }
+    };
+    if (!client) {
+      if (on) {
+        document
+          .getElementById("chatchannel")
+          .addEventListener("scroll", scrollListener);
+        document
+          .getElementById("chatall")
+          .addEventListener("scroll", scrollListener);
+      } else {
+        document
+          .getElementById("chatchannel")
+          .removeEventListener("scroll", scrollListener);
+        document
+          .getElementById("chatall")
+          .removeEventListener("scroll", scrollAllListener);
+      }
+    }
+  },
 
-    listeners: function(on) {
-        var scrollListener = function(e) {
-            if(!programscroll) {
-                userscroll = true;
-                if(document.getElementById("chatchannel").scrollTop + document.getElementById("chatchannel").offsetHeight >= document.getElementById("chatchannel").scrollHeight) {
-                    userscroll = false;
-                }
-            }
-        }
-        var scrollAllListener = function(e) {
-            if(!programscroll) {
-                userscroll = true;
-                if(document.getElementById("chatall").scrollTop+ document.getElementById("chatall").offsetHeight >= document.getElementById("chatall").scrollHeight) {
-                    userscroll = false;
-                }
-            }
-        }
-        if(!client) {
-            if(on) {
-                document.getElementById("chatchannel").addEventListener("scroll", scrollListener);
-                document.getElementById("chatall").addEventListener("scroll", scrollListener);
-            } else {
-                document.getElementById("chatchannel").removeEventListener("scroll", scrollListener);
-                document.getElementById("chatall").removeEventListener("scroll", scrollAllListener);
-            }
-        }
-    },
+  onepage_load: function() {
+    if (changing_to_frontpage) return;
+    if (user_auth_started) {
+      clearTimeout(durationTimeout);
+      Player.stopInterval = true;
+      user_auth_avoid = true;
+      if (!Helper.mobilecheck()) {
+        Helper.tooltip(".castButton", "destroy");
+        Helper.tooltip("#viewers", "destroy");
+        Helper.tooltip("#addToOtherList", "destroy");
+        //$('.castButton-unactive').tooltip("destroy");
+        Helper.tooltip("#offline-mode", "destroy");
+        Helper.tooltip("#admin-lock", "destroy");
+      }
+    }
+    var url_split = window.location.href.split("/");
+    if (
+      url_split[3].substr(0, 1) != "#!" &&
+      url_split[3] !== "" &&
+      !(url_split.length == 5 && url_split[4].substr(0, 1) == "#")
+    ) {
+      socket.emit("change_channel", {
+        channel: channel_before_move
+      });
+      Admin.beginning = true;
 
-    onepage_load: function(){
-        if(changing_to_frontpage) return;
-        if(user_auth_started) {
-            clearTimeout(durationTimeout);
-            Player.stopInterval = true;
-            user_auth_avoid = true;
-            if(!Helper.mobilecheck()) {
-                Helper.tooltip('.castButton', "destroy");
-                Helper.tooltip("#viewers", "destroy");
-                Helper.tooltip('#addToOtherList', 'destroy');
-                //$('.castButton-unactive').tooltip("destroy");
-                Helper.tooltip("#offline-mode", "destroy");
-                Helper.tooltip('#admin-lock', "destroy");
-            }
-        }
-        var url_split = window.location.href.split("/");
-        if(url_split[3].substr(0,1) != "#!" && url_split[3] !== "" && !(url_split.length == 5 && url_split[4].substr(0,1) == "#")){
-            socket.emit("change_channel", {
-                channel: channel_before_move
-            });
-            Admin.beginning = true;
-
-            chan = url_split[3].replace("#", "");
-            document.getElementById("chan").innerHTML = Helper.upperFirst(chan);
-            var add = "";
-            w_p = true;
-            //if(private_channel) add = Crypt.getCookie("_uI") + "_";
-
-            socket.emit("list", {version: parseInt(_VERSION), channel: add + chan.toLowerCase()});
-        } else if(url_split[3] === "") {
-            /*if(client) {
+      chan = url_split[3].replace("#", "");
+      document.getElementById("chan").innerHTML = Helper.upperFirst(chan);
+      var add = "";
+      w_p = true;
+      //if(private_channel) add = Crypt.getCookie("_uI") + "_";
+      socket.emit("list", {
+        version: parseInt(_VERSION),
+        channel: add + chan.toLowerCase()
+      });
+    } else if (url_split[3] === "") {
+      /*if(client) {
                 var host = window.location.hostname.split(".");
                 window.location.hostname = host[host.length -1];
             }*/
-            Admin.display_logged_out();
-            if(hostMode) {
-                Helper.removeClass("#main-row", "fullscreened");
-                document.querySelector(".host_switch_class").checked = false
-                enable_host_mode(false);
-            }
-            var channel_before_move = chan.toLowerCase();
-            clearTimeout(timed_remove_check);
-            changing_to_frontpage = true;
-            user_change_password = false;
-            clearTimeout(width_timeout);
-            if(fireplace_initiated){
-                fireplace_initiated = false;
-                Player.fireplace.destroy();
-                Helper.css("#fireplace_player", "display", "none");
-            }
-            Helper.css("#channel-load", "display", "block");
-            window.scrollTo(0, 0);
+      Admin.display_logged_out();
+      if (hostMode) {
+        Helper.removeClass("#main-row", "fullscreened");
+        document.querySelector(".host_switch_class").checked = false;
+        enable_host_mode(false);
+      }
+      var channel_before_move = chan.toLowerCase();
+      clearTimeout(timed_remove_check);
+      changing_to_frontpage = true;
+      user_change_password = false;
+      clearTimeout(width_timeout);
+      if (fireplace_initiated) {
+        fireplace_initiated = false;
+        Player.fireplace.destroy();
+        Helper.css("#fireplace_player", "display", "none");
+      }
+      Helper.css("#channel-load", "display", "block");
+      window.scrollTo(0, 0);
 
-            //Player.stopInterval = true;
-            Admin.beginning 	 = true;
-            began 				 = false;
-            durationBegun  		 = false;
+      //Player.stopInterval = true;
+      Admin.beginning = true;
+      began = false;
+      durationBegun = false;
 
-            Helper.css("#embed-button", "display", "none");
-            if(!Helper.mobilecheck()) {
-                Helper.tooltip(".castButton", "destroy");
-                Helper.tooltip('#addToOtherList', 'destroy');
-                Helper.tooltip("#viewers", "destroy");
-                Helper.tooltip("#offline-mode", "destroy");
-                Helper.tooltip("search-btn", "destroy");
-                Helper.tooltip('#fullscreen', "destroy");
-                if(M.Tooltip.getInstance(document.getElementById("admin-lock")) != undefined) {
-                    Helper.tooltip('#admin-lock', "destroy");
-                }
-                Helper.tooltip(".search-btn-container", "destroy");
-                Helper.tooltip(".shuffle-btn-container", "destroy");
-                Helper.tooltip("#settings", "destroy");
-            }
-            Helper.removeElement("#seekToDuration");
-
-            M.Sidenav.getInstance(document.getElementsByClassName("sidenav")[0]).destroy();
-            if(!client) {
-                if(!Helper.mobilecheck()) {
-                    Helper.tooltip("#chan", "destroy");
-                }
-                var tap_1 = document.querySelectorAll(".tap-target")
-                if(tap_1.length > 0 && M.TapTarget.getInstance(tap_1[0])) {
-                    M.TapTarget.getInstance(tap_1[0]).close();
-                }
-            }
-            clearTimeout(tap_target_timeout);
-            //before_toast();
-            if(Helper.mobilecheck() || user_auth_avoid || client) {
-                Helper.log(["Removing all listeners"]);
-                //socket.emit("change_channel");
-                //removeAllListeners();
-                //socket.removeEventListener(id);
-                socket.emit("left_channel", {
-                    channel: channel_before_move
-                });
-                socket.emit("change_channel", {
-                    channel: channel_before_move
-                });
-                chan = "";
-                socket.removeEventListener("np");
-                socket.removeEventListener("id");
-                socket.removeEventListener(id);
-                //socket.disconnect();
-            }
-            socket.removeEventListener("chat.all");
-            socket.removeEventListener("chat");
-            socket.removeEventListener("conf");
-            socket.removeEventListener("pw");
-            socket.removeEventListener("toast");
-            //socket.removeEventListener("id");
-            socket.removeEventListener("channel");
-            socket.removeEventListener("auth_required");
-            socket.removeEventListener("auth_accepted");
-            socket.removeEventListener("suggested");
-            socket.removeEventListener("color");
-            socket.removeEventListener("chat_history");
-            Helper.ajax({
-                url: "/",
-                method: "GET",
-                success: function(e){
-
-                    if(!client) {
-                	document.querySelector("#hide-playlist").remove();
-			if(hiddenPlaylist) document.querySelector("main").style.maxWidth = "";
-			hiddenPlaylist = false;
-		        document.getElementById("volume-button").removeEventListener("click", Playercontrols.mute_video);
-                        document.getElementById("playpause").removeEventListener("click", Playercontrols.play_pause);
-                        document.getElementById("fullscreen").removeEventListener("click", Playercontrols.fullscreen);
-                    }
-                    Channel.listeners(false);
-                    if(Helper.mobilecheck() || user_auth_avoid) {
-                        video_id   = "";
-                        song_title = "";
-                    }
-
-                    document.querySelectorAll("meta[name=theme-color]")[0].setAttribute("content", "#2D2D2D");
-
-                    if(!Helper.mobilecheck() && !user_auth_avoid){
-                        Helper.removeElement("#playbar");
-                        Helper.removeElement("#main_components");
-                        Helper.addClass("#player_overlay", "player_bottom");
-                        Helper.addClass("#player", "player_bottom");
-                        Helper.addClass(".video-container", "frontpage-player");
-                        Helper.addClass("#main-row", "frontpage_modified_heights");
-                        Helper.css("#player", "opacity", "1");
-                        Helper.removeClass("#video-container", "no-opacity");
-                        document.getElementById("main-row").insertAdjacentHTML("afterbegin", "
");
-                        document.getElementById("player_bottom_overlay").insertAdjacentHTML("afterbegin", "close");
-                        document.getElementById("player_bottom_overlay").setAttribute("data-channel", channel_before_move.toLowerCase());
-                        Helper.removeElement("#playlist");
-                    } else {
-                        try{
-                            Player.player.destroy();
-                        } catch(error){}
-                        try {
-                            Player.soundcloud_dead = true;
-                            Player.soundcloud_player.kill();
-                        } catch(error){}
-                        Player.player = "";
-                        document.title = "Zoff";
-                    }
-
-                    var response = document.createElement("div");
-                    response.innerHTML = e;
-
-                    var newList = response.querySelector("#lists-script").innerHTML;
-                    newList = newList.trim().replace("window.lists = ", "").replace("window.lists=", "");
-                    newList = newList.substring(0, newList.length);
-                    window.lists = JSON.parse(newList);
-
-                    response.querySelector("#lists-script").remove();
-                    Helper.removeElement("#sidenav-overlay");
-                    document.getElementsByTagName("main")[0].className = "center-align container";
-                    Helper.removeClass("#main-container", "channelpage");
-                    document.getElementById("main-container").setAttribute("style", "");
-                    document.getElementsByTagName("header")[0].innerHTML = response.querySelectorAll("header")[0].outerHTML;
-
-                    document.getElementsByTagName("header")[0].insertAdjacentHTML("afterend", response.querySelectorAll(".section.mega")[0].outerHTML);
-                    //document.getElementsByTagName("header")[0].insertAdjacentHTML("afterend", response.querySelectorAll(".section.mobile-search")[0].innerHTML);
-                    if(Helper.mobilecheck() || user_auth_avoid) {
-                        document.getElementsByTagName("main")[0].innerHTML = response.querySelectorAll("main")[0].innerHTML;
-                    } else {
-                        document.getElementsByTagName("main")[0].insertAdjacentHTML("beforeend", response.querySelectorAll("#main_section_frontpage")[0].outerHTML);
-                    }
-                    Helper.removeClass(".page-footer", "padding-bottom-extra");
-                    Helper.removeClass(".page-footer", "padding-bottom-novideo");
-                    document.getElementById("favicon").setAttribute("href", "/assets/images/favicon-32x32.png");
-
-                    Helper.log(["Socket", socket]);
-                    if(document.querySelectorAll("#alreadyfp").length == 1){
-                        Frontpage.init();
-                    }else {
-                        fromChannel = true;
-                        frontpage 	= true;
-                        Frontpage.init();
-                    }
-
-                    changing_to_frontpage = false;
-
-                    if(document.querySelectorAll("#alreadychannel").length === 0 && !user_auth_avoid){
-                        document.getElementsByTagName("head")[0].insertAdjacentHTML("beforeend", " 0 && M.TapTarget.getInstance(tap_1[0])) {
+          M.TapTarget.getInstance(tap_1[0]).close();
+        }
+      }
+      clearTimeout(tap_target_timeout);
+      //before_toast();
+      if (Helper.mobilecheck() || user_auth_avoid || client) {
+        Helper.log(["Removing all listeners"]);
+        //socket.emit("change_channel");
+        //removeAllListeners();
+        //socket.removeEventListener(id);
+        socket.emit("left_channel", {
+          channel: channel_before_move
+        });
+        socket.emit("change_channel", {
+          channel: channel_before_move
+        });
+        chan = "";
+        socket.removeEventListener("np");
+        socket.removeEventListener("id");
+        socket.removeEventListener(id);
+        //socket.disconnect();
+      }
+      socket.removeEventListener("chat.all");
+      socket.removeEventListener("chat");
+      socket.removeEventListener("conf");
+      socket.removeEventListener("pw");
+      socket.removeEventListener("toast");
+      //socket.removeEventListener("id");
+      socket.removeEventListener("channel");
+      socket.removeEventListener("auth_required");
+      socket.removeEventListener("auth_accepted");
+      socket.removeEventListener("suggested");
+      socket.removeEventListener("color");
+      socket.removeEventListener("chat_history");
+      Helper.ajax({
+        url: "/",
+        method: "GET",
+        success: function(e) {
+          if (!client) {
+            document.querySelector("#hide-playlist").remove();
+            if (hiddenPlaylist)
+              document.querySelector("main").style.maxWidth = "";
+            hiddenPlaylist = false;
+            document
+              .getElementById("volume-button")
+              .removeEventListener("click", Playercontrols.mute_video);
+            document
+              .getElementById("playpause")
+              .removeEventListener("click", Playercontrols.play_pause);
+            document
+              .getElementById("fullscreen")
+              .removeEventListener("click", Playercontrols.fullscreen);
+          }
+          Channel.listeners(false);
+          if (Helper.mobilecheck() || user_auth_avoid) {
+            video_id = "";
+            song_title = "";
+          }
+
+          document
+            .querySelectorAll("meta[name=theme-color]")[0]
+            .setAttribute("content", "#2D2D2D");
+
+          if (!Helper.mobilecheck() && !user_auth_avoid) {
+            Helper.removeElement("#playbar");
+            Helper.removeElement("#main_components");
+            Helper.addClass("#player_overlay", "player_bottom");
+            Helper.addClass("#player", "player_bottom");
+            Helper.addClass(".video-container", "frontpage-player");
+            Helper.addClass("#main-row", "frontpage_modified_heights");
+            Helper.css("#player", "opacity", "1");
+            Helper.removeClass("#video-container", "no-opacity");
+            document
+              .getElementById("main-row")
+              .insertAdjacentHTML(
+                "afterbegin",
+                ""
+              );
+            document
+              .getElementById("player_bottom_overlay")
+              .insertAdjacentHTML(
+                "afterbegin",
+                "close"
+              );
+            document
+              .getElementById("player_bottom_overlay")
+              .setAttribute("data-channel", channel_before_move.toLowerCase());
+            Helper.removeElement("#playlist");
+          } else {
+            try {
+              Player.player.destroy();
+            } catch (error) {}
+            try {
+              Player.soundcloud_dead = true;
+              Player.soundcloud_player.kill();
+            } catch (error) {}
+            Player.player = "";
+            document.title = "Zoff";
+          }
+
+          var response = document.createElement("div");
+          response.innerHTML = e;
+
+          var newList = response.querySelector("#lists-script").innerHTML;
+          newList = newList
+            .trim()
+            .replace("window.lists = ", "")
+            .replace("window.lists=", "");
+          newList = newList.substring(0, newList.length);
+          window.lists = JSON.parse(newList);
+
+          response.querySelector("#lists-script").remove();
+          Helper.removeElement("#sidenav-overlay");
+          document.getElementsByTagName("main")[0].className =
+            "center-align container";
+          Helper.removeClass("#main-container", "channelpage");
+          document.getElementById("main-container").setAttribute("style", "");
+          document.getElementsByTagName(
+            "header"
+          )[0].innerHTML = response.querySelectorAll("header")[0].outerHTML;
+
+          document
+            .getElementsByTagName("header")[0]
+            .insertAdjacentHTML(
+              "afterend",
+              response.querySelectorAll(".section.mega")[0].outerHTML
+            );
+          //document.getElementsByTagName("header")[0].insertAdjacentHTML("afterend", response.querySelectorAll(".section.mobile-search")[0].innerHTML);
+          if (Helper.mobilecheck() || user_auth_avoid) {
+            document.getElementsByTagName(
+              "main"
+            )[0].innerHTML = response.querySelectorAll("main")[0].innerHTML;
+          } else {
+            document
+              .getElementsByTagName("main")[0]
+              .insertAdjacentHTML(
+                "beforeend",
+                response.querySelectorAll("#main_section_frontpage")[0]
+                  .outerHTML
+              );
+          }
+          Helper.removeClass(".page-footer", "padding-bottom-extra");
+          Helper.removeClass(".page-footer", "padding-bottom-novideo");
+          document
+            .getElementById("favicon")
+            .setAttribute("href", "/assets/images/favicon-32x32.png");
+
+          Helper.log(["Socket", socket]);
+          if (document.querySelectorAll("#alreadyfp").length == 1) {
+            Frontpage.init();
+          } else {
+            fromChannel = true;
+            frontpage = true;
+            Frontpage.init();
+          }
+
+          changing_to_frontpage = false;
+
+          if (
+            document.querySelectorAll("#alreadychannel").length === 0 &&
+            !user_auth_avoid
+          ) {
+            document
+              .getElementsByTagName("head")[0]
+              .insertAdjacentHTML(
+                "beforeend",
+                "= 10 ? true : false,
+  pride: function() {
+    return new Date().getMonth() == 5;
+  },
 
-    winter: (new Date()).getMonth() >= 10 ? true : false,
-    pride: function() {
-        return (new Date()).getMonth() == 5;
-    },
+  times_rotated: 0,
 
-    times_rotated: 0,
+  all_channels: [],
 
-    all_channels: [],
+  frontpage_function: function() {
+    frontpage = true;
 
-    frontpage_function: function() {
-        frontpage = true;
+    Helper.log(["Frontpage fetch", msg]);
 
-        Helper.log([
-            "Frontpage fetch",
-            msg
-        ]);
+    Frontpage.all_channels = window.lists;
+    var msg = window.lists;
+    delete window.lists;
+    window.lists = undefined;
+    //document.querySelector("#lists-script").remove();
+    if (msg.length == 0) {
+      //Helper.css("#preloader", "display", "none");
+      document
+        .getElementById("channel-list-container")
+        .insertAdjacentHTML("beforeend", "No channels yet
");
+    } else {
+      Frontpage.populate_channels(msg, true, false);
+    }
+    //Frontpage.set_viewers(msg.viewers);
+  },
 
-        Frontpage.all_channels = window.lists;
-        var msg = window.lists;
-        delete window.lists;
-        window.lists = undefined;
-        //document.querySelector("#lists-script").remove();
-        if(msg.length == 0) {
-            //Helper.css("#preloader", "display", "none");
-            document.getElementById("channel-list-container").insertAdjacentHTML("beforeend", "No channels yet
");
-        } else {
-            Frontpage.populate_channels(msg, true, false);
-        }
-        //Frontpage.set_viewers(msg.viewers);
-    },
+  populate_channels: function(lists, popular, set) {
+    //document.getElementById("channels").innerHTML = "";
 
-    populate_channels: function(lists, popular, set) {
-        //document.getElementById("channels").innerHTML = "";
+    var num = 0;
+    if (!set) Frontpage.add_backdrop(lists, 0);
+    else if (set) {
+      document.getElementById("channels").innerHTML = "";
+      if (popular) {
+        lists = lists.sort(
+          Helper.predicate(
+            {
+              name: "pinned",
+              reverse: true
+            },
+            {
+              name: "viewers",
+              reverse: true
+            },
+            {
+              name: "accessed",
+              reverse: true
+            },
+            {
+              name: "count",
+              reverse: true
+            }
+          )
+        );
+      } else {
+        lists = lists.sort(
+          Helper.predicate(
+            {
+              name: "viewers",
+              reverse: true
+            },
+            {
+              name: "count",
+              reverse: true
+            }
+          )
+        );
+      }
 
-        var num = 0;
-        if(!set) Frontpage.add_backdrop(lists, 0);
-        else if(set) {
-            document.getElementById("channels").innerHTML = "";
-            if(popular) {
-                lists = lists.sort(Helper.predicate({
-                    name: 'pinned',
-                    reverse: true
-                }, {
-                    name: 'viewers',
-                    reverse: true
-                }, {
-                    name: 'accessed',
-                    reverse: true
-                }, {
-                    name: 'count',
-                    reverse: true
-                }));
+      if (!Helper.mobilecheck()) {
+        clearTimeout(rotation_timeout);
+        Frontpage.add_backdrop(lists, 0);
+      }
+
+      pre_card = channel_list;
+
+      Helper.log(["Pre_card: ", pre_card]);
+
+      for (var x in lists) {
+        var chan = Helper.decodeChannelName(lists[x]._id);
+        if (num < 12 || !popular) {
+          var id = lists[x].id;
+          var viewers = lists[x].viewers;
+          var description = lists[x].description;
+          var img;
+          img =
+            "background-image:url('https://img.youtube.com/vi/" +
+            id +
+            "/hqdefault.jpg');";
+          if (lists[x].thumbnail && lists[x].thumbnail != "") {
+            img = "background-image:url('" + lists[x].thumbnail + "');";
+          }
+
+          var song_count = lists[x].count;
+          var card = document.createElement("div");
+          card.innerHTML += pre_card;
+          //card.innerHTML = card.children[0];
+          if (song_count > 3) {
+            if (lists[x].pinned == 1) {
+              card
+                .querySelector(".pin")
+                .setAttribute("style", "display:block;");
+              //card.find(".card").attr("title", "Featured list");
             } else {
-                lists = lists.sort(Helper.predicate({
-                    name: 'viewers',
-                    reverse: true
-                }, {
-                    name: 'count',
-                    reverse: true
-                }));
-            }
-
-            if(!Helper.mobilecheck()) {
-                clearTimeout(rotation_timeout);
-                Frontpage.add_backdrop(lists, 0);
-            }
-
-            pre_card = channel_list;
-
-            Helper.log([
-                "Pre_card: ",
-                pre_card
-            ]);
-
-            for(var x in lists) {
-                var chan = Helper.decodeChannelName(lists[x]._id);
-                if(num<12 || !popular) {
-                    var id = lists[x].id;
-                    var viewers = lists[x].viewers;
-                    var description = lists[x].description;
-                    var img;
-                    img = "background-image:url('https://img.youtube.com/vi/"+id+"/hqdefault.jpg');";
-                    if(lists[x].thumbnail && lists[x].thumbnail != "") {
-                        img = "background-image:url('" + lists[x].thumbnail + "');";
-                    }
-
-                    var song_count = lists[x].count;
-                    var card = document.createElement("div");
-                    card.innerHTML += pre_card;
-                    //card.innerHTML = card.children[0];
-                    if(song_count > 3) {
-                        if(lists[x].pinned == 1) {
-                            card.querySelector(".pin").setAttribute("style", "display:block;");
-                            //card.find(".card").attr("title", "Featured list");
-                        } else {
-                            /*card.find(".pin").attr("style", "display:none;");
+              /*card.find(".pin").attr("style", "display:none;");
                             card.find(".card").attr("title", "");
                             card.querySelector(".pin").remove();*/
-                        }
-                        card.querySelector(".chan-name").innerText = chan;
-                        card.querySelector(".chan-name").setAttribute("title", chan);
-                        card.querySelector(".chan-views").innerText = viewers;
-                        card.querySelector(".chan-songs").innerText = song_count;
-                        card.querySelector(".chan-bg").setAttribute("style", img);
-                        card.querySelector(".chan-link").setAttribute("href", chan + "/");
-
-                        if(description != "" && description != undefined && !Helper.mobilecheck() && description != "This list has no description") {
-                            card.querySelector(".card-title").innerText = chan;
-                            card.querySelector(".description_text").innerText = description;
-                            description = "";
-                        } else {
-                            card.querySelector(".card-reveal").remove();
-                            Helper.removeClass(card.querySelector(".card"), "sticky-action")
-                        }
-
-                        document.getElementById("channels").insertAdjacentHTML("beforeend", card.children[0].innerHTML);
-                    } else {
-                        num--;
-                    }
-
-                }
-                num++;
             }
-        }
+            card.querySelector(".chan-name").innerText = chan;
+            card.querySelector(".chan-name").setAttribute("title", chan);
+            card.querySelector(".chan-views").innerText = viewers;
+            card.querySelector(".chan-songs").innerText = song_count;
+            card.querySelector(".chan-bg").setAttribute("style", img);
+            card.querySelector(".chan-link").setAttribute("href", chan + "/");
 
-        var options_list = lists.slice();
-
-        options_list = options_list.sort(Frontpage.sortFunction_active);
-        var data = {};
-        for(var x in options_list) {
-            data[Helper.decodeChannelName(options_list[x]._id)] = null;
-        }
-        if(document.querySelectorAll(".pin").length == 1 && !Helper.mobilecheck()) {
-            Helper.tooltip(document.querySelectorAll(".pin")[0].parentElement.parentElement.parentElement, {
-                delay: 5,
-                position: "top",
-                html: "Featured playlist"
-            });
-        }
-
-        var to_autocomplete = document.querySelectorAll("input.autocomplete")[0];
-        //if(Helper.mobilecheck()) to_autocomplete = "input.mobile-search";
-
-        M.Autocomplete.init(to_autocomplete, {
-            data: data,
-            limit: 5, // The max amount of results that can be shown at once. Default: Infinity.
-            onAutocomplete: function(val) {
-                Frontpage.to_channel(Helper.encodeChannelName(val), false);
-            },
-        });
-
-        //document.getElementById("preloader").style.display = "none";
-        document.getElementById("channels").style.display = "block";
-        //Materialize.fadeInImage('#channels');
-        //$("#channels").fadeIn(800);
-        //document.getElementById("autocomplete-input").focus();
-        num = 0;
-    },
-
-    sortFunction: function(a, b) {
-        var o1 = a.viewers;
-        var o2 = b.viewers;
-
-        var p1 = a.count;
-        var p2 = b.count;
-
-        if (o1 < o2) return 1;
-        if (o1 > o2) return -1;
-        if (p1 < p2) return 1;
-        if (p1 > p2) return -1;
-        return 0;
-    },
-
-    sortFunction_active: function(a, b){
-        var o1 = a.accessed;
-        var o2 = b.accessed;
-
-        var p1 = a.count;
-        var p2 = b.count;
-
-        if (o1 < o2) return 1;
-        if (o1 > o2) return -1;
-        if (p1 < p2) return 1;
-        if (p1 > p2) return -1;
-        return 0;
-    },
-
-    getCookie: function(cname) {
-        var name = cname + "=";
-        var ca = document.cookie.split(';');
-        for(var i=0; i= list.length || i >= 20) i = 0;
-        if(list[i] == undefined) return;
-        var id = list[i].id;
-        if(Frontpage.blob_list[i] !== undefined){
-            //$(".room-namer").css("opacity", 0);
-            setTimeout(function(){
-                if(frontpage){
-                    Helper.css("#mega-background","background", "url(data:image/png;base64,"+Frontpage.blob_list[i]+")");
-                    Helper.css("#mega-background","background-size" , "cover");
-                    Helper.css("#mega-background","background-repeat" , "no-repeat");
-                    Helper.css("#mega-background","opacity", 1);
-                    document.querySelector(".autocomplete").setAttribute("placeholder", Helper.decodeChannelName(list[i]._id));
-                    //$(".room-namer").css("opacity", 1);
-                }
-            },500);
-        } else {
-            var img = new Image();
-            img.src = "/assets/images/thumbnails/"+id+".jpg";
-
-            img.onerror = function(e){ // Failed to load
-                var add = "";
-                if(window.location.hostname == "fb.zoff.me") {
-                    add = "https://zoff.me";
-                }
-                Helper.ajax({
-                    type: "POST",
-                    data: {id:id},
-                    url: add + "/api/imageblob",
-                    headers: {"Content-Type": "application/json;charset=UTF-8"},
-                    success: function(data){
-                        setTimeout(function(){
-                            try {
-                                Helper.css("#mega-background", "background", "url(/assets/images/thumbnails/"+data+")");
-                                Helper.css("#mega-background", "background-size" , "cover");
-                                Helper.css("#mega-background", "background-repeat" , "no-repeat");
-                                Helper.css("#mega-background", "opacity", 1);
-                                document.querySelector(".autocomplete").setAttribute("placeholder", Helper.decodeChannelName(list[i]._id));
-                            } catch(e) {}
-                        },500);
-                    },
-                    error: function() {
-                        try {
-                            document.querySelector(".autocomplete").setAttribute("placeholder", Helper.decodeChannelName(list[i]._id));
-                        } catch(e) {
-                            console.log("This is a weird error...", e);
-                        }
-                    }
-                });
-            };
-            img.onload = function(){ // Loaded successfully
-                try {
-                    Helper.css("#mega-background", "background", "url("+img.src+")");
-                    Helper.css("#mega-background", "background-size" , "cover");
-                    Helper.css("#mega-background", "background-repeat" , "no-repeat");
-                    Helper.css("#mega-background", "opacity", 1);
-                    document.querySelector(".autocomplete").setAttribute("placeholder", Helper.decodeChannelName(list[i]._id));
-                } catch(e) {}
-            };
-
-        }
-        rotation_timeout = setTimeout(function(){
-            if(Frontpage.times_rotated == 50 && frontpage){
-                Frontpage.times_rotated = 0;
-                i = 0;
-                //Frontpage.get_frontpage_lists();
-            }else if(frontpage){
-                Frontpage.times_rotated += 1;
-                Frontpage.add_backdrop(list, i+1);
+            if (
+              description != "" &&
+              description != undefined &&
+              !Helper.mobilecheck() &&
+              description != "This list has no description"
+            ) {
+              card.querySelector(".card-title").innerText = chan;
+              card.querySelector(".description_text").innerText = description;
+              description = "";
+            } else {
+              card.querySelector(".card-reveal").remove();
+              Helper.removeClass(card.querySelector(".card"), "sticky-action");
             }
-        },6000);
-    },
 
-    get_frontpage_lists: function() {
+            document
+              .getElementById("channels")
+              .insertAdjacentHTML("beforeend", card.children[0].innerHTML);
+          } else {
+            num--;
+          }
+        }
+        num++;
+      }
+    }
+
+    var options_list = lists.slice();
+
+    options_list = options_list.sort(Frontpage.sortFunction_active);
+    var data = {};
+    for (var x in options_list) {
+      data[Helper.decodeChannelName(options_list[x]._id)] = null;
+    }
+    if (
+      document.querySelectorAll(".pin").length == 1 &&
+      !Helper.mobilecheck()
+    ) {
+      Helper.tooltip(
+        document.querySelectorAll(".pin")[0].parentElement.parentElement
+          .parentElement,
+        {
+          delay: 5,
+          position: "top",
+          html: "Featured playlist"
+        }
+      );
+    }
+
+    var to_autocomplete = document.querySelectorAll("input.autocomplete")[0];
+    //if(Helper.mobilecheck()) to_autocomplete = "input.mobile-search";
+
+    M.Autocomplete.init(to_autocomplete, {
+      data: data,
+      limit: 5, // The max amount of results that can be shown at once. Default: Infinity.
+      onAutocomplete: function(val) {
+        Frontpage.to_channel(Helper.encodeChannelName(val), false);
+      }
+    });
+
+    //document.getElementById("preloader").style.display = "none";
+    document.getElementById("channels").style.display = "block";
+    //Materialize.fadeInImage('#channels');
+    //$("#channels").fadeIn(800);
+    //document.getElementById("autocomplete-input").focus();
+    num = 0;
+  },
+
+  sortFunction: function(a, b) {
+    var o1 = a.viewers;
+    var o2 = b.viewers;
+
+    var p1 = a.count;
+    var p2 = b.count;
+
+    if (o1 < o2) return 1;
+    if (o1 > o2) return -1;
+    if (p1 < p2) return 1;
+    if (p1 > p2) return -1;
+    return 0;
+  },
+
+  sortFunction_active: function(a, b) {
+    var o1 = a.accessed;
+    var o2 = b.accessed;
+
+    var p1 = a.count;
+    var p2 = b.count;
+
+    if (o1 < o2) return 1;
+    if (o1 > o2) return -1;
+    if (p1 < p2) return 1;
+    if (p1 > p2) return -1;
+    return 0;
+  },
+
+  getCookie: function(cname) {
+    var name = cname + "=";
+    var ca = document.cookie.split(";");
+    for (var i = 0; i < ca.length; i++) {
+      var c = ca[i];
+      while (c.charAt(0) == " ") c = c.substring(1);
+      if (c.indexOf(name) === 0) return c.substring(name.length, c.length);
+    }
+    return "";
+  },
+
+  add_backdrop: function(list, i) {
+    if (i >= list.length || i >= 20) i = 0;
+    if (list[i] == undefined) return;
+    var id = list[i].id;
+    if (Frontpage.blob_list[i] !== undefined) {
+      //$(".room-namer").css("opacity", 0);
+      setTimeout(function() {
+        if (frontpage) {
+          Helper.css(
+            "#mega-background",
+            "background",
+            "url(data:image/png;base64," + Frontpage.blob_list[i] + ")"
+          );
+          Helper.css("#mega-background", "background-size", "cover");
+          Helper.css("#mega-background", "background-repeat", "no-repeat");
+          Helper.css("#mega-background", "opacity", 1);
+          document
+            .querySelector(".autocomplete")
+            .setAttribute("placeholder", Helper.decodeChannelName(list[i]._id));
+          //$(".room-namer").css("opacity", 1);
+        }
+      }, 500);
+    } else {
+      var img = new Image();
+      img.src = "/assets/images/thumbnails/" + id + ".jpg";
+
+      img.onerror = function(e) {
+        // Failed to load
         var add = "";
-        if(window.location.hostname == "fb.zoff.me") {
-            add = "https://zoff.me";
+        if (window.location.hostname == "fb.zoff.me") {
+          add = "https://zoff.me";
         }
-        Frontpage.frontpage_function();
-        /*Helper.ajax({
+        Helper.ajax({
+          type: "POST",
+          data: { id: id },
+          url: add + "/api/imageblob",
+          headers: { "Content-Type": "application/json;charset=UTF-8" },
+          success: function(data) {
+            setTimeout(function() {
+              try {
+                Helper.css(
+                  "#mega-background",
+                  "background",
+                  "url(/assets/images/thumbnails/" + data + ")"
+                );
+                Helper.css("#mega-background", "background-size", "cover");
+                Helper.css(
+                  "#mega-background",
+                  "background-repeat",
+                  "no-repeat"
+                );
+                Helper.css("#mega-background", "opacity", 1);
+                document
+                  .querySelector(".autocomplete")
+                  .setAttribute(
+                    "placeholder",
+                    Helper.decodeChannelName(list[i]._id)
+                  );
+              } catch (e) {}
+            }, 500);
+          },
+          error: function() {
+            try {
+              document
+                .querySelector(".autocomplete")
+                .setAttribute(
+                  "placeholder",
+                  Helper.decodeChannelName(list[i]._id)
+                );
+            } catch (e) {
+              console.log("This is a weird error...", e);
+            }
+          }
+        });
+      };
+      img.onload = function() {
+        // Loaded successfully
+        try {
+          Helper.css("#mega-background", "background", "url(" + img.src + ")");
+          Helper.css("#mega-background", "background-size", "cover");
+          Helper.css("#mega-background", "background-repeat", "no-repeat");
+          Helper.css("#mega-background", "opacity", 1);
+          document
+            .querySelector(".autocomplete")
+            .setAttribute("placeholder", Helper.decodeChannelName(list[i]._id));
+        } catch (e) {}
+      };
+    }
+    rotation_timeout = setTimeout(function() {
+      if (Frontpage.times_rotated == 50 && frontpage) {
+        Frontpage.times_rotated = 0;
+        i = 0;
+        //Frontpage.get_frontpage_lists();
+      } else if (frontpage) {
+        Frontpage.times_rotated += 1;
+        Frontpage.add_backdrop(list, i + 1);
+      }
+    }, 6000);
+  },
+
+  get_frontpage_lists: function() {
+    var add = "";
+    if (window.location.hostname == "fb.zoff.me") {
+      add = "https://zoff.me";
+    }
+    Frontpage.frontpage_function();
+    /*Helper.ajax({
             url: add + "/api/frontpages",
             method: "POST",
             data: {
@@ -301,237 +353,289 @@ var Frontpage = {
                 }, 3000);
             },
         });*/
-    },
+  },
 
-    start_snowfall: function() {
-        setTimeout(function(){
-            var x = Math.floor((Math.random() * window.innerWidth) + 1);
-            var snow = document.createElement("div");
-            var parent = document.getElementsByClassName("mega")[0];
+  start_snowfall: function() {
+    setTimeout(function() {
+      var x = Math.floor(Math.random() * window.innerWidth + 1);
+      var snow = document.createElement("div");
+      var parent = document.getElementsByClassName("mega")[0];
 
-            snow.className = "snow";
-            //snow.attr("left", x);
-            snow.style.left = x+"px";
-            snow.style.top = "0px";
-            parent.appendChild(snow);
-            Frontpage.fall_snow(snow);
-            Frontpage.start_snowfall();
-        }, 800);
-    },
+      snow.className = "snow";
+      //snow.attr("left", x);
+      snow.style.left = x + "px";
+      snow.style.top = "0px";
+      parent.appendChild(snow);
+      Frontpage.fall_snow(snow);
+      Frontpage.start_snowfall();
+    }, 800);
+  },
 
-    fall_snow: function(corn) {
-        corn.style.top = (parseInt(corn.style.top.replace("px", ""))+2)+"px";
-        if(parseInt(corn.style.top.replace("px", "")) < document.getElementById("mega-background").offsetHeight-2.5){
-            setTimeout(function(){
-                Frontpage.fall_snow(corn);
-            },50);
-        }else{
-            corn.remove();
+  fall_snow: function(corn) {
+    corn.style.top = parseInt(corn.style.top.replace("px", "")) + 2 + "px";
+    if (
+      parseInt(corn.style.top.replace("px", "")) <
+      document.getElementById("mega-background").offsetHeight - 2.5
+    ) {
+      setTimeout(function() {
+        Frontpage.fall_snow(corn);
+      }, 50);
+    } else {
+      corn.remove();
+    }
+  },
+
+  set_viewers: function(viewers) {
+    document.querySelector("#frontpage-viewer-counter").innerHTML =
+      "visibility" + viewers;
+  },
+
+  to_channel: function(new_channel, popstate) {
+    Helper.css("#channel-load", "display", "block");
+    window.scrollTo(0, 0);
+    frontpage = false;
+    new_channel = new_channel.toLowerCase();
+    clearTimeout(rotation_timeout);
+    if (Helper.mobilecheck()) {
+      Helper.log(["removing all listeners"]);
+      removeAllListeners();
+    }
+    Helper.css("#main-container", "background-color", "#2d2d2d");
+    if (!Helper.mobilecheck()) {
+      Helper.tooltip("#frontpage-viewer-counter", "destroy");
+      Helper.tooltip(".generate-channel-name", "destroy");
+      Helper.tooltip("#offline-mode", "destroy");
+      Helper.tooltip("#client-mode-button", "destroy");
+      if (document.querySelectorAll(".pin").length == 1) {
+        Helper.tooltip(
+          document.querySelectorAll(".pin")[0].parentElement.parentElement
+            .parentElement,
+          "destroy"
+        );
+      }
+    }
+
+    currently_showing_channels = 1;
+    clearTimeout(retry_frontpage);
+    Helper.ajax({
+      url: "/" + new_channel,
+      method: "get",
+      data: { channel: new_channel },
+      success: function(e) {
+        if (Player.player !== "") {
+          //Player.player.destroy();
+          socket.emit("change_channel", { channel: chan.toLowerCase() });
         }
-    },
-
-    set_viewers: function(viewers) {
-        document.querySelector("#frontpage-viewer-counter").innerHTML = "visibility" + viewers;
-    },
-
-    to_channel: function(new_channel, popstate) {
-        Helper.css("#channel-load", "display", "block");
-        window.scrollTo(0, 0);
-        frontpage = false;
-        new_channel = new_channel.toLowerCase();
-        clearTimeout(rotation_timeout);
-        if(Helper.mobilecheck()){
-            Helper.log(["removing all listeners"]);
-            removeAllListeners();
+        var _player = document.querySelectorAll("#frontpage_player");
+        if (_player.length > 0) _player[0].innerHTML = "";
+        if (Helper.mobilecheck()) {
+          //Helper.log("disconnecting");
+          //socket.disconnect();
+          socket.removeAllListeners();
         }
-        Helper.css("#main-container", "background-color", "#2d2d2d");
-        if(!Helper.mobilecheck()) {
-            Helper.tooltip("#frontpage-viewer-counter", "destroy");
-            Helper.tooltip(".generate-channel-name", "destroy");
-            Helper.tooltip("#offline-mode", "destroy");
-            Helper.tooltip("#client-mode-button", "destroy");
-            if(document.querySelectorAll(".pin").length == 1) {
-                Helper.tooltip(document.querySelectorAll(".pin")[0].parentElement.parentElement.parentElement, "destroy");
-            }
+        var old_chan = chan;
+        if (!popstate) {
+          window.history.pushState(
+            "to the channel!",
+            "Title",
+            "/" + new_channel
+          );
+          if (prev_chan_list == "") prev_chan_list = new_channel;
+          if (prev_chan_player == "") prev_chan_player = new_channel;
+          chan = new_channel;
         }
 
-        currently_showing_channels = 1;
-        clearTimeout(retry_frontpage);
-        Helper.ajax({
-            url: "/" + new_channel,
-            method: "get",
-            data: {channel: new_channel},
-            success: function(e){
+        var response = document.createElement("div");
+        response.innerHTML = e;
 
-                if(Player.player !== ""){
-                    //Player.player.destroy();
-                    socket.emit("change_channel", {channel: chan.toLowerCase()});
-                }
-                var _player = document.querySelectorAll("#frontpage_player");
-                if(_player.length > 0) _player[0].innerHTML = "";
-                if(Helper.mobilecheck()) {
-                    //Helper.log("disconnecting");
-                    //socket.disconnect();
-                    socket.removeAllListeners();
-                }
-                var old_chan = chan;
-                if(!popstate){
-                    window.history.pushState("to the channel!", "Title", "/" + new_channel);
-                    if(prev_chan_list == "") prev_chan_list = new_channel;
-                    if(prev_chan_player == "") prev_chan_player = new_channel;
-                    chan = new_channel;
-                }
+        M.FormSelect.getInstance(
+          document.querySelector("#view_channels_select")
+        ).destroy();
+        //$('select').formSelect('destroy');
+        Helper.removeElement(".mega");
+        Helper.removeElement(".mobile-search");
+        document.getElementsByTagName("main")[0].className =
+          "container center-align main";
+        Helper.addClass("#main-container", "channelpage");
 
-                var response = document.createElement("div");
-                response.innerHTML = e;
+        document.getElementsByTagName(
+          "header"
+        )[0].innerHTML = response.querySelectorAll("header")[0].innerHTML;
 
-                M.FormSelect.getInstance(document.querySelector("#view_channels_select")).destroy();
-                //$('select').formSelect('destroy');
-                Helper.removeElement(".mega");
-                Helper.removeElement(".mobile-search");
-                document.getElementsByTagName("main")[0].className = "container center-align main";
-                Helper.addClass("#main-container", "channelpage");
-
-                document.getElementsByTagName("header")[0].innerHTML = response.querySelectorAll("header")[0].innerHTML;
-
-                if(document.querySelectorAll("#alreadychannel").length === 0 || Helper.mobilecheck() || Player.player === undefined){
-                    document.getElementsByTagName("main")[0].innerHTML = response.querySelectorAll("main")[0].innerHTML;
-                } else {
-                    document.getElementById("main-row").insertAdjacentHTML("beforeend", response.querySelectorAll("#playlist")[0].outerHTML);
-                    if(!client) document.getElementById("video-container").insertAdjacentHTML("beforeend", response.querySelectorAll("#main_components")[0].outerHTML);
-                    document.getElementById("main-row").insertAdjacentHTML("beforeend", "");
-                    Helper.removeClass("#player", "player_bottom");
-                    Helper.removeClass("#player_overlay", "player_bottom");
-                    Helper.removeClass(".video-container", "frontpage-player");
-                    Helper.removeClass("#main-row", "frontpage_modified_heights");
-                    Helper.removeElement("#main_section_frontpage");
-                    Helper.removeElement("#closePlayer");
-                    Helper.removeElement("#player_bottom_overlay");
-                }
-                document.getElementById("search").setAttribute("placeholder", "Search...");
-                Helper.addClass(".page-footer", "padding-bottom-novideo");
-                from_frontpage = true;
-                //Player.stopInterval =true;
-                //clearTimeout(durationTimeout);
-                if(document.querySelectorAll("#alreadychannel").length == 1){
-                    if(old_chan != new_channel) local_new_channel = true;
-                    Channel.init();
-                }else{
-                    fromFront = true;
-                    Channel.init();
-                }
-                if(document.querySelectorAll("#alreadyfp").length === 0) document.getElementsByTagName("head")[0].insertAdjacentHTML("beforeend", "");
-
-            }
-        });
-    },
-
-    init: function() {
-
-        var date = new Date();
-        Frontpage.blob_list = [];
-        if(date.getMonth() == 3 && date.getDate() == 1){
-            Helper.css(".mega", "-webkit-transform", "rotate(180deg)");
-            Helper.css(".mega", "-moz-transform", "rotate(180deg)");
-            //Materialize.toast('We suck at pranks..Agreed
', 100000);
+        if (
+          document.querySelectorAll("#alreadychannel").length === 0 ||
+          Helper.mobilecheck() ||
+          Player.player === undefined
+        ) {
+          document.getElementsByTagName(
+            "main"
+          )[0].innerHTML = response.querySelectorAll("main")[0].innerHTML;
+        } else {
+          document
+            .getElementById("main-row")
+            .insertAdjacentHTML(
+              "beforeend",
+              response.querySelectorAll("#playlist")[0].outerHTML
+            );
+          if (!client)
+            document
+              .getElementById("video-container")
+              .insertAdjacentHTML(
+                "beforeend",
+                response.querySelectorAll("#main_components")[0].outerHTML
+              );
+          document
+            .getElementById("main-row")
+            .insertAdjacentHTML("beforeend", "");
+          Helper.removeClass("#player", "player_bottom");
+          Helper.removeClass("#player_overlay", "player_bottom");
+          Helper.removeClass(".video-container", "frontpage-player");
+          Helper.removeClass("#main-row", "frontpage_modified_heights");
+          Helper.removeElement("#main_section_frontpage");
+          Helper.removeElement("#closePlayer");
+          Helper.removeElement("#player_bottom_overlay");
         }
-
-        if(window.location.hostname != "localhost") {
-            var page = window.location.pathname;
-            if(page.substring(page.length - 1) != "/") page += "/";
-            ga('send', 'pageview', page);
+        document
+          .getElementById("search")
+          .setAttribute("placeholder", "Search...");
+        Helper.addClass(".page-footer", "padding-bottom-novideo");
+        from_frontpage = true;
+        //Player.stopInterval =true;
+        //clearTimeout(durationTimeout);
+        if (document.querySelectorAll("#alreadychannel").length == 1) {
+          if (old_chan != new_channel) local_new_channel = true;
+          Channel.init();
+        } else {
+          fromFront = true;
+          Channel.init();
         }
+        if (document.querySelectorAll("#alreadyfp").length === 0)
+          document
+            .getElementsByTagName("head")[0]
+            .insertAdjacentHTML("beforeend", "");
+      }
+    });
+  },
 
-        window.onpopstate = function(e){
-            var url_split = window.location.href.split("/");
+  init: function() {
+    var date = new Date();
+    Frontpage.blob_list = [];
+    if (date.getMonth() == 3 && date.getDate() == 1) {
+      Helper.css(".mega", "-webkit-transform", "rotate(180deg)");
+      Helper.css(".mega", "-moz-transform", "rotate(180deg)");
+      //Materialize.toast('We suck at pranks..Agreed
', 100000);
+    }
 
-            if(url_split[3] !== "" && url_split[3].substring(0,1) != "#"){
-                Frontpage.to_channel(url_split[3], true);
-            }
-        };
+    if (window.location.hostname != "localhost") {
+      var page = window.location.pathname;
+      if (page.substring(page.length - 1) != "/") page += "/";
+      ga("send", "pageview", page);
+    }
 
-        if(window.location.hostname == "fb.zoff.me") {
-            Helper.addClass("footer", "hide");
+    window.onpopstate = function(e) {
+      var url_split = window.location.href.split("/");
+      console.log(url_split);
+      if (url_split[3] !== "" && url_split[3].substring(0, 1) != "#") {
+        Frontpage.to_channel(url_split[3], true);
+      }
+    };
+
+    if (window.location.hostname == "fb.zoff.me") {
+      Helper.addClass("footer", "hide");
+    }
+
+    channel_list = document
+      .querySelector(".hidden-channel-list")
+      .cloneNode(true).innerHTML;
+    try {
+      document.querySelector(".hidden-channel-list").remove();
+    } catch (e) {}
+
+    Frontpage.share_link_modifier();
+
+    if (
+      window.location.hostname == "zoff.me" ||
+      window.location.hostname == "fb.zoff.me"
+    )
+      add = "https://zoff.me";
+    else add = window.location.hostname;
+    if (socket === undefined) {
+      no_socket = false;
+      if (window.location.port != "") {
+        add = add + ":" + window.location.port + "/";
+      }
+      socket = io.connect(
+        "" + add,
+        connection_options
+      );
+      socket.on("update_required", function(msg) {
+        if (window.location.hostname == "localhost") {
+          console.log(msg);
+          return;
         }
+        window.location.reload(true);
+      });
+    }
+    if (
+      document.querySelectorAll("#alreadyfp").length === 0 ||
+      Helper.mobilecheck() ||
+      !socket._callbacks.$playlists ||
+      user_auth_avoid
+    ) {
+      setup_playlist_listener();
+    }
 
-        channel_list = document.querySelector(".hidden-channel-list").cloneNode(true).innerHTML;
-        try {
-            document.querySelector(".hidden-channel-list").remove();
-        }catch(e){}
-
-        Frontpage.share_link_modifier();
-
-        if(window.location.hostname == "zoff.me" || window.location.hostname == "fb.zoff.me") add = "https://zoff.me";
-        else add = window.location.hostname;
-        if(socket === undefined) {
-            no_socket = false;
-            socket = io.connect(''+add, connection_options);
-            socket.on('update_required', function(msg) {
-                if(window.location.hostname == "localhost") {
-                    console.log(msg);
-                    return;
-                }
-                window.location.reload(true);
-            });
-        }
-        if(document.querySelectorAll("#alreadyfp").length === 0 || Helper.mobilecheck() || !socket._callbacks.$playlists || user_auth_avoid){
-            setup_playlist_listener();
-        }
-
-        /*M.Modal.init(document.getElementById("about"));
+    /*M.Modal.init(document.getElementById("about"));
         M.Modal.init(document.getElementById("help"));
         M.Modal.init(document.getElementById("contact"));*/
-        var elem = document.querySelector('select');
-        document.querySelector(".no-jump-select").remove();
-        M.FormSelect.init(elem);
+    var elem = document.querySelector("select");
+    document.querySelector(".no-jump-select").remove();
+    M.FormSelect.init(elem);
 
-        Helper.log([
-            "Sending frontpage_lists",
-            "Socket"
-        ]);
+    Helper.log(["Sending frontpage_lists", "Socket"]);
 
-        Crypt.init();
-        if(Crypt.get_offline()){
-            change_offline(true, offline);
-        } else {
-            if(!Helper.mobilecheck()) {
-                Helper.tooltip("#offline-mode", {
-                    delay: 5,
-                    position: "bottom",
-                    html: "Enable local mode"
-                });
-            }
-        }
-        if(!Helper.mobilecheck()) {
-            Helper.tooltip("#frontpage-viewer-counter", {
-                delay: 5,
-                position: "bottom",
-                html: "Total Viewers"
-            });
-            Helper.tooltip("#client-mode-button", {
-                delay: 5,
-                position: "bottom",
-                html: "Client mode"
-            });
-            Helper.tooltip(".generate-channel-name", {
-                delay: 5,
-                position: "bottom",
-                html: "Generate name"
-            });
-        }
-        Frontpage.get_frontpage_lists();
+    Crypt.init();
+    if (Crypt.get_offline()) {
+      change_offline(true, offline);
+    } else {
+      if (!Helper.mobilecheck()) {
+        Helper.tooltip("#offline-mode", {
+          delay: 5,
+          position: "bottom",
+          html: "Enable local mode"
+        });
+      }
+    }
+    if (!Helper.mobilecheck()) {
+      Helper.tooltip("#frontpage-viewer-counter", {
+        delay: 5,
+        position: "bottom",
+        html: "Total Viewers"
+      });
+      Helper.tooltip("#client-mode-button", {
+        delay: 5,
+        position: "bottom",
+        html: "Client mode"
+      });
+      Helper.tooltip(".generate-channel-name", {
+        delay: 5,
+        position: "bottom",
+        html: "Generate name"
+      });
+    }
+    Frontpage.get_frontpage_lists();
 
-        Helper.css("#channel-load", "display", "none");
-        //Materialize.toast("Try out our new feature, remote!", 8000)
-        if(window.location.hash == "#donation") {
-            window.location.hash = "#";
-            M.Modal.init(document.getElementById("donation"));;
-            M.Modal.getInstance(document.getElementById("donation")).open();
-        }
+    Helper.css("#channel-load", "display", "none");
+    //Materialize.toast("Try out our new feature, remote!", 8000)
+    if (window.location.hash == "#donation") {
+      window.location.hash = "#";
+      M.Modal.init(document.getElementById("donation"));
+      M.Modal.getInstance(document.getElementById("donation")).open();
+    }
 
-        //var pad = 0;
+    //var pad = 0;
 
-        /*$(".zicon").on("click", function(e) {
+    /*$(".zicon").on("click", function(e) {
             e.preventDefault();
 
             pad += 10;
@@ -540,35 +644,57 @@ var Frontpage = {
             window.location.href = 'http://etys.no';
         });*/
 
-        if(!Helper.mobilecheck() && Frontpage.winter) {
-            document.getElementsByClassName("mega")[0].insertAdjacentHTML("afterbegin", '');
-        }
-        if(Frontpage.pride()) {
-            Helper.addClass("#fp-nav", "pride-background");
-        }
-
-        if(Helper.mobilecheck()){
-            //$('input#autocomplete-input').characterCounter();
-        }
-
-        window['__onGCastApiAvailable'] = function(loaded, errorInfo) {
-            if (loaded) {
-                chromecastReady = true;
-            } else {
-            }
-        }
-    },
-
-    share_link_modifier: function() {
-        document.getElementById("facebook-code-link").setAttribute("href", "https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/");
-        document.getElementById("facebook-code-link").setAttribute("onclick", "window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/', 'Share Zoff','width=600,height=300'); return false;");
-        document.getElementById("twitter-code-link").setAttribute("href", "https://twitter.com/intent/tweet?url=https://zoff.me/&text=Check%20out%20Zoff!&via=zoffmusic");
-        document.getElementById("twitter-code-link").setAttribute("onclick", "window.open('https://twitter.com/intent/tweet?url=https://zoff.me/&text=Check%20out%20Zoff!&via=zoffmusic','Share Playlist','width=600,height=300'); return false;");
-        //$("#qr-code-link").attr("href", "//chart.googleapis.com/chart?chs=500x500&cht=qr&chl=https://zoff.me/&choe=UTF-8&chld=L%7C1");
-        //$("#qr-code-image-link").attr("src", "//chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https://zoff.me/&choe=UTF-8&chld=L%7C1");
+    if (!Helper.mobilecheck() && Frontpage.winter) {
+      document
+        .getElementsByClassName("mega")[0]
+        .insertAdjacentHTML("afterbegin", '');
     }
+    if (Frontpage.pride()) {
+      Helper.addClass("#fp-nav", "pride-background");
+    }
+
+    if (Helper.mobilecheck()) {
+      //$('input#autocomplete-input').characterCounter();
+    }
+
+    window["__onGCastApiAvailable"] = function(loaded, errorInfo) {
+      if (loaded) {
+        chromecastReady = true;
+      } else {
+      }
+    };
+  },
+
+  share_link_modifier: function() {
+    document
+      .getElementById("facebook-code-link")
+      .setAttribute(
+        "href",
+        "https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/"
+      );
+    document
+      .getElementById("facebook-code-link")
+      .setAttribute(
+        "onclick",
+        "window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/', 'Share Zoff','width=600,height=300'); return false;"
+      );
+    document
+      .getElementById("twitter-code-link")
+      .setAttribute(
+        "href",
+        "https://twitter.com/intent/tweet?url=https://zoff.me/&text=Check%20out%20Zoff!&via=zoffmusic"
+      );
+    document
+      .getElementById("twitter-code-link")
+      .setAttribute(
+        "onclick",
+        "window.open('https://twitter.com/intent/tweet?url=https://zoff.me/&text=Check%20out%20Zoff!&via=zoffmusic','Share Playlist','width=600,height=300'); return false;"
+      );
+    //$("#qr-code-link").attr("href", "//chart.googleapis.com/chart?chs=500x500&cht=qr&chl=https://zoff.me/&choe=UTF-8&chld=L%7C1");
+    //$("#qr-code-image-link").attr("src", "//chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https://zoff.me/&choe=UTF-8&chld=L%7C1");
+  }
 };
 
 String.prototype.capitalizeFirstLetter = function() {
-    return this.charAt(0).toUpperCase() + this.slice(1);
+  return this.charAt(0).toUpperCase() + this.slice(1);
 };
diff --git a/server/public/assets/js/functions.js b/server/public/assets/js/functions.js
index 1cf5e38a..b1b15894 100644
--- a/server/public/assets/js/functions.js
+++ b/server/public/assets/js/functions.js
@@ -1,1430 +1,1961 @@
-
 function removeAllListeners() {
-    Helper.log(["Removing all listeners"]);
-    socket.removeEventListener("chat.all");
-    socket.removeEventListener("chat");
-    socket.removeEventListener("conf");
-    socket.removeEventListener("pw");
-    socket.removeEventListener("toast");
-    socket.removeEventListener("id");
-    socket.removeEventListener("channel");
-    socket.removeEventListener("np");
-    socket.removeEventListener("get_list");
-    //socket.removeEventListener("self_ping");
-    socket.removeEventListener("viewers");
-    socket.removeEventListener("auth_required");
-    socket.removeEventListener("auth_accepted");
-    socket.removeEventListener("suggested");
-    socket.removeEventListener("color");
-    socket.removeEventListener("chat_history");
-    //socket.removeEventListener("name");
-    socket.removeEventListener(id);
+  Helper.log(["Removing all listeners"]);
+  socket.removeEventListener("chat.all");
+  socket.removeEventListener("chat");
+  socket.removeEventListener("conf");
+  socket.removeEventListener("pw");
+  socket.removeEventListener("toast");
+  socket.removeEventListener("id");
+  socket.removeEventListener("channel");
+  socket.removeEventListener("np");
+  socket.removeEventListener("get_list");
+  //socket.removeEventListener("self_ping");
+  socket.removeEventListener("viewers");
+  socket.removeEventListener("auth_required");
+  socket.removeEventListener("auth_accepted");
+  socket.removeEventListener("suggested");
+  socket.removeEventListener("color");
+  socket.removeEventListener("chat_history");
+  //socket.removeEventListener("name");
+  socket.removeEventListener(id);
 }
 
 function list_last_logs() {
-    console.log(JSON.stringify(Helper.logs));
+  console.log(JSON.stringify(Helper.logs));
 }
 
 function filterPlaylistElements(page) {
-    var value = document.getElementById("filtersearch_input").value;
-    var search_type = document.querySelector(".category-advanced-select").value;
-    if(search_type != "category" && search_type != "title") {
-        document.querySelector(".filter-results").innerHTML = "Something went wrong with fetching data..";
-        return;
-    }
-    if(value == "") return;
-    Helper.ajax({
-        type: "POST",
-        headers: {
-            "Content-Type": "application/json"
-        },
-        url: "/api/search/" + chan.toLowerCase(),
-        data: {
-            searchQuery: value,
-            page: page,
-            type: search_type
-        },
-        success: function(data){
-            var json = JSON.parse(data);
-            document.querySelector(".filter-results").innerHTML = "";
-            if(json.results.search_results.length > 0) {
-                addFilterButtons("top", json);
-                for(var i = 0; i < json.results.search_results.length; i++) {
-                    document.querySelector(".filter-results").innerHTML += List.generateSong(json.results.search_results[i], false, false, true, false, "block", false, true);;
-                }
-                addFilterButtons("bottom", json);
-            } else {
-                toast("Couldn't find any items with those tags..", "red");
-                document.querySelector(".filter-results").innerHTML = "Couldn't find any items with those tags..";
-            }
-        },
-        error: function(e) {
-            if(e.status != 429) {
-                toast("Couldn't find any items with those tags..", "red");
-
-                document.querySelector(".filter-results").innerHTML = "Couldn't find any items with those tags..";
-            } else {
-                toast("You are doing that too much..", "red");
-            }
+  var value = document.getElementById("filtersearch_input").value;
+  var search_type = document.querySelector(".category-advanced-select").value;
+  if (search_type != "category" && search_type != "title") {
+    document.querySelector(".filter-results").innerHTML =
+      "Something went wrong with fetching data..";
+    return;
+  }
+  if (value == "") return;
+  Helper.ajax({
+    type: "POST",
+    headers: {
+      "Content-Type": "application/json"
+    },
+    url: "/api/search/" + chan.toLowerCase(),
+    data: {
+      searchQuery: value,
+      page: page,
+      type: search_type
+    },
+    success: function(data) {
+      var json = JSON.parse(data);
+      document.querySelector(".filter-results").innerHTML = "";
+      if (json.results.search_results.length > 0) {
+        addFilterButtons("top", json);
+        for (var i = 0; i < json.results.search_results.length; i++) {
+          document.querySelector(
+            ".filter-results"
+          ).innerHTML += List.generateSong(
+            json.results.search_results[i],
+            false,
+            false,
+            true,
+            false,
+            "block",
+            false,
+            true
+          );
         }
-    });
+        addFilterButtons("bottom", json);
+      } else {
+        toast("Couldn't find any items with those tags..", "red");
+        document.querySelector(".filter-results").innerHTML =
+          "Couldn't find any items with those tags..";
+      }
+    },
+    error: function(e) {
+      if (e.status != 429) {
+        toast("Couldn't find any items with those tags..", "red");
+
+        document.querySelector(".filter-results").innerHTML =
+          "Couldn't find any items with those tags..";
+      } else {
+        toast("You are doing that too much..", "red");
+      }
+    }
+  });
 }
 
 function addFilterButtons(position, json) {
-    if(json.results.next != undefined || json.results.prev != undefined) {
-        document.querySelector(".filter-results").innerHTML += ""
-        if(json.results.prev != undefined) {
-            document.querySelector("." + position + "-filter-container").innerHTML += "Prev";
-        } else {
-            document.querySelector("." + position + "-filter-container").innerHTML += "Prev";
-        }
-        if(json.results.next != undefined) {
-            document.querySelector("." + position + "-filter-container").innerHTML += "Next";
-        } else {
-            document.querySelector("." + position + "-filter-container").innerHTML += "Next";
-        }
+  if (json.results.next != undefined || json.results.prev != undefined) {
+    document.querySelector(".filter-results").innerHTML +=
+      "";
+    if (json.results.prev != undefined) {
+      document.querySelector("." + position + "-filter-container").innerHTML +=
+        "Prev";
+    } else {
+      document.querySelector("." + position + "-filter-container").innerHTML +=
+        "Prev";
     }
+    if (json.results.next != undefined) {
+      document.querySelector("." + position + "-filter-container").innerHTML +=
+        "Next";
+    } else {
+      document.querySelector("." + position + "-filter-container").innerHTML +=
+        "Next";
+    }
+  }
 }
 
 function say_updated() {
-    setTimeout(function() {
-        before_toast();
-        M.toast({html: "The list was updated, want to refresh?  yesno", displayLength: 10000000});
-    }, 500);
+  setTimeout(function() {
+    before_toast();
+    M.toast({
+      html:
+        "The list was updated, want to refresh?  yesno",
+      displayLength: 10000000
+    });
+  }, 500);
 }
 
 function sendDescription() {
-    emit("suggest_description", {channel: chan, description: document.getElementById("description_input").value});
-    document.getElementById("description_input").value = "";
+  emit("suggest_description", {
+    channel: chan,
+    description: document.getElementById("description_input").value
+  });
+  document.getElementById("description_input").value = "";
 }
 
 function sendThumbnail() {
-    emit("suggest_thumbnail", {channel: chan, thumbnail: document.getElementById("thumbnail_input").value});
-    document.getElementById("thumbnail_input").value = "";
+  emit("suggest_thumbnail", {
+    channel: chan,
+    thumbnail: document.getElementById("thumbnail_input").value
+  });
+  document.getElementById("thumbnail_input").value = "";
 }
 
 function sendRules() {
-    emit("suggest_rules", {channel: chan, rules: document.getElementById("rules_input").value});
-    document.getElementById("rules_input").value = "";
+  emit("suggest_rules", {
+    channel: chan,
+    rules: document.getElementById("rules_input").value
+  });
+  document.getElementById("rules_input").value = "";
 }
 
 function resizeFunction() {
-    if(chan && !Helper.mobilecheck()){
-        if(document.querySelector("#wrapper") == null) return;
-        if(!client && !embed) document.querySelector("#hide-playlist").style.left = (document.querySelector("#video-container").offsetWidth - document.querySelector("#hide-playlist").offsetWidth) + "px";
-        if(((window.innerWidth > 600 && !embed) || (window.innerWidth > 500 && embed)) && document.querySelector("#wrapper").style.height != "") {
-            document.querySelector("#wrapper").style.height = "";
-            document.querySelector("#chat-bar").style.height = "";
-            document.querySelector("#channelchat").style.height = "";
-            document.querySelector("#all_chat").style.height = "";
-            document.querySelector("#chat-container").style.height = "";
-        } else if(((window.innerWidth < 601 && !embed) || (window.innerWidth < 501 && embed))) {
-            if(!client && !embed) {
-                var scPlaying = false;
-                var ytPlaying = false;
-                if(scUsingWidget) {
-                    Player.soundcloud_player.isPaused(function(paused) {
-                        try {
-                            ytPlaying = Player.player.getPlayerState() == YT.PlayerState.PLAYING || Player.player.getPlayerState() == YT.PlayerState.BUFFERING;
-                        } catch(e) {}
-                        scPlaying = !paused;
-                        resizePlaylistPlaying(ytPlaying || scPlaying, true);
-                        return;
-                    })
-                } else {
-                    try {
-                        ytPlaying = Player.player.getPlayerState() == YT.PlayerState.PLAYING || Player.player.getPlayerState() == YT.PlayerState.BUFFERING;
-                    } catch(e) {}
-                    try {
-                        scPlaying = Player.soundcloud_player.isPlaying();
-                    } catch(e){}
-                    resizePlaylistPlaying(ytPlaying || scPlaying, true);
-                }
-                return;
-            }
-        }
-        var temp_fit;
-
-        if(!embed && !client){
-            temp_fit = Math.round(Helper.computedStyle("#wrapper", "height") / 71);
-            List.element_height = (Helper.computedStyle("#wrapper", "height") / temp_fit)-5.3;
-        } else if(embed) {
-            temp_fit = Math.round(Helper.computedStyle("#wrapper", "height") / 91) + 1;
-            List.element_height = (Helper.computedStyle("#wrapper", "height") / temp_fit)-4;
-        } else if(!client){
-            temp_fit = Math.round((Helper.computedStyle(".tabs", "height") - Helper.computedStyle("header", "height") - 64 - 40) / 71)+1;
-            List.element_height = ((window.innerHeight - Helper.computedStyle(".tabs", "height") - Helper.computedStyle("header", "height") - 64 - 40) / temp_fit)-5;
+  if (chan && !Helper.mobilecheck()) {
+    if (document.querySelector("#wrapper") == null) return;
+    if (!client && !embed)
+      document.querySelector("#hide-playlist").style.left =
+        document.querySelector("#video-container").offsetWidth -
+        document.querySelector("#hide-playlist").offsetWidth +
+        "px";
+    if (
+      ((window.innerWidth > 600 && !embed) ||
+        (window.innerWidth > 500 && embed)) &&
+      document.querySelector("#wrapper").style.height != ""
+    ) {
+      document.querySelector("#wrapper").style.height = "";
+      document.querySelector("#chat-bar").style.height = "";
+      document.querySelector("#channelchat").style.height = "";
+      document.querySelector("#all_chat").style.height = "";
+      document.querySelector("#chat-container").style.height = "";
+    } else if (
+      (window.innerWidth < 601 && !embed) ||
+      (window.innerWidth < 501 && embed)
+    ) {
+      if (!client && !embed) {
+        var scPlaying = false;
+        var ytPlaying = false;
+        if (scUsingWidget) {
+          Player.soundcloud_player.isPaused(function(paused) {
+            try {
+              ytPlaying =
+                Player.player.getPlayerState() == YT.PlayerState.PLAYING ||
+                Player.player.getPlayerState() == YT.PlayerState.BUFFERING;
+            } catch (e) {}
+            scPlaying = !paused;
+            resizePlaylistPlaying(ytPlaying || scPlaying, true);
+            return;
+          });
         } else {
-            temp_fit = Math.round(Helper.computedStyle("#wrapper", "height") / 71)+1;
-            List.element_height = (Helper.computedStyle("#wrapper", "height") / temp_fit)-5.3;
-        }
-        if(List.element_height < 55.2 && !client && !embed){
-            temp_fit = temp_fit - 1;
-            List.element_height = 55.2;
-            temp_fit = Math.round((window.innerHeight - Helper.computedStyle(".tabs", "height") - Helper.computedStyle("header", "height") - 64 - 40) / 71);
-            List.element_height = ((window.innerHeight - Helper.computedStyle(".tabs", "height") - Helper.computedStyle("header", "height") - 64 - 40) / temp_fit)-5;
-        } else if(List.element_height < 55.2 && embed) {
-            //List.can_fit = List.can_fit - 1;
-            temp_fit = Math.round((window.innerHeight - Helper.computedStyle(".tabs", "height") - Helper.computedStyle("header", "height") - 64 - 40) / 71);
-            List.element_height = ((window.innerHeight - Helper.computedStyle(".tabs", "height") - Helper.computedStyle("header", "height") - 64 - 40) / temp_fit)-5;
-            temp_fit = temp_fit - 2;
-        }
-        if(temp_fit > List.can_fit || temp_fit < List.can_fit){
-            List.dynamicContentPage(-10);
-        }
-        if(List.can_fit < temp_fit){
-            for(var i = 0; i < List.page + temp_fit; i++) {
-                Helper.css(document.querySelector("#wrapper").children[i], "display", "inline-flex");
-            }
-        } else if(List.can_fit > temp_fit){
-            Helper.css(document.querySelector("#wrapper").children[List.page + temp_fit], "display", "none");
-            var elements = document.querySelector("#wrapper").children;
-            for(var i = List.page + temp_fit; i < elements.length; i++) {
-                Helper.css(document.querySelector("#wrapper").children[i], "display", "none");
-            }
-        }
-        List.can_fit = temp_fit;
-        //List.element_height = (Helper.computedStyle("#wrapper", "height") / List.can_fit)-5.3;
-        Helper.css(".list-song", "height", List.element_height + "px");
-        Channel.set_title_width();
-        if(!client) {
-            var controlsPosition = document.querySelector("#controls").offsetHeight - Helper.computedStyle("#controls", "height");
-            if(document.querySelectorAll("#controls").length > 0 && !Helper.mobilecheck()) {
-                Helper.css(document.querySelector("#seekToDuration"), "top", controlsPosition - 55);
-            } else if(document.querySelectorAll("#controls").length > 0) {
-                Helper.css(document.querySelector("#seekToDuration"), "top", controlsPosition - 20);
-            }
-            Channel.window_width_volume_slider();
+          try {
+            ytPlaying =
+              Player.player.getPlayerState() == YT.PlayerState.PLAYING ||
+              Player.player.getPlayerState() == YT.PlayerState.BUFFERING;
+          } catch (e) {}
+          try {
+            scPlaying = Player.soundcloud_player.isPlaying();
+          } catch (e) {}
+          resizePlaylistPlaying(ytPlaying || scPlaying, true);
         }
+        return;
+      }
     }
+    var temp_fit;
+
+    if (!embed && !client) {
+      temp_fit = Math.round(Helper.computedStyle("#wrapper", "height") / 71);
+      List.element_height =
+        Helper.computedStyle("#wrapper", "height") / temp_fit - 5.3;
+    } else if (embed) {
+      temp_fit =
+        Math.round(Helper.computedStyle("#wrapper", "height") / 91) + 1;
+      List.element_height =
+        Helper.computedStyle("#wrapper", "height") / temp_fit - 4;
+    } else if (!client) {
+      temp_fit =
+        Math.round(
+          (Helper.computedStyle(".tabs", "height") -
+            Helper.computedStyle("header", "height") -
+            64 -
+            40) /
+            71
+        ) + 1;
+      List.element_height =
+        (window.innerHeight -
+          Helper.computedStyle(".tabs", "height") -
+          Helper.computedStyle("header", "height") -
+          64 -
+          40) /
+          temp_fit -
+        5;
+    } else {
+      temp_fit =
+        Math.round(Helper.computedStyle("#wrapper", "height") / 71) + 1;
+      List.element_height =
+        Helper.computedStyle("#wrapper", "height") / temp_fit - 5.3;
+    }
+    if (List.element_height < 55.2 && !client && !embed) {
+      temp_fit = temp_fit - 1;
+      List.element_height = 55.2;
+      temp_fit = Math.round(
+        (window.innerHeight -
+          Helper.computedStyle(".tabs", "height") -
+          Helper.computedStyle("header", "height") -
+          64 -
+          40) /
+          71
+      );
+      List.element_height =
+        (window.innerHeight -
+          Helper.computedStyle(".tabs", "height") -
+          Helper.computedStyle("header", "height") -
+          64 -
+          40) /
+          temp_fit -
+        5;
+    } else if (List.element_height < 55.2 && embed) {
+      //List.can_fit = List.can_fit - 1;
+      temp_fit = Math.round(
+        (window.innerHeight -
+          Helper.computedStyle(".tabs", "height") -
+          Helper.computedStyle("header", "height") -
+          64 -
+          40) /
+          71
+      );
+      List.element_height =
+        (window.innerHeight -
+          Helper.computedStyle(".tabs", "height") -
+          Helper.computedStyle("header", "height") -
+          64 -
+          40) /
+          temp_fit -
+        5;
+      temp_fit = temp_fit - 2;
+    }
+    if (temp_fit > List.can_fit || temp_fit < List.can_fit) {
+      List.dynamicContentPage(-10);
+    }
+    if (List.can_fit < temp_fit) {
+      for (var i = 0; i < List.page + temp_fit; i++) {
+        Helper.css(
+          document.querySelector("#wrapper").children[i],
+          "display",
+          "inline-flex"
+        );
+      }
+    } else if (List.can_fit > temp_fit) {
+      Helper.css(
+        document.querySelector("#wrapper").children[List.page + temp_fit],
+        "display",
+        "none"
+      );
+      var elements = document.querySelector("#wrapper").children;
+      for (var i = List.page + temp_fit; i < elements.length; i++) {
+        Helper.css(
+          document.querySelector("#wrapper").children[i],
+          "display",
+          "none"
+        );
+      }
+    }
+    List.can_fit = temp_fit;
+    //List.element_height = (Helper.computedStyle("#wrapper", "height") / List.can_fit)-5.3;
+    Helper.css(".list-song", "height", List.element_height + "px");
+    Channel.set_title_width();
+    if (!client) {
+      var controlsPosition =
+        document.querySelector("#controls").offsetHeight -
+        Helper.computedStyle("#controls", "height");
+      if (
+        document.querySelectorAll("#controls").length > 0 &&
+        !Helper.mobilecheck()
+      ) {
+        Helper.css(
+          document.querySelector("#seekToDuration"),
+          "top",
+          controlsPosition - 55
+        );
+      } else if (document.querySelectorAll("#controls").length > 0) {
+        Helper.css(
+          document.querySelector("#seekToDuration"),
+          "top",
+          controlsPosition - 20
+        );
+      }
+      Channel.window_width_volume_slider();
+    }
+  }
 }
 
 function fullVideo(hide) {
-    if(hide) {
-        document.querySelector("#playlist").className += " show-only-mobile";
-        document.querySelector("#video-container").classList.remove("m9");
-        document.querySelector("#video-container").className += " m12";
-        document.querySelector("main").style.maxWidth = "100%";
-        document.querySelector("#hide-playlist").style.left = (document.querySelector("#video-container").offsetWidth - document.querySelector("#hide-playlist").offsetWidth) + "px";
-        document.querySelector("#hide-playlist .material-icons").innerText = "keyboard_arrow_left";
-    } else {
-        document.querySelector("#playlist").classList.remove("show-only-mobile");
-        document.querySelector("#video-container").classList.remove("m12");
-        document.querySelector("#video-container").className += " m9";
-        document.querySelector("main").style.maxWidth = "";
-        document.querySelector("#hide-playlist").style.left = (document.querySelector("#video-container").offsetWidth - document.querySelector("#hide-playlist").offsetWidth) + "px";
-        document.querySelector("#hide-playlist .material-icons").innerText = "keyboard_arrow_right";
-    }
-    hiddenPlaylist = hide;
+  if (hide) {
+    document.querySelector("#playlist").className += " show-only-mobile";
+    document.querySelector("#video-container").classList.remove("m9");
+    document.querySelector("#video-container").className += " m12";
+    document.querySelector("main").style.maxWidth = "100%";
+    document.querySelector("#hide-playlist").style.left =
+      document.querySelector("#video-container").offsetWidth -
+      document.querySelector("#hide-playlist").offsetWidth +
+      "px";
+    document.querySelector("#hide-playlist .material-icons").innerText =
+      "keyboard_arrow_left";
+  } else {
+    document.querySelector("#playlist").classList.remove("show-only-mobile");
+    document.querySelector("#video-container").classList.remove("m12");
+    document.querySelector("#video-container").className += " m9";
+    document.querySelector("main").style.maxWidth = "";
+    document.querySelector("#hide-playlist").style.left =
+      document.querySelector("#video-container").offsetWidth -
+      document.querySelector("#hide-playlist").offsetWidth +
+      "px";
+    document.querySelector("#hide-playlist .material-icons").innerText =
+      "keyboard_arrow_right";
+  }
+  hiddenPlaylist = hide;
 }
 
 function getColor(id) {
-    Helper.ajax({
-        method: "POST",
-        url: "/api/color",
-        headers: {"Content-Type": "application/json;charset=UTF-8"},
-        data: JSON.stringify({
-            id: id
-        }),
-        success: function(c) {
-            c = JSON.parse(c);
-            if(typeof(c) == "object") {
-                Player.setBGimage({color:c, only:true});
-            }
-        },
-    });
+  Helper.ajax({
+    method: "POST",
+    url: "/api/color",
+    headers: { "Content-Type": "application/json;charset=UTF-8" },
+    data: JSON.stringify({
+      id: id
+    }),
+    success: function(c) {
+      c = JSON.parse(c);
+      if (typeof c == "object") {
+        Player.setBGimage({ color: c, only: true });
+      }
+    }
+  });
 }
 
 function hide_native(way) {
-    if(way == 1){
-        Helper.addClass('.castButton', 'castButton-white-active');
-        if(!Helper.mobilecheck()) {
-            if(M.Tooltip.getInstance(document.getElementsByClassName("castButton")[0])) {
-                Helper.tooltip('.castButton', 'destroy');
-            }
-            Helper.tooltip('.castButton', {
-                delay: 5,
-                position: "top",
-                html: "Stop casting"
-            });
-        }
-        Helper.toggleClass("#duration", "hide");
-        Helper.toggleClass("#fullscreen", "hide");
-        try{
-            if(videoSource == "youtube") {
-                Player.player.stopVideo();
-            } else if(videoSource == "soundcloud") {
-                Player.soundcloud_player.pause();
-            }
-        } catch(e){}
-        //clearTimeout(durationTimeout);
-        Player.stopInterval = true;
-        if(Helper.mobilecheck()){
-            if(document.querySelector("#pause").classList.contains("hide")){
-                Helper.toggleClass("#play", "hide");
-                Helper.toggleClass("#pause", "hide");
-            } else if(document.querySelector("#play").classList.contains("hide")){
-                Helper.toggleClass("#play", "hide");
-                Helper.toggleClass("#pause", "hide");
-            }
-        } else {
-            Playercontrols.visualVolume(100);
-        }
-        if(Helper.mobilecheck()) {
-            Helper.addClass("#player_overlay", "hide")
-            Helper.css("#player_overlay", "display", "none");
-            Helper.css("#playing_on", "display", "none");
-        } else {
-            var thisThumbnail;
-            if(Player.np.thumbnail == undefined) thisThumbnail = "https://img.youtube.com/vi/" + video_id + "/hqdefault.jpg";
-            else thisThumbnail = Player.np.thumbnail;
-            Helper.removeClass("#player_overlay", "hide");
-            Helper.css("#player_overlay", "display", "block");
-            Helper.css("#player_overlay", "background", "url(" + thisThumbnail + ")");
-            Helper.css("#player_overlay", "background-position", "center");
-            Helper.css("#player_overlay", "background-size", "100%");
-            Helper.css("#player_overlay", "background-color", "black");
-            Helper.css("#player_overlay", "background-repeat", "no-repeat");
-            Helper.css("#playing_on", "display", "flex");
-            Helper.setHtml("#chromecast_text", "Playing on
" + castSession.getCastDevice().friendlyName);
-        }
-        Player.player.setVolume(100);
-        if(scUsingWidget) Player.soundcloud_player.setVolume(100);
-        else Player.soundcloud_player.setVolume(1);
-
-        Helper.addClass("#player_overlay_text", "hide");
-    } else if(way == 0){
-        if(!Helper.mobilecheck()) {
-            if(M.Tooltip.getInstance(document.getElementsByClassName("castButton")[0])) {
-                Helper.tooltip('.castButton', 'destroy');
-            }
-            Helper.tooltip('.castButton', {
-                delay: 5,
-                position: "top",
-                html: "Cast Zoff to TV"
-            });
-        }
-        Helper.removeClass('.castButton', 'castButton-white-active');
-
-        Helper.toggleClass("#duration", "hide");
-        Helper.toggleClass("#fullscreen", "hide");
-        if(videoSource == "youtube") {
-            Player.player.playVideo();
-        } else if(videoSource == "soundcloud") {
-            Player.soundcloud_player.play();
-        }
-        Player.stopInterval = false;
-        duration = Player.player.getDuration();
-        Player.durationSetter();
-        if(!Helper.mobilecheck()){
-            Player.player.setVolume(Crypt.get_volume());
-            Playercontrols.visualVolume(Crypt.get_volume());
-            if(scUsingWidget) Player.soundcloud_player.setVolume(embed ? 1 : Crypt.get_volume());
-            else Player.soundcloud_player.setVolume(embed ? 1 : Crypt.get_volume() / 100);
-        }
-        Helper.addClass("#player_overlay", "hide");
-        Helper.removeClass("#player_overlay_text", "hide");
-        Helper.setHtml("#chromecast_text", "");
-        Helper.css("#playing_on", "display", "none");
-        if(!offline){
-            socket.emit('pos', {channel: chan.toLowerCase()});
-        } else {
-            Player.loadVideoById(video_id);
-        }
+  if (way == 1) {
+    Helper.addClass(".castButton", "castButton-white-active");
+    if (!Helper.mobilecheck()) {
+      if (
+        M.Tooltip.getInstance(document.getElementsByClassName("castButton")[0])
+      ) {
+        Helper.tooltip(".castButton", "destroy");
+      }
+      Helper.tooltip(".castButton", {
+        delay: 5,
+        position: "top",
+        html: "Stop casting"
+      });
     }
+    Helper.toggleClass("#duration", "hide");
+    Helper.toggleClass("#fullscreen", "hide");
+    try {
+      if (videoSource == "youtube") {
+        Player.player.stopVideo();
+      } else if (videoSource == "soundcloud") {
+        Player.soundcloud_player.pause();
+      }
+    } catch (e) {}
+    //clearTimeout(durationTimeout);
+    Player.stopInterval = true;
+    if (Helper.mobilecheck()) {
+      if (document.querySelector("#pause").classList.contains("hide")) {
+        Helper.toggleClass("#play", "hide");
+        Helper.toggleClass("#pause", "hide");
+      } else if (document.querySelector("#play").classList.contains("hide")) {
+        Helper.toggleClass("#play", "hide");
+        Helper.toggleClass("#pause", "hide");
+      }
+    } else {
+      Playercontrols.visualVolume(100);
+    }
+    if (Helper.mobilecheck()) {
+      Helper.addClass("#player_overlay", "hide");
+      Helper.css("#player_overlay", "display", "none");
+      Helper.css("#playing_on", "display", "none");
+    } else {
+      var thisThumbnail;
+      if (Player.np.thumbnail == undefined)
+        thisThumbnail =
+          "https://img.youtube.com/vi/" + video_id + "/hqdefault.jpg";
+      else thisThumbnail = Player.np.thumbnail;
+      Helper.removeClass("#player_overlay", "hide");
+      Helper.css("#player_overlay", "display", "block");
+      Helper.css("#player_overlay", "background", "url(" + thisThumbnail + ")");
+      Helper.css("#player_overlay", "background-position", "center");
+      Helper.css("#player_overlay", "background-size", "100%");
+      Helper.css("#player_overlay", "background-color", "black");
+      Helper.css("#player_overlay", "background-repeat", "no-repeat");
+      Helper.css("#playing_on", "display", "flex");
+      Helper.setHtml(
+        "#chromecast_text",
+        "Playing on
" + castSession.getCastDevice().friendlyName
+      );
+    }
+    Player.player.setVolume(100);
+    if (scUsingWidget) Player.soundcloud_player.setVolume(100);
+    else Player.soundcloud_player.setVolume(1);
+
+    Helper.addClass("#player_overlay_text", "hide");
+  } else if (way == 0) {
+    if (!Helper.mobilecheck()) {
+      if (
+        M.Tooltip.getInstance(document.getElementsByClassName("castButton")[0])
+      ) {
+        Helper.tooltip(".castButton", "destroy");
+      }
+      Helper.tooltip(".castButton", {
+        delay: 5,
+        position: "top",
+        html: "Cast Zoff to TV"
+      });
+    }
+    Helper.removeClass(".castButton", "castButton-white-active");
+
+    Helper.toggleClass("#duration", "hide");
+    Helper.toggleClass("#fullscreen", "hide");
+    if (videoSource == "youtube") {
+      Player.player.playVideo();
+    } else if (videoSource == "soundcloud") {
+      Player.soundcloud_player.play();
+    }
+    Player.stopInterval = false;
+    duration = Player.player.getDuration();
+    Player.durationSetter();
+    if (!Helper.mobilecheck()) {
+      Player.player.setVolume(Crypt.get_volume());
+      Playercontrols.visualVolume(Crypt.get_volume());
+      if (scUsingWidget)
+        Player.soundcloud_player.setVolume(embed ? 1 : Crypt.get_volume());
+      else
+        Player.soundcloud_player.setVolume(
+          embed ? 1 : Crypt.get_volume() / 100
+        );
+    }
+    Helper.addClass("#player_overlay", "hide");
+    Helper.removeClass("#player_overlay_text", "hide");
+    Helper.setHtml("#chromecast_text", "");
+    Helper.css("#playing_on", "display", "none");
+    if (!offline) {
+      socket.emit("pos", { channel: chan.toLowerCase() });
+    } else {
+      Player.loadVideoById(video_id);
+    }
+  }
 }
 
 function chromecastListener(evt, data) {
-    var json_parsed = JSON.parse(data);
-    switch(json_parsed.type){
-        case -1:
-        if(offline){
-            Player.playNext();
-        } else {
-            socket.emit("end", {id: json_parsed.videoId, channel: chan.toLowerCase()});
-        }
-        break;
-        case 0:
-        if(offline){
-            Player.playNext();
-        } else {
-            emit("skip", {error: json_parsed.data_code, id: json_parsed.videoId, channel: chan.toLowerCase()});
-        }
-        break;
-        case 1:
-        Helper.addClass("#play", "hide");
-        Helper.removeClass("#pause", "hide");
-        break;
-        case 2:
-        Helper.addClass("#pause", "hide");
-        Helper.removeClass("#play", "hide");
-        break;
-    }
+  var json_parsed = JSON.parse(data);
+  switch (json_parsed.type) {
+    case -1:
+      if (offline) {
+        Player.playNext();
+      } else {
+        socket.emit("end", {
+          id: json_parsed.videoId,
+          channel: chan.toLowerCase()
+        });
+      }
+      break;
+    case 0:
+      if (offline) {
+        Player.playNext();
+      } else {
+        emit("skip", {
+          error: json_parsed.data_code,
+          id: json_parsed.videoId,
+          channel: chan.toLowerCase()
+        });
+      }
+      break;
+    case 1:
+      Helper.addClass("#play", "hide");
+      Helper.removeClass("#pause", "hide");
+      break;
+    case 2:
+      Helper.addClass("#pause", "hide");
+      Helper.removeClass("#play", "hide");
+      break;
+  }
 }
 
 function start_auth() {
-    if(!user_auth_started) {
-        user_auth_started = true;
-        Helper.removeClass("#player_overlay", "hide");
-        Helper.css("#player_overlay", "display", "block");
-        M.Modal.getInstance(document.getElementById("user_password")).open();
-        document.querySelector("#user-pass-input").focus();
-        //Crypt.remove_userpass(chan.toLowerCase());
-        before_toast();
-        M.toast({html: "That is not the correct password, try again..", displayLength: 4000});
-    }
+  if (!user_auth_started) {
+    user_auth_started = true;
+    Helper.removeClass("#player_overlay", "hide");
+    Helper.css("#player_overlay", "display", "block");
+    M.Modal.getInstance(document.getElementById("user_password")).open();
+    document.querySelector("#user-pass-input").focus();
+    //Crypt.remove_userpass(chan.toLowerCase());
+    before_toast();
+    M.toast({
+      html: "That is not the correct password, try again..",
+      displayLength: 4000
+    });
+  }
 }
 
 function emit_list() {
-    var add = "";
-    //if(private_channel) add = Crypt.getCookie("_uI") + "_";
-    /*var p = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
+  var add = "";
+  //if(private_channel) add = Crypt.getCookie("_uI") + "_";
+  /*var p = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
     if(p == undefined) p = "";*/
-    if(socket.id) {
-        socket.emit("list", {version: parseInt(_VERSION), channel: add + chan.toLowerCase()});
-    } else {
-        setTimeout(function(){
-            emit_list();
-        }, 50);
-    }
+  if (socket.id) {
+    socket.emit("list", {
+      version: parseInt(_VERSION),
+      channel: add + chan.toLowerCase()
+    });
+  } else {
+    setTimeout(function() {
+      emit_list();
+    }, 50);
+  }
 }
 
 function get_list_ajax() {
-    //var c = Crypt.get_userpass(chan.toLowerCase());
-    Helper.ajax({
-        type: "POST",
-        data: {
-            userpass: "",
-            token: zoff_api_token,
-        },
-        headers: {"Content-Type": "application/json;charset=UTF-8"},
-        url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()),
-        success: function(response) {
-            response = JSON.parse(response);
-            if(response.results.length > 0) {
-                if(response.status == 403) {
-                    start_auth();
-                } else if(response.status == 404) return;
-                if(client) {
-                    Helper.removeElement("#channel-load");
-                }
-                List.populate_list(response.results);
-            }
-        },
-        error: function(response) {
-            //response = JSON.parse(response);
-            if(response.status == 403) {
-                start_auth();
-            } else if(response.status == 429) {
-                setTimeout(function() {
-                    get_list_ajax();
-                }, xmlhttp.getResponseHeader("Retry-After") * 1000)
-            } else if(response.status == 404) return;
-            if(client) {
-                Helper.removeElement("#channel-load");
-            }
-            //List.populate_list(response.responseJSON.results);
+  //var c = Crypt.get_userpass(chan.toLowerCase());
+  Helper.ajax({
+    type: "POST",
+    data: {
+      userpass: "",
+      token: zoff_api_token
+    },
+    headers: { "Content-Type": "application/json;charset=UTF-8" },
+    url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()),
+    success: function(response) {
+      response = JSON.parse(response);
+      if (response.results.length > 0) {
+        if (response.status == 403) {
+          start_auth();
+        } else if (response.status == 404) return;
+        if (client) {
+          Helper.removeElement("#channel-load");
         }
-    });
+        List.populate_list(response.results);
+      }
+    },
+    error: function(response) {
+      //response = JSON.parse(response);
+      if (response.status == 403) {
+        start_auth();
+      } else if (response.status == 429) {
+        setTimeout(function() {
+          get_list_ajax();
+        }, xmlhttp.getResponseHeader("Retry-After") * 1000);
+      } else if (response.status == 404) return;
+      if (client) {
+        Helper.removeElement("#channel-load");
+      }
+      //List.populate_list(response.responseJSON.results);
+    }
+  });
 }
 
 function contextListener(that, event) {
-    var parent = that.parentElement;
-    var suggested = false;
-    if(parent.id.indexOf("suggested-") > -1) suggested = true;
-    document.getElementsByClassName("context-menu-root")[0].setAttribute("data-suggested", suggested);
-    document.getElementsByClassName("context-menu-root")[0].setAttribute("data-id", parent.getAttribute("id").replace("suggested-", ""));
-    document.getElementsByClassName("context-menu-root")[0].setAttribute("data-source", parent.getAttribute("data-video-source"));
-    Helper.removeClass("#context-menu-overlay", "hide");
-    var left = event.pageX - document.querySelector(".context-menu-root").offsetWidth / 2;
-    var top = event.pageY;
-    if(left + 200 > window.innerWidth) {
-        left = window.innerWidth - 200 - 15;
-    } else if (left < 0) {
-        left = 11;
-    }
-    if(top + 96 > window.innerHeight) {
-        top = window.innerHeight - 96 - 15;
-    } else if(top < 0) {
-        top = 15;
-    }
-    if(parent.getAttribute("data-video-source") == "soundcloud") {
-        Helper.addClass(".find-context-menu", "context-menu-disabled");
-    } else {
-        Helper.removeClass(".find-context-menu", "context-menu-disabled");
-    }
-    Helper.css(".context-menu-root", "left", left + "px");
-    Helper.css(".context-menu-root", "top", top + "px");
-    Helper.removeClass(".context-menu-root","hide");
-    if(!Helper.mobilecheck()) {
-        mouseContext(left, top);
-    }
+  var parent = that.parentElement;
+  var suggested = false;
+  if (parent.id.indexOf("suggested-") > -1) suggested = true;
+  document
+    .getElementsByClassName("context-menu-root")[0]
+    .setAttribute("data-suggested", suggested);
+  document
+    .getElementsByClassName("context-menu-root")[0]
+    .setAttribute(
+      "data-id",
+      parent.getAttribute("id").replace("suggested-", "")
+    );
+  document
+    .getElementsByClassName("context-menu-root")[0]
+    .setAttribute("data-source", parent.getAttribute("data-video-source"));
+  Helper.removeClass("#context-menu-overlay", "hide");
+  var left =
+    event.pageX - document.querySelector(".context-menu-root").offsetWidth / 2;
+  var top = event.pageY;
+  if (left + 200 > window.innerWidth) {
+    left = window.innerWidth - 200 - 15;
+  } else if (left < 0) {
+    left = 11;
+  }
+  if (top + 96 > window.innerHeight) {
+    top = window.innerHeight - 96 - 15;
+  } else if (top < 0) {
+    top = 15;
+  }
+  if (parent.getAttribute("data-video-source") == "soundcloud") {
+    Helper.addClass(".find-context-menu", "context-menu-disabled");
+  } else {
+    Helper.removeClass(".find-context-menu", "context-menu-disabled");
+  }
+  Helper.css(".context-menu-root", "left", left + "px");
+  Helper.css(".context-menu-root", "top", top + "px");
+  Helper.removeClass(".context-menu-root", "hide");
+  if (!Helper.mobilecheck()) {
+    mouseContext(left, top);
+  }
 }
 
-function inIframe () {
-    try {
-        return window.self !== window.top;
-    } catch (e) {
-        return true;
-    }
+function inIframe() {
+  try {
+    return window.self !== window.top;
+  } catch (e) {
+    return true;
+  }
 }
 
 function mouseContext(left, top) {
-    var moveFunction = function( event ) {
-        if(event.pageX < left - 60 || event.pageX > left + document.querySelector(".context-menu-root").offsetWidth + 60 ||
-        event.pageY < top - 60 || event.pageY > top + document.querySelector(".context-menu-root").offsetHeight + 60) {
-            Helper.addClass(".context-menu-root", "hide");
-            Helper.addClass("#context-menu-overlay", "hide");
-            document.removeEventListener("mousemove", moveFunction);
-        }
-    };
-    try {
-        document.removeEventListener("mousemove", moveFunction);
-    } catch(e) {}
-    document.addEventListener("mousemove", moveFunction, false);
+  var moveFunction = function(event) {
+    if (
+      event.pageX < left - 60 ||
+      event.pageX >
+        left + document.querySelector(".context-menu-root").offsetWidth + 60 ||
+      event.pageY < top - 60 ||
+      event.pageY >
+        top + document.querySelector(".context-menu-root").offsetHeight + 60
+    ) {
+      Helper.addClass(".context-menu-root", "hide");
+      Helper.addClass("#context-menu-overlay", "hide");
+      document.removeEventListener("mousemove", moveFunction);
+    }
+  };
+  try {
+    document.removeEventListener("mousemove", moveFunction);
+  } catch (e) {}
+  document.addEventListener("mousemove", moveFunction, false);
 }
 
 function get_np_ajax() {
-    /*var c = Crypt.get_userpass(chan.toLowerCase());
+  /*var c = Crypt.get_userpass(chan.toLowerCase());
     if(c == undefined) c = "";*/
-    Helper.ajax({
-        type: "POST",
-        data: {
-            userpass: "",
-            fetch_song: true,
-            token: zoff_api_token
-        },
-        headers: {"Content-Type": "application/json;charset=UTF-8"},
-        url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/__np__",
-        success: function(response) {
-            response = JSON.parse(response);
-            Player.getTitle(response.results[0].title, 1);
-        },
-        error: function(response, xmlhttp) {
-            //response = JSON.parse(response);
-            if(response.status == 403) {
-                start_auth();
-            } else if(response.status == 429) {
-                setTimeout(function() {
-                    get_np_ajax();
-                }, xmlhttp.getResponseHeader("Retry-After") * 1000)
-            }
-        }
-    })
+  Helper.ajax({
+    type: "POST",
+    data: {
+      userpass: "",
+      fetch_song: true,
+      token: zoff_api_token
+    },
+    headers: { "Content-Type": "application/json;charset=UTF-8" },
+    url:
+      "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/__np__",
+    success: function(response) {
+      response = JSON.parse(response);
+      Player.getTitle(response.results[0].title, 1);
+    },
+    error: function(response, xmlhttp) {
+      //response = JSON.parse(response);
+      if (response.status == 403) {
+        start_auth();
+      } else if (response.status == 429) {
+        setTimeout(function() {
+          get_np_ajax();
+        }, xmlhttp.getResponseHeader("Retry-After") * 1000);
+      }
+    }
+  });
 }
 
 function del_ajax(id) {
-    /*var a = Crypt.get_pass(chan.toLowerCase());
+  /*var a = Crypt.get_pass(chan.toLowerCase());
     var u = Crypt.get_userpass(chan.toLowerCase());
     if(a == undefined) a = "";
     if(u == undefined) u = "";*/
-    Helper.ajax({
-        type: "DELETE",
-        data: {
-            adminpass: "",
-            userpass: "",
-            token: zoff_api_token
-        },
-        headers: {"Content-Type": "application/json;charset=UTF-8"},
-        url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/" + id,
-        success: function(response) {
-            toast("deletesong");
-            get_list_ajax();
-        },
-        error: function(response, xmlhttp) {
-            //response = JSON.parse(response);
-            if(response.status == 403) {
-                toast("listhaspass");
-            } else if(response.status == 429) {
-                setTimeout(function() {
-                    del_ajax(id);
-                }, xmlhttp.getResponseHeader("Retry-After") * 1000);
-            }
-        }
-    })
+  Helper.ajax({
+    type: "DELETE",
+    data: {
+      adminpass: "",
+      userpass: "",
+      token: zoff_api_token
+    },
+    headers: { "Content-Type": "application/json;charset=UTF-8" },
+    url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/" + id,
+    success: function(response) {
+      toast("deletesong");
+      get_list_ajax();
+    },
+    error: function(response, xmlhttp) {
+      //response = JSON.parse(response);
+      if (response.status == 403) {
+        toast("listhaspass");
+      } else if (response.status == 429) {
+        setTimeout(function() {
+          del_ajax(id);
+        }, xmlhttp.getResponseHeader("Retry-After") * 1000);
+      }
+    }
+  });
 }
 
-function add_ajax(id, title, duration, playlist, num, full_num, start, end, source, thumbnail) {
-    /*var a = Crypt.get_pass(chan.toLowerCase());
+function add_ajax(
+  id,
+  title,
+  duration,
+  playlist,
+  num,
+  full_num,
+  start,
+  end,
+  source,
+  thumbnail
+) {
+  /*var a = Crypt.get_pass(chan.toLowerCase());
     var u = Crypt.get_userpass(chan.toLowerCase());
     if(a == undefined) a = "";
     if(u == undefined) u = "";*/
-    Helper.ajax({
-        type: "POST",
-        data: {
-            adminpass: "",
-            userpass: "",
-            title: title,
-            duration: duration,
-            end_time: end,
-            start_time: start,
-            thumbnail: thumbnail,
-            source: source,
-            token: zoff_api_token
-        },
-        headers: {"Content-Type": "application/json;charset=UTF-8"},
-        url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/" + id,
-        success: function(response) {
-            toast("addedsong");
-            get_list_ajax();
-        },
-        error: function(response, xmlhttp) {
-            //response = JSON.parse(response);
-            if(response.status == 403) {
-                toast("listhaspass");
-            } else if(response.status == 409) {
-                vote_ajax(id);
-            } else if(response.status == 429) {
-                setTimeout(function() {
-                    add_ajax(id, title, duration, playlist, num, full_num, start, end);
-                }, xmlhttp.getResponseHeader("Retry-After") * 1000);
-            }
-        }
-    });
+  Helper.ajax({
+    type: "POST",
+    data: {
+      adminpass: "",
+      userpass: "",
+      title: title,
+      duration: duration,
+      end_time: end,
+      start_time: start,
+      thumbnail: thumbnail,
+      source: source,
+      token: zoff_api_token
+    },
+    headers: { "Content-Type": "application/json;charset=UTF-8" },
+    url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/" + id,
+    success: function(response) {
+      toast("addedsong");
+      get_list_ajax();
+    },
+    error: function(response, xmlhttp) {
+      //response = JSON.parse(response);
+      if (response.status == 403) {
+        toast("listhaspass");
+      } else if (response.status == 409) {
+        vote_ajax(id);
+      } else if (response.status == 429) {
+        setTimeout(function() {
+          add_ajax(id, title, duration, playlist, num, full_num, start, end);
+        }, xmlhttp.getResponseHeader("Retry-After") * 1000);
+      }
+    }
+  });
 }
 
 function vote_ajax(id) {
-    /*var a = Crypt.get_pass(chan.toLowerCase());
+  /*var a = Crypt.get_pass(chan.toLowerCase());
     var u = Crypt.get_userpass(chan.toLowerCase());
     if(a == undefined) a = "";
     if(u == undefined) u = "";*/
-    Helper.ajax({
-        type: "PUT",
-        data: {
-            adminpass: "",
-            userpass: "",
-            token: zoff_api_token
-        },
-        headers: {"Content-Type": "application/json;charset=UTF-8"},
-        url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/" + id,
-        success: function(response) {
-            toast("voted");
-            get_list_ajax();
-        },
-        error: function(response, xmlhttp) {
-            //response = JSON.parse(response);
-            if(response.status == 403) {
-                toast("listhaspass");
-            } else if(response.status == 429) {
-                setTimeout(function() {
-                    vote_ajax(id);
-                }, xmlhttp.getResponseHeader("Retry-After") * 1000);
-            }
-        }
-    })
+  Helper.ajax({
+    type: "PUT",
+    data: {
+      adminpass: "",
+      userpass: "",
+      token: zoff_api_token
+    },
+    headers: { "Content-Type": "application/json;charset=UTF-8" },
+    url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/" + id,
+    success: function(response) {
+      toast("voted");
+      get_list_ajax();
+    },
+    error: function(response, xmlhttp) {
+      //response = JSON.parse(response);
+      if (response.status == 403) {
+        toast("listhaspass");
+      } else if (response.status == 429) {
+        setTimeout(function() {
+          vote_ajax(id);
+        }, xmlhttp.getResponseHeader("Retry-After") * 1000);
+      }
+    }
+  });
 }
 
 function setup_auth_listener() {
-    socket.on('auth_required', function() {
-        start_auth();
-    });
+  socket.on("auth_required", function() {
+    start_auth();
+  });
 
-    socket.on('auth_accepted', function(msg) {
-        if(msg.hasOwnProperty("value") && msg.value) {
-            if(temp_user_pass != "") {
-                userpass = temp_user_pass;
-                //Crypt.set_userpass(chan.toLowerCase(), userpass);
-            }
-        }
-    });
+  socket.on("auth_accepted", function(msg) {
+    if (msg.hasOwnProperty("value") && msg.value) {
+      if (temp_user_pass != "") {
+        userpass = temp_user_pass;
+        //Crypt.set_userpass(chan.toLowerCase(), userpass);
+      }
+    }
+  });
 }
 
-function setup_no_connection_listener(){
-    socket.on('connect_failed', function(){
-        Helper.log(['Connection Failed']);
-        if(!connect_error){
-            connect_error = true;
-            M.toast({html: "Error connecting to server, please wait..", displayLength: 100000000, classes: "red lighten connect_error"});
-        }
-    });
+function setup_no_connection_listener() {
+  socket.on("connect_failed", function() {
+    Helper.log(["Connection Failed"]);
+    if (!connect_error) {
+      connect_error = true;
+      M.toast({
+        html: "Error connecting to server, please wait..",
+        displayLength: 100000000,
+        classes: "red lighten connect_error"
+      });
+    }
+  });
 
-    socket.on("connect_error", function(){
-        Helper.log(["Connection Failed."]);
-        if(!connect_error){
-            connect_error = true;
-            M.toast({html: "Error connecting to server, please wait..", displayLength: 100000000, classes: "red lighten connect_error"});
-        }
-    });
+  socket.on("connect_error", function() {
+    Helper.log(["Connection Failed."]);
+    if (!connect_error) {
+      connect_error = true;
+      M.toast({
+        html: "Error connecting to server, please wait..",
+        displayLength: 100000000,
+        classes: "red lighten connect_error"
+      });
+    }
+  });
 }
 
 function loadChromecastVideo() {
-    castSession = cast.framework.CastContext.getInstance().getCurrentSession();
-    var _seekTo;
-    try{
-        if(videoSource == "youtube") {
-            _seekTo = Player.player.getCurrentTime();
-        } else if(videoSource == "soundcloud") {
-            _seekTo = Player.soundcloud_player.currentTime() / 1000;
-        }
-    } catch(event){
-        _seekTo = seekTo;
+  castSession = cast.framework.CastContext.getInstance().getCurrentSession();
+  var _seekTo;
+  try {
+    if (videoSource == "youtube") {
+      _seekTo = Player.player.getCurrentTime();
+    } else if (videoSource == "soundcloud") {
+      _seekTo = Player.soundcloud_player.currentTime() / 1000;
     }
-    var mediaInfo = new chrome.cast.media.MediaInfo(video_id, "video");
-    var image = {url:'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg', heigth: 180, width: 320};
-    if(Player.np.thumbnail) image.url = Player.np.thumbnail;
-    mediaInfo.metadata = new chrome.cast.media.GenericMediaMetadata();
-    mediaInfo.metadata.title = Player.np.title;
-    mediaInfo.metadata.image = image;
-    mediaInfo.metadata.images = [image];
-    var request = new chrome.cast.media.LoadRequest(mediaInfo);
-    request.media.customData = {
-        start: Player.np.start,
-        end: Player.np.end,
-        seekTo: _seekTo,
-        channel: chan.toLowerCase(),
-        source: videoSource,
-        thumbnail: Player.np.thumbnail != undefined ? Player.np.thumbnail : 'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg',
-    };
-    castSession.loadMedia(request).then(function() {
-        console.log("Loaded chromecast-video. Don't look here, look at your TV!");
+  } catch (event) {
+    _seekTo = seekTo;
+  }
+  var mediaInfo = new chrome.cast.media.MediaInfo(video_id, "video");
+  var image = {
+    url: "https://img.youtube.com/vi/" + video_id + "/mqdefault.jpg",
+    heigth: 180,
+    width: 320
+  };
+  if (Player.np.thumbnail) image.url = Player.np.thumbnail;
+  mediaInfo.metadata = new chrome.cast.media.GenericMediaMetadata();
+  mediaInfo.metadata.title = Player.np.title;
+  mediaInfo.metadata.image = image;
+  mediaInfo.metadata.images = [image];
+  var request = new chrome.cast.media.LoadRequest(mediaInfo);
+  request.media.customData = {
+    start: Player.np.start,
+    end: Player.np.end,
+    seekTo: _seekTo,
+    channel: chan.toLowerCase(),
+    source: videoSource,
+    thumbnail:
+      Player.np.thumbnail != undefined
+        ? Player.np.thumbnail
+        : "https://img.youtube.com/vi/" + video_id + "/mqdefault.jpg"
+  };
+  castSession.loadMedia(request).then(
+    function() {
+      console.log("Loaded chromecast-video. Don't look here, look at your TV!");
     },
     function(errorCode) {
-        console.log('Error code: ' + errorCode);
-    });
+      console.log("Error code: " + errorCode);
+    }
+  );
 }
 
 function showOnSmallNotMobile() {
-    var elements = document.querySelectorAll(".hide-on-mobile-only");
-    for(var i = 0; i < elements.length; i++) {
-        Helper.removeClass(elements[i], "hide-on-small-only");
-    }
+  var elements = document.querySelectorAll(".hide-on-mobile-only");
+  for (var i = 0; i < elements.length; i++) {
+    Helper.removeClass(elements[i], "hide-on-small-only");
+  }
 }
 
 function enable_intelligent_list() {
-    if(Crypt.get_intelligent_list_enabled()) {
-        intelligentList = true;
-    }
+  if (Crypt.get_intelligent_list_enabled()) {
+    intelligentList = true;
+  }
 }
 
 function change_intelligent(enabled) {
-    document.querySelector(".intelligent_switch_class").checked = enabled;
+  document.querySelector(".intelligent_switch_class").checked = enabled;
 }
 
 function clearIntelligentQueue() {
-    intelligentList = false;
-    for(var i = 0; i < intelligentQueue.length; i++) {
-        var currentElement = intelligentQueue[i];
-        if(currentElement.type == "vote") {
-            Helper.removeElement("#"+currentElement.element.id);
-            List.insertAtIndex(currentElement.element, false);
-        } else if(currentElement.type == "delete") {
-            List.deleted_song(currentElement.element.id, false, true, currentElement.index);
-            deleted_elements += 1;
-        } else if(currentElement.type == "add") {
-            List.insertAtIndex(currentElement.element, true);
-            Helper.css(document.querySelector("#wrapper").children[List.page + List.can_fit], "display", "none");
-            if(document.querySelector("#wrapper").children.length > List.page + List.can_fit){
-                Helper.css(".next_page_hide", "display", "none");
-                Helper.removeClass(".next_page", "hide");
-                Helper.css(".last_page_hide", "display", "none");
-                Helper.css(".next_page", "display", "inline-flex");
-                Helper.css(".last_page", "display", "inline-flex");
-            } else {
-                Helper.css(".next_page_hide", "display", "inline-flex");
-                Helper.css(".next_page", "display", "none");
-            }
-        }
+  intelligentList = false;
+  for (var i = 0; i < intelligentQueue.length; i++) {
+    var currentElement = intelligentQueue[i];
+    if (currentElement.type == "vote") {
+      Helper.removeElement("#" + currentElement.element.id);
+      List.insertAtIndex(currentElement.element, false);
+    } else if (currentElement.type == "delete") {
+      List.deleted_song(
+        currentElement.element.id,
+        false,
+        true,
+        currentElement.index
+      );
+      deleted_elements += 1;
+    } else if (currentElement.type == "add") {
+      List.insertAtIndex(currentElement.element, true);
+      Helper.css(
+        document.querySelector("#wrapper").children[List.page + List.can_fit],
+        "display",
+        "none"
+      );
+      if (
+        document.querySelector("#wrapper").children.length >
+        List.page + List.can_fit
+      ) {
+        Helper.css(".next_page_hide", "display", "none");
+        Helper.removeClass(".next_page", "hide");
+        Helper.css(".last_page_hide", "display", "none");
+        Helper.css(".next_page", "display", "inline-flex");
+        Helper.css(".last_page", "display", "inline-flex");
+      } else {
+        Helper.css(".next_page_hide", "display", "inline-flex");
+        Helper.css(".next_page", "display", "none");
+      }
     }
-    intelligentQueue = [];
+  }
+  intelligentQueue = [];
 }
 
 function updateChromecastMetadata() {
-    if(!chromecastAvailable) return;
-    var image = {url:'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg', heigth: 180, width: 320};
-    if(Player.np.thumbnail) image.url = Player.np.thumbnail;
-    chrome.cast.media.GenericMediaMetadata({metadataType: 0, title:Player.np.title, image: image, images: [image]});
-    return new chrome.cast.media.GenericMediaMetadata({metadataType: 0, title:Player.np.title, image: image, images: [image]});
+  if (!chromecastAvailable) return;
+  var image = {
+    url: "https://img.youtube.com/vi/" + video_id + "/mqdefault.jpg",
+    heigth: 180,
+    width: 320
+  };
+  if (Player.np.thumbnail) image.url = Player.np.thumbnail;
+  chrome.cast.media.GenericMediaMetadata({
+    metadataType: 0,
+    title: Player.np.title,
+    image: image,
+    images: [image]
+  });
+  return new chrome.cast.media.GenericMediaMetadata({
+    metadataType: 0,
+    title: Player.np.title,
+    image: image,
+    images: [image]
+  });
 }
 
-function setup_now_playing_listener(){
-    socket.on("np", Player.now_playing_listener);
+function setup_now_playing_listener() {
+  socket.on("np", Player.now_playing_listener);
 }
 
 function exitHandler(event) {
-    if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) {
-        if(!document.getElementById("main-row").classList.contains("fullscreened")) {
-            Helper.addClass("#main-row", "fullscreened");
-        } else {
-            Helper.removeClass("#main-row", "fullscreened");
-            document.querySelector(".host_switch_class").checked = false
-            enable_host_mode(false);
-        }
+  if (
+    document.webkitIsFullScreen ||
+    document.mozFullScreen ||
+    document.msFullscreenElement !== null
+  ) {
+    if (
+      !document.getElementById("main-row").classList.contains("fullscreened")
+    ) {
+      Helper.addClass("#main-row", "fullscreened");
+    } else {
+      Helper.removeClass("#main-row", "fullscreened");
+      document.querySelector(".host_switch_class").checked = false;
+      enable_host_mode(false);
     }
+  }
 }
 
 function enable_host_mode(enabled) {
-    if(!hostMode) {
-        var playerElement = document.querySelector("main");
-        var requestFullScreen = playerElement.requestFullScreen || playerElement.mozRequestFullScreen || playerElement.webkitRequestFullScreen;
-        if (requestFullScreen) {
-            requestFullScreen.bind(playerElement)();
-            M.Tabs.getInstance(document.querySelector('.playlist-tabs-loggedIn')).select("wrapper");
-            Helper.addClass("#main-row", "host-mode-height");
-            Helper.addClass("#main-row", "host-mode-width");
-            Helper.addClass("main", "host-mode-height");
-            Helper.addClass("main", "host-mode-width");
-            Helper.addClass("#video-container", "host-mode-height");
-            Helper.addClass("#playlist", "host-mode-height");
-            Helper.css(".playlist-tabs-loggedIn", "display", "none");
-            Helper.removeClass("#wrapper", "tabs_height");
-            Helper.addClass("#wrapper", "host-mode-wrapper");
-            Helper.css(".skip", "display", "none");
-            var removeElements = document.querySelectorAll(".list-remove");
-            for(var i = 0; i < removeElements.length; i++) {
-                removeElements[i].style.display = "none";
-            }
-            Helper.css(".prev", "display", "none");
-            Helper.css("#fullscreen", "display", "none");
-            Helper.css("#playlist", "backgroundColor", "inherit");
-            Helper.css("#main-row", "backgroundColor", "inherit");
-            Helper.css(".main", "backgroundColor", "inherit");
-            Helper.removeClass("#host-title", "hide");
-            Helper.css("#soundcloud_info_container", "display", "none");
-            Helper.css("#player", "pointer-events", "none");
-            hostMode = enabled;
-            document.querySelector("#playlist").insertAdjacentHTML("beforeend", "");
-            document.addEventListener('webkitfullscreenchange', exitHandler, false);
-            document.addEventListener('mozfullscreenchange', exitHandler, false);
-            document.addEventListener('fullscreenchange', exitHandler, false);
-            document.addEventListener('MSFullscreenChange', exitHandler, false);
-        }
-    } else {
-        Helper.removeClass("#main-row", "host-mode-height");
-        Helper.removeClass("#main-row", "host-mode-width");
-        Helper.css(".prev", "display", "block");
-        Helper.removeClass(".main", "host-mode-height");
-        Helper.removeClass(".main", "host-mode-width");
-        Helper.removeClass("#video-container", "host-mode-height");
-        Helper.removeClass("#playlist", "host-mode-height");
-        Helper.css(".playlist-tabs-loggedIn", "display", "flex");
-        Helper.css("#player", "pointer-events", "all");
-        Helper.addClass("#wrapper", "tabs_height");
-        Helper.addClass("#host-title", "hide");
-        Helper.removeClass("#wrapper", "host-mode-wrapper");
-        Helper.css("#soundcloud_info_container", "display", "flex");
-        Helper.css(".skip", "display", "block");
-        document.querySelector("#join-sidebar").remove();
-        var removeElements = document.querySelectorAll(".list-remove");
-        for(var i = 0; i < removeElements.length; i++) {
-            removeElements[i].style.display = "block";
-        }
-        Helper.css("#fullscreen", "display", "block");
-        hostMode = false;
-        document.removeEventListener('webkitfullscreenchange', exitHandler, false);
-        document.removeEventListener('mozfullscreenchange', exitHandler, false);
-        document.removeEventListener('fullscreenchange', exitHandler, false);
-        document.removeEventListener('MSFullscreenChange', exitHandler, false);
+  if (!hostMode) {
+    var playerElement = document.querySelector("main");
+    var requestFullScreen =
+      playerElement.requestFullScreen ||
+      playerElement.mozRequestFullScreen ||
+      playerElement.webkitRequestFullScreen;
+    if (requestFullScreen) {
+      requestFullScreen.bind(playerElement)();
+      M.Tabs.getInstance(
+        document.querySelector(".playlist-tabs-loggedIn")
+      ).select("wrapper");
+      Helper.addClass("#main-row", "host-mode-height");
+      Helper.addClass("#main-row", "host-mode-width");
+      Helper.addClass("main", "host-mode-height");
+      Helper.addClass("main", "host-mode-width");
+      Helper.addClass("#video-container", "host-mode-height");
+      Helper.addClass("#playlist", "host-mode-height");
+      Helper.css(".playlist-tabs-loggedIn", "display", "none");
+      Helper.removeClass("#wrapper", "tabs_height");
+      Helper.addClass("#wrapper", "host-mode-wrapper");
+      Helper.css(".skip", "display", "none");
+      var removeElements = document.querySelectorAll(".list-remove");
+      for (var i = 0; i < removeElements.length; i++) {
+        removeElements[i].style.display = "none";
+      }
+      Helper.css(".prev", "display", "none");
+      Helper.css("#fullscreen", "display", "none");
+      Helper.css("#playlist", "backgroundColor", "inherit");
+      Helper.css("#main-row", "backgroundColor", "inherit");
+      Helper.css(".main", "backgroundColor", "inherit");
+      Helper.removeClass("#host-title", "hide");
+      Helper.css("#soundcloud_info_container", "display", "none");
+      Helper.css("#player", "pointer-events", "none");
+      hostMode = enabled;
+      document
+        .querySelector("#playlist")
+        .insertAdjacentHTML(
+          "beforeend",
+          ""
+        );
+      document.addEventListener("webkitfullscreenchange", exitHandler, false);
+      document.addEventListener("mozfullscreenchange", exitHandler, false);
+      document.addEventListener("fullscreenchange", exitHandler, false);
+      document.addEventListener("MSFullscreenChange", exitHandler, false);
     }
-    resizeFunction();
-    List.dynamicContentPage(-10);
+  } else {
+    Helper.removeClass("#main-row", "host-mode-height");
+    Helper.removeClass("#main-row", "host-mode-width");
+    Helper.css(".prev", "display", "block");
+    Helper.removeClass(".main", "host-mode-height");
+    Helper.removeClass(".main", "host-mode-width");
+    Helper.removeClass("#video-container", "host-mode-height");
+    Helper.removeClass("#playlist", "host-mode-height");
+    Helper.css(".playlist-tabs-loggedIn", "display", "flex");
+    Helper.css("#player", "pointer-events", "all");
+    Helper.addClass("#wrapper", "tabs_height");
+    Helper.addClass("#host-title", "hide");
+    Helper.removeClass("#wrapper", "host-mode-wrapper");
+    Helper.css("#soundcloud_info_container", "display", "flex");
+    Helper.css(".skip", "display", "block");
+    document.querySelector("#join-sidebar").remove();
+    var removeElements = document.querySelectorAll(".list-remove");
+    for (var i = 0; i < removeElements.length; i++) {
+      removeElements[i].style.display = "block";
+    }
+    Helper.css("#fullscreen", "display", "block");
+    hostMode = false;
+    document.removeEventListener("webkitfullscreenchange", exitHandler, false);
+    document.removeEventListener("mozfullscreenchange", exitHandler, false);
+    document.removeEventListener("fullscreenchange", exitHandler, false);
+    document.removeEventListener("MSFullscreenChange", exitHandler, false);
+  }
+  resizeFunction();
+  List.dynamicContentPage(-10);
 }
 
-function get_list_listener(){
-    socket.on("get_list", function(){
-        var add = "";
-        socket_connected = true;
-        //if(private_channel) add = Crypt.getCookie("_uI") + "_";
-        /*var p = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
+function get_list_listener() {
+  socket.on("get_list", function() {
+    var add = "";
+    socket_connected = true;
+    //if(private_channel) add = Crypt.getCookie("_uI") + "_";
+    /*var p = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
         if(p == undefined) p = "";*/
-        socket.emit("list", { offline: offline, version: parseInt(_VERSION), channel: add + chan.toLowerCase()});
+    socket.emit("list", {
+      offline: offline,
+      version: parseInt(_VERSION),
+      channel: add + chan.toLowerCase()
     });
-    socket.on("id_chromecast", function(msg) {
-        chromecast_specs_sent = true;
-        castSession.sendMessage("urn:x-cast:zoff.me", {type: "mobilespecs", guid: msg.guid, socketid: msg.cookie_id, channel: chan.toLowerCase()})
-    })
-}
-
-function setup_suggested_listener(){
-    if(client) return;
-    socket.on("suggested", function(params){
-        var single = true;
-        if(params.id === undefined)
-        single = false;
-        Suggestions.catchUserSuggests(params, single);
+  });
+  socket.on("id_chromecast", function(msg) {
+    chromecast_specs_sent = true;
+    castSession.sendMessage("urn:x-cast:zoff.me", {
+      type: "mobilespecs",
+      guid: msg.guid,
+      socketid: msg.cookie_id,
+      channel: chan.toLowerCase()
     });
+  });
 }
 
-function setup_viewers_listener(){
-    socket.on("viewers", function(view){
-        viewers = view;
-        var outPutWord    = "visibility"//v > 1 ? "viewers" : "viewer";
-
-        Helper.setHtml("#viewers", outPutWord + " " + view);
-
-        if(song_title !== undefined)
-        Player.getTitle(song_title, viewers);
-    });
+function setup_suggested_listener() {
+  if (client) return;
+  socket.on("suggested", function(params) {
+    var single = true;
+    if (params.id === undefined) single = false;
+    Suggestions.catchUserSuggests(params, single);
+  });
 }
 
-function setup_admin_listener(){
-    socket.on("toast", toast);
-    socket.on("pw", Admin.pw);
-    socket.on("conf", Admin.conf);
+function setup_viewers_listener() {
+  socket.on("viewers", function(view) {
+    viewers = view;
+    var outPutWord = "visibility"; //v > 1 ? "viewers" : "viewer";
+
+    Helper.setHtml("#viewers", outPutWord + " " + view);
+
+    if (song_title !== undefined) Player.getTitle(song_title, viewers);
+  });
 }
 
-function setup_chat_listener(){
-    socket.on("chat_history", function(msg) {
-        var data = msg.data;
-        for(var i = 0; i < data.length; i++) {
-            if(msg.all) {
-                Chat.allchat(data[i], data[i].createdAt, true);
-                document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
-            } else {
-                Chat.channelchat(data[i], data[i].createdAt, true);
-                document.getElementById("chatchannel").scrollTop = document.getElementById("chatchannel").scrollHeight;
-            }
-        }
-    });
-    socket.on("chat.all", Chat.allchat);
-    socket.on("chat", Chat.channelchat);
+function setup_admin_listener() {
+  socket.on("toast", toast);
+  socket.on("pw", Admin.pw);
+  socket.on("conf", Admin.conf);
 }
 
-function setup_list_listener(){
-    if(!offline) {
-        socket.on("color", Player.setBGimage);
+function setup_chat_listener() {
+  socket.on("chat_history", function(msg) {
+    var data = msg.data;
+    for (var i = 0; i < data.length; i++) {
+      if (msg.all) {
+        Chat.allchat(data[i], data[i].createdAt, true);
+        document.getElementById("chatall").scrollTop = document.getElementById(
+          "chatall"
+        ).scrollHeight;
+      } else {
+        Chat.channelchat(data[i], data[i].createdAt, true);
+        document.getElementById(
+          "chatchannel"
+        ).scrollTop = document.getElementById("chatchannel").scrollHeight;
+      }
     }
-    socket.on("channel", List.channel_function);
+  });
+  socket.on("chat.all", Chat.allchat);
+  socket.on("chat", Chat.channelchat);
 }
 
-function setup_playlist_listener(){
-    Helper.log(["Setting up playlist_listener"]);
-    socket.on('playlists', Frontpage.frontpage_function);
+function setup_list_listener() {
+  if (!offline) {
+    socket.on("color", Player.setBGimage);
+  }
+  socket.on("channel", List.channel_function);
 }
 
-function setup_host_initialization(){
-    if(!client) {
-        Helper.log(["Setting up host initialization listener"]);
-        socket.on("id", Hostcontroller.host_listener);
+function setup_playlist_listener() {
+  Helper.log(["Setting up playlist_listener"]);
+  socket.on("playlists", Frontpage.frontpage_function);
+}
+
+function setup_host_initialization() {
+  if (!client) {
+    Helper.log(["Setting up host initialization listener"]);
+    socket.on("id", Hostcontroller.host_listener);
+  }
+}
+
+function setup_host_listener(id) {
+  if (!client) {
+    Helper.log(["Setting up host action listener"]);
+    socket.on(id, Hostcontroller.host_on_action);
+  }
+}
+
+function enable_debug() {
+  try {
+    localStorage.debug = true;
+  } catch (e) {}
+}
+
+function disable_debug() {
+  try {
+    localStorage.debug = false;
+  } catch (e) {}
+}
+
+function embed_code(
+  autoplay,
+  width,
+  height,
+  color,
+  embed_videoonly,
+  embed_localmode
+) {
+  var autoplay_add = "";
+  if (autoplay == "&autoplay=true") autoplay_add = 'allow="autoplay"';
+  return (
+    '"
+  );
+}
+
+function change_offline(enabled, already_offline) {
+  if (client) {
+    offline = false;
+    return;
+  }
+  Crypt.set_offline(enabled);
+  offline = enabled;
+  ga("send", "event", "button-click", "offline", "", offline ? 1 : 0);
+  socket.emit("offline", {
+    status: enabled,
+    channel: chan != undefined ? chan.toLowerCase() : ""
+  });
+  if (!Helper.mobilecheck()) {
+    if (
+      document.querySelectorAll("#offline-mode").length == 1 &&
+      M.Tooltip.getInstance(document.getElementById("offline-mode"))
+    ) {
+      Helper.tooltip("#offline-mode", "destroy");
     }
-}
+  }
 
-function setup_host_listener(id){
-    if(!client) {
-        Helper.log(["Setting up host action listener"]);
-        socket.on(id, Hostcontroller.host_on_action);
-    }
-}
+  var mouseEnter = function(e) {
+    Helper.removeClass("#seekToDuration", "hide");
+  };
 
-function enable_debug(){
-    try {
-        localStorage.debug = true;
-    } catch(e){}
-}
+  var mouseLeave = function(e) {
+    dragging = false;
+    Helper.addClass("#seekToDuration", "hide");
+  };
 
-function disable_debug(){
-    try {
-        localStorage.debug = false;
-    } catch(e){}
-}
-
-function embed_code(autoplay, width, height, color, embed_videoonly, embed_localmode){
-    var autoplay_add = "";
-    if(autoplay == "&autoplay=true") autoplay_add = 'allow="autoplay"';
-    return '';
-}
-
-function change_offline(enabled, already_offline){
-    if(client) {
-        offline = false;
-        return;
-    }
-    Crypt.set_offline(enabled);
-    offline = enabled;
-    ga('send', 'event', "button-click", "offline", "", offline ? 1 : 0);
-    socket.emit("offline", {status: enabled, channel: chan != undefined ? chan.toLowerCase() : ""});
-    if(!Helper.mobilecheck()) {
-        if(document.querySelectorAll("#offline-mode").length == 1 && M.Tooltip.getInstance(document.getElementById("offline-mode"))) {
-            Helper.tooltip("#offline-mode", 'destroy');
-        }
-    }
-
-    var mouseEnter = function(e){
-        Helper.removeClass("#seekToDuration", "hide");
-    };
-
-    var mouseLeave = function(e){
-        dragging = false;
-        Helper.addClass("#seekToDuration", "hide");
-    };
-
-    var mouseDown = function(e) {
-        var acceptable = ["bar", "controls", "duration"];
-        if(acceptable.indexOf(e.target.id) >= 0) {
-            dragging = true;
-        }
-    };
-
-    var mouseUp = function(e) {
-        dragging = false;
-    };
-
-    if(enabled){
-        Helper.addClass("#viewers", "hide");
-        Helper.removeClass(".margin-playbar", "margin-playbar");
-        Helper.addClass(".prev playbar", "margin-playbar");
-        Helper.removeClass(".prev playbar", "hide");
-        Helper.removeClass("#offline-mode", "waves-cyan");
-        Helper.addClass("#offline-mode", "cyan");
-        Helper.removeClass(".delete-context-menu", "context-menu-disabled");
-        if(!Helper.mobilecheck()) {
-            Helper.tooltip("#offline-mode", {
-                delay: 5,
-                position: "bottom",
-                html: "Disable local mode"
-            });
-        }
-
-        if(window.location.pathname != "/"){
-            socket.removeEventListener("color");
-            document.getElementById("controls").addEventListener("mouseenter", mouseEnter, false);
-            document.getElementById("controls").addEventListener("mouseleave", mouseLeave, false);
-            document.getElementById("controls").addEventListener("mousedown", mouseDown, false);
-            document.getElementById("controls").addEventListener("mouseup", mouseUp, false);
-            document.getElementById("controls").addEventListener("mousemove", seekToMove);
-            document.getElementById("controls").addEventListener("click", seekToClick);
-
-            document.querySelector("#main_components").insertAdjacentHTML("beforeend", "00:00/01:00
");
-            var controlElement = document.querySelector("#controls");
-            if(!Helper.mobilecheck()) Helper.css("#seekToDuration", "top", -controlElement.offsetHeight - 25 + "px");
-            else if(Helper.mobilecheck()) Helper.css("#seekToDuration", "top", -controlElement.offsetHeight - 25 + "px");
-            Helper.addClass("#controls", "ewresize");
-        }
-        if(full_playlist != undefined && !already_offline){
-            for(var x = 0; x < full_playlist.length; x++){
-                full_playlist[x].votes = 0;
-            }
-            List.sortList();
-            List.populate_list(full_playlist);
-        }
-    } else {
-        if(!Admin.logged_in) Helper.addClass(".delete-context-menu", "context-menu-disabled");
-        Helper.removeClass(".margin-playbar", "margin-playbar");
-        Helper.addClass("#playpause", "margin-playbar");
-        Helper.removeClass("#viewers", "hide");
-        Helper.addClass(".prev playbar", "hide");
-        Helper.addClass("#offline-mode", "waves-cyan");
-        Helper.removeClass("#offline-mode", "cyan");
-        if(!Helper.mobilecheck()) {
-            Helper.tooltip("#offline-mode", {
-                delay: 5,
-                position: "bottom",
-                html: "Enable local mode"
-            });
-        }
-
-        if(window.location.pathname != "/"){
-            document.getElementById("controls").removeEventListener("mouseenter", mouseEnter, false);
-            document.getElementById("controls").removeEventListener("mouseleave", mouseLeave, false);
-            document.getElementById("controls").removeEventListener("mousedown", mouseDown, false);
-            document.getElementById("controls").removeEventListener("mouseup", mouseUp, false);
-            document.getElementById("controls").removeEventListener("mousemove", seekToMove);
-            document.getElementById("controls").removeEventListener("click", seekToClick);
-            Helper.removeElement("#seekToDuration");
-            socket.on("color", Player.setBGimage);
-            socket.emit("pos", {channel: chan.toLowerCase()});
-            var add = "";
-            socket.emit("list", {version: parseInt(_VERSION), channel: add + chan.toLowerCase()});
-            Helper.removeClass("#controls", "ewresize");
-        }
-    }
-}
-
-function seekToClick(e){
+  var mouseDown = function(e) {
     var acceptable = ["bar", "controls", "duration"];
-
-    if(acceptable.indexOf(e.target.getAttribute("id")) >= 0) {
-        if(full_playlist == undefined) return;
-        var total = full_playlist[full_playlist.length - 1].duration / document.getElementById("controls").offsetWidth;
-        total = total * e.clientX;
-
-        if(!chromecastAvailable){
-            if(videoSource == "youtube") Player.player.seekTo(total + Player.np.start);
-            else if(videoSource == "soundcloud") Player.soundcloud_player.seek((total + Player.np.start) * 1000);
-            dMinutes = Math.floor(duration / 60);
-            dSeconds = duration - dMinutes * 60;
-            currDurr = total;
-            if(currDurr - Player.np.start > duration) {
-                currDurr = duration - Player.np.start;
-            }
-            currDurr = currDurr - Player.np.start;
-            minutes = Math.floor(currDurr / 60);
-            seconds = currDurr - (minutes * 60);
-            document.getElementById("duration").innerHTML = Helper.pad(minutes)+":"+Helper.pad(seconds)+" / "+Helper.pad(dMinutes)+":"+Helper.pad(dSeconds);
-            per = (100 / duration) * currDurr;
-            if(per >= 100)
-            per = 100;
-            else if(duration === 0)
-            per = 0;
-            document.getElementById("bar").style.width = per + "%"
-        } else {
-            castSession.sendMessage("urn:x-cast:zoff.me", {type: "seekTo", seekTo: total});
-        }
+    if (acceptable.indexOf(e.target.id) >= 0) {
+      dragging = true;
     }
+  };
+
+  var mouseUp = function(e) {
+    dragging = false;
+  };
+
+  if (enabled) {
+    Helper.addClass("#viewers", "hide");
+    Helper.removeClass(".margin-playbar", "margin-playbar");
+    Helper.addClass(".prev playbar", "margin-playbar");
+    Helper.removeClass(".prev playbar", "hide");
+    Helper.removeClass("#offline-mode", "waves-cyan");
+    Helper.addClass("#offline-mode", "cyan");
+    Helper.removeClass(".delete-context-menu", "context-menu-disabled");
+    if (!Helper.mobilecheck()) {
+      Helper.tooltip("#offline-mode", {
+        delay: 5,
+        position: "bottom",
+        html: "Disable local mode"
+      });
+    }
+
+    if (window.location.pathname != "/") {
+      socket.removeEventListener("color");
+      document
+        .getElementById("controls")
+        .addEventListener("mouseenter", mouseEnter, false);
+      document
+        .getElementById("controls")
+        .addEventListener("mouseleave", mouseLeave, false);
+      document
+        .getElementById("controls")
+        .addEventListener("mousedown", mouseDown, false);
+      document
+        .getElementById("controls")
+        .addEventListener("mouseup", mouseUp, false);
+      document
+        .getElementById("controls")
+        .addEventListener("mousemove", seekToMove);
+      document
+        .getElementById("controls")
+        .addEventListener("click", seekToClick);
+
+      document
+        .querySelector("#main_components")
+        .insertAdjacentHTML(
+          "beforeend",
+          "00:00/01:00
"
+        );
+      var controlElement = document.querySelector("#controls");
+      if (!Helper.mobilecheck())
+        Helper.css(
+          "#seekToDuration",
+          "top",
+          -controlElement.offsetHeight - 25 + "px"
+        );
+      else if (Helper.mobilecheck())
+        Helper.css(
+          "#seekToDuration",
+          "top",
+          -controlElement.offsetHeight - 25 + "px"
+        );
+      Helper.addClass("#controls", "ewresize");
+    }
+    if (full_playlist != undefined && !already_offline) {
+      for (var x = 0; x < full_playlist.length; x++) {
+        full_playlist[x].votes = 0;
+      }
+      List.sortList();
+      List.populate_list(full_playlist);
+    }
+  } else {
+    if (!Admin.logged_in)
+      Helper.addClass(".delete-context-menu", "context-menu-disabled");
+    Helper.removeClass(".margin-playbar", "margin-playbar");
+    Helper.addClass("#playpause", "margin-playbar");
+    Helper.removeClass("#viewers", "hide");
+    Helper.addClass(".prev playbar", "hide");
+    Helper.addClass("#offline-mode", "waves-cyan");
+    Helper.removeClass("#offline-mode", "cyan");
+    if (!Helper.mobilecheck()) {
+      Helper.tooltip("#offline-mode", {
+        delay: 5,
+        position: "bottom",
+        html: "Enable local mode"
+      });
+    }
+
+    if (window.location.pathname != "/") {
+      document
+        .getElementById("controls")
+        .removeEventListener("mouseenter", mouseEnter, false);
+      document
+        .getElementById("controls")
+        .removeEventListener("mouseleave", mouseLeave, false);
+      document
+        .getElementById("controls")
+        .removeEventListener("mousedown", mouseDown, false);
+      document
+        .getElementById("controls")
+        .removeEventListener("mouseup", mouseUp, false);
+      document
+        .getElementById("controls")
+        .removeEventListener("mousemove", seekToMove);
+      document
+        .getElementById("controls")
+        .removeEventListener("click", seekToClick);
+      Helper.removeElement("#seekToDuration");
+      socket.on("color", Player.setBGimage);
+      socket.emit("pos", { channel: chan.toLowerCase() });
+      var add = "";
+      socket.emit("list", {
+        version: parseInt(_VERSION),
+        channel: add + chan.toLowerCase()
+      });
+      Helper.removeClass("#controls", "ewresize");
+    }
+  }
 }
 
-function seekToMove(e){
-    var pos_x = event.clientX - Math.ceil(document.getElementById("seekToDuration").offsetWidth / 2);
-    if(pos_x < 0) pos_x = 0;
-    else if(pos_x + document.getElementById("seekToDuration").offsetWidth > document.getElementById("controls").offsetWidth) {
-        pos_x = document.getElementById("controls").offsetWidth - document.getElementById("seekToDuration").offsetWidth;
-    }
-    Helper.css("#seekToDuration", "left", pos_x + "px");
-    try{
-        var total = full_playlist[full_playlist.length - 1].duration / document.getElementById("controls").offsetWidth;
-        total = total * event.clientX;
-        var _time = Helper.secondsToOther(total);
-        var _minutes = Helper.pad(_time[0]);
-        var _seconds = Helper.pad(Math.ceil(_time[1]));
-        Helper.setHtml("#seekToDuration", _minutes + ":" + _seconds);
+function seekToClick(e) {
+  var acceptable = ["bar", "controls", "duration"];
 
-        var acceptable = ["bar", "controls", "duration"];
-        if(acceptable.indexOf(event.target.getAttribute("id")) >= 0 && dragging) {
-            document.getElementById("bar").style.width(((100 / duration) * total) + "%");
-        }
-    } catch(e){}
+  if (acceptable.indexOf(e.target.getAttribute("id")) >= 0) {
+    if (full_playlist == undefined) return;
+    var total =
+      full_playlist[full_playlist.length - 1].duration /
+      document.getElementById("controls").offsetWidth;
+    total = total * e.clientX;
+
+    if (!chromecastAvailable) {
+      if (videoSource == "youtube")
+        Player.player.seekTo(total + Player.np.start);
+      else if (videoSource == "soundcloud")
+        Player.soundcloud_player.seek((total + Player.np.start) * 1000);
+      dMinutes = Math.floor(duration / 60);
+      dSeconds = duration - dMinutes * 60;
+      currDurr = total;
+      if (currDurr - Player.np.start > duration) {
+        currDurr = duration - Player.np.start;
+      }
+      currDurr = currDurr - Player.np.start;
+      minutes = Math.floor(currDurr / 60);
+      seconds = currDurr - minutes * 60;
+      document.getElementById("duration").innerHTML =
+        Helper.pad(minutes) +
+        ":" +
+        Helper.pad(seconds) +
+        " / " +
+        Helper.pad(dMinutes) +
+        ":" +
+        Helper.pad(dSeconds);
+      per = (100 / duration) * currDurr;
+      if (per >= 100) per = 100;
+      else if (duration === 0) per = 0;
+      document.getElementById("bar").style.width = per + "%";
+    } else {
+      castSession.sendMessage("urn:x-cast:zoff.me", {
+        type: "seekTo",
+        seekTo: total
+      });
+    }
+  }
+}
+
+function seekToMove(e) {
+  var pos_x =
+    event.clientX -
+    Math.ceil(document.getElementById("seekToDuration").offsetWidth / 2);
+  if (pos_x < 0) pos_x = 0;
+  else if (
+    pos_x + document.getElementById("seekToDuration").offsetWidth >
+    document.getElementById("controls").offsetWidth
+  ) {
+    pos_x =
+      document.getElementById("controls").offsetWidth -
+      document.getElementById("seekToDuration").offsetWidth;
+  }
+  Helper.css("#seekToDuration", "left", pos_x + "px");
+  try {
+    var total =
+      full_playlist[full_playlist.length - 1].duration /
+      document.getElementById("controls").offsetWidth;
+    total = total * event.clientX;
+    var _time = Helper.secondsToOther(total);
+    var _minutes = Helper.pad(_time[0]);
+    var _seconds = Helper.pad(Math.ceil(_time[1]));
+    Helper.setHtml("#seekToDuration", _minutes + ":" + _seconds);
+
+    var acceptable = ["bar", "controls", "duration"];
+    if (acceptable.indexOf(event.target.getAttribute("id")) >= 0 && dragging) {
+      document
+        .getElementById("bar")
+        .style.width((100 / duration) * total + "%");
+    }
+  } catch (e) {}
 }
 
 function resizePlaylistPlaying(playing, resizing) {
-    if(document.querySelector("#wrapper") == null || embed || client) return;
-    if(window.innerWidth < 601) {
-        var subtract = 0;
-        if(playing) {
-            var height = window.innerHeight - 246 - 170 - subtract;
-            Helper.css("#chat-bar", "height", height + "px");
-            Helper.css("#channelchat", "height", height - 130 + "px");
-            Helper.css("#all_chat", "height", height - 130 + "px");
-            Helper.css("#chat-container", "height", height + "px");
-            subtract = 200;
-        } else {
-            document.querySelector("#chat-bar").style.height = "";
-            document.querySelector("#channelchat").style.height = "";
-            document.querySelector("#all_chat").style.height = "";
-            document.querySelector("#chat-container").style.height = "";
-        }
-        var page = List.page;
-        var canFit = List.can_fit;
-        Helper.css("#wrapper", "height", window.innerHeight - 246 - subtract + "px");
-
-        if(!embed && !client){
-            temp_fit = Math.round(Helper.computedStyle("#wrapper", "height") / 71);
-            List.element_height = (Helper.computedStyle("#wrapper", "height") / temp_fit)-5.3;
-        } else {
-            temp_fit = Math.round(Helper.computedStyle("#wrapper", "height") / 71)+1;
-            List.element_height = (Helper.computedStyle("#wrapper", "height") / temp_fit)-5.3;
-        }
-        if(List.element_height < 55.2 && !client){
-            temp_fit = temp_fit - 1;
-            List.element_height = 55.2;
-            temp_fit = Math.round((window.innerHeight - Helper.computedStyle(".tabs", "height") - Helper.computedStyle("header", "height") - 64 - 40) / 71);
-            List.element_height = ((window.innerHeight - Helper.computedStyle(".tabs", "height") - Helper.computedStyle("header", "height") - 64 - 40) / temp_fit)-5;
-        }
-
-        if(temp_fit > List.can_fit || temp_fit < List.can_fit){
-            List.dynamicContentPage(-10);
-        }
-        if(List.can_fit < temp_fit){
-            Helper.css(document.querySelector("#wrapper").children, "display", "none");
-            for(var i = 0; i < List.page + temp_fit; i++) {
-                Helper.css(document.querySelector("#wrapper").children[i], "display", "inline-flex");
-            }
-        } else if(List.can_fit > temp_fit){
-            //Helper.css(document.querySelector("#wrapper").children, "display", "none");
-            Helper.css(document.querySelector("#wrapper").children[List.page + temp_fit], "display", "none");
-            var elements = document.querySelector("#wrapper").children;
-            for(var i = List.page + temp_fit; i < elements.length; i++) {
-                Helper.css(document.querySelector("#wrapper").children[i], "display", "none");
-            }
-        }
-        List.can_fit = temp_fit;
-        List.element_height = (Helper.computedStyle("#wrapper", "height") / List.can_fit)-5.3;
-        Helper.css(".list-song", "height", List.element_height + "px");
-        Channel.set_title_width();
-        var toJumpTo = page / canFit;
-        if(toJumpTo > Math.floor(full_playlist.length / List.can_fit) && resizing) {
-            toJumpTo = Math.floor(full_playlist.length / List.can_fit);
-        }
-        List.dynamicContentPageJumpTo(toJumpTo);
-        if(!client) {
-            var controlsPosition = document.querySelector("#controls").offsetHeight - Helper.computedStyle("#controls", "height");
-            if(document.querySelectorAll("#controls").length > 0 && !Helper.mobilecheck()) {
-                Helper.css(document.querySelector("#seekToDuration"), "top", controlsPosition - 55);
-            } else if(document.querySelectorAll("#controls").length > 0) {
-                Helper.css(document.querySelector("#seekToDuration"), "top", controlsPosition - 20);
-            }
-            Channel.window_width_volume_slider();
-        }
+  if (document.querySelector("#wrapper") == null || embed || client) return;
+  if (window.innerWidth < 601) {
+    var subtract = 0;
+    if (playing) {
+      var height = window.innerHeight - 246 - 170 - subtract;
+      Helper.css("#chat-bar", "height", height + "px");
+      Helper.css("#channelchat", "height", height - 130 + "px");
+      Helper.css("#all_chat", "height", height - 130 + "px");
+      Helper.css("#chat-container", "height", height + "px");
+      subtract = 200;
+    } else {
+      document.querySelector("#chat-bar").style.height = "";
+      document.querySelector("#channelchat").style.height = "";
+      document.querySelector("#all_chat").style.height = "";
+      document.querySelector("#chat-container").style.height = "";
     }
+    var page = List.page;
+    var canFit = List.can_fit;
+    Helper.css(
+      "#wrapper",
+      "height",
+      window.innerHeight - 246 - subtract + "px"
+    );
+
+    if (!embed && !client) {
+      temp_fit = Math.round(Helper.computedStyle("#wrapper", "height") / 71);
+      List.element_height =
+        Helper.computedStyle("#wrapper", "height") / temp_fit - 5.3;
+    } else {
+      temp_fit =
+        Math.round(Helper.computedStyle("#wrapper", "height") / 71) + 1;
+      List.element_height =
+        Helper.computedStyle("#wrapper", "height") / temp_fit - 5.3;
+    }
+    if (List.element_height < 55.2 && !client) {
+      temp_fit = temp_fit - 1;
+      List.element_height = 55.2;
+      temp_fit = Math.round(
+        (window.innerHeight -
+          Helper.computedStyle(".tabs", "height") -
+          Helper.computedStyle("header", "height") -
+          64 -
+          40) /
+          71
+      );
+      List.element_height =
+        (window.innerHeight -
+          Helper.computedStyle(".tabs", "height") -
+          Helper.computedStyle("header", "height") -
+          64 -
+          40) /
+          temp_fit -
+        5;
+    }
+
+    if (temp_fit > List.can_fit || temp_fit < List.can_fit) {
+      List.dynamicContentPage(-10);
+    }
+    if (List.can_fit < temp_fit) {
+      Helper.css(
+        document.querySelector("#wrapper").children,
+        "display",
+        "none"
+      );
+      for (var i = 0; i < List.page + temp_fit; i++) {
+        Helper.css(
+          document.querySelector("#wrapper").children[i],
+          "display",
+          "inline-flex"
+        );
+      }
+    } else if (List.can_fit > temp_fit) {
+      //Helper.css(document.querySelector("#wrapper").children, "display", "none");
+      Helper.css(
+        document.querySelector("#wrapper").children[List.page + temp_fit],
+        "display",
+        "none"
+      );
+      var elements = document.querySelector("#wrapper").children;
+      for (var i = List.page + temp_fit; i < elements.length; i++) {
+        Helper.css(
+          document.querySelector("#wrapper").children[i],
+          "display",
+          "none"
+        );
+      }
+    }
+    List.can_fit = temp_fit;
+    List.element_height =
+      Helper.computedStyle("#wrapper", "height") / List.can_fit - 5.3;
+    Helper.css(".list-song", "height", List.element_height + "px");
+    Channel.set_title_width();
+    var toJumpTo = page / canFit;
+    if (
+      toJumpTo > Math.floor(full_playlist.length / List.can_fit) &&
+      resizing
+    ) {
+      toJumpTo = Math.floor(full_playlist.length / List.can_fit);
+    }
+    List.dynamicContentPageJumpTo(toJumpTo);
+    if (!client) {
+      var controlsPosition =
+        document.querySelector("#controls").offsetHeight -
+        Helper.computedStyle("#controls", "height");
+      if (
+        document.querySelectorAll("#controls").length > 0 &&
+        !Helper.mobilecheck()
+      ) {
+        Helper.css(
+          document.querySelector("#seekToDuration"),
+          "top",
+          controlsPosition - 55
+        );
+      } else if (document.querySelectorAll("#controls").length > 0) {
+        Helper.css(
+          document.querySelector("#seekToDuration"),
+          "top",
+          controlsPosition - 20
+        );
+      }
+      Channel.window_width_volume_slider();
+    }
+  }
 }
 
 function pagination_results(e) {
-    this.preventDefault();
-    var that = e;
-    var pageToken = that.getAttribute("data-pagination");
-    var searchInput = that.getAttribute("data-original-search");
+  this.preventDefault();
+  var that = e;
+  var pageToken = that.getAttribute("data-pagination");
+  var searchInput = that.getAttribute("data-original-search");
 
-    Helper.addClass(".next-results-button", "disabled");
-    Helper.addClass(".prev-results-button", "disabled");
-    Search.search(searchInput, false, false, pageToken);
+  Helper.addClass(".next-results-button", "disabled");
+  Helper.addClass(".prev-results-button", "disabled");
+  Search.search(searchInput, false, false, pageToken);
 }
 
 function handleEvent(e, target, tried, type) {
-    var path = e.path || (e.composedPath && e.composedPath());
-    if(!path) {
-        var path = [target];
-        var parent = target.parentElement;
-        while(parent != null) {
-            path.push(parent);
-            try {
-                parent = parent.parentElement;
-            } catch(e){break;}
-        }
+  var path = e.path || (e.composedPath && e.composedPath());
+  if (!path) {
+    var path = [target];
+    var parent = target.parentElement;
+    while (parent != null) {
+      path.push(parent);
+      try {
+        parent = parent.parentElement;
+      } catch (e) {
+        break;
+      }
     }
-    if(path) {
-        for(var y = 0; y < path.length; y++) {
-            var target = path[y];
-            if(dynamicListeners[type] && dynamicListeners[type]["#" + target.id]) {
-                dynamicListeners[type]["#" + target.id].call(e, target);
-                return;
-            } else {
-                if(target.classList == undefined) return;
-                for(var i = 0; i < target.classList.length; i++) {
-                    if(dynamicListeners[type] && dynamicListeners[type]["." + target.classList[i]]) {
-                        dynamicListeners[type]["." + target.classList[i]].call(e, target);
-                        return;
-                    }
-                }
-            }
+  }
+  if (path) {
+    for (var y = 0; y < path.length; y++) {
+      var target = path[y];
+      if (dynamicListeners[type] && dynamicListeners[type]["#" + target.id]) {
+        dynamicListeners[type]["#" + target.id].call(e, target);
+        return;
+      } else {
+        if (target.classList == undefined) return;
+        for (var i = 0; i < target.classList.length; i++) {
+          if (
+            dynamicListeners[type] &&
+            dynamicListeners[type]["." + target.classList[i]]
+          ) {
+            dynamicListeners[type]["." + target.classList[i]].call(e, target);
+            return;
+          }
         }
+      }
     }
+  }
 }
 
 function addListener(type, element, callback) {
-    if(dynamicListeners[type] == undefined) dynamicListeners[type] = {};
-    dynamicListeners[type][element] = callback;
+  if (dynamicListeners[type] == undefined) dynamicListeners[type] = {};
+  dynamicListeners[type][element] = callback;
 }
 
 function removeListener(type, element) {
-    delete dynamicListeners[type][element];
+  delete dynamicListeners[type][element];
 }
 
 function toast(msg, _class) {
-    switch(msg) {
-        case "other_list_pass":
-        msg = "The other list has a pass, can't import the songs..";
-        break;
-        case "suggested_rules":
-        msg = "Your rules have been suggested";
-        break;
-        case "rules_denied":
-        msg = "Your rules will be denied";
-        break;
-        case "nolist":
-        msg = "There is no list with that name";
-        break;
-        case "suggested_thumbnail":
-        if(embed) return;
-        msg = "The thumbnail has been suggested!";
-        break;
-        case "faulty_start_end":
-        if(embed) return;
-        msg = "You tried to send a faulty start/end value. Try again..";
-        break;
-        case "wait_longer":
-        if(embed) return;
-        msg = Helper.rnd(["Have you tried to wait longer between commands?!", "Looks like you're clicking that button too much..", "You need to wait longer between clicks.."]);
-        break;
-        case "suggested_description":
-        if(embed) return;
-        msg = "The description has been suggested!";
-        break;
-        case "thumbnail_denied":
-        if(embed) return;
-        msg = "The thumbnail is not an url..";
-        break;
-        case "description_denied":
-        if(embed) return;
-        msg = "The description will be denied";
-        break;
-        case "addedsong":
-        if(embed) return;
-        msg=Helper.rnd(["I added your song", "Your song has been added", "Yay, more songs!", "Thats a cool song!", "I added that song for you", "I see you like adding songs..."]);
-        break;
-        case "addedplaylist":
-        if(embed) return;
-        if(Search.submitYouTubeError) {
-            M.toast({html: "Added most of your playlist, but something was wrong. Check the playlist..", displayLength: 4000, classes: "red lighten connect_error"});
-            Search.submitYouTubeError = false;
-            return;
+  switch (msg) {
+    case "other_list_pass":
+      msg = "The other list has a pass, can't import the songs..";
+      break;
+    case "suggested_rules":
+      msg = "Your rules have been suggested";
+      break;
+    case "rules_denied":
+      msg = "Your rules will be denied";
+      break;
+    case "nolist":
+      msg = "There is no list with that name";
+      break;
+    case "suggested_thumbnail":
+      if (embed) return;
+      msg = "The thumbnail has been suggested!";
+      break;
+    case "faulty_start_end":
+      if (embed) return;
+      msg = "You tried to send a faulty start/end value. Try again..";
+      break;
+    case "wait_longer":
+      if (embed) return;
+      msg = Helper.rnd([
+        "Have you tried to wait longer between commands?!",
+        "Looks like you're clicking that button too much..",
+        "You need to wait longer between clicks.."
+      ]);
+      break;
+    case "suggested_description":
+      if (embed) return;
+      msg = "The description has been suggested!";
+      break;
+    case "thumbnail_denied":
+      if (embed) return;
+      msg = "The thumbnail is not an url..";
+      break;
+    case "description_denied":
+      if (embed) return;
+      msg = "The description will be denied";
+      break;
+    case "addedsong":
+      if (embed) return;
+      msg = Helper.rnd([
+        "I added your song",
+        "Your song has been added",
+        "Yay, more songs!",
+        "Thats a cool song!",
+        "I added that song for you",
+        "I see you like adding songs..."
+      ]);
+      break;
+    case "addedplaylist":
+      if (embed) return;
+      if (Search.submitYouTubeError) {
+        M.toast({
+          html:
+            "Added most of your playlist, but something was wrong. Check the playlist..",
+          displayLength: 4000,
+          classes: "red lighten connect_error"
+        });
+        Search.submitYouTubeError = false;
+        return;
+      }
+      msg = Helper.rnd([
+        "I added the playlist",
+        "Your playlist has been added",
+        "Yay, many more songs!",
+        "Thats a cool playlist!",
+        "I added all the songs for you",
+        "I see you like adding songs.."
+      ]);
+      document.getElementById("import").disabled = false;
+      Helper.addClass("#playlist_loader", "hide");
+      Helper.removeClass("#import", "hide");
+      break;
+    case "savedsettings":
+      if (embed) return;
+      msg = Helper.rnd([
+        "I've saved your settings",
+        "I stored all your settings",
+        "Your settings have been stored in a safe place"
+      ]);
+      break;
+    case "wrongpass":
+      if (embed) return;
+      msg = Helper.rnd([
+        "That's not the right password!",
+        "Wrong! Better luck next time...",
+        "You seem to have mistyped the password",
+        "Incorrect. Have you tried meditating?",
+        "Nope, wrong password!",
+        "Wrong password. The authorities have been notified."
+      ]);
+      //Crypt.remove_pass(chan.toLowerCase());
+      Admin.display_logged_out();
+      Helper.css("#thumbnail_form", "display", "none");
+      Helper.css("#description_form", "display", "none");
+      w_p = true;
+      break;
+    case "deleted_songs":
+      if (embed) return;
+      msg = "All songs in the channel has been deleted!";
+      break;
+    case "shuffled":
+      if (embed) return;
+      msg = Helper.rnd([
+        "♫ You stir me right round, baby. ♫",
+        "♫ Stir, stir, stir my boat ♫",
+        "I vigorously stirred your playlist!",
+        "I hope you like your list stirred, not shaken.",
+        "I shuffled your playlist with the cosmic background radiation as a seed. Enjoy.",
+        "100% randomized, for your listening pleasure!",
+        "I hope you enjoy your fresh playlist!"
+      ]);
+      break;
+    case "deletesong":
+      if (embed) return;
+      msg = Helper.rnd([
+        "Your song is now in a better place...",
+        "You won't be seeing any more of that video...",
+        "EXTERMINATE! EXTERMINATE! EXTERMINATE!",
+        "I killed it with fire",
+        "Thanks for deleting that song. I didn't like it anyways...",
+        "Removed song securely."
+      ]);
+      break;
+    case "voted":
+      msg = Helper.rnd([
+        "You voted!",
+        "You vote like a boss",
+        "Voting is the key to democracy",
+        "May you get your song to the very top!",
+        "I love that song! I vouch for you.",
+        "Only you vote that good",
+        "I like the way you vote...",
+        "Up the video goes!",
+        "Voted Zoff for president",
+        "Only 999 more to go!"
+      ]);
+      break;
+    case "alreadyvoted":
+      msg = Helper.rnd([
+        "You can't vote twice on that song!",
+        "I see you have voted on that song before",
+        "One vote per person!",
+        "I know you want to hear your song, but have patience!",
+        "I'm sorry, but I can't let you vote twice, Dave."
+      ]);
+      break;
+    case "skip":
+      if (embed) return;
+      msg = Helper.rnd([
+        "The song was skipped",
+        "I have skipped a song",
+        "Skipped to the beat",
+        "Skipmaster3000",
+        "They see me skippin', they hatin'"
+      ]);
+      break;
+    case "listhaspass":
+      if (embed) return;
+      if (!tried_again && lastCommand != undefined && lastCommand.length > 0) {
+        if (Crypt.get_pass() != undefined) {
+          tried_again = true;
+          if (lastCommand.length == 1) {
+            socket.emit(lastCommand[0]);
+          } else if (lastCommand.length == 2) {
+            socket.emit(lastCommand[0], lastCommand[1]);
+          }
+          lastCommand = [];
+          return;
         }
-        msg=Helper.rnd(["I added the playlist", "Your playlist has been added", "Yay, many more songs!", "Thats a cool playlist!", "I added all the songs for you", "I see you like adding songs.."]);
-        document.getElementById("import").disabled = false;
-        Helper.addClass("#playlist_loader", "hide");
-        Helper.removeClass("#import", "hide");
-        break;
-        case "savedsettings":
-        if(embed) return;
-        msg=Helper.rnd(["I've saved your settings", "I stored all your settings", "Your settings have been stored in a safe place"]);
-        break;
-        case "wrongpass":
-        if(embed) return;
-        msg=Helper.rnd(["That's not the right password!", "Wrong! Better luck next time...", "You seem to have mistyped the password", "Incorrect. Have you tried meditating?","Nope, wrong password!", "Wrong password. The authorities have been notified."]);
-        //Crypt.remove_pass(chan.toLowerCase());
-        Admin.display_logged_out();
-        Helper.css("#thumbnail_form", "display", "none");
-        Helper.css("#description_form", "display", "none");
-        w_p = true;
-        break;
-        case "deleted_songs":
-        if(embed) return;
-        msg="All songs in the channel has been deleted!";
-        break;
-        case "shuffled":
-        if(embed) return;
-        msg=Helper.rnd(["♫ You stir me right round, baby. ♫","♫ Stir, stir, stir my boat ♫","I vigorously stirred your playlist!", "I hope you like your list stirred, not shaken.", "I shuffled your playlist with the cosmic background radiation as a seed. Enjoy.", "100% randomized, for your listening pleasure!", "I hope you enjoy your fresh playlist!"]);
-        break;
-        case "deletesong":
-        if(embed) return;
-        msg=Helper.rnd(["Your song is now in a better place...", "You won't be seeing any more of that video...", "EXTERMINATE! EXTERMINATE! EXTERMINATE!", "I killed it with fire", "Thanks for deleting that song. I didn't like it anyways...", "Removed song securely."]);
-        break;
-        case "voted":
-        msg=Helper.rnd(["You voted!", "You vote like a boss", "Voting is the key to democracy", "May you get your song to the very top!", "I love that song! I vouch for you.", "Only you vote that good", "I like the way you vote...", "Up the video goes!", "Voted Zoff for president", "Only 999 more to go!"]);
-        break;
-        case "alreadyvoted":
-        msg=Helper.rnd(["You can't vote twice on that song!", "I see you have voted on that song before", "One vote per person!", "I know you want to hear your song, but have patience!", "I'm sorry, but I can't let you vote twice, Dave."]);
-        break;
-        case "skip":
-        if(embed) return;
-        msg=Helper.rnd(["The song was skipped", "I have skipped a song", "Skipped to the beat", "Skipmaster3000", "They see me skippin', they hatin'"]);
-        break;
-        case "listhaspass":
-        if(embed) return;
-        if(!tried_again && lastCommand != undefined && lastCommand.length > 0) {
-            if(Crypt.get_pass() != undefined) {
-                tried_again = true;
-                if(lastCommand.length == 1) {
-                    socket.emit(lastCommand[0]);
-                } else if(lastCommand.length == 2) {
-                    socket.emit(lastCommand[0], lastCommand[1]);
-                }
-                lastCommand = [];
-                return;
-            }
+      }
+      document.getElementById("import_spotify").disabled = false;
+      document.getElementById("import").disabled = false;
+      tried_again = false;
+      msg = Helper.rnd([
+        "I'm sorry, but you have to be an admin to do that!",
+        "Only admins can do that",
+        "You're not allowed to do that, try logging in!",
+        "I can't let you do that",
+        "Please log in to do that"
+      ]);
+      //Crypt.remove_pass(chan.toLowerCase());
+      Admin.display_logged_out();
+      Helper.css("#thumbnail_form", "display", "none");
+      Helper.css("#description_form", "display", "none");
+      w_p = true;
+      Helper.addClass("#playlist_loader", "hide");
+      Helper.addClass("#playlist_loader_spotify", "hide");
+      Helper.removeClass("#import_spotify", "hide");
+      Helper.removeClass("#import", "hide");
+      break;
+    case "noskip":
+      if (embed) return;
+      if (!tried_again && lastCommand != undefined && lastCommand.length > 0) {
+        if (Crypt.get_pass() != undefined) {
+          tried_again = true;
+          if (lastCommand.length == 1) {
+            socket.emit(lastCommand[0]);
+          } else if (lastCommand.length == 2) {
+            socket.emit(lastCommand[0], lastCommand[1]);
+          }
+          lastCommand = [];
+          return;
         }
-        document.getElementById("import_spotify").disabled = false;
-        document.getElementById("import").disabled = false;
-        tried_again = false;
-        msg=Helper.rnd(["I'm sorry, but you have to be an admin to do that!", "Only admins can do that", "You're not allowed to do that, try logging in!", "I can't let you do that", "Please log in to do that"]);
-        //Crypt.remove_pass(chan.toLowerCase());
-        Admin.display_logged_out();
-        Helper.css("#thumbnail_form", "display", "none");
-        Helper.css("#description_form", "display", "none");
-        w_p = true;
-        Helper.addClass("#playlist_loader", "hide");
-        Helper.addClass("#playlist_loader_spotify", "hide");
-        Helper.removeClass("#import_spotify", "hide");
-        Helper.removeClass("#import", "hide");
-        break;
-        case "noskip":
-        if(embed) return;
-        if(!tried_again && lastCommand != undefined && lastCommand.length > 0) {
-            if(Crypt.get_pass() != undefined) {
-                tried_again = true;
-                if(lastCommand.length == 1) {
-                    socket.emit(lastCommand[0]);
-                } else if(lastCommand.length == 2) {
-                    socket.emit(lastCommand[0], lastCommand[1]);
-                }
-                lastCommand = [];
-                return;
-            }
-        }
-        tried_again = false;
-        msg=Helper.rnd(["Only Admins can skip songs, peasant!", "You have to log in to skip songs on this channel", "Try clicking the settings icon and logging in before you skip"]);
-        break;
-        case "alreadyskip":
-        if(embed) return;
-        msg=Helper.rnd(["Skipping is democratic, only one vote per person!", "More people have to vote to skip, not just you!", "Get someone else to skip too! You can't do it on yourself."]);
-        break;
-        case "notyetskip":
-        if(embed) return;
-        msg="Skipping is disabled the first 10 seconds.";
-        break;
-        case "correctpass":
-        if(embed) return;
-        tried_again = false;
-        adminpass = Crypt.get_pass(chan.toLowerCase()) == undefined ? Crypt.tmp_pass : Crypt.get_pass(chan.toLowerCase());
-        msg="Correct password. You now have access to the sacred realm of The Admin.";
-        Helper.css("#thumbnail_form", "display", "inline-block");
-        Helper.css("#description_form", "display", "inline-block");
-        break;
-        case "changedpass":
-        if(embed) return;
-        msg="Your password has been changed!";
-        break;
-        case "suggested":
-        if(embed) return;
-        msg="Your song was suggested!";
-        break;
-        case "alreadyplay":
-        if(embed) return;
-        msg="Seems the song you want is already playing. No fooling the system!";
-        break;
-    }
-    before_toast();
-    var classes = _class == undefined ? "" : _class;
-    M.toast({ html: msg, displayLength: 4000, classes: classes});
+      }
+      tried_again = false;
+      msg = Helper.rnd([
+        "Only Admins can skip songs, peasant!",
+        "You have to log in to skip songs on this channel",
+        "Try clicking the settings icon and logging in before you skip"
+      ]);
+      break;
+    case "alreadyskip":
+      if (embed) return;
+      msg = Helper.rnd([
+        "Skipping is democratic, only one vote per person!",
+        "More people have to vote to skip, not just you!",
+        "Get someone else to skip too! You can't do it on yourself."
+      ]);
+      break;
+    case "notyetskip":
+      if (embed) return;
+      msg = "Skipping is disabled the first 10 seconds.";
+      break;
+    case "correctpass":
+      if (embed) return;
+      tried_again = false;
+      adminpass =
+        Crypt.get_pass(chan.toLowerCase()) == undefined
+          ? Crypt.tmp_pass
+          : Crypt.get_pass(chan.toLowerCase());
+      msg =
+        "Correct password. You now have access to the sacred realm of The Admin.";
+      Helper.css("#thumbnail_form", "display", "inline-block");
+      Helper.css("#description_form", "display", "inline-block");
+      break;
+    case "changedpass":
+      if (embed) return;
+      msg = "Your password has been changed!";
+      break;
+    case "suggested":
+      if (embed) return;
+      msg = "Your song was suggested!";
+      break;
+    case "alreadyplay":
+      if (embed) return;
+      msg =
+        "Seems the song you want is already playing. No fooling the system!";
+      break;
+  }
+  before_toast();
+  var classes = _class == undefined ? "" : _class;
+  M.toast({ html: msg, displayLength: 4000, classes: classes });
 }
 
 function emit() {
-    if(!embed) {
-        lastCommand = [];
-        for(var i = 0; i < arguments.length; i++) {
-            lastCommand.push(arguments[i]);
-        }
-    }
-    if(arguments.length == 1) {
-        socket.emit(arguments[0]);
-    } else {
-        socket.emit(arguments[0], arguments[1]);
+  if (!embed) {
+    lastCommand = [];
+    for (var i = 0; i < arguments.length; i++) {
+      lastCommand.push(arguments[i]);
     }
+  }
+  if (arguments.length == 1) {
+    socket.emit(arguments[0]);
+  } else {
+    socket.emit(arguments[0], arguments[1]);
+  }
 }
 
-function before_toast(){
-    M.Toast.dismissAll();
+function before_toast() {
+  M.Toast.dismissAll();
 }
 
 function addJoinBox() {
-    document.querySelector("#video-container").insertAdjacentHTML("beforeend", 'Listen directly on https://zoff.me
');
+  document
+    .querySelector("#video-container")
+    .insertAdjacentHTML(
+      "beforeend",
+      'Listen directly on https://zoff.me
'
+    );
 }
 
 function scrollChat() {
-    var current = document.querySelector(".chatTabs .active").getAttribute("href");
-    if(current == "#channelchat") {
-        document.querySelector('#chatchannel').scrollTop = document.querySelector('#chatchannel').scrollHeight;
-    } else if(current == "#all_chat") {
-        document.querySelector('#chatall').scrollTop = document.querySelector('#chatall').scrollHeight;
-    }
+  var current = document
+    .querySelector(".chatTabs .active")
+    .getAttribute("href");
+  if (current == "#channelchat") {
+    document.querySelector("#chatchannel").scrollTop = document.querySelector(
+      "#chatchannel"
+    ).scrollHeight;
+  } else if (current == "#all_chat") {
+    document.querySelector("#chatall").scrollTop = document.querySelector(
+      "#chatall"
+    ).scrollHeight;
+  }
 }
 
 function hideAllExtra() {
-    document.querySelector(".settings-collapsible").children[0].style.display = "none";
-    document.querySelector(".settings-collapsible").children[2].style.display = "none";
-    document.querySelector(".settings-collapsible").children[3].style.display = "none";
-    document.querySelector(".settings-collapsible").children[4].style.display = "none";
-    document.querySelector(".settings-collapsible").children[5].style.display = "none";
-    document.querySelector(".settings-collapsible").children[6].style.display = "none";
-    document.querySelector(".settings-collapsible").children[7].style.display = "none";
-
+  document.querySelector(".settings-collapsible").children[0].style.display =
+    "none";
+  document.querySelector(".settings-collapsible").children[2].style.display =
+    "none";
+  document.querySelector(".settings-collapsible").children[3].style.display =
+    "none";
+  document.querySelector(".settings-collapsible").children[4].style.display =
+    "none";
+  document.querySelector(".settings-collapsible").children[5].style.display =
+    "none";
+  document.querySelector(".settings-collapsible").children[6].style.display =
+    "none";
+  document.querySelector(".settings-collapsible").children[7].style.display =
+    "none";
 }
 
 function searchTimeout(event) {
-    search_input = document.getElementsByClassName("search_input")[0].value;
+  search_input = document.getElementsByClassName("search_input")[0].value;
 
-    code = event.keyCode || event.which;
+  code = event.keyCode || event.which;
 
-    if (code != 40 && code != 38 && code != 13 && code != 39 && code != 37 && code != 17 && code != 16 && code != 225 && code != 18 && code != 27) {
-        clearTimeout(timeout_search);
-        /*if(search_input.length < 3){
+  if (
+    code != 40 &&
+    code != 38 &&
+    code != 13 &&
+    code != 39 &&
+    code != 37 &&
+    code != 17 &&
+    code != 16 &&
+    code != 225 &&
+    code != 18 &&
+    code != 27
+  ) {
+    clearTimeout(timeout_search);
+    /*if(search_input.length < 3){
         Helper.css(".results-tabs", "display", "none");
         document.querySelector("#results").innerHTML = "";
         document.querySelector("#results_soundcloud").innerHTML = "";
@@ -1433,14 +1964,14 @@ function searchTimeout(event) {
         document.querySelector("body").setAttribute("style", "overflow-y: auto");
     }
 }*/
-if(code == 13){
-    Search.search(search_input);
-    Search.soundcloudSearch(search_input);
-}else{
-    timeout_search = setTimeout(function(){
+    if (code == 13) {
+      Search.search(search_input);
+      Search.soundcloudSearch(search_input);
+    } else {
+      timeout_search = setTimeout(function() {
         Search.search(search_input);
         Search.soundcloudSearch(search_input);
-    }, 1000);
-}
-}
+      }, 1000);
+    }
+  }
 }
diff --git a/server/public/assets/js/list.js b/server/public/assets/js/list.js
index 07a8ca1d..95bd1e55 100755
--- a/server/public/assets/js/list.js
+++ b/server/public/assets/js/list.js
@@ -1,1376 +1,2018 @@
 var List = {
+  empty: false,
+  page: 0,
+  can_fit:
+    document.querySelectorAll("#wrapper").length > 0
+      ? Math.round(Helper.computedStyle("#wrapper", "height") / 71)
+      : 0,
+  element_height:
+    document.querySelectorAll("#wrapper").length > 0
+      ? Helper.computedStyle("#wrapper", "height") /
+          Math.round(Helper.computedStyle("#wrapper", "height") / 71) -
+        25
+      : 0,
+  uris: [],
+  not_found: [],
+  num_songs: 0,
+  found: [],
 
-    empty: false,
-    page: 0,
-    can_fit: document.querySelectorAll("#wrapper").length > 0 ? Math.round(Helper.computedStyle("#wrapper", "height") / 71) : 0,
-    element_height: document.querySelectorAll("#wrapper").length > 0 ? (Helper.computedStyle("#wrapper", "height") / Math.round(Helper.computedStyle("#wrapper", "height") / 71)) - 25 : 0,
-    uris: [],
-    not_found: [],
-    num_songs: 0,
-    found: [],
-
-    channel_function: function(msg) {
-        if(Helper.mobilecheck()) socket_connected = true;
-        if(user_auth_started) {
-            user_auth_started = false;
-            M.Modal.getInstance(document.getElementById("user_password")).close();
-        }
-        switch(msg.type)
-        {
-
-            case "list":
-                //if(full_playlist == undefined || !offline){
-                if((!offline || (offline && !msg.shuffled)) && !(offline && prev_chan_list == chan)){
-                    prev_chan_list = chan;
-                    List.populate_list(msg.playlist);
-                    if(full_playlist.length > 0) {
-                        Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail});
-                    }
-                } else if(offline && prev_chan_list == chan && full_playlist != undefined && !msg.shuffled){
-                    List.populate_list(full_playlist, true);
-                    if(full_playlist.length > 0) {
-                        Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail});
-                    }
-                }
-                break;
-            case "added":
-                List.added_song(msg.value);
-                if(full_playlist.length > 0) {
-                    Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail});
-                }
-                found_array = [];
-                found_array_index = 0;
-                break;
-            case "deleted":
-                List.deleted_song(msg.value, msg.removed);
-                found_array = [];
-                found_array_index = 0;
-                break;
-            case "vote":
-                if(!offline){
-                    List.voted_song(msg.value, msg.time);
-                    if(full_playlist.length > 0) {
-                        Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail});
-                    }
-                }
-                found_array = [];
-                found_array_index = 0;
-                break;
-            case "song_change":
-                if((offline && msg.offline_change) || !offline) {
-                    if(window.location.pathname != "/") List.song_change(msg.time, msg.remove, msg.id);
-                    if(full_playlist.length > 0) {
-                        Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail});
-                    }
-                    found_array = [];
-                    found_array_index = 0;
-                }
-                break;
-            case "changed_values":
-                List.changedValues(msg.value);
-                break;
-            case "song_change_prev":
-                if((offline && msg.offline_change) || !offline) {
-
-                    if(window.location.pathname != "/") List.song_change_prev(msg.time);
-                    if(full_playlist.length > 0) {
-                        Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail});
-                    }
-                    found_array = [];
-                    found_array_index = 0;
-                }
-                break;
-        }
-    },
-
-    changedValues: function(song) {
-        if(song.type == "suggested") {
-            try {
-                document.querySelector("#suggested-" + song.id).querySelector(".vote-container").setAttribute("title", song.title);
-                document.querySelector("#suggested-" + song.id).querySelector(".list-title").setAttribute("title", song.title);
-                document.querySelector("#suggested-" + song.id).querySelector(".list-title").innerText =  song.title;
-                var _temp_duration = Helper.secondsToOther(song.duration);
-                document.querySelector("#suggested-" + song.id).querySelector(".card-duration").innerText =  Helper.pad(_temp_duration[0]) + ":" + Helper.pad(_temp_duration[1]);
-                document.querySelector("#suggested-" + song.id).querySelector(".list-image").setAttribute("style", "background-image:url('//img.youtube.com/vi/"+song.new_id+"/mqdefault.jpg');");
-                document.querySelector("#suggested-" + song.id).setAttribute("id", song.new_id);
-            } catch(e) {}
-            return;
-        }
-        var i = List.getIndexOfSong(song.id);
-        if(i >= 0 && window.location.pathname != "/") {
-            full_playlist[i].title = song.title;
-            full_playlist[i].duration = song.duration;
-            full_playlist[i].start = song.start;
-            full_playlist[i].end = song.end;
-            full_playlist[i].id = song.new_id;
-            try {
-                document.querySelector("#" + song.id).querySelector(".vote-container").setAttribute("title", song.title);
-                document.querySelector("#" + song.id).querySelector(".list-title").setAttribute("title", song.title);
-                document.querySelector("#" + song.id).querySelector(".list-title").innerText = song.title;
-                var _temp_duration = Helper.secondsToOther(song.duration);
-                document.querySelector("#" + song.id).querySelector(".card-duration").innerText = Helper.pad(_temp_duration[0]) + ":" + Helper.pad(_temp_duration[1]);
-                document.querySelector("#" + song.id).querySelector(".list-image").setAttribute("style", "background-image:url('//img.youtube.com/vi/"+song.new_id+"/mqdefault.jpg');");
-                document.querySelector("#" + song.id).setAttribute("id", song.new_id);
-            } catch(e) {}
-        }
-    },
-
-    insertAtBeginning: function(song_info, transition) {
-        if(document.querySelector("#wrapper") == null) return;
-        var display = List.page == 0 ? "" : "none";
-        var add = List.generateSong(song_info, transition, false, true, false, display, false);
-        document.querySelector("#wrapper").insertAdjacentHTML("beforeend", add);
-    },
-
-    insertAtIndex: function(song_info, transition, change) {
-        if(document.querySelector("#wrapper") == null) return;
-        var i = List.getIndexOfSong(song_info.id);
-        if(i == -1) return;
-        if(!song_info.now_playing){
-            var display = "none";
-            if(i >= List.page && i < List.page + (List.can_fit)) display = "inline-flex"
-            var add = List.generateSong(song_info, transition, false, true, false, display, false);
-            if(i === 0) {
-                document.querySelector("#wrapper").insertAdjacentHTML("afterbegin", add);
-            } else {
-                document.querySelector("#wrapper > div:nth-child(" + (i) + ")").insertAdjacentHTML("afterend", add);
-            }
-            var added = document.querySelector("#wrapper").children[i];
-            Helper.css(added, "display", display);
-            if(display == "inline-flex" && document.querySelector("#wrapper").children.length >= List.page + List.can_fit + 1){
-                Helper.css(document.querySelector("#wrapper").children[List.page + List.can_fit], "display", "none");
-            } else if(i < List.page && document.querySelector("#wrapper").children.length - (List.page + 1) >= 0){
-                Helper.css(document.querySelector("#wrapper").children[List.page], "display", "inline-flex");
-            } else if(document.querySelector("#wrapper").children.length > List.page + List.can_fit){
-                Helper.css(document.querySelector("#wrapper").children[List.page + List.can_fit - 1], "display", "inline-flex");
-            }
-            if(change && List.page > 0){
-                Helper.css(document.querySelector("#wrapper").children[List.page - 1], "display", "none");
-            }
-            if(transition){
-                setTimeout(function(){
-                    Helper.css(added, "transform", "translateX(0%)");
-                    setTimeout(function() {
-                        Helper.removeClass(added, "side_away");
-                    }, 300);
-                },5);
-            }
-        }
-    },
-
-    calculate_song_heights: function(){
-        if(!Helper.mobilecheck() && !embed && !client){
-            List.can_fit = Math.round(Helper.computedStyle("#wrapper", "height") / 71);
-            List.element_height = (Helper.computedStyle("#wrapper", "height") / List.can_fit)-5.3;
-        } else if(embed) {
-            List.can_fit = Math.round(Helper.computedStyle("#wrapper", "height") / 91) + 1;
-            List.element_height = (Helper.computedStyle("#wrapper", "height") / List.can_fit)-4;
-        } else if(!client){
-            List.can_fit = Math.round((Helper.computedStyle(".tabs", "height") - Helper.computedStyle("header", "height") - 64 - 40) / 71)+1;
-            List.element_height = ((window.innerHeight - Helper.computedStyle(".tabs", "height") - Helper.computedStyle("header", "height") - 64 - 40) / List.can_fit)-5;
-        } else {
-            List.can_fit = Math.round(Helper.computedStyle("#wrapper", "height") / 71)+1;
-            List.element_height = (Helper.computedStyle("#wrapper", "height") / List.can_fit)-5.3;
-        }
-        if(List.element_height < 55.2 && !client && !embed){
-            List.can_fit = List.can_fit - 1;
-            List.element_height = 55.2;
-            List.can_fit = Math.round((window.innerHeight - Helper.computedStyle(".tabs", "height") - Helper.computedStyle("header", "height") - 64 - 40) / 71);
-            List.element_height = ((window.innerHeight - Helper.computedStyle(".tabs", "height") - Helper.computedStyle("header", "height") - 64 - 40) / List.can_fit)-5;
-        } else if(List.element_height < 55.2 && embed) {
-            //List.can_fit = List.can_fit - 1;
-            List.can_fit = Math.round((window.innerHeight - Helper.computedStyle(".tabs", "height") - Helper.computedStyle("header", "height") - 64 - 40) / 71);
-            List.element_height = ((window.innerHeight - Helper.computedStyle(".tabs", "height") - Helper.computedStyle("header", "height") - 64 - 40) / List.can_fit)-5;
-            List.can_fit = List.can_fit - 2;
-        }
-    },
-
-    populate_list: function(msg, no_reset) {
-        if(document.querySelector("#wrapper") == null) return;
-        // This math is fucked and I don't know how it works. Should be fixed sometime
-        if(list_html === undefined) list_html = Helper.html("#list-song-html");
-        full_playlist = msg;
-        if(offline && !no_reset){
-            for(var x = 0; x < full_playlist.length; x++){
-                full_playlist[x].votes = 0;
-            }
-        }
-        List.sortList();
-
-        Helper.setHtml("#wrapper", "");
-
-        Helper.log([
-            "FULL PLAYLIST",
-            full_playlist
-        ]);
-        if(full_playlist.length > 1){
-            for(var j = 0; j < full_playlist.length; j++) {
-                var _current_song = full_playlist[j];
-                if(!_current_song.hasOwnProperty("start")) full_playlist[j].start = 0;
-                if(!_current_song.hasOwnProperty("end")) full_playlist[j].end = full_playlist[j].duration;
-                if(!_current_song.now_playing && _current_song.type != "suggested"){ //check that the song isnt playing
-                    var generated = List.generateSong(_current_song, false, lazy_load, true, false, "inline-flex", true)
-                    document.querySelector("#wrapper").insertAdjacentHTML("beforeend", generated);
-                }
-            }
-            if(document.querySelector("#wrapper").children.length > List.can_fit && !document.querySelectorAll("#pageButtons").length){
-                Helper.css(".prev_page", "display", "none");
-                Helper.css(".first_page", "display", "none");
-                Helper.css(".next_page_hide", "display","none");
-                Helper.css(".last_page_hide", "display","none");
-            } else if(!document.querySelectorAll("#pageButtons").length){
-                Helper.css(".prev_page", "display", "none");
-                Helper.css(".next_page", "display", "none");
-                Helper.css(".last_page", "display", "none");
-                Helper.css(".first_page", "display", "none");
-                Helper.css(".next_page_hide", "display","inline-flex");
-                Helper.css(".prev_page_hide", "display","inline-flex");
-            } else {
-                Helper.css(".next_page", "display", "none");
-                Helper.css(".last_page", "display", "none");
-            }
-
-            List.dynamicContentPage(-10);
-
-
-        } else {
-            List.empty = true;
-            Helper.setHtml("#wrapper", "The playlist is empty.");
-            Helper.css(".prev_page","display", "none");
-            Helper.css(".next_page","display", "none");
-            Helper.css(".last_page","display", "none");
-            Helper.css(".last_page_hide","display", "inline-flex");
-            Helper.css(".first_page","display", "none");
-            Helper.css(".next_page_hide", "display","inline-flex");
-            Helper.css(".prev_page_hide","display","inline-flex");
-        }
-        Helper.css("#settings","visibility", "visible");
-        Helper.css("#settings","opacity", "1");
-        Helper.css("#wrapper","opacity", "1");
-        Helper.removeClass("#pageButtons", "hide");
-
-        if(!embed) {
-            Helper.log(["Starting empty-checker"]);
-            clearTimeout(timed_remove_check);
-            timed_remove_check = setTimeout(function() {
-                if(full_playlist.length > 0) {
-                    List.check_error_videos(0);
-                }
-            }, 1500);
-        }
-    },
-
-    check_error_videos: function(i) {
-        //Helper.log("Empty-checker at " + i);
-        if(full_playlist.length == 0) return;
-        else if(full_playlist[i].source == "soundcloud" && full_playlist.length > i + 1 && window.location.pathname != "/") List.check_error_videos(i + 1);
-        else {
-            Helper.ajax({
-                method: "get",
-                url: 'https://www.googleapis.com/youtube/v3/videos?id=' + full_playlist[i].id
-                       + "&key=" + api_key.youtube + "&part=snippet",
-                success:  function (data) {
-                    data = JSON.parse(data);
-                      //Helper.log("Empty-checker items " + data.items.length);
-                    if (data.items.length == 0) {
-                        Helper.log(["Emtpy-checker error at " + full_playlist[i].id + " " + full_playlist[i].title]);
-                        socket.emit("error_video", {channel: chan.toLowerCase(), id: full_playlist[i].id, title: full_playlist[i].title, source: full_playlist[i].source});
-                    }
-                    if(full_playlist.length > i + 1 && window.location.pathname != "/") {
-                        List.check_error_videos(i + 1);
-                    }
-                }
+  channel_function: function(msg) {
+    if (Helper.mobilecheck()) socket_connected = true;
+    if (user_auth_started) {
+      user_auth_started = false;
+      M.Modal.getInstance(document.getElementById("user_password")).close();
+    }
+    switch (msg.type) {
+      case "list":
+        //if(full_playlist == undefined || !offline){
+        if (
+          (!offline || (offline && !msg.shuffled)) &&
+          !(offline && prev_chan_list == chan)
+        ) {
+          prev_chan_list = chan;
+          List.populate_list(msg.playlist);
+          if (full_playlist.length > 0) {
+            Player.sendNext({
+              title: full_playlist[0].title,
+              videoId: full_playlist[0].id,
+              source: full_playlist[0].source,
+              thumbnail: full_playlist[0].thumbnail
             });
+          }
+        } else if (
+          offline &&
+          prev_chan_list == chan &&
+          full_playlist != undefined &&
+          !msg.shuffled
+        ) {
+          List.populate_list(full_playlist, true);
+          if (full_playlist.length > 0) {
+            Player.sendNext({
+              title: full_playlist[0].title,
+              videoId: full_playlist[0].id,
+              source: full_playlist[0].source,
+              thumbnail: full_playlist[0].thumbnail
+            });
+          }
         }
-    },
-
-    dynamicContentPageJumpTo: function(page) {
-        if(document.querySelector("#wrapper") == null) return
-        page = page * List.can_fit;
-        var wrapperChildren = [].slice.call(document.querySelector("#wrapper").children);
-        if(page > List.page || page < List.page){
-            Helper.css(wrapperChildren.slice(List.page, List.page + List.can_fit), "display", "none");
-            List.page = page;
-            Helper.css(wrapperChildren.slice(List.page, List.page + List.can_fit), "display", "inline-flex");
-            if(List.page > 0 && document.querySelector(".prev_page").style.display == "none"){
-                Helper.css(".prev_page", "display", "inline-flex");
-                Helper.css(".prev_page_hide", "display", "none");
-                Helper.css(".first_page", "display", "inline-flex");
-                Helper.css(".first_page_hide", "display", "none");
-            }
-
-            if(List.page + List.can_fit >= wrapperChildren.length){
-                Helper.css(".next_page_hide", "display", "inline-flex");
-                Helper.css(".next_page", "display", "none");
-                Helper.css(".last_page_hide", "display", "inline-flex");
-                Helper.css(".last_page", "display", "none");
-            }
-
-            Helper.setHtml("#pageNumber", (List.page / List.can_fit) + 1);
+        break;
+      case "added":
+        List.added_song(msg.value);
+        if (full_playlist.length > 0) {
+          Player.sendNext({
+            title: full_playlist[0].title,
+            videoId: full_playlist[0].id,
+            source: full_playlist[0].source,
+            thumbnail: full_playlist[0].thumbnail
+          });
         }
-    },
+        found_array = [];
+        found_array_index = 0;
+        break;
+      case "deleted":
+        List.deleted_song(msg.value, msg.removed);
+        found_array = [];
+        found_array_index = 0;
+        break;
+      case "vote":
+        if (!offline) {
+          List.voted_song(msg.value, msg.time);
+          if (full_playlist.length > 0) {
+            Player.sendNext({
+              title: full_playlist[0].title,
+              videoId: full_playlist[0].id,
+              source: full_playlist[0].source,
+              thumbnail: full_playlist[0].thumbnail
+            });
+          }
+        }
+        found_array = [];
+        found_array_index = 0;
+        break;
+      case "song_change":
+        if ((offline && msg.offline_change) || !offline) {
+          if (window.location.pathname != "/")
+            List.song_change(msg.time, msg.remove, msg.id);
+          if (full_playlist.length > 0) {
+            Player.sendNext({
+              title: full_playlist[0].title,
+              videoId: full_playlist[0].id,
+              source: full_playlist[0].source,
+              thumbnail: full_playlist[0].thumbnail
+            });
+          }
+          found_array = [];
+          found_array_index = 0;
+        }
+        break;
+      case "changed_values":
+        List.changedValues(msg.value);
+        break;
+      case "song_change_prev":
+        if ((offline && msg.offline_change) || !offline) {
+          if (window.location.pathname != "/") List.song_change_prev(msg.time);
+          if (full_playlist.length > 0) {
+            Player.sendNext({
+              title: full_playlist[0].title,
+              videoId: full_playlist[0].id,
+              source: full_playlist[0].source,
+              thumbnail: full_playlist[0].thumbnail
+            });
+          }
+          found_array = [];
+          found_array_index = 0;
+        }
+        break;
+    }
+  },
 
-    dynamicContentPage: function(way) {
-        if(document.querySelector("#wrapper") == null) return
-        var wrapperChildren = [].slice.call(document.querySelector("#wrapper").children);
-        if(way == 1 || way == 10) {
-            Helper.css(wrapperChildren.slice(List.page, List.page + List.can_fit), "display", "none");
-            if(way == 1){
-                List.page = List.page + List.can_fit;
-            } else if(way == 10) {
-                List.page = (Math.floor((document.querySelector("#wrapper").children.length - 1)/ List.can_fit) * List.can_fit);
+  changedValues: function(song) {
+    if (song.type == "suggested") {
+      try {
+        document
+          .querySelector("#suggested-" + song.id)
+          .querySelector(".vote-container")
+          .setAttribute("title", song.title);
+        document
+          .querySelector("#suggested-" + song.id)
+          .querySelector(".list-title")
+          .setAttribute("title", song.title);
+        document
+          .querySelector("#suggested-" + song.id)
+          .querySelector(".list-title").innerText = song.title;
+        var _temp_duration = Helper.secondsToOther(song.duration);
+        document
+          .querySelector("#suggested-" + song.id)
+          .querySelector(".card-duration").innerText =
+          Helper.pad(_temp_duration[0]) + ":" + Helper.pad(_temp_duration[1]);
+        document
+          .querySelector("#suggested-" + song.id)
+          .querySelector(".list-image")
+          .setAttribute(
+            "style",
+            "background-image:url('//img.youtube.com/vi/" +
+              song.new_id +
+              "/mqdefault.jpg');"
+          );
+        document
+          .querySelector("#suggested-" + song.id)
+          .setAttribute("id", song.new_id);
+      } catch (e) {}
+      return;
+    }
+    var i = List.getIndexOfSong(song.id);
+    if (i >= 0 && window.location.pathname != "/") {
+      full_playlist[i].title = song.title;
+      full_playlist[i].duration = song.duration;
+      full_playlist[i].start = song.start;
+      full_playlist[i].end = song.end;
+      full_playlist[i].id = song.new_id;
+      try {
+        document
+          .querySelector("#" + song.id)
+          .querySelector(".vote-container")
+          .setAttribute("title", song.title);
+        document
+          .querySelector("#" + song.id)
+          .querySelector(".list-title")
+          .setAttribute("title", song.title);
+        document
+          .querySelector("#" + song.id)
+          .querySelector(".list-title").innerText = song.title;
+        var _temp_duration = Helper.secondsToOther(song.duration);
+        document
+          .querySelector("#" + song.id)
+          .querySelector(".card-duration").innerText =
+          Helper.pad(_temp_duration[0]) + ":" + Helper.pad(_temp_duration[1]);
+        document
+          .querySelector("#" + song.id)
+          .querySelector(".list-image")
+          .setAttribute(
+            "style",
+            "background-image:url('//img.youtube.com/vi/" +
+              song.new_id +
+              "/mqdefault.jpg');"
+          );
+        document.querySelector("#" + song.id).setAttribute("id", song.new_id);
+      } catch (e) {}
+    }
+  },
 
-            }
-            Helper.css(wrapperChildren.slice(List.page, List.page + List.can_fit), "display", "inline-flex");
+  insertAtBeginning: function(song_info, transition) {
+    if (document.querySelector("#wrapper") == null) return;
+    var display = List.page == 0 ? "" : "none";
+    var add = List.generateSong(
+      song_info,
+      transition,
+      false,
+      true,
+      false,
+      display,
+      false
+    );
+    document.querySelector("#wrapper").insertAdjacentHTML("beforeend", add);
+  },
 
-            if(List.page > 0 && document.querySelector(".prev_page").style.display  == "none"){
-                Helper.css(".prev_page", "display", "inline-flex");
-                Helper.css(".prev_page_hide", "display", "none");
-                Helper.css(".first_page", "display", "inline-flex");
-                Helper.css(".first_page_hide", "display", "none");
-            }
-            if(List.page + List.can_fit >= document.querySelector("#wrapper").children.length){
-                Helper.css(".next_page_hide", "display", "inline-flex");
-                Helper.css(".next_page", "display", "none");
-                Helper.css(".last_page_hide", "display", "inline-flex");
-                Helper.css(".last_page", "display", "none");
-            }
+  insertAtIndex: function(song_info, transition, change) {
+    if (document.querySelector("#wrapper") == null) return;
+    var i = List.getIndexOfSong(song_info.id);
+    if (i == -1) return;
+    if (!song_info.now_playing) {
+      var display = "none";
+      if (i >= List.page && i < List.page + List.can_fit)
+        display = "inline-flex";
+      var add = List.generateSong(
+        song_info,
+        transition,
+        false,
+        true,
+        false,
+        display,
+        false
+      );
+      if (i === 0) {
+        document
+          .querySelector("#wrapper")
+          .insertAdjacentHTML("afterbegin", add);
+      } else {
+        document
+          .querySelector("#wrapper > div:nth-child(" + i + ")")
+          .insertAdjacentHTML("afterend", add);
+      }
+      var added = document.querySelector("#wrapper").children[i];
+      Helper.css(added, "display", display);
+      if (
+        display == "inline-flex" &&
+        document.querySelector("#wrapper").children.length >=
+          List.page + List.can_fit + 1
+      ) {
+        Helper.css(
+          document.querySelector("#wrapper").children[List.page + List.can_fit],
+          "display",
+          "none"
+        );
+      } else if (
+        i < List.page &&
+        document.querySelector("#wrapper").children.length - (List.page + 1) >=
+          0
+      ) {
+        Helper.css(
+          document.querySelector("#wrapper").children[List.page],
+          "display",
+          "inline-flex"
+        );
+      } else if (
+        document.querySelector("#wrapper").children.length >
+        List.page + List.can_fit
+      ) {
+        Helper.css(
+          document.querySelector("#wrapper").children[
+            List.page + List.can_fit - 1
+          ],
+          "display",
+          "inline-flex"
+        );
+      }
+      if (change && List.page > 0) {
+        Helper.css(
+          document.querySelector("#wrapper").children[List.page - 1],
+          "display",
+          "none"
+        );
+      }
+      if (transition) {
+        setTimeout(function() {
+          Helper.css(added, "transform", "translateX(0%)");
+          setTimeout(function() {
+            Helper.removeClass(added, "side_away");
+          }, 300);
+        }, 5);
+      }
+    }
+  },
+
+  calculate_song_heights: function() {
+    if (!Helper.mobilecheck() && !embed && !client) {
+      List.can_fit = Math.round(
+        Helper.computedStyle("#wrapper", "height") / 71
+      );
+      List.element_height =
+        Helper.computedStyle("#wrapper", "height") / List.can_fit - 5.3;
+    } else if (embed) {
+      List.can_fit =
+        Math.round(Helper.computedStyle("#wrapper", "height") / 91) + 1;
+      List.element_height =
+        Helper.computedStyle("#wrapper", "height") / List.can_fit - 4;
+    } else if (!client) {
+      List.can_fit =
+        Math.round(
+          (Helper.computedStyle(".tabs", "height") -
+            Helper.computedStyle("header", "height") -
+            64 -
+            40) /
+            71
+        ) + 1;
+      List.element_height =
+        (window.innerHeight -
+          Helper.computedStyle(".tabs", "height") -
+          Helper.computedStyle("header", "height") -
+          64 -
+          40) /
+          List.can_fit -
+        5;
+    } else {
+      List.can_fit =
+        Math.round(Helper.computedStyle("#wrapper", "height") / 71) + 1;
+      List.element_height =
+        Helper.computedStyle("#wrapper", "height") / List.can_fit - 5.3;
+    }
+    if (List.element_height < 55.2 && !client && !embed) {
+      List.can_fit = List.can_fit - 1;
+      List.element_height = 55.2;
+      List.can_fit = Math.round(
+        (window.innerHeight -
+          Helper.computedStyle(".tabs", "height") -
+          Helper.computedStyle("header", "height") -
+          64 -
+          40) /
+          71
+      );
+      List.element_height =
+        (window.innerHeight -
+          Helper.computedStyle(".tabs", "height") -
+          Helper.computedStyle("header", "height") -
+          64 -
+          40) /
+          List.can_fit -
+        5;
+    } else if (List.element_height < 55.2 && embed) {
+      //List.can_fit = List.can_fit - 1;
+      List.can_fit = Math.round(
+        (window.innerHeight -
+          Helper.computedStyle(".tabs", "height") -
+          Helper.computedStyle("header", "height") -
+          64 -
+          40) /
+          71
+      );
+      List.element_height =
+        (window.innerHeight -
+          Helper.computedStyle(".tabs", "height") -
+          Helper.computedStyle("header", "height") -
+          64 -
+          40) /
+          List.can_fit -
+        5;
+      List.can_fit = List.can_fit - 2;
+    }
+  },
+
+  populate_list: function(msg, no_reset) {
+    if (document.querySelector("#wrapper") == null) return;
+    // This math is fucked and I don't know how it works. Should be fixed sometime
+    if (list_html === undefined) list_html = Helper.html("#list-song-html");
+    full_playlist = msg;
+    if (offline && !no_reset) {
+      for (var x = 0; x < full_playlist.length; x++) {
+        full_playlist[x].votes = 0;
+      }
+    }
+    List.sortList();
+
+    Helper.setHtml("#wrapper", "");
+
+    Helper.log(["FULL PLAYLIST", full_playlist]);
+    if (full_playlist.length > 1) {
+      for (var j = 0; j < full_playlist.length; j++) {
+        var _current_song = full_playlist[j];
+        if (!_current_song.hasOwnProperty("start")) full_playlist[j].start = 0;
+        if (!_current_song.hasOwnProperty("end"))
+          full_playlist[j].end = full_playlist[j].duration;
+        if (!_current_song.now_playing && _current_song.type != "suggested") {
+          //check that the song isnt playing
+          var generated = List.generateSong(
+            _current_song,
+            false,
+            lazy_load,
+            true,
+            false,
+            "inline-flex",
+            true
+          );
+          document
+            .querySelector("#wrapper")
+            .insertAdjacentHTML("beforeend", generated);
+        }
+      }
+      if (
+        document.querySelector("#wrapper").children.length > List.can_fit &&
+        !document.querySelectorAll("#pageButtons").length
+      ) {
+        Helper.css(".prev_page", "display", "none");
+        Helper.css(".first_page", "display", "none");
+        Helper.css(".next_page_hide", "display", "none");
+        Helper.css(".last_page_hide", "display", "none");
+      } else if (!document.querySelectorAll("#pageButtons").length) {
+        Helper.css(".prev_page", "display", "none");
+        Helper.css(".next_page", "display", "none");
+        Helper.css(".last_page", "display", "none");
+        Helper.css(".first_page", "display", "none");
+        Helper.css(".next_page_hide", "display", "inline-flex");
+        Helper.css(".prev_page_hide", "display", "inline-flex");
+      } else {
+        Helper.css(".next_page", "display", "none");
+        Helper.css(".last_page", "display", "none");
+      }
+
+      List.dynamicContentPage(-10);
+    } else {
+      List.empty = true;
+      Helper.setHtml(
+        "#wrapper",
+        "The playlist is empty."
+      );
+      Helper.css(".prev_page", "display", "none");
+      Helper.css(".next_page", "display", "none");
+      Helper.css(".last_page", "display", "none");
+      Helper.css(".last_page_hide", "display", "inline-flex");
+      Helper.css(".first_page", "display", "none");
+      Helper.css(".next_page_hide", "display", "inline-flex");
+      Helper.css(".prev_page_hide", "display", "inline-flex");
+    }
+    Helper.css("#settings", "visibility", "visible");
+    Helper.css("#settings", "opacity", "1");
+    Helper.css("#wrapper", "opacity", "1");
+    Helper.removeClass("#pageButtons", "hide");
+
+    if (!embed) {
+      Helper.log(["Starting empty-checker"]);
+      clearTimeout(timed_remove_check);
+      timed_remove_check = setTimeout(function() {
+        if (full_playlist.length > 0) {
+          List.check_error_videos(0);
+        }
+      }, 1500);
+    }
+  },
+
+  check_error_videos: function(i) {
+    //Helper.log("Empty-checker at " + i);
+    if (full_playlist.length == 0) return;
+    else if (
+      full_playlist[i].source == "soundcloud" &&
+      full_playlist.length > i + 1 &&
+      window.location.pathname != "/"
+    )
+      List.check_error_videos(i + 1);
+    else {
+      Helper.ajax({
+        method: "get",
+        url:
+          "https://www.googleapis.com/youtube/v3/videos?id=" +
+          full_playlist[i].id +
+          "&key=" +
+          api_key.youtube +
+          "&part=snippet",
+        success: function(data) {
+          data = JSON.parse(data);
+          //Helper.log("Empty-checker items " + data.items.length);
+          if (data.items.length == 0) {
+            Helper.log([
+              "Emtpy-checker error at " +
+                full_playlist[i].id +
+                " " +
+                full_playlist[i].title
+            ]);
+            socket.emit("error_video", {
+              channel: chan.toLowerCase(),
+              id: full_playlist[i].id,
+              title: full_playlist[i].title,
+              source: full_playlist[i].source
+            });
+          }
+          if (full_playlist.length > i + 1 && window.location.pathname != "/") {
+            List.check_error_videos(i + 1);
+          }
+        }
+      });
+    }
+  },
+
+  dynamicContentPageJumpTo: function(page) {
+    if (document.querySelector("#wrapper") == null) return;
+    page = page * List.can_fit;
+    var wrapperChildren = [].slice.call(
+      document.querySelector("#wrapper").children
+    );
+    if (page > List.page || page < List.page) {
+      Helper.css(
+        wrapperChildren.slice(List.page, List.page + List.can_fit),
+        "display",
+        "none"
+      );
+      List.page = page;
+      Helper.css(
+        wrapperChildren.slice(List.page, List.page + List.can_fit),
+        "display",
+        "inline-flex"
+      );
+      if (
+        List.page > 0 &&
+        document.querySelector(".prev_page").style.display == "none"
+      ) {
+        Helper.css(".prev_page", "display", "inline-flex");
+        Helper.css(".prev_page_hide", "display", "none");
+        Helper.css(".first_page", "display", "inline-flex");
+        Helper.css(".first_page_hide", "display", "none");
+      }
+
+      if (List.page + List.can_fit >= wrapperChildren.length) {
+        Helper.css(".next_page_hide", "display", "inline-flex");
+        Helper.css(".next_page", "display", "none");
+        Helper.css(".last_page_hide", "display", "inline-flex");
+        Helper.css(".last_page", "display", "none");
+      }
+
+      Helper.setHtml("#pageNumber", List.page / List.can_fit + 1);
+    }
+  },
+
+  dynamicContentPage: function(way) {
+    if (document.querySelector("#wrapper") == null) return;
+    var wrapperChildren = [].slice.call(
+      document.querySelector("#wrapper").children
+    );
+    if (way == 1 || way == 10) {
+      Helper.css(
+        wrapperChildren.slice(List.page, List.page + List.can_fit),
+        "display",
+        "none"
+      );
+      if (way == 1) {
+        List.page = List.page + List.can_fit;
+      } else if (way == 10) {
+        List.page =
+          Math.floor(
+            (document.querySelector("#wrapper").children.length - 1) /
+              List.can_fit
+          ) * List.can_fit;
+      }
+      Helper.css(
+        wrapperChildren.slice(List.page, List.page + List.can_fit),
+        "display",
+        "inline-flex"
+      );
+
+      if (
+        List.page > 0 &&
+        document.querySelector(".prev_page").style.display == "none"
+      ) {
+        Helper.css(".prev_page", "display", "inline-flex");
+        Helper.css(".prev_page_hide", "display", "none");
+        Helper.css(".first_page", "display", "inline-flex");
+        Helper.css(".first_page_hide", "display", "none");
+      }
+      if (
+        List.page + List.can_fit >=
+        document.querySelector("#wrapper").children.length
+      ) {
+        Helper.css(".next_page_hide", "display", "inline-flex");
+        Helper.css(".next_page", "display", "none");
+        Helper.css(".last_page_hide", "display", "inline-flex");
+        Helper.css(".last_page", "display", "none");
+      }
+    } else {
+      if (way == -10) {
+        Helper.css(
+          wrapperChildren.slice(List.page, List.page + List.can_fit),
+          "display",
+          "none"
+        );
+        List.page = 0;
+        Helper.css(
+          wrapperChildren.slice(List.page, List.page + List.can_fit),
+          "display",
+          "inline-flex"
+        );
+      } else {
+        Helper.css(
+          wrapperChildren.slice(List.page - List.can_fit, List.page),
+          "display",
+          "inline-flex"
+        );
+        Helper.css(
+          wrapperChildren.slice(List.page, List.page + List.can_fit),
+          "display",
+          "none"
+        );
+        List.page = List.page - List.can_fit < 0 ? 0 : List.page - List.can_fit;
+      }
+      if (
+        List.page == 0 &&
+        document.querySelector(".prev_page").style.display != "none"
+      ) {
+        Helper.css(".prev_page", "display", "none");
+        Helper.css(".prev_page_hide", "display", "inline-flex");
+        Helper.css(".first_page", "display", "none");
+        Helper.css(".first_page_hide", "display", "inline-flex");
+      } else if (document.querySelector(".prev_page").style.display == "none") {
+        Helper.css(".prev_page_hide", "display", "inline-flex");
+        Helper.css(".first_page_hide", "display", "inline-flex");
+      } else {
+        Helper.css(".prev_page_hide", "display", "none");
+        Helper.css(".first_page_hide", "display", "none");
+      }
+      if (
+        List.page + List.can_fit <
+        document.querySelector("#wrapper").children.length
+      ) {
+        Helper.css(".next_page_hide", "display", "none");
+        Helper.css(".next_page", "display", "inline-flex");
+        Helper.css(".last_page_hide", "display", "none");
+        Helper.css(".last_page", "display", "inline-flex");
+      }
+    }
+    document.querySelector("#pageNumber").innerText =
+      List.page / List.can_fit + 1;
+  },
+
+  added_song: function(added) {
+    var now_playing;
+    if (added != undefined) {
+      if (full_playlist.length !== 0) {
+        now_playing = full_playlist.pop();
+      }
+      full_playlist.push(added);
+      List.sortList();
+      if (now_playing) {
+        full_playlist.push(now_playing);
+      }
+
+      if (hostMode) {
+        M.toast({
+          html:
+            "
New song added
" +
+            added.title +
+            "

New song added
" + added.title + "
Thanks for signing up for the API, here is your key: https://zoff.me/api/apply/" + uniqid_link + "
This link will expire in 1 day, so please write it down.
 ";
-                    var msg = {
-                        from: mailconfig.from,
-                        to: name,
-                        subject: subject,
-                        text: message,
-                        html: message,
-                    }
-                    transporter.sendMail(msg, (error, info) => {
-                        if (error) {
-                            res.send("failed");
-                            transporter.close();
-                            return;
-                        }
-                        res.status(200).send("success");
-                        transporter.close();
-                        return;
-                    });
-                }
+  function createApiLink(req, res, uniqid_link, id, name) {
+    token_db
+      .collection("api_links")
+      .insert({ id: uniqid_link, token: id, createdAt: new Date() }, function(
+        err,
+        docs
+      ) {
+        let transporter = nodemailer.createTransport(mailconfig);
+        transporter.verify(function(error, success) {
+          if (error) {
+            token_db
+              .collection("api_links")
+              .remove({ id: uniqid_link }, function(e, d) {
+                res.send("failed");
+                return;
+              });
+          } else {
+            var subject = "ZOFF: API-key";
+            var message =
+              "Hello,
";
-                    var msg = {
-                        from: mailconfig.from,
-                        to: name,
-                        subject: subject,
-                        text: message,
-                        html: message,
-                    }
-                    transporter.sendMail(msg, (error, info) => {
-                        if (error) {
-                            res.send("failed");
-                            transporter.close();
-                            return;
-                        }
-                        res.status(200).send("success");
-                        transporter.close();
-                        return;
-                    });
-                }
+  function createApiLink(req, res, uniqid_link, id, name) {
+    token_db
+      .collection("api_links")
+      .insert({ id: uniqid_link, token: id, createdAt: new Date() }, function(
+        err,
+        docs
+      ) {
+        let transporter = nodemailer.createTransport(mailconfig);
+        transporter.verify(function(error, success) {
+          if (error) {
+            token_db
+              .collection("api_links")
+              .remove({ id: uniqid_link }, function(e, d) {
+                res.send("failed");
+                return;
+              });
+          } else {
+            var subject = "ZOFF: API-key";
+            var message =
+              "Hello,
Thanks for signing up for the API, here is your key: https://zoff.me/api/apply/" +
+              uniqid_link +
+              "
This link will expire in 1 day, so please write it down.
 ";
+            var msg = {
+              from: mailconfig.from,
+              to: name,
+              subject: subject,
+              text: message,
+              html: message
+            };
+            transporter.sendMail(msg, (error, info) => {
+              if (error) {
+                res.send("failed");
+                transporter.close();
+                return;
+              }
+              res.status(200).send("success");
+              transporter.close();
+              return;
             });
-        })
-    }
+          }
+        });
+      });
+  }
 
-    router.route('/api/mail').post(recaptcha.middleware.verify, function(req, res) {
-        if(req.recaptcha.error == null) {
-            let transporter = nodemailer.createTransport(mailconfig);
+  router
+    .route("/api/mail")
+    .post(recaptcha.middleware.verify, function(req, res) {
+      if (req.recaptcha.error == null) {
+        let transporter = nodemailer.createTransport(mailconfig);
 
-            transporter.verify(function(error, success) {
-                if (error) {
-                    res.sendStatus(500);
-                    return;
-                } else {
-                    var subject = 'ZOFF: Contact form webpage';
-                    if(req.body.error_report) {
-                        subject = 'ZOFF: Error report';
-                    }
-                    var from = req.body.from;
-                    var message = req.body.message;
-                    var msg = {
-                        from: mailconfig.from,
-                        to: mailconfig.to,
-                        subject: subject,
-                        text: message,
-                        html: message,
-                        replyTo: from
-                    }
-                    transporter.sendMail(msg, (error, info) => {
-                        if (error) {
-                            res.status(500).send("failed");
-                            transporter.close();
-                            return;
-                        }
-                        res.status(200).send("success");
-                        transporter.close();
-                    });
-                }
-            });
-        } else {
-            res.status(500).send("failed");
+        transporter.verify(function(error, success) {
+          if (error) {
+            res.sendStatus(500);
             return;
-        }
-    });
-} catch(e) {
-    console.log("Mail is not configured and wont work");
-    console.log("Seems you forgot to create a mailconfig.js in /server/config/. Have a look at the mailconfig.example.js.");
-    router.route('/api/mail').post(function(req, res) {
-        console.log("Someone tried to send a mail, but the mailsystem hasn't been enabled..")
+          } else {
+            var subject = "ZOFF: Contact form webpage";
+            if (req.body.error_report) {
+              subject = "ZOFF: Error report";
+            }
+            var from = req.body.from;
+            var message = req.body.message;
+            var msg = {
+              from: mailconfig.from,
+              to: mailconfig.to,
+              subject: subject,
+              text: message,
+              html: message,
+              replyTo: from
+            };
+            transporter.sendMail(msg, (error, info) => {
+              if (error) {
+                res.status(500).send("failed");
+                transporter.close();
+                return;
+              }
+              res.status(200).send("success");
+              transporter.close();
+            });
+          }
+        });
+      } else {
         res.status(500).send("failed");
         return;
+      }
     });
+} catch (e) {
+  console.log("Mail is not configured and wont work");
+  console.log(
+    "Seems you forgot to create a mailconfig.js in /server/config/. Have a look at the mailconfig.example.js."
+  );
+  router.route("/api/mail").post(function(req, res) {
+    console.log(
+      "Someone tried to send a mail, but the mailsystem hasn't been enabled.."
+    );
+    res.status(500).send("failed");
+    return;
+  });
 }
 
 function updateTimeout(guid, res, authorized, type, callback) {
-    if(authorized) {
-        callback(null, null);
-        return;
+  if (authorized) {
+    callback(null, null);
+    return;
+  }
+  db.collection("timeout_api").update(
+    { type: type, guid: guid },
+    {
+      $set: {
+        createdAt: new Date(),
+        type: type,
+        guid: guid
+      }
+    },
+    { upsert: true },
+    function(err, docs) {
+      callback(err, docs);
     }
-    db.collection("timeout_api").update({type: type, guid: guid}, {
-        $set: {
-            "createdAt": new Date(),
-            type: type,
-            guid: guid,
-        },
-    }, {upsert: true}, function(err, docs) {
-        callback(err, docs);
-    });
+  );
 }
 
 function checkTimeout(guid, res, authorized, type, callback) {
-    if(authorized) {
-        callback();
-        return;
-    }
-    db.collection("timeout_api").find({
-        type: type,
-        guid: guid,
-    }, function(err, docs) {
-        if(docs.length > 0) {
-            var date = new Date(docs[0].createdAt);
-            date.setSeconds(date.getSeconds() + 1);
-            var now = new Date();
-            var retry_in = (date.getTime() - now.getTime()) / 1000;
-            if(retry_in > 0) {
-                res.header({'Retry-After': retry_in});
-                var thisErrorString = JSON.stringify(error.tooMany);
-                var thisError = JSON.parse(thisErrorString);
-                thisError.error += " To get an API-key, visit https://zoff.me/api/apply.";
-                res.status(429).send(thisError);
-                return;
-            }
+  if (authorized) {
+    callback();
+    return;
+  }
+  db.collection("timeout_api").find(
+    {
+      type: type,
+      guid: guid
+    },
+    function(err, docs) {
+      if (docs.length > 0) {
+        var date = new Date(docs[0].createdAt);
+        date.setSeconds(date.getSeconds() + 1);
+        var now = new Date();
+        var retry_in = (date.getTime() - now.getTime()) / 1000;
+        if (retry_in > 0) {
+          res.header({ "Retry-After": retry_in });
+          var thisErrorString = JSON.stringify(error.tooMany);
+          var thisError = JSON.parse(thisErrorString);
+          thisError.error +=
+            " To get an API-key, visit https://zoff.me/api/apply.";
+          res.status(429).send(thisError);
+          return;
         }
-        var now_date = new Date();
-        db.collection("timeout_api").update({type: type, guid: guid}, {
-            $set: {
-                "createdAt": now_date,
-                type: type,
-                guid: guid,
-            },
-        }, {upsert: true}, function(err, docs) {
-            callback();
-            return;
-        });
-    });
+      }
+      var now_date = new Date();
+      db.collection("timeout_api").update(
+        { type: type, guid: guid },
+        {
+          $set: {
+            createdAt: now_date,
+            type: type,
+            guid: guid
+          }
+        },
+        { upsert: true },
+        function(err, docs) {
+          callback();
+          return;
+        }
+      );
+    }
+  );
 }
 
 function cleanChannelName(channel_name) {
-    var coll = Functions.removeEmojis(channel_name).toLowerCase();
-    //coll = coll.replace("_", "");
-    //coll = encodeURIComponent(coll).replace(/\W/g, '');
-    coll = Functions.encodeChannelName(channel_name);
-    coll = filter.clean(coll);
-    return coll;
+  var coll = Functions.removeEmojis(channel_name).toLowerCase();
+  //coll = coll.replace("_", "");
+  //coll = encodeURIComponent(coll).replace(/\W/g, '');
+  coll = Functions.encodeChannelName(channel_name);
+  coll = filter.clean(coll);
+  return coll;
 }
 
 function validateLogin(adminpass, userpass, channel_name, type, res, callback) {
-    db.collection(channel_name + "_settings").find({ id: "config" }, function(err, conf) {
-        var exists = false;
-        if(conf.length > 0 && ((conf[0].userpass == undefined || conf[0].userpass == "" || conf[0].userpass == userpass))) {
-            exists = true;
-        } else if(conf.length > 0 && type == "config") {
-            res.status(404).send(error.not_found.list);
-            return;
-        } else if(conf.length == 0) {
-            res.status(404).send(error.not_found.list);
-            return;
-        }
+  db.collection(channel_name + "_settings").find({ id: "config" }, function(
+    err,
+    conf
+  ) {
+    var exists = false;
+    if (
+      conf.length > 0 &&
+      (conf[0].userpass == undefined ||
+        conf[0].userpass == "" ||
+        conf[0].userpass == userpass)
+    ) {
+      exists = true;
+    } else if (conf.length > 0 && type == "config") {
+      res.status(404).send(error.not_found.list);
+      return;
+    } else if (conf.length == 0) {
+      res.status(404).send(error.not_found.list);
+      return;
+    }
 
-        if(
-            (type == "fetch_song") ||
-            (type == "add" && ((conf[0].addsongs && (conf[0].adminpass == "" || conf[0].adminpass == undefined || conf[0].adminpass == adminpass)) || !conf[0].addsongs)) ||
-            (type == "delete" && (conf[0].adminpass == "" || conf[0].adminpass == undefined || conf[0].adminpass == adminpass)) ||
-            (type == "vote" && ((conf[0].vote && (conf[0].adminpass == "" || conf[0].adminpass == undefined || conf[0].adminpass == adminpass)) || !conf[0].vote)) ||
-            (type == "config" && (conf[0].adminpass == "" || conf[0].adminpass == undefined || conf[0].adminpass == adminpass))
-        ) {
-            callback(exists, conf, true);
-        } else if(type == "add") {
-            callback(exists, conf, false);
-        } else {
-            res.status(403).send(error.not_authenticated);
-            return;
-        }
-    });
+    if (
+      type == "fetch_song" ||
+      (type == "add" &&
+        ((conf[0].addsongs &&
+          (conf[0].adminpass == "" ||
+            conf[0].adminpass == undefined ||
+            conf[0].adminpass == adminpass)) ||
+          !conf[0].addsongs)) ||
+      (type == "delete" &&
+        (conf[0].adminpass == "" ||
+          conf[0].adminpass == undefined ||
+          conf[0].adminpass == adminpass)) ||
+      (type == "vote" &&
+        ((conf[0].vote &&
+          (conf[0].adminpass == "" ||
+            conf[0].adminpass == undefined ||
+            conf[0].adminpass == adminpass)) ||
+          !conf[0].vote)) ||
+      (type == "config" &&
+        (conf[0].adminpass == "" ||
+          conf[0].adminpass == undefined ||
+          conf[0].adminpass == adminpass))
+    ) {
+      callback(exists, conf, true);
+    } else if (type == "add") {
+      callback(exists, conf, false);
+    } else {
+      res.status(403).send(error.not_authenticated);
+      return;
+    }
+  });
 }
 
-function postEnd(channel_name, configs, new_song, guid, res, authenticated, authorized) {
-    if(configs != undefined) {
-        io.to(channel_name).emit("conf", configs);
+function postEnd(
+  channel_name,
+  configs,
+  new_song,
+  guid,
+  res,
+  authenticated,
+  authorized
+) {
+  if (configs != undefined) {
+    io.to(channel_name).emit("conf", configs);
+  }
+  List.getNextSong(channel_name, undefined, function() {
+    //updateTimeout(guid, res, authorized, "POST", function(err, docs) {
+    var to_return = error.no_error;
+    if (!authenticated) {
+      to_return = error.not_authenticated;
+      to_return.success = true;
     }
-    List.getNextSong(channel_name, undefined, function() {
-        //updateTimeout(guid, res, authorized, "POST", function(err, docs) {
-            var to_return = error.no_error;
-            if(!authenticated) {
-                to_return = error.not_authenticated;
-                to_return.success = true;
-            }
-            to_return.results = [new_song];
-            res.status(authenticated ? 200 : 403).send(to_return);
-            return;
-        //});
-    });
+    to_return.results = [new_song];
+    res.status(authenticated ? 200 : 403).send(to_return);
+    return;
+    //});
+  });
 }
 
 module.exports = _exports;
";
+            var msg = {
+              from: mailconfig.from,
+              to: name,
+              subject: subject,
+              text: message,
+              html: message
+            };
+            transporter.sendMail(msg, (error, info) => {
+              if (error) {
+                res.send("failed");
+                transporter.close();
+                return;
+              }
+              res.status(200).send("success");
+              transporter.close();
+              return;
             });
-        })
-    }
+          }
+        });
+      });
+  }
 
-    router.route('/api/mail').post(recaptcha.middleware.verify, function(req, res) {
-        if(req.recaptcha.error == null) {
-            let transporter = nodemailer.createTransport(mailconfig);
+  router
+    .route("/api/mail")
+    .post(recaptcha.middleware.verify, function(req, res) {
+      if (req.recaptcha.error == null) {
+        let transporter = nodemailer.createTransport(mailconfig);
 
-            transporter.verify(function(error, success) {
-                if (error) {
-                    res.sendStatus(500);
-                    return;
-                } else {
-                    var subject = 'ZOFF: Contact form webpage';
-                    if(req.body.error_report) {
-                        subject = 'ZOFF: Error report';
-                    }
-                    var from = req.body.from;
-                    var message = req.body.message;
-                    var msg = {
-                        from: mailconfig.from,
-                        to: mailconfig.to,
-                        subject: subject,
-                        text: message,
-                        html: message,
-                        replyTo: from
-                    }
-                    transporter.sendMail(msg, (error, info) => {
-                        if (error) {
-                            res.status(500).send("failed");
-                            transporter.close();
-                            return;
-                        }
-                        res.status(200).send("success");
-                        transporter.close();
-                    });
-                }
-            });
-        } else {
-            res.status(500).send("failed");
+        transporter.verify(function(error, success) {
+          if (error) {
+            res.sendStatus(500);
             return;
-        }
-    });
-} catch(e) {
-    console.log("Mail is not configured and wont work");
-    console.log("Seems you forgot to create a mailconfig.js in /server/config/. Have a look at the mailconfig.example.js.");
-    router.route('/api/mail').post(function(req, res) {
-        console.log("Someone tried to send a mail, but the mailsystem hasn't been enabled..")
+          } else {
+            var subject = "ZOFF: Contact form webpage";
+            if (req.body.error_report) {
+              subject = "ZOFF: Error report";
+            }
+            var from = req.body.from;
+            var message = req.body.message;
+            var msg = {
+              from: mailconfig.from,
+              to: mailconfig.to,
+              subject: subject,
+              text: message,
+              html: message,
+              replyTo: from
+            };
+            transporter.sendMail(msg, (error, info) => {
+              if (error) {
+                res.status(500).send("failed");
+                transporter.close();
+                return;
+              }
+              res.status(200).send("success");
+              transporter.close();
+            });
+          }
+        });
+      } else {
         res.status(500).send("failed");
         return;
+      }
     });
+} catch (e) {
+  console.log("Mail is not configured and wont work");
+  console.log(
+    "Seems you forgot to create a mailconfig.js in /server/config/. Have a look at the mailconfig.example.js."
+  );
+  router.route("/api/mail").post(function(req, res) {
+    console.log(
+      "Someone tried to send a mail, but the mailsystem hasn't been enabled.."
+    );
+    res.status(500).send("failed");
+    return;
+  });
 }
 
 function updateTimeout(guid, res, authorized, type, callback) {
-    if(authorized) {
-        callback(null, null);
-        return;
+  if (authorized) {
+    callback(null, null);
+    return;
+  }
+  db.collection("timeout_api").update(
+    { type: type, guid: guid },
+    {
+      $set: {
+        createdAt: new Date(),
+        type: type,
+        guid: guid
+      }
+    },
+    { upsert: true },
+    function(err, docs) {
+      callback(err, docs);
     }
-    db.collection("timeout_api").update({type: type, guid: guid}, {
-        $set: {
-            "createdAt": new Date(),
-            type: type,
-            guid: guid,
-        },
-    }, {upsert: true}, function(err, docs) {
-        callback(err, docs);
-    });
+  );
 }
 
 function checkTimeout(guid, res, authorized, type, callback) {
-    if(authorized) {
-        callback();
-        return;
-    }
-    db.collection("timeout_api").find({
-        type: type,
-        guid: guid,
-    }, function(err, docs) {
-        if(docs.length > 0) {
-            var date = new Date(docs[0].createdAt);
-            date.setSeconds(date.getSeconds() + 1);
-            var now = new Date();
-            var retry_in = (date.getTime() - now.getTime()) / 1000;
-            if(retry_in > 0) {
-                res.header({'Retry-After': retry_in});
-                var thisErrorString = JSON.stringify(error.tooMany);
-                var thisError = JSON.parse(thisErrorString);
-                thisError.error += " To get an API-key, visit https://zoff.me/api/apply.";
-                res.status(429).send(thisError);
-                return;
-            }
+  if (authorized) {
+    callback();
+    return;
+  }
+  db.collection("timeout_api").find(
+    {
+      type: type,
+      guid: guid
+    },
+    function(err, docs) {
+      if (docs.length > 0) {
+        var date = new Date(docs[0].createdAt);
+        date.setSeconds(date.getSeconds() + 1);
+        var now = new Date();
+        var retry_in = (date.getTime() - now.getTime()) / 1000;
+        if (retry_in > 0) {
+          res.header({ "Retry-After": retry_in });
+          var thisErrorString = JSON.stringify(error.tooMany);
+          var thisError = JSON.parse(thisErrorString);
+          thisError.error +=
+            " To get an API-key, visit https://zoff.me/api/apply.";
+          res.status(429).send(thisError);
+          return;
         }
-        var now_date = new Date();
-        db.collection("timeout_api").update({type: type, guid: guid}, {
-            $set: {
-                "createdAt": now_date,
-                type: type,
-                guid: guid,
-            },
-        }, {upsert: true}, function(err, docs) {
-            callback();
-            return;
-        });
-    });
+      }
+      var now_date = new Date();
+      db.collection("timeout_api").update(
+        { type: type, guid: guid },
+        {
+          $set: {
+            createdAt: now_date,
+            type: type,
+            guid: guid
+          }
+        },
+        { upsert: true },
+        function(err, docs) {
+          callback();
+          return;
+        }
+      );
+    }
+  );
 }
 
 function cleanChannelName(channel_name) {
-    var coll = Functions.removeEmojis(channel_name).toLowerCase();
-    //coll = coll.replace("_", "");
-    //coll = encodeURIComponent(coll).replace(/\W/g, '');
-    coll = Functions.encodeChannelName(channel_name);
-    coll = filter.clean(coll);
-    return coll;
+  var coll = Functions.removeEmojis(channel_name).toLowerCase();
+  //coll = coll.replace("_", "");
+  //coll = encodeURIComponent(coll).replace(/\W/g, '');
+  coll = Functions.encodeChannelName(channel_name);
+  coll = filter.clean(coll);
+  return coll;
 }
 
 function validateLogin(adminpass, userpass, channel_name, type, res, callback) {
-    db.collection(channel_name + "_settings").find({ id: "config" }, function(err, conf) {
-        var exists = false;
-        if(conf.length > 0 && ((conf[0].userpass == undefined || conf[0].userpass == "" || conf[0].userpass == userpass))) {
-            exists = true;
-        } else if(conf.length > 0 && type == "config") {
-            res.status(404).send(error.not_found.list);
-            return;
-        } else if(conf.length == 0) {
-            res.status(404).send(error.not_found.list);
-            return;
-        }
+  db.collection(channel_name + "_settings").find({ id: "config" }, function(
+    err,
+    conf
+  ) {
+    var exists = false;
+    if (
+      conf.length > 0 &&
+      (conf[0].userpass == undefined ||
+        conf[0].userpass == "" ||
+        conf[0].userpass == userpass)
+    ) {
+      exists = true;
+    } else if (conf.length > 0 && type == "config") {
+      res.status(404).send(error.not_found.list);
+      return;
+    } else if (conf.length == 0) {
+      res.status(404).send(error.not_found.list);
+      return;
+    }
 
-        if(
-            (type == "fetch_song") ||
-            (type == "add" && ((conf[0].addsongs && (conf[0].adminpass == "" || conf[0].adminpass == undefined || conf[0].adminpass == adminpass)) || !conf[0].addsongs)) ||
-            (type == "delete" && (conf[0].adminpass == "" || conf[0].adminpass == undefined || conf[0].adminpass == adminpass)) ||
-            (type == "vote" && ((conf[0].vote && (conf[0].adminpass == "" || conf[0].adminpass == undefined || conf[0].adminpass == adminpass)) || !conf[0].vote)) ||
-            (type == "config" && (conf[0].adminpass == "" || conf[0].adminpass == undefined || conf[0].adminpass == adminpass))
-        ) {
-            callback(exists, conf, true);
-        } else if(type == "add") {
-            callback(exists, conf, false);
-        } else {
-            res.status(403).send(error.not_authenticated);
-            return;
-        }
-    });
+    if (
+      type == "fetch_song" ||
+      (type == "add" &&
+        ((conf[0].addsongs &&
+          (conf[0].adminpass == "" ||
+            conf[0].adminpass == undefined ||
+            conf[0].adminpass == adminpass)) ||
+          !conf[0].addsongs)) ||
+      (type == "delete" &&
+        (conf[0].adminpass == "" ||
+          conf[0].adminpass == undefined ||
+          conf[0].adminpass == adminpass)) ||
+      (type == "vote" &&
+        ((conf[0].vote &&
+          (conf[0].adminpass == "" ||
+            conf[0].adminpass == undefined ||
+            conf[0].adminpass == adminpass)) ||
+          !conf[0].vote)) ||
+      (type == "config" &&
+        (conf[0].adminpass == "" ||
+          conf[0].adminpass == undefined ||
+          conf[0].adminpass == adminpass))
+    ) {
+      callback(exists, conf, true);
+    } else if (type == "add") {
+      callback(exists, conf, false);
+    } else {
+      res.status(403).send(error.not_authenticated);
+      return;
+    }
+  });
 }
 
-function postEnd(channel_name, configs, new_song, guid, res, authenticated, authorized) {
-    if(configs != undefined) {
-        io.to(channel_name).emit("conf", configs);
+function postEnd(
+  channel_name,
+  configs,
+  new_song,
+  guid,
+  res,
+  authenticated,
+  authorized
+) {
+  if (configs != undefined) {
+    io.to(channel_name).emit("conf", configs);
+  }
+  List.getNextSong(channel_name, undefined, function() {
+    //updateTimeout(guid, res, authorized, "POST", function(err, docs) {
+    var to_return = error.no_error;
+    if (!authenticated) {
+      to_return = error.not_authenticated;
+      to_return.success = true;
     }
-    List.getNextSong(channel_name, undefined, function() {
-        //updateTimeout(guid, res, authorized, "POST", function(err, docs) {
-            var to_return = error.no_error;
-            if(!authenticated) {
-                to_return = error.not_authenticated;
-                to_return.success = true;
-            }
-            to_return.results = [new_song];
-            res.status(authenticated ? 200 : 403).send(to_return);
-            return;
-        //});
-    });
+    to_return.results = [new_song];
+    res.status(authenticated ? 200 : 403).send(to_return);
+    return;
+    //});
+  });
 }
 
 module.exports = _exports;