@@ -23,10 +23,7 @@ console.log(`
23
23
* https://www.fghrsh.net/post/123.html
24
24
*/
25
25
26
- function initWidget ( waifuPath = "/waifu-tips.json" , apiPath = "" ) {
27
- if ( screen . width <= 768 || ( localStorage . getItem ( "waifu-display" ) && new Date ( ) . getTime ( ) - localStorage . getItem ( "waifu-display" ) <= 86400000 ) ) {
28
- return ;
29
- }
26
+ function loadWidget ( waifuPath , apiPath ) {
30
27
localStorage . removeItem ( "waifu-display" ) ;
31
28
sessionStorage . removeItem ( "waifu-text" ) ;
32
29
$ ( "body" ) . append ( `<div id="waifu">
@@ -42,13 +39,14 @@ function initWidget(waifuPath = "/waifu-tips.json", apiPath = "") {
42
39
<span class="fa fa-lg fa-times"></span>
43
40
</div>
44
41
</div>` ) ;
42
+ $ ( "#waifu" ) . show ( ) . animate ( { bottom : 0 } , 3000 ) ;
45
43
46
44
function registerEventListener ( ) {
47
45
$ ( "#waifu-tool .fa-comment" ) . click ( showHitokoto ) ;
48
46
$ ( "#waifu-tool .fa-paper-plane" ) . click ( function ( ) {
49
47
var s = document . createElement ( "script" ) ;
50
48
document . body . appendChild ( s ) ;
51
- s . src = "https://galaxymimi.com/js /asteroids.js" ;
49
+ s . src = "https://cdn.jsdelivr.net/gh/GalaxyMimi/CDN /asteroids.js" ;
52
50
} ) ;
53
51
$ ( "#waifu-tool .fa-user-circle" ) . click ( loadOtherModel ) ;
54
52
$ ( "#waifu-tool .fa-street-view" ) . click ( loadRandModel ) ;
@@ -65,6 +63,7 @@ function initWidget(waifuPath = "/waifu-tips.json", apiPath = "") {
65
63
showMessage ( "愿你有一天能与重要的人重逢。" , 2000 , 11 ) ;
66
64
$ ( "#waifu" ) . animate ( { bottom : - 500 } , 3000 , function ( ) {
67
65
$ ( "#waifu" ) . hide ( ) ;
66
+ $ ( "#waifu-toggle" ) . show ( ) . animate ( { "margin-left" : - 50 } , 1000 ) ;
68
67
} ) ;
69
68
} ) ;
70
69
var re = / x / ;
@@ -238,3 +237,33 @@ function initWidget(waifuPath = "/waifu-tips.json", apiPath = "") {
238
237
} ) ;
239
238
}
240
239
}
240
+
241
+ function initWidget ( waifuPath = "/waifu-tips.json" , apiPath = "" ) {
242
+ if ( screen . width <= 768 ) return ;
243
+ $ ( "body" ) . append ( `<div id="waifu-toggle" style="margin-left: -100px;">
244
+ <span>看板娘</span>
245
+ </div>` ) ;
246
+ $ ( "#waifu-toggle" ) . hover ( function ( ) {
247
+ $ ( "#waifu-toggle" ) . animate ( { "margin-left" : - 30 } , 500 ) ;
248
+ } , function ( ) {
249
+ $ ( "#waifu-toggle" ) . animate ( { "margin-left" : - 50 } , 500 ) ;
250
+ } ) . click ( function ( ) {
251
+ $ ( "#waifu-toggle" ) . animate ( { "margin-left" : - 100 } , 1000 , function ( ) {
252
+ $ ( "#waifu-toggle" ) . hide ( ) ;
253
+ } ) ;
254
+ if ( $ ( "#waifu-toggle" ) . attr ( "first-time" ) ) {
255
+ loadWidget ( waifuPath , apiPath ) ;
256
+ $ ( "#waifu-toggle" ) . attr ( "first-time" , false ) ;
257
+ }
258
+ else {
259
+ localStorage . removeItem ( "waifu-display" ) ;
260
+ $ ( "#waifu" ) . show ( ) . animate ( { bottom : 0 } , 3000 ) ;
261
+ }
262
+ } ) ;
263
+ if ( localStorage . getItem ( "waifu-display" ) && new Date ( ) . getTime ( ) - localStorage . getItem ( "waifu-display" ) <= 86400000 ) {
264
+ $ ( "#waifu-toggle" ) . attr ( "first-time" , true ) . css ( { "margin-left" : - 50 } ) ;
265
+ }
266
+ else {
267
+ loadWidget ( waifuPath , apiPath ) ;
268
+ }
269
+ }
0 commit comments