mirror of
				https://github.com/KevinMidboe/zoff.git
				synced 2025-10-29 18:00:23 +00:00 
			
		
		
		
	Merge pull request #508 from zoff-music/refactor/audit-fixes
Fixed some audit-issues, and started using prettify
This commit is contained in:
		
							
								
								
									
										236
									
								
								gulpfile.js
									
									
									
									
									
								
							
							
						
						
									
										236
									
								
								gulpfile.js
									
									
									
									
									
								
							| @@ -1,120 +1,198 @@ | ||||
| var gulp    = require('gulp'), | ||||
| 	gutil   = require('gulp-util'), | ||||
| 	uglify  = require('gulp-uglify'), | ||||
| 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'); | ||||
|   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']) | ||||
| 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({ | ||||
|       .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()); }) | ||||
|         }) | ||||
|       ) | ||||
|       .on("error", function(err) { | ||||
|         gutil.log(gutil.colors.red("[Error]"), err.toString()); | ||||
|       }) | ||||
|       //.pipe(sourcemaps.write('maps')) | ||||
|         .pipe(gulp.dest('server/public/assets/dist')); | ||||
|       .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']) | ||||
| 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('token.min.js')) | ||||
|         .pipe(uglify({ | ||||
|       .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()); }) | ||||
|  | ||||
|         }) | ||||
|       ) | ||||
|       .on("error", function(err) { | ||||
|         gutil.log(gutil.colors.red("[Error]"), err.toString()); | ||||
|       }) | ||||
|       //.pipe(sourcemaps.write('maps')) | ||||
|         .pipe(gulp.dest('server/public/assets/dist')); | ||||
|       .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('callback', function () { | ||||
|     return gulp.src(['server/VERSION.js', 'server/config/api_key.js', 'server/public/assets/js/callback.js']) | ||||
|       //.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({ | ||||
|       .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()); }) | ||||
|         }) | ||||
|       ) | ||||
|       .on("error", function(err) { | ||||
|         gutil.log(gutil.colors.red("[Error]"), err.toString()); | ||||
|       }) | ||||
|  | ||||
|       //.pipe(sourcemaps.write('maps')) | ||||
|         .pipe(gulp.dest('server/public/assets/dist')); | ||||
|       .pipe(gulp.dest("server/public/assets/dist")) | ||||
|   ); | ||||
| }); | ||||
|  | ||||
| gulp.task('build', done => { | ||||
|     gulp.series('css', 'css-embed', 'js', 'embed', 'remotecontroller', 'callback', 'token')(); | ||||
| gulp.task("build", done => { | ||||
|   gulp.series( | ||||
|     "css", | ||||
|     "css-embed", | ||||
|     "js", | ||||
|     "embed", | ||||
|     "remotecontroller", | ||||
|     "callback", | ||||
|     "token" | ||||
|   )(); | ||||
|   done(); | ||||
| }); | ||||
|  | ||||
| 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']) | ||||
| 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({ | ||||
|       .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()); }) | ||||
|         }) | ||||
|       ) | ||||
|       .on("error", function(err) { | ||||
|         gutil.log(gutil.colors.red("[Error]"), err.toString()); | ||||
|       }) | ||||
|  | ||||
|       //.pipe(sourcemaps.write('maps')) | ||||
|         .pipe(gulp.dest('server/public/assets/dist')); | ||||
|       .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.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.watch( | ||||
|     ["server/VERSION.js", "server/public/assets/js/remotecontroller.js"], | ||||
|     ["remotecontroller"] | ||||
|   ); | ||||
| }); | ||||
|   | ||||
							
								
								
									
										100
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										100
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -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": { | ||||
|   | ||||
| @@ -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", | ||||
|   | ||||
| @@ -1,26 +1,26 @@ | ||||
| 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){ | ||||
|   io.on("connection", function(socket) { | ||||
|     try { | ||||
|       var parsedCookies = cookie.parse(socket.handshake.headers.cookie); | ||||
|       socket.cookie_id = parsedCookies["_uI"]; | ||||
| @@ -30,15 +30,18 @@ module.exports = function() { | ||||
|     } | ||||
|     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"]); | ||||
|     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("close", function() {}); | ||||
|  | ||||
|         socket.on('pinging', function() { | ||||
|     socket.on("pinging", function() { | ||||
|       socket.emit("ok"); | ||||
|     }); | ||||
|  | ||||
| @@ -54,8 +57,7 @@ module.exports = function() { | ||||
|  | ||||
|     socket.emit("guid", guid); | ||||
|  | ||||
|         socket.on('self_ping', function(msg) { | ||||
|  | ||||
|     socket.on("self_ping", function(msg) { | ||||
|       var channel = msg.channel; | ||||
|       if (channel.indexOf("?") > -1) { | ||||
|         channel = channel.substring(0, channel.indexOf("?")); | ||||
| @@ -65,53 +67,102 @@ module.exports = function() { | ||||
|       } | ||||
|       //channel = channel.replace(/ /g,''); | ||||
|       if (offline) { | ||||
|                 db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, {upsert: true}, function(err, docs){}); | ||||
|         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(){}); | ||||
|                 }); | ||||
|         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){}); | ||||
|         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() {}) | ||||
|       Functions.removeSessionAdminPass( | ||||
|         Functions.getSession(socket), | ||||
|         coll, | ||||
|         function() {} | ||||
|       ); | ||||
|     }); | ||||
|  | ||||
|         socket.on('next_song', function(obj) { | ||||
|             if(obj == undefined || !obj.hasOwnProperty("channel")) return; | ||||
|     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"); | ||||
|           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))) { | ||||
|         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) { | ||||
|     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 ( | ||||
|           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) { | ||||
|           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) { | ||||
|                             }); | ||||
|               Functions.setChromecastHost( | ||||
|                 socket.cookie_id, | ||||
|                 msg.socket_id, | ||||
|                 msg.channel, | ||||
|                 function(results) {} | ||||
|               ); | ||||
|               //socket.cookie_id = msg.guid; | ||||
|               guid = msg.guid; | ||||
|               socketid = msg.socket_id; | ||||
| @@ -129,7 +180,10 @@ module.exports = function() { | ||||
|     }); | ||||
|  | ||||
|     socket.on("get_id", function() { | ||||
|             socket.emit("id_chromecast", {cookie_id: Functions.getSession(socket), guid: guid}); | ||||
|       socket.emit("id_chromecast", { | ||||
|         cookie_id: Functions.getSession(socket), | ||||
|         guid: guid | ||||
|       }); | ||||
|     }); | ||||
|  | ||||
|     socket.on("error_video", function(msg) { | ||||
| @@ -155,20 +209,37 @@ module.exports = function() { | ||||
|     }); | ||||
|  | ||||
|     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) { | ||||
|       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}); | ||||
|                   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.emit("spread_listeners", { | ||||
|                     offline: off[0].users.length, | ||||
|                     total: tot[0].total_users.length, | ||||
|                     online_users: users_list | ||||
|                   }); | ||||
|                 } | ||||
|                     }); | ||||
|                 }); | ||||
|               } | ||||
|             ); | ||||
|           } | ||||
|         ); | ||||
|       }); | ||||
|     }); | ||||
|  | ||||
|         socket.on('suggest_thumbnail', function(msg){ | ||||
|     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; | ||||
| @@ -179,7 +250,7 @@ module.exports = function() { | ||||
|       Suggestions.thumbnail(msg, coll, guid, offline, socket); | ||||
|     }); | ||||
|  | ||||
|         socket.on('suggest_description', function(msg){ | ||||
|     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; | ||||
| @@ -190,7 +261,7 @@ module.exports = function() { | ||||
|       Suggestions.description(msg, coll, guid, offline, socket); | ||||
|     }); | ||||
|  | ||||
|         socket.on('suggest_rules', function(msg){ | ||||
|     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; | ||||
| @@ -220,14 +291,14 @@ module.exports = function() { | ||||
|       if (msg.hasOwnProperty("channel")) { | ||||
|         msg.channel = Functions.encodeChannelName(msg.channel); | ||||
|       } | ||||
|             if(typeof(msg) != "object" || !msg.hasOwnProperty("channel")) { | ||||
|       if (typeof msg != "object" || !msg.hasOwnProperty("channel")) { | ||||
|         var result = { | ||||
|           channel: { | ||||
|             expected: "string", | ||||
|                         got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined, | ||||
|             got: msg.hasOwnProperty("channel") ? typeof msg.channel : undefined | ||||
|           } | ||||
|         }; | ||||
|                 socket.emit('update_required', result); | ||||
|         socket.emit("update_required", result); | ||||
|         return; | ||||
|       } | ||||
|       Chat.removename(guid, msg.channel, socket); | ||||
| @@ -241,19 +312,23 @@ module.exports = function() { | ||||
|       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") { | ||||
|       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, | ||||
|             got: msg.hasOwnProperty("status") ? typeof msg.status : undefined | ||||
|           }, | ||||
|           channel: { | ||||
|             expected: "string", | ||||
|                         got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined | ||||
|             got: msg.hasOwnProperty("channel") ? typeof msg.channel : undefined | ||||
|           } | ||||
|         }; | ||||
|                 socket.emit('update_required', result); | ||||
|         socket.emit("update_required", result); | ||||
|         return; | ||||
|       } | ||||
|       var status = msg.status; | ||||
| @@ -265,40 +340,74 @@ module.exports = function() { | ||||
|         if (coll !== undefined) { | ||||
|           coll = Functions.removeEmojis(coll).toLowerCase(); | ||||
|           //coll = filter.clean(coll); | ||||
|                     db.collection("connected_users").findAndModify({ | ||||
|                         query: {"_id": coll}, | ||||
|           db.collection("connected_users").findAndModify( | ||||
|             { | ||||
|               query: { _id: coll }, | ||||
|               update: { $pull: { users: guid } }, | ||||
|                         upsert: true, | ||||
|                     }, function(err, updated, d) { | ||||
|               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) {}); | ||||
|                 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"); | ||||
|                 }); | ||||
|         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) { | ||||
|     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; | ||||
| @@ -306,29 +415,33 @@ module.exports = function() { | ||||
|       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") { | ||||
|       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, | ||||
|             got: msg.hasOwnProperty("all") ? typeof msg.all : undefined | ||||
|           }, | ||||
|           channel: { | ||||
|             expected: "string", | ||||
|                         got: msg.hasOwnProperty("channel") ? typeof(msg.channel) : undefined, | ||||
|             got: msg.hasOwnProperty("channel") ? typeof msg.channel : undefined | ||||
|           }, | ||||
|           pass: { | ||||
|             expected: "string", | ||||
|                         got: msg.hasOwnProperty("pass") ? typeof(msg.pass) : undefined, | ||||
|             got: msg.hasOwnProperty("pass") ? typeof msg.pass : undefined | ||||
|           } | ||||
|         }; | ||||
|                 socket.emit('update_required', result); | ||||
|         socket.emit("update_required", result); | ||||
|         return; | ||||
|       } | ||||
|       Chat.get_history(msg.channel, msg.all, socket); | ||||
|     }); | ||||
|  | ||||
|         socket.on('chat', function (msg) { | ||||
|     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; | ||||
| @@ -339,8 +452,7 @@ module.exports = function() { | ||||
|       Chat.chat(msg, guid, offline, socket); | ||||
|     }); | ||||
|  | ||||
|         socket.on("all,chat", function(data) | ||||
|         { | ||||
|     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; | ||||
| @@ -351,8 +463,7 @@ module.exports = function() { | ||||
|       Chat.all_chat(data, guid, offline, socket); | ||||
|     }); | ||||
|  | ||||
|         socket.on('frontpage_lists', function(msg) | ||||
|         { | ||||
|     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; | ||||
| @@ -363,7 +474,7 @@ module.exports = function() { | ||||
|       Frontpage.frontpage_lists(msg, socket); | ||||
|     }); | ||||
|  | ||||
|         socket.on('import_zoff', function(msg) { | ||||
|     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; | ||||
| @@ -372,15 +483,13 @@ module.exports = function() { | ||||
|         msg.channel = Functions.encodeChannelName(msg.channel); | ||||
|       } | ||||
|       ListChange.addFromOtherList(msg, guid, offline, socket); | ||||
|         }) | ||||
|     }); | ||||
|  | ||||
|         socket.on('now_playing', function(list, fn) | ||||
|         { | ||||
|     socket.on("now_playing", function(list, fn) { | ||||
|       List.now_playing(list, fn, socket); | ||||
|     }); | ||||
|  | ||||
|         socket.on('id', function(arr) | ||||
|         { | ||||
|     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; | ||||
| @@ -388,12 +497,14 @@ module.exports = function() { | ||||
|       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}); | ||||
|       if (typeof arr == "object") | ||||
|         io.to(arr.id).emit(arr.id.toLowerCase(), { | ||||
|           type: arr.type, | ||||
|           value: arr.value | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|         socket.on('list', function(msg) | ||||
|         { | ||||
|     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; | ||||
| @@ -424,8 +535,7 @@ module.exports = function() { | ||||
|       Functions.get_short_id(socket); | ||||
|     }); | ||||
|  | ||||
|         socket.on('end', function(obj) | ||||
|         { | ||||
|     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; | ||||
| @@ -447,7 +557,7 @@ module.exports = function() { | ||||
|       List.end(obj, coll, guid, offline, socket); | ||||
|     }); | ||||
|  | ||||
|         socket.on('addPlaylist', function(arr) { | ||||
|     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; | ||||
| @@ -456,10 +566,9 @@ module.exports = function() { | ||||
|         arr.channel = Functions.encodeChannelName(arr.channel); | ||||
|       } | ||||
|       ListChange.addPlaylist(arr, guid, offline, socket); | ||||
|         }) | ||||
|     }); | ||||
|  | ||||
|         socket.on('add', function(arr) | ||||
|         { | ||||
|     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; | ||||
| @@ -467,7 +576,11 @@ module.exports = function() { | ||||
|       if (arr.hasOwnProperty("list")) { | ||||
|         arr.list = Functions.encodeChannelName(arr.list); | ||||
|       } | ||||
|             if(coll !== undefined && ((arr.hasOwnProperty("offsiteAdd") && !arr.offsiteAdd) || !arr.hasOwnProperty("offsiteAdd"))) { | ||||
|       if ( | ||||
|         coll !== undefined && | ||||
|         ((arr.hasOwnProperty("offsiteAdd") && !arr.offsiteAdd) || | ||||
|           !arr.hasOwnProperty("offsiteAdd")) | ||||
|       ) { | ||||
|         try { | ||||
|           coll = arr.list; //.replace(/ /g,''); | ||||
|           if (coll.length == 0) return; | ||||
| @@ -484,7 +597,7 @@ module.exports = function() { | ||||
|       ListChange.add_function(arr, coll, guid, offline, socket); | ||||
|     }); | ||||
|  | ||||
|         socket.on('delete_all', function(msg) { | ||||
|     socket.on("delete_all", function(msg) { | ||||
|       try { | ||||
|         if (msg.hasOwnProperty("channel") && msg.channel.indexOf("?") > -1) { | ||||
|           var _list = msg.channel.substring(0, msg.channel.indexOf("?")); | ||||
| @@ -506,8 +619,7 @@ module.exports = function() { | ||||
|       ListChange.delete_all(msg, coll, guid, offline, socket); | ||||
|     }); | ||||
|  | ||||
|         socket.on('vote', function(msg) | ||||
|         { | ||||
|     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; | ||||
| @@ -530,8 +642,7 @@ module.exports = function() { | ||||
|       ListChange.voteUndecided(msg, coll, guid, offline, socket); | ||||
|     }); | ||||
|  | ||||
|         socket.on('password', function(inp) | ||||
|         { | ||||
|     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; | ||||
| @@ -543,8 +654,7 @@ module.exports = function() { | ||||
|       ListSettings.password(inp, coll, guid, offline, socket); | ||||
|     }); | ||||
|  | ||||
|         socket.on('skip', function(list) | ||||
|         { | ||||
|     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; | ||||
| @@ -557,8 +667,7 @@ module.exports = function() { | ||||
|       List.skip(list, guid, coll, offline, socket); | ||||
|     }); | ||||
|  | ||||
|         socket.on('conf', function(conf) | ||||
|         { | ||||
|     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; | ||||
| @@ -572,8 +681,7 @@ module.exports = function() { | ||||
|       ListSettings.conf_function(conf, coll, guid, offline, socket); | ||||
|     }); | ||||
|  | ||||
|         socket.on('shuffle', function(msg) | ||||
|         { | ||||
|     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; | ||||
| @@ -595,12 +703,15 @@ module.exports = function() { | ||||
|       ListChange.shuffle(msg, coll, guid, offline, socket); | ||||
|     }); | ||||
|  | ||||
|         socket.on('change_channel', function(obj) | ||||
|         { | ||||
|     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){ | ||||
|       } else if ( | ||||
|         obj != undefined && | ||||
|         obj.hasOwnProperty("channel") && | ||||
|         obj.channel.indexOf("?") > -1 | ||||
|       ) { | ||||
|         var _list = obj.channel.substring(0, obj.channel.indexOf("?")); | ||||
|         obj.channel = _list; | ||||
|       } | ||||
| @@ -610,7 +721,11 @@ module.exports = function() { | ||||
|       if (obj.hasOwnProperty("channel")) { | ||||
|         obj.channel = Functions.encodeChannelName(obj.channel); | ||||
|       } | ||||
|             if(coll === undefined && obj !== undefined && obj.channel !== undefined){ | ||||
|       if ( | ||||
|         coll === undefined && | ||||
|         obj !== undefined && | ||||
|         obj.channel !== undefined | ||||
|       ) { | ||||
|         try { | ||||
|           coll = obj.channel.toLowerCase(); //.replace(/ /g,''); | ||||
|           if (coll.length == 0) return; | ||||
| @@ -622,18 +737,40 @@ module.exports = function() { | ||||
|           return; | ||||
|         } | ||||
|       } | ||||
|             Functions.left_channel(coll, guid, short_id, in_list, socket, true, "left 1"); | ||||
|       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("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("disconnected", function() { | ||||
|       Functions.left_channel( | ||||
|         coll, | ||||
|         guid, | ||||
|         short_id, | ||||
|         in_list, | ||||
|         socket, | ||||
|         false, | ||||
|         "left 3" | ||||
|       ); | ||||
|     }); | ||||
|  | ||||
|     socket.on("left_channel", function(msg) { | ||||
| @@ -644,32 +781,68 @@ module.exports = function() { | ||||
|       if (msg.hasOwnProperty("channel")) { | ||||
|         msg.channel = Functions.encodeChannelName(msg.channel); | ||||
|       } | ||||
|             if(msg.hasOwnProperty("channel") && msg.channel != "" && typeof(msg.channel) == "string") { | ||||
|       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"); | ||||
|         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("reconnect_failed", function() { | ||||
|       Functions.left_channel( | ||||
|         coll, | ||||
|         guid, | ||||
|         short_id, | ||||
|         in_list, | ||||
|         socket, | ||||
|         false, | ||||
|         "left 5" | ||||
|       ); | ||||
|     }); | ||||
|  | ||||
|         socket.on('error', function() | ||||
|         { | ||||
|             Functions.left_channel(coll, guid, short_id, in_list, socket, false, "left 7"); | ||||
|     socket.on("connect_timeout", function() { | ||||
|       Functions.left_channel( | ||||
|         coll, | ||||
|         guid, | ||||
|         short_id, | ||||
|         in_list, | ||||
|         socket, | ||||
|         false, | ||||
|         "left 6" | ||||
|       ); | ||||
|     }); | ||||
|  | ||||
|         socket.on('pos', function(obj) | ||||
|         { | ||||
|             if(obj != undefined && obj.hasOwnProperty("channel") && obj.channel.indexOf("?") > -1){ | ||||
|     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; | ||||
|       } | ||||
| @@ -692,43 +865,60 @@ module.exports = function() { | ||||
|         } | ||||
|       } | ||||
|  | ||||
|             if(!obj.hasOwnProperty("channel") || typeof(obj.channel) != "string") { | ||||
|       if (!obj.hasOwnProperty("channel") || typeof obj.channel != "string") { | ||||
|         var result = { | ||||
|           channel: { | ||||
|             expected: "string", | ||||
|                         got: obj.hasOwnProperty("channel") ? typeof(obj.channel) : undefined | ||||
|             got: obj.hasOwnProperty("channel") ? typeof obj.channel : undefined | ||||
|           }, | ||||
|           pass: { | ||||
|             expected: "string", | ||||
|                         got: obj.hasOwnProperty("pass") ? typeof(obj.pass) : undefined | ||||
|             got: obj.hasOwnProperty("pass") ? typeof obj.pass : undefined | ||||
|           } | ||||
|         }; | ||||
|                 socket.emit('update_required', result); | ||||
|         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) { | ||||
|         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") | ||||
|               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"); | ||||
|             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() { | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,6 +1,6 @@ | ||||
| var Channel = { | ||||
|   init: function() { | ||||
|         if(window.location.hash == "#small" || inIframe()) { | ||||
|     if (window.location.hash == "#small" || inIframe()) { | ||||
|       small_player = true; | ||||
|       document.querySelector("footer").style.display = "none"; | ||||
|       //addJoinBox(); | ||||
| @@ -31,12 +31,20 @@ var Channel = { | ||||
|                 }, function() { | ||||
|                 });*/ | ||||
|       } | ||||
|             if(cast_ready_connect || chromecastAvailable || chromecastReady) { | ||||
|       if (cast_ready_connect || chromecastAvailable || chromecastReady) { | ||||
|         Helper.addClass(".volume-container", "volume-container-cast"); | ||||
|       } | ||||
|       if (!embed) { | ||||
|     	    	document.querySelector("#main-container").insertAdjacentHTML("beforeend", "<a id='hide-playlist' class='hide-on-small-only hide-playlist-button' href='#!'><i class='material-icons'>keyboard_arrow_right</i></div>"); | ||||
|     	          document.querySelector("#hide-playlist").style.left = (document.querySelector("#video-container").offsetWidth - document.querySelector("#hide-playlist").offsetWidth) + "px"; | ||||
|         document | ||||
|           .querySelector("#main-container") | ||||
|           .insertAdjacentHTML( | ||||
|             "beforeend", | ||||
|             "<a id='hide-playlist' class='hide-on-small-only hide-playlist-button' href='#!'><i class='material-icons'>keyboard_arrow_right</i></div>" | ||||
|           ); | ||||
|         document.querySelector("#hide-playlist").style.left = | ||||
|           document.querySelector("#video-container").offsetWidth - | ||||
|           document.querySelector("#hide-playlist").offsetWidth + | ||||
|           "px"; | ||||
|       } | ||||
|       //Player.soundcloud_player = document.querySelector("#soundcloud_player"); | ||||
|     } | ||||
| @@ -58,7 +66,7 @@ var Channel = { | ||||
|     if (window.location.hostname != "localhost") { | ||||
|       var page = window.location.pathname; | ||||
|       if (page.substring(page.length - 1) != "/") page += "/"; | ||||
|             ga('send', 'pageview', page); | ||||
|       ga("send", "pageview", page); | ||||
|     } | ||||
|  | ||||
|     window.onpopstate = function(e) { | ||||
| @@ -70,7 +78,11 @@ var Channel = { | ||||
|     } | ||||
|  | ||||
|     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"; | ||||
|     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) { | ||||
| @@ -79,19 +91,26 @@ var Channel = { | ||||
|  | ||||
|     if (!client) { | ||||
|       //Helper.tabs('.playlist-tabs'); | ||||
|             Helper.tabs('.playlist-tabs-loggedIn', { | ||||
|       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"); | ||||
|             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;"); | ||||
|             document | ||||
|               .getElementsByClassName("chat-link")[0] | ||||
|               .setAttribute("style", "color: white !important;"); | ||||
|             blinking = false; | ||||
|             //Helper.css("#chat-container", "display", "block"); | ||||
|             //Helper.css("#wrapper", "display", "none"); | ||||
| @@ -105,16 +124,22 @@ var Channel = { | ||||
|       }); | ||||
|  | ||||
|       if (window.location.hash == "#chat-container") { | ||||
|                 M.Tabs.getInstance(document.querySelector('.playlist-tabs-loggedIn')).select("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"); | ||||
|         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"); | ||||
|         M.Tabs.getInstance( | ||||
|           document.querySelector(".playlist-tabs-loggedIn") | ||||
|         ).select("wrapper"); | ||||
|       } | ||||
|  | ||||
|             Helper.tabs('.chatTabs'); | ||||
|       Helper.tabs(".chatTabs"); | ||||
|     } | ||||
|         Helper.tabs('.results-tabs'); | ||||
|     Helper.tabs(".results-tabs"); | ||||
|     var sidenavElem = document.getElementsByClassName("sidenav")[0]; | ||||
|     M.Sidenav.init(sidenavElem, { | ||||
|       menuWidth: 310, | ||||
| @@ -126,11 +151,14 @@ var Channel = { | ||||
|       }, | ||||
|       onCloseStart: function(el) { | ||||
|         Helper.removeClass(".hamburger-sidenav", "open"); | ||||
|             }, | ||||
|       } | ||||
|     }); | ||||
|         M.Collapsible.init(document.getElementsByClassName("settings-collapsible")[0], { | ||||
|     M.Collapsible.init( | ||||
|       document.getElementsByClassName("settings-collapsible")[0], | ||||
|       { | ||||
|         accordion: true | ||||
|         }); | ||||
|       } | ||||
|     ); | ||||
|  | ||||
|     if (!client) { | ||||
|       M.Modal.init(document.getElementById("embed"), { | ||||
| @@ -154,7 +182,7 @@ var Channel = { | ||||
|       } | ||||
|     }); | ||||
|  | ||||
|         M.FormSelect.init(document.querySelector('.category-advanced-select')); | ||||
|     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")); | ||||
| @@ -162,13 +190,17 @@ var Channel = { | ||||
|       dismissible: false | ||||
|     }); | ||||
|     M.Modal.init(document.getElementById("user_password"), { | ||||
|             dismissible: false, | ||||
|       dismissible: false | ||||
|     }); | ||||
|  | ||||
|     Channel.spotify_is_authenticated(spotify_authenticated); | ||||
|  | ||||
|     result_html = document.getElementById("temp-results-container"); | ||||
|         pagination_buttons_html = "<div class='pagination-results'>" + document.getElementsByClassName("pagination-results")[0].cloneNode(true).innerHTML + "</div>"; | ||||
|     pagination_buttons_html = | ||||
|       "<div class='pagination-results'>" + | ||||
|       document.getElementsByClassName("pagination-results")[0].cloneNode(true) | ||||
|         .innerHTML + | ||||
|       "</div>"; | ||||
|     empty_results_html = Helper.html("#empty-results-container"); | ||||
|     not_import_html = Helper.html(".not-imported-container"); | ||||
|     not_export_html = Helper.html(".not-exported-container"); | ||||
| @@ -177,8 +209,14 @@ var Channel = { | ||||
|  | ||||
|     if (socket === undefined) { | ||||
|       no_socket = false; | ||||
|             socket = io.connect(''+add, connection_options); | ||||
|             socket.on('update_required', function(msg) { | ||||
|       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; | ||||
| @@ -195,12 +233,22 @@ var Channel = { | ||||
|       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(); | ||||
|     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()){ | ||||
|     if ( | ||||
|       document.querySelectorAll("#alreadychannel").length === 0 || | ||||
|       Helper.mobilecheck() | ||||
|     ) { | ||||
|       setup_now_playing_listener(); | ||||
|       get_list_listener(); | ||||
|  | ||||
| @@ -221,24 +269,52 @@ var Channel = { | ||||
|             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); | ||||
|             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-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())); | ||||
|         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 = "<p>To listen to this channel with more features, go to</p><p>https://zoff.me/" + encodeURIComponent(chan.toLowerCase()) + "</p><img src='/assets/images/favicon.png' height='100' width='100' alt='circle-logo-zoff'>"; | ||||
|                 //M.Modal.getInstance(document.getElementById("channel-share-modal")).open(); | ||||
| @@ -265,7 +341,7 @@ var Channel = { | ||||
|         Helper.tooltip("#chan", { | ||||
|           delay: 5, | ||||
|           position: "bottom", | ||||
|                     html: "Show join URL", | ||||
|           html: "Show join URL" | ||||
|         }); | ||||
|       } | ||||
|  | ||||
| @@ -293,23 +369,27 @@ var Channel = { | ||||
|         html: "Search" | ||||
|       }); | ||||
|  | ||||
|  | ||||
|       Helper.tooltip(".shuffle-btn-container", { | ||||
|         delay: 5, | ||||
|         position: "bottom", | ||||
|                 html: "Shuffle", | ||||
|         html: "Shuffle" | ||||
|       }); | ||||
|  | ||||
|       Helper.tooltip("#settings", { | ||||
|         delay: 5, | ||||
|         position: "bottom", | ||||
|                 html: "Settings", | ||||
|         html: "Settings" | ||||
|       }); | ||||
|     } | ||||
|  | ||||
|     if (!client) { | ||||
|       window.onYouTubeIframeAPIReady = Player.onYouTubeIframeAPIReady; | ||||
|             if(Player.player === "" || Player.player === undefined || Helper.mobilecheck()) Player.loadPlayer(); | ||||
|       if ( | ||||
|         Player.player === "" || | ||||
|         Player.player === undefined || | ||||
|         Helper.mobilecheck() | ||||
|       ) | ||||
|         Player.loadPlayer(); | ||||
|     } else { | ||||
|       Player.loadSoundCloudPlayer(); | ||||
|     } | ||||
| @@ -332,20 +412,25 @@ var Channel = { | ||||
|       setup_chat_listener(); | ||||
|       get_history(); | ||||
|     } | ||||
|         if(client || Helper.mobilecheck()){ | ||||
|     if (client || Helper.mobilecheck()) { | ||||
|       get_list_ajax(); | ||||
|       get_np_ajax(); | ||||
|  | ||||
|     } | ||||
|  | ||||
|     try { | ||||
|         	if(!Helper.msieversion() && !Helper.mobilecheck() && !client && Notification != undefined) Notification.requestPermission(); | ||||
|       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', { | ||||
|       Helper.tooltip(".castButton", { | ||||
|         delay: 5, | ||||
|         position: "top", | ||||
|         html: "Cast Zoff to TV" | ||||
| @@ -382,21 +467,35 @@ var Channel = { | ||||
|  | ||||
|     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); | ||||
|       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){ | ||||
|     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) { | ||||
|       initializeCastApi(); | ||||
|     } else if (!client) { | ||||
|             window['__onGCastApiAvailable'] = function(loaded, errorInfo) { | ||||
|       window["__onGCastApiAvailable"] = function(loaded, errorInfo) { | ||||
|         if (loaded) { | ||||
|           setTimeout(function() { | ||||
|             chromecastReady = true; | ||||
| @@ -405,27 +504,36 @@ var Channel = { | ||||
|         } 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); | ||||
|       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 | ||||
|       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; | ||||
|       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"; | ||||
|       document.getElementsByClassName("title-container")[0].style.width = | ||||
|         title_width + "px"; | ||||
|     } else { | ||||
|             document.getElementsByClassName("title-container")[0].style.width = "100%"; | ||||
|       document.getElementsByClassName("title-container")[0].style.width = | ||||
|         "100%"; | ||||
|     } | ||||
|   }, | ||||
|  | ||||
| @@ -472,10 +580,41 @@ var Channel = { | ||||
|   }, | ||||
|  | ||||
|   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;"); | ||||
|     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() { | ||||
| @@ -493,26 +632,42 @@ var Channel = { | ||||
|     var scrollListener = function(e) { | ||||
|       if (!programscroll) { | ||||
|         userscroll = true; | ||||
|                 if(document.getElementById("chatchannel").scrollTop + document.getElementById("chatchannel").offsetHeight >= document.getElementById("chatchannel").scrollHeight) { | ||||
|         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) { | ||||
|         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); | ||||
|         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); | ||||
|         document | ||||
|           .getElementById("chatchannel") | ||||
|           .removeEventListener("scroll", scrollListener); | ||||
|         document | ||||
|           .getElementById("chatall") | ||||
|           .removeEventListener("scroll", scrollAllListener); | ||||
|       } | ||||
|     } | ||||
|   }, | ||||
| @@ -524,16 +679,20 @@ var Channel = { | ||||
|       Player.stopInterval = true; | ||||
|       user_auth_avoid = true; | ||||
|       if (!Helper.mobilecheck()) { | ||||
|                 Helper.tooltip('.castButton', "destroy"); | ||||
|         Helper.tooltip(".castButton", "destroy"); | ||||
|         Helper.tooltip("#viewers", "destroy"); | ||||
|                 Helper.tooltip('#addToOtherList', 'destroy'); | ||||
|         Helper.tooltip("#addToOtherList", "destroy"); | ||||
|         //$('.castButton-unactive').tooltip("destroy"); | ||||
|         Helper.tooltip("#offline-mode", "destroy"); | ||||
|                 Helper.tooltip('#admin-lock', "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) == "#")){ | ||||
|     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 | ||||
|       }); | ||||
| @@ -544,8 +703,10 @@ var Channel = { | ||||
|       var add = ""; | ||||
|       w_p = true; | ||||
|       //if(private_channel) add = Crypt.getCookie("_uI") + "_"; | ||||
|  | ||||
|             socket.emit("list", {version: parseInt(_VERSION), channel: add + chan.toLowerCase()}); | ||||
|       socket.emit("list", { | ||||
|         version: parseInt(_VERSION), | ||||
|         channel: add + chan.toLowerCase() | ||||
|       }); | ||||
|     } else if (url_split[3] === "") { | ||||
|       /*if(client) { | ||||
|                 var host = window.location.hostname.split("."); | ||||
| @@ -554,7 +715,7 @@ var Channel = { | ||||
|       Admin.display_logged_out(); | ||||
|       if (hostMode) { | ||||
|         Helper.removeClass("#main-row", "fullscreened"); | ||||
|                 document.querySelector(".host_switch_class").checked = false | ||||
|         document.querySelector(".host_switch_class").checked = false; | ||||
|         enable_host_mode(false); | ||||
|       } | ||||
|       var channel_before_move = chan.toLowerCase(); | ||||
| @@ -578,13 +739,16 @@ var Channel = { | ||||
|       Helper.css("#embed-button", "display", "none"); | ||||
|       if (!Helper.mobilecheck()) { | ||||
|         Helper.tooltip(".castButton", "destroy"); | ||||
|                 Helper.tooltip('#addToOtherList', '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("#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"); | ||||
| @@ -592,12 +756,14 @@ var Channel = { | ||||
|       } | ||||
|       Helper.removeElement("#seekToDuration"); | ||||
|  | ||||
|             M.Sidenav.getInstance(document.getElementsByClassName("sidenav")[0]).destroy(); | ||||
|       M.Sidenav.getInstance( | ||||
|         document.getElementsByClassName("sidenav")[0] | ||||
|       ).destroy(); | ||||
|       if (!client) { | ||||
|         if (!Helper.mobilecheck()) { | ||||
|           Helper.tooltip("#chan", "destroy"); | ||||
|         } | ||||
|                 var tap_1 = document.querySelectorAll(".tap-target") | ||||
|         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(); | ||||
|         } | ||||
| @@ -637,22 +803,30 @@ var Channel = { | ||||
|         url: "/", | ||||
|         method: "GET", | ||||
|         success: function(e) { | ||||
|  | ||||
|           if (!client) { | ||||
|             document.querySelector("#hide-playlist").remove(); | ||||
| 			if(hiddenPlaylist) document.querySelector("main").style.maxWidth = ""; | ||||
|             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); | ||||
|             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) { | ||||
|           if (Helper.mobilecheck() || user_auth_avoid) { | ||||
|             video_id = ""; | ||||
|             song_title = ""; | ||||
|           } | ||||
|  | ||||
|                     document.querySelectorAll("meta[name=theme-color]")[0].setAttribute("content", "#2D2D2D"); | ||||
|           document | ||||
|             .querySelectorAll("meta[name=theme-color]")[0] | ||||
|             .setAttribute("content", "#2D2D2D"); | ||||
|  | ||||
|           if (!Helper.mobilecheck() && !user_auth_avoid) { | ||||
|             Helper.removeElement("#playbar"); | ||||
| @@ -663,9 +837,21 @@ var Channel = { | ||||
|             Helper.addClass("#main-row", "frontpage_modified_heights"); | ||||
|             Helper.css("#player", "opacity", "1"); | ||||
|             Helper.removeClass("#video-container", "no-opacity"); | ||||
|                         document.getElementById("main-row").insertAdjacentHTML("afterbegin", "<div id='player_bottom_overlay' class='player player_bottom'></div>"); | ||||
|                         document.getElementById("player_bottom_overlay").insertAdjacentHTML("afterbegin", "<a id='closePlayer' title='Close Player'><i class='material-icons'>close</i></a>"); | ||||
|                         document.getElementById("player_bottom_overlay").setAttribute("data-channel", channel_before_move.toLowerCase()); | ||||
|             document | ||||
|               .getElementById("main-row") | ||||
|               .insertAdjacentHTML( | ||||
|                 "afterbegin", | ||||
|                 "<div id='player_bottom_overlay' class='player player_bottom'></div>" | ||||
|               ); | ||||
|             document | ||||
|               .getElementById("player_bottom_overlay") | ||||
|               .insertAdjacentHTML( | ||||
|                 "afterbegin", | ||||
|                 "<a id='closePlayer' title='Close Player'><i class='material-icons'>close</i></a>" | ||||
|               ); | ||||
|             document | ||||
|               .getElementById("player_bottom_overlay") | ||||
|               .setAttribute("data-channel", channel_before_move.toLowerCase()); | ||||
|             Helper.removeElement("#playlist"); | ||||
|           } else { | ||||
|             try { | ||||
| @@ -683,27 +869,48 @@ var Channel = { | ||||
|           response.innerHTML = e; | ||||
|  | ||||
|           var newList = response.querySelector("#lists-script").innerHTML; | ||||
|                     newList = newList.trim().replace("window.lists = ", "").replace("window.lists=", ""); | ||||
|           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"; | ||||
|           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].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.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; | ||||
|           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); | ||||
|             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"); | ||||
|           document | ||||
|             .getElementById("favicon") | ||||
|             .setAttribute("href", "/assets/images/favicon-32x32.png"); | ||||
|  | ||||
|           Helper.log(["Socket", socket]); | ||||
|           if (document.querySelectorAll("#alreadyfp").length == 1) { | ||||
| @@ -716,8 +923,16 @@ var Channel = { | ||||
|  | ||||
|           changing_to_frontpage = false; | ||||
|  | ||||
|                     if(document.querySelectorAll("#alreadychannel").length === 0 && !user_auth_avoid){ | ||||
|                         document.getElementsByTagName("head")[0].insertAdjacentHTML("beforeend", "<div id='alreadychannel'></div"); | ||||
|           if ( | ||||
|             document.querySelectorAll("#alreadychannel").length === 0 && | ||||
|             !user_auth_avoid | ||||
|           ) { | ||||
|             document | ||||
|               .getElementsByTagName("head")[0] | ||||
|               .insertAdjacentHTML( | ||||
|                 "beforeend", | ||||
|                 "<div id='alreadychannel'></div" | ||||
|               ); | ||||
|           } else if (user_auth_avoid) { | ||||
|             Helper.removeElement("#alreadychannel"); | ||||
|           } | ||||
| @@ -727,7 +942,7 @@ var Channel = { | ||||
|       }); | ||||
|     } | ||||
|   } | ||||
| } | ||||
| }; | ||||
|  | ||||
| function get_history() { | ||||
|   if (socket && socket.id) { | ||||
|   | ||||
| @@ -4,12 +4,11 @@ var socket; | ||||
| var rotation_timeout; | ||||
|  | ||||
| var Frontpage = { | ||||
|  | ||||
|   blob_list: [], | ||||
|  | ||||
|     winter: (new Date()).getMonth() >= 10 ? true : false, | ||||
|   winter: new Date().getMonth() >= 10 ? true : false, | ||||
|   pride: function() { | ||||
|         return (new Date()).getMonth() == 5; | ||||
|     return new Date().getMonth() == 5; | ||||
|   }, | ||||
|  | ||||
|   times_rotated: 0, | ||||
| @@ -19,10 +18,7 @@ var Frontpage = { | ||||
|   frontpage_function: function() { | ||||
|     frontpage = true; | ||||
|  | ||||
|         Helper.log([ | ||||
|             "Frontpage fetch", | ||||
|             msg | ||||
|         ]); | ||||
|     Helper.log(["Frontpage fetch", msg]); | ||||
|  | ||||
|     Frontpage.all_channels = window.lists; | ||||
|     var msg = window.lists; | ||||
| @@ -31,7 +27,9 @@ var Frontpage = { | ||||
|     //document.querySelector("#lists-script").remove(); | ||||
|     if (msg.length == 0) { | ||||
|       //Helper.css("#preloader", "display", "none"); | ||||
|             document.getElementById("channel-list-container").insertAdjacentHTML("beforeend", "<p>No channels yet</p>"); | ||||
|       document | ||||
|         .getElementById("channel-list-container") | ||||
|         .insertAdjacentHTML("beforeend", "<p>No channels yet</p>"); | ||||
|     } else { | ||||
|       Frontpage.populate_channels(msg, true, false); | ||||
|     } | ||||
| @@ -46,27 +44,39 @@ var Frontpage = { | ||||
|     else if (set) { | ||||
|       document.getElementById("channels").innerHTML = ""; | ||||
|       if (popular) { | ||||
|                 lists = lists.sort(Helper.predicate({ | ||||
|                     name: 'pinned', | ||||
|         lists = lists.sort( | ||||
|           Helper.predicate( | ||||
|             { | ||||
|               name: "pinned", | ||||
|               reverse: true | ||||
|                 }, { | ||||
|                     name: 'viewers', | ||||
|             }, | ||||
|             { | ||||
|               name: "viewers", | ||||
|               reverse: true | ||||
|                 }, { | ||||
|                     name: 'accessed', | ||||
|             }, | ||||
|             { | ||||
|               name: "accessed", | ||||
|               reverse: true | ||||
|                 }, { | ||||
|                     name: 'count', | ||||
|             }, | ||||
|             { | ||||
|               name: "count", | ||||
|               reverse: true | ||||
|                 })); | ||||
|             } | ||||
|           ) | ||||
|         ); | ||||
|       } else { | ||||
|                 lists = lists.sort(Helper.predicate({ | ||||
|                     name: 'viewers', | ||||
|         lists = lists.sort( | ||||
|           Helper.predicate( | ||||
|             { | ||||
|               name: "viewers", | ||||
|               reverse: true | ||||
|                 }, { | ||||
|                     name: 'count', | ||||
|             }, | ||||
|             { | ||||
|               name: "count", | ||||
|               reverse: true | ||||
|                 })); | ||||
|             } | ||||
|           ) | ||||
|         ); | ||||
|       } | ||||
|  | ||||
|       if (!Helper.mobilecheck()) { | ||||
| @@ -76,10 +86,7 @@ var Frontpage = { | ||||
|  | ||||
|       pre_card = channel_list; | ||||
|  | ||||
|             Helper.log([ | ||||
|                 "Pre_card: ", | ||||
|                 pre_card | ||||
|             ]); | ||||
|       Helper.log(["Pre_card: ", pre_card]); | ||||
|  | ||||
|       for (var x in lists) { | ||||
|         var chan = Helper.decodeChannelName(lists[x]._id); | ||||
| @@ -88,7 +95,10 @@ var Frontpage = { | ||||
|           var viewers = lists[x].viewers; | ||||
|           var description = lists[x].description; | ||||
|           var img; | ||||
|                     img = "background-image:url('https://img.youtube.com/vi/"+id+"/hqdefault.jpg');"; | ||||
|           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 + "');"; | ||||
|           } | ||||
| @@ -99,7 +109,9 @@ var Frontpage = { | ||||
|           //card.innerHTML = card.children[0]; | ||||
|           if (song_count > 3) { | ||||
|             if (lists[x].pinned == 1) { | ||||
|                             card.querySelector(".pin").setAttribute("style", "display:block;"); | ||||
|               card | ||||
|                 .querySelector(".pin") | ||||
|                 .setAttribute("style", "display:block;"); | ||||
|               //card.find(".card").attr("title", "Featured list"); | ||||
|             } else { | ||||
|               /*card.find(".pin").attr("style", "display:none;"); | ||||
| @@ -113,20 +125,26 @@ var Frontpage = { | ||||
|             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") { | ||||
|             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") | ||||
|               Helper.removeClass(card.querySelector(".card"), "sticky-action"); | ||||
|             } | ||||
|  | ||||
|                         document.getElementById("channels").insertAdjacentHTML("beforeend", card.children[0].innerHTML); | ||||
|             document | ||||
|               .getElementById("channels") | ||||
|               .insertAdjacentHTML("beforeend", card.children[0].innerHTML); | ||||
|           } else { | ||||
|             num--; | ||||
|           } | ||||
|  | ||||
|         } | ||||
|         num++; | ||||
|       } | ||||
| @@ -139,12 +157,19 @@ var Frontpage = { | ||||
|     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, { | ||||
|     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]; | ||||
| @@ -155,7 +180,7 @@ var Frontpage = { | ||||
|       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"; | ||||
| @@ -196,10 +221,10 @@ var Frontpage = { | ||||
|  | ||||
|   getCookie: function(cname) { | ||||
|     var name = cname + "="; | ||||
|         var ca = document.cookie.split(';'); | ||||
|     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); | ||||
|       while (c.charAt(0) == " ") c = c.substring(1); | ||||
|       if (c.indexOf(name) === 0) return c.substring(name.length, c.length); | ||||
|     } | ||||
|     return ""; | ||||
| @@ -213,11 +238,17 @@ var Frontpage = { | ||||
|       //$(".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", | ||||
|             "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)); | ||||
|           document | ||||
|             .querySelector(".autocomplete") | ||||
|             .setAttribute("placeholder", Helper.decodeChannelName(list[i]._id)); | ||||
|           //$(".room-namer").css("opacity", 1); | ||||
|         } | ||||
|       }, 500); | ||||
| @@ -225,7 +256,8 @@ var Frontpage = { | ||||
|       var img = new Image(); | ||||
|       img.src = "/assets/images/thumbnails/" + id + ".jpg"; | ||||
|  | ||||
|             img.onerror = function(e){ // Failed to load | ||||
|       img.onerror = function(e) { | ||||
|         // Failed to load | ||||
|         var add = ""; | ||||
|         if (window.location.hostname == "fb.zoff.me") { | ||||
|           add = "https://zoff.me"; | ||||
| @@ -238,33 +270,53 @@ var Frontpage = { | ||||
|           success: function(data) { | ||||
|             setTimeout(function() { | ||||
|               try { | ||||
|                                 Helper.css("#mega-background", "background", "url(/assets/images/thumbnails/"+data+")"); | ||||
|                 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", | ||||
|                   "background-repeat", | ||||
|                   "no-repeat" | ||||
|                 ); | ||||
|                 Helper.css("#mega-background", "opacity", 1); | ||||
|                                 document.querySelector(".autocomplete").setAttribute("placeholder", Helper.decodeChannelName(list[i]._id)); | ||||
|                             } catch(e) {} | ||||
|                 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)); | ||||
|               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 | ||||
|       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)); | ||||
|           document | ||||
|             .querySelector(".autocomplete") | ||||
|             .setAttribute("placeholder", Helper.decodeChannelName(list[i]._id)); | ||||
|         } catch (e) {} | ||||
|       }; | ||||
|  | ||||
|     } | ||||
|     rotation_timeout = setTimeout(function() { | ||||
|       if (Frontpage.times_rotated == 50 && frontpage) { | ||||
| @@ -305,7 +357,7 @@ var Frontpage = { | ||||
|  | ||||
|   start_snowfall: function() { | ||||
|     setTimeout(function() { | ||||
|             var x = Math.floor((Math.random() * window.innerWidth) + 1); | ||||
|       var x = Math.floor(Math.random() * window.innerWidth + 1); | ||||
|       var snow = document.createElement("div"); | ||||
|       var parent = document.getElementsByClassName("mega")[0]; | ||||
|  | ||||
| @@ -320,8 +372,11 @@ var Frontpage = { | ||||
|   }, | ||||
|  | ||||
|   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){ | ||||
|     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); | ||||
| @@ -331,7 +386,8 @@ var Frontpage = { | ||||
|   }, | ||||
|  | ||||
|   set_viewers: function(viewers) { | ||||
|         document.querySelector("#frontpage-viewer-counter").innerHTML = "<i class='material-icons frontpage-viewers'>visibility</i>" + viewers; | ||||
|     document.querySelector("#frontpage-viewer-counter").innerHTML = | ||||
|       "<i class='material-icons frontpage-viewers'>visibility</i>" + viewers; | ||||
|   }, | ||||
|  | ||||
|   to_channel: function(new_channel, popstate) { | ||||
| @@ -351,7 +407,11 @@ var Frontpage = { | ||||
|       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"); | ||||
|         Helper.tooltip( | ||||
|           document.querySelectorAll(".pin")[0].parentElement.parentElement | ||||
|             .parentElement, | ||||
|           "destroy" | ||||
|         ); | ||||
|       } | ||||
|     } | ||||
|  | ||||
| @@ -362,7 +422,6 @@ var Frontpage = { | ||||
|       method: "get", | ||||
|       data: { channel: new_channel }, | ||||
|       success: function(e) { | ||||
|  | ||||
|         if (Player.player !== "") { | ||||
|           //Player.player.destroy(); | ||||
|           socket.emit("change_channel", { channel: chan.toLowerCase() }); | ||||
| @@ -376,7 +435,11 @@ var Frontpage = { | ||||
|         } | ||||
|         var old_chan = chan; | ||||
|         if (!popstate) { | ||||
|                     window.history.pushState("to the channel!", "Title", "/" + new_channel); | ||||
|           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; | ||||
| @@ -385,21 +448,45 @@ var Frontpage = { | ||||
|         var response = document.createElement("div"); | ||||
|         response.innerHTML = e; | ||||
|  | ||||
|                 M.FormSelect.getInstance(document.querySelector("#view_channels_select")).destroy(); | ||||
|         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"; | ||||
|         document.getElementsByTagName("main")[0].className = | ||||
|           "container center-align main"; | ||||
|         Helper.addClass("#main-container", "channelpage"); | ||||
|  | ||||
|                 document.getElementsByTagName("header")[0].innerHTML = response.querySelectorAll("header")[0].innerHTML; | ||||
|         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; | ||||
|         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", "<div id='playbar'></div>"); | ||||
|           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", "<div id='playbar'></div>"); | ||||
|           Helper.removeClass("#player", "player_bottom"); | ||||
|           Helper.removeClass("#player_overlay", "player_bottom"); | ||||
|           Helper.removeClass(".video-container", "frontpage-player"); | ||||
| @@ -408,7 +495,9 @@ var Frontpage = { | ||||
|           Helper.removeElement("#closePlayer"); | ||||
|           Helper.removeElement("#player_bottom_overlay"); | ||||
|         } | ||||
|                 document.getElementById("search").setAttribute("placeholder", "Search..."); | ||||
|         document | ||||
|           .getElementById("search") | ||||
|           .setAttribute("placeholder", "Search..."); | ||||
|         Helper.addClass(".page-footer", "padding-bottom-novideo"); | ||||
|         from_frontpage = true; | ||||
|         //Player.stopInterval =true; | ||||
| @@ -420,14 +509,15 @@ var Frontpage = { | ||||
|           fromFront = true; | ||||
|           Channel.init(); | ||||
|         } | ||||
|                 if(document.querySelectorAll("#alreadyfp").length === 0) document.getElementsByTagName("head")[0].insertAdjacentHTML("beforeend", "<div id='alreadyfp'></div>"); | ||||
|  | ||||
|         if (document.querySelectorAll("#alreadyfp").length === 0) | ||||
|           document | ||||
|             .getElementsByTagName("head")[0] | ||||
|             .insertAdjacentHTML("beforeend", "<div id='alreadyfp'></div>"); | ||||
|       } | ||||
|     }); | ||||
|   }, | ||||
|  | ||||
|   init: function() { | ||||
|  | ||||
|     var date = new Date(); | ||||
|     Frontpage.blob_list = []; | ||||
|     if (date.getMonth() == 3 && date.getDate() == 1) { | ||||
| @@ -439,12 +529,12 @@ var Frontpage = { | ||||
|     if (window.location.hostname != "localhost") { | ||||
|       var page = window.location.pathname; | ||||
|       if (page.substring(page.length - 1) != "/") page += "/"; | ||||
|             ga('send', 'pageview', page); | ||||
|       ga("send", "pageview", page); | ||||
|     } | ||||
|  | ||||
|     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); | ||||
|       } | ||||
| @@ -454,19 +544,31 @@ var Frontpage = { | ||||
|       Helper.addClass("footer", "hide"); | ||||
|     } | ||||
|  | ||||
|         channel_list = document.querySelector(".hidden-channel-list").cloneNode(true).innerHTML; | ||||
|     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"; | ||||
|     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.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; | ||||
| @@ -474,21 +576,23 @@ var Frontpage = { | ||||
|         window.location.reload(true); | ||||
|       }); | ||||
|     } | ||||
|         if(document.querySelectorAll("#alreadyfp").length === 0 || Helper.mobilecheck() || !socket._callbacks.$playlists || user_auth_avoid){ | ||||
|     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("help")); | ||||
|         M.Modal.init(document.getElementById("contact"));*/ | ||||
|         var elem = document.querySelector('select'); | ||||
|     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()) { | ||||
| @@ -525,7 +629,7 @@ var Frontpage = { | ||||
|     //Materialize.toast("<a href='/remote' style='color:white;'>Try out our new feature, remote!</a>", 8000) | ||||
|     if (window.location.hash == "#donation") { | ||||
|       window.location.hash = "#"; | ||||
|             M.Modal.init(document.getElementById("donation"));; | ||||
|       M.Modal.init(document.getElementById("donation")); | ||||
|       M.Modal.getInstance(document.getElementById("donation")).open(); | ||||
|     } | ||||
|  | ||||
| @@ -541,7 +645,9 @@ var Frontpage = { | ||||
|         });*/ | ||||
|  | ||||
|     if (!Helper.mobilecheck() && Frontpage.winter) { | ||||
|             document.getElementsByClassName("mega")[0].insertAdjacentHTML("afterbegin", '<div id="snow"></div>'); | ||||
|       document | ||||
|         .getElementsByClassName("mega")[0] | ||||
|         .insertAdjacentHTML("afterbegin", '<div id="snow"></div>'); | ||||
|     } | ||||
|     if (Frontpage.pride()) { | ||||
|       Helper.addClass("#fp-nav", "pride-background"); | ||||
| @@ -551,19 +657,39 @@ var Frontpage = { | ||||
|       //$('input#autocomplete-input').characterCounter(); | ||||
|     } | ||||
|  | ||||
|         window['__onGCastApiAvailable'] = function(loaded, errorInfo) { | ||||
|     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;"); | ||||
|     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"); | ||||
|   } | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user