mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Added manifest.json and serviceworker for more functioning webapps
This commit is contained in:
14
manifest.json
Normal file
14
manifest.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"short_name": "Zöff",
|
||||
"name": "Zöff",
|
||||
"icons": [
|
||||
{
|
||||
"src": "static/images/144x144.png",
|
||||
"sizes": "144x144",
|
||||
"type": "image/png"
|
||||
}
|
||||
],
|
||||
"start_url": "/",
|
||||
"display": "standalone",
|
||||
"orientation": "portrait"
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
<meta property="og:title" content="Zöff"/>
|
||||
<meta property="og:description" content="The Shared (free) YouTube radio. Being built around the YouTube search and video API it enables the creation of collaborative and shared live playlists, with billions of videos and songs to choose from, all for free and without registration. Enjoy!"/>
|
||||
<meta property="og:type" content="website"/>
|
||||
<link rel="manifest" href="/manifest.json">
|
||||
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.min.css">
|
||||
<link tyle="text/css" rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
|
||||
<link type="text/css" rel="stylesheet" href="/static/css/materialize.min.css" />
|
||||
|
||||
68
service-worker.js
Normal file
68
service-worker.js
Normal file
@@ -0,0 +1,68 @@
|
||||
importScripts('/static/dist/lib/cache-polyfill.js');
|
||||
|
||||
var CACHE_VERSION = 'app-v1';
|
||||
var CACHE_FILES = [
|
||||
'/static/images/favicon.png',
|
||||
'/static/css/style.css',
|
||||
'/static/css/materialize.min.css',
|
||||
'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.min.css',
|
||||
'https://fonts.googleapis.com/icon?family=Material+Icons',
|
||||
'https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js',
|
||||
'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js',
|
||||
'/static/dist/lib/materialize.min.js',
|
||||
'https://cdn.socket.io/socket.io-1.4.5.js',
|
||||
'/static/dist/lib/jquery.lazyload.js',
|
||||
'/static/dist/lib/color-thief.js',
|
||||
'/static/dist/main.min.js'
|
||||
];
|
||||
|
||||
self.addEventListener('install', function (event) {
|
||||
event.waitUntil(
|
||||
caches.open(CACHE_VERSION)
|
||||
.then(function (cache) {
|
||||
console.log('Opened cache');
|
||||
return cache.addAll(CACHE_FILES);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener('activate', function (event) {
|
||||
event.waitUntil(
|
||||
caches.keys().then(function(keys){
|
||||
return Promise.all(keys.map(function(key, i){
|
||||
if(key !== CACHE_VERSION){
|
||||
return caches.delete(keys[i]);
|
||||
}
|
||||
}))
|
||||
})
|
||||
)
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', function (event) {
|
||||
event.respondWith(
|
||||
caches.match(event.request).then(function(res){
|
||||
if(res){
|
||||
return res;
|
||||
}
|
||||
requestBackend(event);
|
||||
})
|
||||
)
|
||||
});
|
||||
|
||||
function requestBackend(event){
|
||||
var url = event.request.clone();
|
||||
return fetch(url).then(function(res){
|
||||
//if not a valid response send the error
|
||||
if(!res || res.status !== 200 || res.type !== 'basic'){
|
||||
return res;
|
||||
}
|
||||
|
||||
var response = res.clone();
|
||||
|
||||
caches.open(CACHE_VERSION).then(function(cache){
|
||||
cache.put(event.request, response);
|
||||
});
|
||||
|
||||
return res;
|
||||
})
|
||||
}
|
||||
103
static/dist/lib/cache-polyfill.js
vendored
Normal file
103
static/dist/lib/cache-polyfill.js
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* Copyright 2015 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var nativeAddAll = Cache.prototype.addAll;
|
||||
var userAgent = navigator.userAgent.match(/(Firefox|Chrome)\/(\d+\.)/);
|
||||
|
||||
// Has nice behavior of `var` which everyone hates
|
||||
if (userAgent) {
|
||||
var agent = userAgent[1];
|
||||
var version = parseInt(userAgent[2]);
|
||||
}
|
||||
|
||||
if (
|
||||
nativeAddAll && (!userAgent ||
|
||||
(agent === 'Firefox' && version >= 46) ||
|
||||
(agent === 'Chrome' && version >= 50)
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
Cache.prototype.addAll = function addAll(requests) {
|
||||
var cache = this;
|
||||
|
||||
// Since DOMExceptions are not constructable:
|
||||
function NetworkError(message) {
|
||||
this.name = 'NetworkError';
|
||||
this.code = 19;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
NetworkError.prototype = Object.create(Error.prototype);
|
||||
|
||||
return Promise.resolve().then(function() {
|
||||
if (arguments.length < 1) throw new TypeError();
|
||||
|
||||
// Simulate sequence<(Request or USVString)> binding:
|
||||
var sequence = [];
|
||||
|
||||
requests = requests.map(function(request) {
|
||||
if (request instanceof Request) {
|
||||
return request;
|
||||
}
|
||||
else {
|
||||
return String(request); // may throw TypeError
|
||||
}
|
||||
});
|
||||
|
||||
return Promise.all(
|
||||
requests.map(function(request) {
|
||||
if (typeof request === 'string') {
|
||||
request = new Request(request);
|
||||
}
|
||||
|
||||
var scheme = new URL(request.url).protocol;
|
||||
|
||||
if (scheme !== 'http:' && scheme !== 'https:') {
|
||||
throw new NetworkError("Invalid scheme");
|
||||
}
|
||||
|
||||
return fetch(request.clone());
|
||||
})
|
||||
);
|
||||
}).then(function(responses) {
|
||||
// If some of the responses has not OK-eish status,
|
||||
// then whole operation should reject
|
||||
if (responses.some(function(response) {
|
||||
return !response.ok;
|
||||
})) {
|
||||
throw new NetworkError('Incorrect response status');
|
||||
}
|
||||
|
||||
// TODO: check that requests don't overwrite one another
|
||||
// (don't think this is possible to polyfill due to opaque responses)
|
||||
return Promise.all(
|
||||
responses.map(function(response, i) {
|
||||
return cache.put(requests[i], response);
|
||||
})
|
||||
);
|
||||
}).then(function() {
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
|
||||
Cache.prototype.add = function add(request) {
|
||||
return this.addAll([request]);
|
||||
};
|
||||
}());
|
||||
4
static/dist/main.min.js
vendored
4
static/dist/main.min.js
vendored
File diff suppressed because one or more lines are too long
BIN
static/images/144x144.png
Normal file
BIN
static/images/144x144.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.1 KiB |
@@ -1,4 +1,4 @@
|
||||
var chan = $("#chan").html();
|
||||
var chan = window.chan == undefined ? $("#chan").html() : window.chan;
|
||||
var w_p = true;
|
||||
var hasadmin = 0;
|
||||
var showToggle = true;
|
||||
@@ -54,6 +54,18 @@ var connection_options = {
|
||||
'force new connection': true
|
||||
};
|
||||
|
||||
if (navigator.serviceWorker) {
|
||||
navigator.serviceWorker.register('/service-worker.js')
|
||||
.then(function (registration) {
|
||||
console.log(registration);
|
||||
})
|
||||
.catch(function (e) {
|
||||
console.error(e);
|
||||
})
|
||||
} else {
|
||||
console.log('Service Worker is not supported in this browser.');
|
||||
}
|
||||
|
||||
$().ready(function(){
|
||||
if(!window.fromFront && window.location.pathname != "/") init();
|
||||
});
|
||||
@@ -61,7 +73,8 @@ $().ready(function(){
|
||||
|
||||
function init(){
|
||||
|
||||
chan = $("#chan").html();
|
||||
chan = window.chan == undefined ? $("#chan").html() : window.chan;
|
||||
console.log(chan);
|
||||
mobile_beginning = window.mobilecheck();
|
||||
|
||||
window.onpopstate = function(e){
|
||||
@@ -71,7 +84,7 @@ function init(){
|
||||
share_link_modifier_channel();
|
||||
|
||||
if(window.location.hostname == "zoff.no") add = "https://zoff.no";
|
||||
else add = "localhost";
|
||||
else add = window.location.hostname;
|
||||
|
||||
|
||||
//setTimeout(function(){
|
||||
@@ -80,12 +93,6 @@ function init(){
|
||||
//window.submit = Search.submit;
|
||||
//window.submitAndClose = Search.submitAndClose;
|
||||
|
||||
if(!localStorage["list_update"] || localStorage["list_update"] != "13.06.15")
|
||||
{
|
||||
localStorage.setItem("list_update", "13.06.15");
|
||||
window.location.reload(true);
|
||||
}
|
||||
|
||||
$('ul.playlist-tabs').tabs();
|
||||
$('ul.playlist-tabs-loggedIn').tabs();
|
||||
$('.chatTabs').tabs();
|
||||
@@ -502,7 +509,6 @@ function onepage_load(){
|
||||
url: "php/nochan.php",
|
||||
success: function(e){
|
||||
|
||||
|
||||
socket.disconnect();
|
||||
|
||||
document.getElementById("volume-button").removeEventListener("click", Playercontrols.mute_video);
|
||||
@@ -521,10 +527,10 @@ function onepage_load(){
|
||||
$("main").attr("class", "center-align container");
|
||||
$("body").attr("id", "");
|
||||
$("body").attr("style", "");
|
||||
$("header").html($($(e)[57]).html());
|
||||
$($(e)[59]).insertAfter("header");
|
||||
$($(e)[61]).insertAfter(".mega");
|
||||
$("main").html($($(e)[65]).html());
|
||||
$("header").html($($(e)[59]).html());
|
||||
$($(e)[61]).insertAfter("header");
|
||||
$($(e)[63]).insertAfter(".mega");
|
||||
$("main").html($($(e)[67]).html());
|
||||
$(".page-footer").removeClass("padding-bottom-extra");
|
||||
$(".page-footer").removeClass("padding-bottom-novideo");
|
||||
$("#favicon").attr("href", "static/images/favicon.png");
|
||||
|
||||
@@ -235,14 +235,17 @@ var Nochan = {
|
||||
$("body").css("background-color", "#2d2d2d");
|
||||
socket.disconnect();
|
||||
|
||||
if(!popstate) window.history.pushState("to the channel!", "Title", "/" + chan + "/");
|
||||
if(!popstate){
|
||||
window.history.pushState("to the channel!", "Title", "/" + chan);
|
||||
window.chan = chan;
|
||||
}
|
||||
|
||||
$(".mega").remove();
|
||||
$(".mobile-search").remove();
|
||||
$("main").attr("class", "container center-align main");
|
||||
$("body").attr("id", "channelpage");
|
||||
$("header").html($($(e)[57]).html());
|
||||
$("main").html($($(e)[61]).html());
|
||||
$("header").html($($(e)[59]).html());
|
||||
$("main").html($($(e)[63]).html());
|
||||
$("#search").attr("placeholder", "Find song on YouTube...");
|
||||
$(".page-footer").addClass("padding-bottom-novideo");
|
||||
if($("#alreadychannel").length == 1){
|
||||
@@ -252,6 +255,7 @@ var Nochan = {
|
||||
window.init();
|
||||
}
|
||||
if($("#alreadyfp").length == 0) $("head").append("<div id='alreadyfp'></div>");
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -304,7 +308,7 @@ function initfp(){
|
||||
};
|
||||
|
||||
if(window.location.hostname == "zoff.no") add = "https://zoff.no";
|
||||
else add = "localhost";
|
||||
else add = window.location.hostname;
|
||||
socket = io.connect(''+add+':8880', connection_options);
|
||||
socket.on('playlists', function(msg){
|
||||
$("#channels").empty();
|
||||
|
||||
Reference in New Issue
Block a user