Compare commits

...

2 Commits

Author SHA1 Message Date
iotcat ae61165c69 3.6.10 3 years ago
iotcat 7c3ac008e7 v3.6.10 3 years ago
  1. 88
      dist/ushio-footer.js
  2. 2
      dist/ushio-footer.min.js
  3. 8
      dist/ushio-head.js
  4. 2
      dist/ushio-head.min.js
  5. 2
      package.json
  6. 88
      src/ushio-footer.js
  7. 8
      src/ushio-head.js
  8. 6
      test/test.html

@ -92,11 +92,13 @@ if (getHiddenProp())
page.window = false; page.window = false;
log_update(); log_update();
var rand = Math.random() * 100; var rand = Math.random() * 100;
if(rand < 30) {if(page.tran.getLang() == 'zh')document.title = '啊咧(⊙0⊙)';else document.title = 'Aha (⊙0⊙)';} let title = '';
else if(rand < 55) {if(page.tran.getLang() == 'zh')document.title = '快来戳我呀( ´∀`)σ';else document.title = 'Click Me ( ´∀`)σ';} if(rand < 30) {if(page.tran.getLang() == 'zh')title = '啊咧(⊙0⊙)';else title = 'Aha (⊙0⊙)';}
else if(rand < 75) {if(page.tran.getLang() == 'zh')document.title = '躲起来(´・ω・`)';else document.title = 'Hiding(´・ω・`)';} else if(rand < 55) {if(page.tran.getLang() == 'zh')title = '快来戳我呀( ´∀`)σ';else title = 'Click Me ( ´∀`)σ';}
else {if(page.tran.getLang() == 'zh')document.title = '哎呦,页面崩掉了吗(>﹏<)';else document.title = 'Wow, page crashed(>﹏<)';} else if(rand < 75) {if(page.tran.getLang() == 'zh')title = '躲起来(´・ω・`)';else title = 'Hiding(´・ω・`)';}
setTimeout("document.title = page.title", 2400); else {if(page.tran.getLang() == 'zh')title = '哎呦,页面崩掉了吗(>﹏<)';else title = 'Wow, page crashed(>﹏<)';}
setTimeout(function(){document.title = title;}, 800);
setTimeout("document.title = page.title", 3800);
clearInterval(page.TimerObj); clearInterval(page.TimerObj);
page.TimerObj = null; page.TimerObj = null;
} }
@ -134,6 +136,8 @@ async function log_ini(){
who(); who();
}); });
updateHref(); updateHref();
fast_fetch();
} }
@ -163,6 +167,18 @@ if(page.cache && getCache()){
})*/ })*/
function fast_fetch(){
$.get('https://session.yimian.xyz/php/get.php?fp='+page.fp+'&flag='+page.flag+'&mask='+page.mask, function(res2){
res2 = JSON.parse(res2);
page.session = res2;
//session.status = true;
session.LastSyncTime = new Date().valueOf();
session.method = 'fast_fetch';
console.log('Ushio - Fast Fetched.. '+(new Date().valueOf()/1000 - page.openTime)+'s');
}).fail(function () {session.status = false;console.log('Ushio - Fast Fetch Failed!!');});
}
async function session_ini_pre () { async function session_ini_pre () {
//if(!page.fp || !page.ip) {setTimeout(session_ini_pre, 30);return;} //if(!page.fp || !page.ip) {setTimeout(session_ini_pre, 30);return;}
if(typeof WebSocket != 'undefined'){ if(typeof WebSocket != 'undefined'){
@ -206,7 +222,7 @@ function updateHref(){
/* cache session cohere */ /* cache session cohere */
/*
function checkCacheCohere(){ function checkCacheCohere(){
let chash = null; let chash = null;
@ -216,11 +232,12 @@ function checkCacheCohere(){
chash = null; chash = null;
} }
if(chash != page.session.hash){ if(chash && chash != page.session.hash){
setTimeout('window.location.reload();', 2000);
tips.question({ tips.question({
timeout: 9999999, timeout: 9999999,
title: 'Warning', title: 'Warning',
message: 'Session has changed. Please reload this page!', message: 'Session has changed. This page will reload!',
position: 'center', position: 'center',
color: 'red', color: 'red',
buttons: [ buttons: [
@ -233,7 +250,7 @@ function checkCacheCohere(){
}); });
} }
} }
*/
/* connect to session server */ /* connect to session server */
@ -404,7 +421,7 @@ session.onload(function(){
} }
} }
if(session.LastSyncTime < new Date().valueOf() - 12*1000){ if(session.LastSyncTime < new Date().valueOf() - 12*1000){
session.onload(player_ini_pre); session.onload(player_ini_pre, false, true);
}else{ }else{
player_ini_pre(); player_ini_pre();
} }
@ -416,10 +433,25 @@ session.onload(function(){
var isStop = false; var isStop = false;
if(typeof session.get('group') == "undefined"){ if(typeof session.get('group') == "undefined"){
isStop = true; isStop = true;
if(page.tran.getLang() == 'zh') alert('Ushio-session没有您的记录,将登出...'); tips.question({
else alert('Ushio-session do not have your record, Ushio will logout..'); timeout: 9999999,
window.location.href='https://auth.yimian.xyz/checkout.php?from='+ btoa(page.url); title: 'Warning',
throw new Error('ushio::Redirect to Ushio-Logout!'); message: (page.tran.getLang() == 'zh')?'Ushio-session没有您的记录!!':'Session Lost!! ',
position: 'center',
color: 'red',
buttons: [
['<button><b>RELOAD</b></button>', function (instance, toast) {
window.location.reload();
throw new Error('ushio::Page Reload!');
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button');
}, true],
['<button>LOGOUT</button>', function (instance, toast) {
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button');
window.location.href='https://auth.yimian.xyz/checkout.php?from='+ btoa(page.url);
throw new Error('ushio::Redirect to Ushio-Logout!');
}],
]
});
} }
if(page.auth.indexOf('any') != -1){ if(page.auth.indexOf('any') != -1){
if(session.get('group') == 'anonymous'){ if(session.get('group') == 'anonymous'){
@ -520,7 +552,9 @@ session.onload(function(){
ll = ll.concat(JSON.parse(atob(session.get('lang')))); ll = ll.concat(JSON.parse(atob(session.get('lang'))));
} }
ll.push(lan); ll.push(lan);
session.set('lang', btoa(JSON.stringify(ll))); session.onload(function(){
session.set('lang', btoa(JSON.stringify(ll)));
});
page.tran.setLang(lan); page.tran.setLang(lan);
page.lang.push(lan); page.lang.push(lan);
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button'); instance.hide({ transitionOut: 'fadeOut' }, toast, 'button');
@ -532,7 +566,9 @@ session.onload(function(){
ll = ll.concat(JSON.parse(atob(session.get('nolang')))); ll = ll.concat(JSON.parse(atob(session.get('nolang'))));
} }
ll.push(lan); ll.push(lan);
session.set('nolang', btoa(JSON.stringify(ll))); session.onload(function(){
session.set('nolang', btoa(JSON.stringify(ll)));
});
page.nolang = ll; page.nolang = ll;
if(lang.every((item)=>{ if(lang.every((item)=>{
return page.nolang.indexOf(item) != -1; return page.nolang.indexOf(item) != -1;
@ -572,7 +608,7 @@ session.onload(function(){
} }
} }
}); }, false, true);
/* audio player */ /* audio player */
@ -602,8 +638,12 @@ function player_ini(){
window.aplayers[0].play(); window.aplayers[0].play();
if(window.aplayers[0].audio.paused) { if(window.aplayers[0].audio.paused) {
//window.aplayers[0].notice('Click Here', 20000, 0.8); //window.aplayers[0].notice('Click Here', 20000, 0.8);
if(page.tran.getLang() == 'zh') tips.info({timeout: 13000, position:"bottomCenter",message: "<--戳左下角继续音乐哦(^_−)☆"}); let pos = 'topRight';
else tips.info({timeout: 13000, position:"bottomCenter",message: "Click bottom left conner to continue music (^_−)☆"}); if(page.availableScreenResolution[1] >= 570){
pos = 'bottomCenter';
}
if(page.tran.getLang() == 'zh') tips.info({timeout: 13000, position: pos,message: "<--戳左下角继续音乐哦(^_−)☆"});
else tips.info({timeout: 13000, position: pos,message: "Click bottom left conner to continue music (^_−)☆"});
}; };
} }
@ -631,7 +671,7 @@ function player_ini(){
}); });
setInterval(function(){ setInterval(function(){
try{ try{
if(!window.aplayers[0].audio.paused) session.set('aplayer/seek', window.aplayers[0].audio.currentTime); if(!window.aplayers[0].audio.paused) session.onload(function(){session.set('aplayer/seek', window.aplayers[0].audio.currentTime);});
}catch(e){ }catch(e){
} }
@ -750,7 +790,7 @@ page.showUshio = function(){
session.onload(function(){ session.onload(function(){
if(page.tran.getLang() == 'zh'){ if(page.tran.getLang() == 'zh'){
var title = 'Ushio菜单'; var title = `<a onClick="tips.info({message:'`+page.version+`<br>${page.fp}'})">Ushio</a>菜单`;
var guide = '导航'; var guide = '导航';
var cool = '主页'; var cool = '主页';
var github = '源码'; var github = '源码';
@ -776,7 +816,7 @@ page.showUshio = function(){
} }
}else{ }else{
var title = 'Ushio Menu'; var title = `<a onClick="tips.info({message:'`+page.version+`'})">Ushio</a> Menu`;
var guide = 'Guide'; var guide = 'Guide';
var cool = 'Cool'; var cool = 'Cool';
var github = 'Github'; var github = 'Github';
@ -844,7 +884,7 @@ page.showUshio = function(){
}, },
}); });
}, true); }, false, true);
} }
@ -936,7 +976,7 @@ setInterval(()=>{
console.log('Session unhealthy!!'); console.log('Session unhealthy!!');
session_ajax_ini(session_errCnt++ % 2); session_ajax_ini(session_errCnt++ % 2);
} }
if(!session_ignore && new Date().valueOf() - SessionLastCntTime > 30000){ if(!session_ignore && new Date().valueOf() - SessionLastCntTime > 15000){
tips.question({ tips.question({
timeout: 9999999, timeout: 9999999,
title: 'Warning', title: 'Warning',

File diff suppressed because one or more lines are too long

@ -39,7 +39,7 @@ if(typeof block_tips == "undefined"){
/* global default page config */ /* global default page config */
var page = { var page = {
version: 'v3.5.3', version: 'v3.6.10',
url: window.location.href, url: window.location.href,
title: 'Lovely Ushio', title: 'Lovely Ushio',
icon: 'https://cdn.yimian.xyz/img/head/head3r.ico', icon: 'https://cdn.yimian.xyz/img/head/head3r.ico',
@ -185,15 +185,15 @@ function getCache(){
/* session ini */ /* session ini */
session.onload = function(f, enCache, isFirst){ session.onload = function(f, enCache, fast_fetch, isFirst){
if((enCache&&page.cache&&getCache()) || session.status){ if((enCache&&page.cache&&getCache()) || (fast_fetch&&session.method === 'fast_fetch') || session.status){
if(isFirst == true){ if(isFirst == true){
session_wait(f); session_wait(f);
}else{ }else{
f(); f();
} }
}else{ }else{
setTimeout(session.onload, 30, f, enCache, true); setTimeout(session.onload, 30, f, enCache, fast_fetch, true);
} }
} }

File diff suppressed because one or more lines are too long

@ -1,6 +1,6 @@
{ {
"name": "ushio-js", "name": "ushio-js",
"version": "3.5.3", "version": "3.6.10",
"main": "ushio-head.js", "main": "ushio-head.js",
"repository": "https://github.com/iotcat/ushio-js", "repository": "https://github.com/iotcat/ushio-js",
"author": "iotcat <i@iotcat.me>", "author": "iotcat <i@iotcat.me>",

@ -92,11 +92,13 @@ if (getHiddenProp())
page.window = false; page.window = false;
log_update(); log_update();
var rand = Math.random() * 100; var rand = Math.random() * 100;
if(rand < 30) {if(page.tran.getLang() == 'zh')document.title = '啊咧(⊙0⊙)';else document.title = 'Aha (⊙0⊙)';} let title = '';
else if(rand < 55) {if(page.tran.getLang() == 'zh')document.title = '快来戳我呀( ´∀`)σ';else document.title = 'Click Me ( ´∀`)σ';} if(rand < 30) {if(page.tran.getLang() == 'zh')title = '啊咧(⊙0⊙)';else title = 'Aha (⊙0⊙)';}
else if(rand < 75) {if(page.tran.getLang() == 'zh')document.title = '躲起来(´・ω・`)';else document.title = 'Hiding(´・ω・`)';} else if(rand < 55) {if(page.tran.getLang() == 'zh')title = '快来戳我呀( ´∀`)σ';else title = 'Click Me ( ´∀`)σ';}
else {if(page.tran.getLang() == 'zh')document.title = '哎呦,页面崩掉了吗(>﹏<)';else document.title = 'Wow, page crashed(>﹏<)';} else if(rand < 75) {if(page.tran.getLang() == 'zh')title = '躲起来(´・ω・`)';else title = 'Hiding(´・ω・`)';}
setTimeout("document.title = page.title", 2400); else {if(page.tran.getLang() == 'zh')title = '哎呦,页面崩掉了吗(>﹏<)';else title = 'Wow, page crashed(>﹏<)';}
setTimeout(function(){document.title = title;}, 800);
setTimeout("document.title = page.title", 3800);
clearInterval(page.TimerObj); clearInterval(page.TimerObj);
page.TimerObj = null; page.TimerObj = null;
} }
@ -134,6 +136,8 @@ async function log_ini(){
who(); who();
}); });
updateHref(); updateHref();
fast_fetch();
} }
@ -163,6 +167,18 @@ if(page.cache && getCache()){
})*/ })*/
function fast_fetch(){
$.get('https://session.yimian.xyz/php/get.php?fp='+page.fp+'&flag='+page.flag+'&mask='+page.mask, function(res2){
res2 = JSON.parse(res2);
page.session = res2;
//session.status = true;
session.LastSyncTime = new Date().valueOf();
session.method = 'fast_fetch';
console.log('Ushio - Fast Fetched.. '+(new Date().valueOf()/1000 - page.openTime)+'s');
}).fail(function () {session.status = false;console.log('Ushio - Fast Fetch Failed!!');});
}
async function session_ini_pre () { async function session_ini_pre () {
//if(!page.fp || !page.ip) {setTimeout(session_ini_pre, 30);return;} //if(!page.fp || !page.ip) {setTimeout(session_ini_pre, 30);return;}
if(typeof WebSocket != 'undefined'){ if(typeof WebSocket != 'undefined'){
@ -206,7 +222,7 @@ function updateHref(){
/* cache session cohere */ /* cache session cohere */
/*
function checkCacheCohere(){ function checkCacheCohere(){
let chash = null; let chash = null;
@ -216,11 +232,12 @@ function checkCacheCohere(){
chash = null; chash = null;
} }
if(chash != page.session.hash){ if(chash && chash != page.session.hash){
setTimeout('window.location.reload();', 2000);
tips.question({ tips.question({
timeout: 9999999, timeout: 9999999,
title: 'Warning', title: 'Warning',
message: 'Session has changed. Please reload this page!', message: 'Session has changed. This page will reload!',
position: 'center', position: 'center',
color: 'red', color: 'red',
buttons: [ buttons: [
@ -233,7 +250,7 @@ function checkCacheCohere(){
}); });
} }
} }
*/
/* connect to session server */ /* connect to session server */
@ -404,7 +421,7 @@ session.onload(function(){
} }
} }
if(session.LastSyncTime < new Date().valueOf() - 12*1000){ if(session.LastSyncTime < new Date().valueOf() - 12*1000){
session.onload(player_ini_pre); session.onload(player_ini_pre, false, true);
}else{ }else{
player_ini_pre(); player_ini_pre();
} }
@ -416,10 +433,25 @@ session.onload(function(){
var isStop = false; var isStop = false;
if(typeof session.get('group') == "undefined"){ if(typeof session.get('group') == "undefined"){
isStop = true; isStop = true;
if(page.tran.getLang() == 'zh') alert('Ushio-session没有您的记录,将登出...'); tips.question({
else alert('Ushio-session do not have your record, Ushio will logout..'); timeout: 9999999,
window.location.href='https://auth.yimian.xyz/checkout.php?from='+ btoa(page.url); title: 'Warning',
throw new Error('ushio::Redirect to Ushio-Logout!'); message: (page.tran.getLang() == 'zh')?'Ushio-session没有您的记录!!':'Session Lost!! ',
position: 'center',
color: 'red',
buttons: [
['<button><b>RELOAD</b></button>', function (instance, toast) {
window.location.reload();
throw new Error('ushio::Page Reload!');
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button');
}, true],
['<button>LOGOUT</button>', function (instance, toast) {
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button');
window.location.href='https://auth.yimian.xyz/checkout.php?from='+ btoa(page.url);
throw new Error('ushio::Redirect to Ushio-Logout!');
}],
]
});
} }
if(page.auth.indexOf('any') != -1){ if(page.auth.indexOf('any') != -1){
if(session.get('group') == 'anonymous'){ if(session.get('group') == 'anonymous'){
@ -520,7 +552,9 @@ session.onload(function(){
ll = ll.concat(JSON.parse(atob(session.get('lang')))); ll = ll.concat(JSON.parse(atob(session.get('lang'))));
} }
ll.push(lan); ll.push(lan);
session.set('lang', btoa(JSON.stringify(ll))); session.onload(function(){
session.set('lang', btoa(JSON.stringify(ll)));
});
page.tran.setLang(lan); page.tran.setLang(lan);
page.lang.push(lan); page.lang.push(lan);
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button'); instance.hide({ transitionOut: 'fadeOut' }, toast, 'button');
@ -532,7 +566,9 @@ session.onload(function(){
ll = ll.concat(JSON.parse(atob(session.get('nolang')))); ll = ll.concat(JSON.parse(atob(session.get('nolang'))));
} }
ll.push(lan); ll.push(lan);
session.set('nolang', btoa(JSON.stringify(ll))); session.onload(function(){
session.set('nolang', btoa(JSON.stringify(ll)));
});
page.nolang = ll; page.nolang = ll;
if(lang.every((item)=>{ if(lang.every((item)=>{
return page.nolang.indexOf(item) != -1; return page.nolang.indexOf(item) != -1;
@ -572,7 +608,7 @@ session.onload(function(){
} }
} }
}); }, false, true);
/* audio player */ /* audio player */
@ -602,8 +638,12 @@ function player_ini(){
window.aplayers[0].play(); window.aplayers[0].play();
if(window.aplayers[0].audio.paused) { if(window.aplayers[0].audio.paused) {
//window.aplayers[0].notice('Click Here', 20000, 0.8); //window.aplayers[0].notice('Click Here', 20000, 0.8);
if(page.tran.getLang() == 'zh') tips.info({timeout: 13000, position:"bottomCenter",message: "<--戳左下角继续音乐哦(^_−)☆"}); let pos = 'topRight';
else tips.info({timeout: 13000, position:"bottomCenter",message: "Click bottom left conner to continue music (^_−)☆"}); if(page.availableScreenResolution[1] >= 570){
pos = 'bottomCenter';
}
if(page.tran.getLang() == 'zh') tips.info({timeout: 13000, position: pos,message: "<--戳左下角继续音乐哦(^_−)☆"});
else tips.info({timeout: 13000, position: pos,message: "Click bottom left conner to continue music (^_−)☆"});
}; };
} }
@ -631,7 +671,7 @@ function player_ini(){
}); });
setInterval(function(){ setInterval(function(){
try{ try{
if(!window.aplayers[0].audio.paused) session.set('aplayer/seek', window.aplayers[0].audio.currentTime); if(!window.aplayers[0].audio.paused) session.onload(function(){session.set('aplayer/seek', window.aplayers[0].audio.currentTime);});
}catch(e){ }catch(e){
} }
@ -750,7 +790,7 @@ page.showUshio = function(){
session.onload(function(){ session.onload(function(){
if(page.tran.getLang() == 'zh'){ if(page.tran.getLang() == 'zh'){
var title = 'Ushio菜单'; var title = `<a onClick="tips.info({message:'`+page.version+`<br>${page.fp}'})">Ushio</a>菜单`;
var guide = '导航'; var guide = '导航';
var cool = '主页'; var cool = '主页';
var github = '源码'; var github = '源码';
@ -776,7 +816,7 @@ page.showUshio = function(){
} }
}else{ }else{
var title = 'Ushio Menu'; var title = `<a onClick="tips.info({message:'`+page.version+`'})">Ushio</a> Menu`;
var guide = 'Guide'; var guide = 'Guide';
var cool = 'Cool'; var cool = 'Cool';
var github = 'Github'; var github = 'Github';
@ -844,7 +884,7 @@ page.showUshio = function(){
}, },
}); });
}, true); }, false, true);
} }
@ -936,7 +976,7 @@ setInterval(()=>{
console.log('Session unhealthy!!'); console.log('Session unhealthy!!');
session_ajax_ini(session_errCnt++ % 2); session_ajax_ini(session_errCnt++ % 2);
} }
if(!session_ignore && new Date().valueOf() - SessionLastCntTime > 30000){ if(!session_ignore && new Date().valueOf() - SessionLastCntTime > 15000){
tips.question({ tips.question({
timeout: 9999999, timeout: 9999999,
title: 'Warning', title: 'Warning',

@ -39,7 +39,7 @@ if(typeof block_tips == "undefined"){
/* global default page config */ /* global default page config */
var page = { var page = {
version: 'v3.5.3', version: 'v3.6.10',
url: window.location.href, url: window.location.href,
title: 'Lovely Ushio', title: 'Lovely Ushio',
icon: 'https://cdn.yimian.xyz/img/head/head3r.ico', icon: 'https://cdn.yimian.xyz/img/head/head3r.ico',
@ -185,15 +185,15 @@ function getCache(){
/* session ini */ /* session ini */
session.onload = function(f, enCache, isFirst){ session.onload = function(f, enCache, fast_fetch, isFirst){
if((enCache&&page.cache&&getCache()) || session.status){ if((enCache&&page.cache&&getCache()) || (fast_fetch&&session.method === 'fast_fetch') || session.status){
if(isFirst == true){ if(isFirst == true){
session_wait(f); session_wait(f);
}else{ }else{
f(); f();
} }
}else{ }else{
setTimeout(session.onload, 30, f, enCache, true); setTimeout(session.onload, 30, f, enCache, fast_fetch, true);
} }
} }

@ -2,9 +2,13 @@
<html> <html>
<head> <head>
<script type="text/javascript">var aplayer_playlist = 3066230257 </script> <script type="text/javascript">var aplayer_playlist = 3066230257 </script>
<script type="text/javascript">allow_no_cookie = true;//delete WebSocket;//page.auth = ['tel'];</script> <script type="text/javascript">allow_no_cookie = true;delete WebSocket;
</script>
<script type="text/javascript">lang = ['en', 'zh']</script> <script type="text/javascript">lang = ['en', 'zh']</script>
<script src="../src/ushio-head.js" charset="utf-8"></script> <script src="../src/ushio-head.js" charset="utf-8"></script>
<script type="text/javascript">
page.auth = ['tel'];
</script>
</head> </head>

Loading…
Cancel
Save