-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbs.user.js
779 lines (668 loc) · 21.4 KB
/
bs.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
// ==UserScript==
// @name OPR_brainStorming
// @namespace asldufhiu32hr9283hf83123
// @include https://wayfarer.nianticlabs.com/*
// @require https://cdn.jsdelivr.net/gh/jquery/jquery@3/dist/jquery.min.js
// @updateURL https://github.com/6582/1/raw/main/bs.meta.js
// @downloadURL https://github.com/6582/1/raw/main/bs.user.js
// @version 6.2
// @run-at document-start
// @grant none
// ==/UserScript==
/*
致 愛好審po的各位:
使用本script審po時,會把打分和comments自動傳送到server公開,其他使用者審到同樣的po時,會看得到別人打過的分數和comment。
目的是互相提醒、交流和學習,同時獨立思考,讓po審核更加盡善盡美。
你可以把需要注意的地方寫在 comment 中。
v6.2 17/5/2024
- 加入(以往存在的)評論文字輸入
v6 25/4/2024
6.1 - 上傳意見等待最多2秒後在背景繼續處理
6.0 - 需要update post URL,舊版本不能再用。
v5 23/8/2021
- 因為網站又更新修正
v4.0 x/01/2021
- 因為網站更新修正
- 等待記錄完成才繼續,以防止記錄不成功
- Edit 中的 report abuse 可被記錄
- 打 1 或 dup 也可同時記錄位置修訂
- passcode 改了在 UI 上設定,儲存在 localStorage (為方便bookmarklet)
dev:
- 改用 jsdelivr 來載入 jQuery; 除了 @require, 需要時自動動態載入 (為方便bookmarklet)
- 重寫了結構,方便開發 mod 而不用對本 script 作改動
- 改了 html 的各種 class
v3.3.1 11/10/2019
- 適用新的網址
v3.3 18/4/2019
- 加入輔助圖片、文字的記錄
v3.2 27/9/2018
- 加入1星(低質/spam)的理由記錄
v3.1 緊急修正 25/8/2018
- 因對方系統改變,需要更新,否則"1星"的review不能成功紀錄到Brainstorming系統
v3.0 26/4/2018
- 改從Firebase讀取資料,能顯示更久遠的意見(不受sheet的容量限制),更快速
- 與Cojad大的script相容
v2.0 20/12/2017
- 必須輸入帳號passcode
- 改為顯示6組星星的平均值
- 取消 duplicate 欄位,改為在 comment 加插文字
- 介面修改
- 舊版本不能再用
v1.1 6/12/2017
- 自動調整高度,加入scrollbar
- 更改欄位次序 (star author reason duplicate)
v1.0 26/10/2017
- 防止滑鼠連點時重複送出資料
- 介面樣式修改
- 載入完成前顯示 "⌛ Loading"
- 顯示 hashtag 以方便在 telegram 搜索
- 如修訂位置,會在你的 Comment 加插大約的方向和公尺(如: ⇖19m)
- 如果顯示意見有 comment,在分數旁顯示小圖示 "✍"
- 如果顯示意見有 修訂位置,在分數旁顯示小圖示 "📍"
v0.9 基本功能 8/2017
v0.6 31/7/2017
v0.5 30/7/2017
*/
window.bs = {
_VERSION: "6.2",
iOS: false,
isQueryFromFirebase: true,
isQueryFromSheet: false,
imgUrlToHashId( url ){ return url.replace( /[^a-zA-Z0-9]/g, '' ).slice(-10).toLowerCase(); },
// https://stackoverflow.com/questions/1787322/htmlspecialchars-equivalent-in-javascript/4835406#4835406
escapeHtml(text){
if( text ){
let map = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": ''',
};
return text.toString().replace(/[&<>"']/g, function(m){ return map[m]; } );
}else{
return "";
}
},
parseJsonToPortal( json ){
if( json==null ){
return null;
}
let p = {
reviews: [],
};
for (let key in json) {
let o = json[key];
if( o.author ){
try{
let t = {
timestamp: o.Timestamp,
author: o.author,
stars: o.stars,
reasons: o.reasons,
};
t.htmlEsc_author = this.escapeHtml( t.author );
t.htmlEsc_stars = this.escapeHtml( t.stars );
t.htmlEsc_reasons = this.escapeHtml( t.reasons );
p.reviews.push( t );
}catch(error){}
}
}
return p;
},
showReviewsFirebase(){
let p = this.parseJsonToPortal( this.firebaseJsonObj );
if( p==null ){
this.Pane.$otherReviews_firebase.html( "(未有資料 / no data)<br>" );
this.Pane.$div_notification_icons.empty();
return;
}
let notification_icons = "";
let html_review = /*html*/`<table>
<tr class='head'>
<th class='stars'>stars</th>
<th class='author'>reviewer</th>
<th class='reasons'>comments</th>
</tr>`;
for( let i=0; i<p.reviews.length; i++ ){
let r = p.reviews[i];
let hasNewlocation = /\[📍.+m\]/.test( r.reasons );
let hasComment = !( /^(\[(📍.+m|dup:.+)\]\s*)+$|^\s*$/.test( r.reasons ) );
html_review += /*html*/`
<tr
class='${hasComment?"hasComment":""} ${hasNewlocation?"hasNewlocation":""}'
title='${(i+1)}) ${new Date(r.timestamp).toLocaleString()}'>
<td class='stars'>${r.htmlEsc_stars}</td>
<td class='author'>${r.htmlEsc_author}</td>
<td class='reasons'>${r.htmlEsc_reasons} <span class='date'>(${new Date(r.timestamp).toLocaleDateString()})</span></td>
</tr>`;
// notification
notification_icons += /*html*/`
<p class='item ${hasComment?"hasComment":""} ${hasNewlocation?"hasNewlocation":""}'>
${r.stars}
${hasComment ? "✍" : ""}
${hasNewlocation ? "📍" : ""}
</p>`;
}
html_review += "</table>";
this.Pane.$otherReviews_firebase.html( html_review );
this.Pane.$div_notification_icons.html(notification_icons);
},
showReviewsSheet(){
let json = this.sheetJsonObj;
if( json.table.rows.length == 0 ){
this.Pane.$otherReviews_sheet
.html( "(未有資料 / no data)<br>" );
if( !this.isQueryFromFirebase ) this.Pane.$div_notification_icons.empty();
return;
}
var notification_icons = "";
var col_stars = 0;
var col_author = 1;
var col_comment = 2;
var html = "<table>";
html += "<tr>";
for( var i=0; i<3; i++ ){
var label = this.escapeHtml(json.table.cols[i].label);
html += `<th class="${label}">${label}</th>`;
}
html += "</tr>";
for( var i=0; i<json.table.rows.length; i++ ){
var userId = json.table.rows[i].c[col_author].v;
var hasComment = false;
var hasNewlocation = false;
var star = 0;
for( var k=0; k<3; k++ ){
var r = json.table.rows[i].c[k];
if( k==col_stars ){
star = r ? (r.v==0? "." : (r.v).toFixed(1)) : "D";
html += `<td class='stars'>${star}</td>`;
}else{
var value1 = (r==null ? "" : this.escapeHtml(r.v) );
html += `<td class="${k==col_author?"author":"reasons"}">${value1}</td>`;
if( k==col_comment ){
if( ! /^\s*$/.test(value1) ){
hasNewlocation = /\[📍.+m\]/.test( r.reasons );
hasComment = !( /^(\[(📍.+m|dup:.+)\]\s*)+$|^\s*$/.test( r.reasons ) );
}
}
}
}
notification_icons += /*html*/`
<p class='item ${hasComment?"hasComment":""} ${hasNewlocation?"hasNewlocation":""}'>
${star}
${hasComment ? "✍" : ""}
${hasNewlocation ? "📍" : ""}
</p>`;
html += "</tr>";
}
html += "</table>";
this.Pane.$otherReviews_sheet.html( html );
if( !this.isQueryFromFirebase ) this.Pane.$div_notification_icons.html(notification_icons);
},
queryReviewsFromFirebase(){
let hashID = this.hashID;
// hashID = "9os32nej78";
$.getJSON(
`https://oprbrainstorming.firebaseio.com/c/reviews/${hashID}.json`,
data=>{
this.firebaseJsonObj = data;
this.showReviewsFirebase();
}
);
},
queryReviewsFromSheet(){
window.google = window.google || {};
window.google.visualization = window.google.visualization || {};
window.google.visualization.Query = window.google.visualization.Query || {};
window.google.visualization.Query = { // handler for google Sheet's Query
setResponse: json=>{
this.sheetJsonObj = json;
this.showReviewsSheet.apply(this);
}
};
let QUERY = "https://docs.google.com/spreadsheets/d/1qNgNT73vrgyD8fg8VZjBXl0wtNnv0YOYeakMaODiLSU/gviz/tq?tq="
+ encodeURIComponent( `select I,H,J where B='${this.pageData.imageUrl}'` );
//+ encodeURIComponent( "select I,H,J where B='"+"http://lh3.googleusercontent.com/lnKhxhS35rhum-wT2Q9FBnj1XUe73SC3RM4yqNEWUkfvUU_B6W0_ZZG1rZJshIOMYSLNB3VDrnjJxUUpIVg"+"'" );
// + encodeURIComponent( "select I,H,J order by A desc LIMIT 19" );
$.getScript( QUERY );
},
};
bs.postPortal = function( d ){
if( !this.passcode ) return;
let reviewData = JSON.parse( d );
// console.log( reviewData );
// TODO: 就算 1星 也可傳送移位點
// try{
// let locationMarker = this.ReviewResponsesService.getNewLocationMarker();
// if( null != locationMarker ){
// let p = locationMarker.getPosition();
// reviewData.newLocation = `${p.lat()}, ${p.lng()}`;
// }
// }catch(error){}
// dup
if( reviewData.duplicate ){
reviewData.duplicateTitle =
this.pageData.nearbyPortals
.find( p=>p.guid==reviewData.duplicateOf )
.title;
}
// removes unnecessary data.
delete this.pageData.nearbyPortals;
delete this.pageData.prediction;
let postData = {
pageData: this.pageData,
reviewData,
passcode: this.passcode,
version: +this._VERSION,
iOS: this.iOS,
comment: document.querySelector("#bsComment_5k8qr4 textarea")?.value ?? "",
};
this.PostingLoader.show();
// console.log( postData );
return $.post(
"https://script.google.com/macros/s/AKfycbzNYqJOCJGvTo8rvAZM3YDM93POz-bmUN4i9BWA9yIjvtd4K_w5UeRQdZ78QKmtgKm5og/exec",
JSON.stringify( postData )
).done( result=>{
try{
let msg = JSON.parse(result).msg;
if( msg != "ok" ) alert( msg );
}catch(error){};
} )
.always( ()=>{ // finally is not supported by some browsers.
this.PostingLoader.hide();
} );
};
/**
* 為了方便 extend 或建立 mod
*/
bs.loadOverrides = function(){
Object.assign( this, window.bsOverrides ); // assign all var and functions from bsOverrides to bs
// run every values in beforeInit as function
for( let func in this.beforeInit || {} ){
try {
this.beforeInit[func].apply( this );
} catch (error) {
console.log( error );
}
}
};
bs.isIOS = function() {
return [
'iPad Simulator',
'iPhone Simulator',
'iPod Simulator',
'iPad',
'iPhone',
'iPod',
'MacIntel', // for iPads running iOS 13 or later
].includes(navigator.platform)
// iPad on iOS 13 detection
|| (navigator.userAgent.includes("Mac") && "ontouchend" in document)
}
bs.fix_iOS_hover = function(){
document.querySelector('html').setAttribute('ontouchmove','');
document.body.setAttribute('tabIndex',"0");
};
bs.initPasscode = function(){
// 優先次序: 1.bsOverrides 2.localStorage
this.passcode = this.passcode || localStorage.BSpasscode || "";
try {
// 如果user連前面的 `var passcode = "` 也輸入了,取出 str 部份
this.passcode = this.passcode.match( /"(.*)"/ )[1];
} catch (error) {}
if( !this.passcode ){
this.Pane.$el.find(".otherReviews").html( "<br><br>必須輸入 passcode 才能運作。<br>請申請一個 passcode 並在上方設定<br>設定後須要重新載入頁面。" );
this.Pane.$div_notification_icons.html(
`<p class="item">⚠️</p>`
);
}
};
bs.editPasscode = function(){
let str = prompt(
`[passcode]:
可輸入
var passcode="name_xxx";
或
name_xxx`,
localStorage.BSpasscode || ""
);
if( str!==null ){
localStorage.BSpasscode = str.trim();
this.initPasscode();
if( confirm("passcode修改後,需要重新載入,選'OK'重新載入。") ){
location.reload();
}
}
};
bs.injectBsFunctions = function(){
let bs = this;
let func = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function( method, url ){
if( url=="/api/v1/vault/review" ){
if( method=="GET" ){
this.addEventListener( 'load', function(){
bs.loadNewPortal(
JSON.parse(this.responseText).result
);
} );
} else { // POST
let send2 = this.send;
this.send = function (d) {
const postPortalPromise = bs.postPortal(d).catch(error => {
console.log(error);
alert(`🤔bs 上傳失敗 - ${error.message}\n${error.stack}`);
});
const timeoutPromise = new Promise(resolve =>
setTimeout(resolve, 2000)
);
// Wait for either the postPortalPromise or the timeoutPromise to resolve
Promise.race([
postPortalPromise,
timeoutPromise
]).then(() => {
return send2.apply(this, arguments);
});
};
}
}
return func.apply(this, arguments);
}
};
/**
* 為了 script 獨立執行時,沒有 @require 到 jQuery
*/
bs.jQueryReady = function(){
return new Promise( (resolve,reject)=>{
if(window.jQuery){
resolve();
}else{
var script = document.createElement("script");
script.src = "https://cdn.jsdelivr.net/gh/jquery/jquery@3/dist/jquery.min.js";
script.onload = resolve;
script.onerror = reject;
document.head.appendChild(script);
}
});
};
bs.documentReady = function(){
return new Promise( resolve=>{
let timer = setInterval( ()=>{
if( document.readyState=='complete' ){
clearInterval( timer );
resolve();
}
}, 99 );
});
};
bs.init = function(){
this.injectBsFunctions();
return this.documentReady()
.then( this.jQueryReady.bind(this) )
.then( this.loadOverrides.bind(this) )
.then( ()=>{
this.iOS = this.isIOS();
if( this.iOS ){
this.fix_iOS_hover();
}
this.initTimerForAddingBSCommentField();
this.Pane.init( this );
this.PostingLoader.init();
this.initPasscode();
if( this.passcode && !this.pageData ){
this.Pane.$el.find(".otherReviews").append( /*html*/
`<br><br><hr><br>未取得本頁的審po內容,請在審po官方menu轉到其他頁再轉回來「★REVIEW」 (不是 reload page)`
);
this.Pane.$div_notification_icons.html(
`<p class="item">⚠️</p>`
);
}
} );
};
bs.loadNewPortal = function( pageData ){
// console.log(pageData);
if( this.passcode ){
this.pageData = pageData;
this.hashID = this.imgUrlToHashId( this.pageData.imageUrl );
this.Pane.showNewPortal();
if( this.isQueryFromSheet ){
this.queryReviewsFromSheet();
}
if( this.isQueryFromFirebase ){
this.queryReviewsFromFirebase();
}
}
};
bs.initTimerForAddingBSCommentField = function(){
setInterval(()=>{
if( ! location.href.includes("new/review") ) return;
if( this.pageData?.type != "NEW" ) return;
if( document.getElementById("bsComment_5k8qr4") ) return;
document.querySelector("#categorization-card")?.
insertAdjacentHTML("afterbegin", /*html*/ `
<div id="bsComment_5k8qr4">
<textarea placeholder="在此輸入提交到 brainstorming 的評論... (只提交到bs)"></textarea>
</div>
<style>
#bsComment_5k8qr4{
width: 100%;
display: flex;
flex-direction: column;
padding: 7px 10px;
border: 1px solid #71ffff;
color: #71ffff;
background-color: #014949;
}
#bsComment_5k8qr4 textarea{
height: 4.3em;
border: 1px solid #716666;
color: #003838;
background-color: #e1f7f7;
}
</style>
`);
}, 777);
}
bs.Pane = {
$el:null,
$div_notification_icons:null,
$otherReviews_firebase:null,
$otherReviews_sheet:null,
init( bs ){
this.bs = bs;
this.$el = $(/*html*/`
<div id="brainStorming">
<div class="briefing">
<span class="versionNo">v${bs._VERSION}</span>
※使用本script時,評分意見會傳送到server公開
※其他人的意見僅作參考,請為了良好的遊戲環境努力審核,獨立思考,集思廣益
</div>
<div class="buttons">
<input class="T_hashtag" size="15" onClick="this.select();" readonly />
<a class="link" onclick="bs.editPasscode()">passcode</a>
<a class="link link_watermeter" target="_blank" href="https://brainstorming.azurewebsites.net/watermeter.html"><span class="short">查</span><span class="long">水表</span></a>
<a class="link" target="_blank" href="https://brainstorming.azurewebsites.net/bs.html"><span class="short">牆</span><span class="long">wall</span></a>
<a class="link" target="_blank" href="https://docs.google.com/spreadsheets/d/e/2PACX-1vSrXYajaKHfO0aDANr-aFu61DEzB0wy5X87uQUBKFza__1J7ttnqJh_84Gvp9-tETIzjbiK_yPx7Llk/pubhtml?gid=621294114&single=true"><span class="short">統</span><span class="long">使用統計</span></a>
</div>
</div>
`)
this.$el.append(
bs.isQueryFromFirebase && (
this.$otherReviews_firebase =$(/*html*/
`<div class="otherReviews otherReviews_firebase"></div>`)
),
bs.isQueryFromSheet && (
this.$otherReviews_sheet = $(/*html*/
`<div class="otherReviews otherReviews_sheet"></div>`)
),
this.$div_notification_icons = $(/*html*/
`<div class="div_notification_icons"></div>`),
);
$(document.body).append(this.css, this.$el );
},
showNewPortal(){
this.$el
.find(".T_hashtag").val(`#${bs.hashID}`).end()
.find(".link_watermeter").attr(
"href", `https://brainstorming.azurewebsites.net/watermeter.html#${bs.hashID}`
).end()
.find(".otherReviews").html(" ⌛ Loading...");
this.$div_notification_icons.html(`<span class="loading">⌛</span>`);
},
css:/*html*/`
<style>
#brainStorming{
--W_PANE: 500px;
--W_SIDE: 30px;
top:60px; left: calc(100% - var(--W_SIDE));
max-width:95%;
width: var(--W_PANE);
min-height: 200px;
max-height: calc(100vh - 80px);
position: fixed;
z-index: 99999;
border: 1px solid #71ffff;
color: #71ffff;
background-color: #013030;
overflow-y: auto;
padding-bottom: 15px;
padding-left: calc(var(--W_SIDE) + 3px);
padding-right: 5px;
}
#brainStorming:hover {right:0px !important; left: unset !important; padding-left:5px !important; }
#brainStorming:hover > .div_notification_icons { display: none;}
#brainStorming .versionNo{
margin-right: 5px;
color: #778833;
font-weight: bold;
}
#brainStorming .briefing{
margin-bottom: 9px;
}
#brainStorming .T_hashtag{
background-color:#194848; color:#71AAAA; border: 1px solid #71AAAA; text-align:center; height: 27px;
}
#brainStorming .link { color: #77FFFF; border: 1px solid #105050; display: inline-block; padding: 0px 4px; margin-left: 3px; height: 26px; }
#brainStorming .link:hover { color: #DD2CFF; text-decoration: underline; }
#brainStorming .link .long { display:none; }
@media (min-width: 700px) {
#brainStorming .link .long { display:inline; }
#brainStorming .link .short { display:none; }
}
.otherReviews{
margin-top:10px; margin-bottom:10px;
}
.otherReviews>table{
width:100%;
table-layout: fixed;
}
.otherReviews>table, .otherReviews>table th, .otherReviews>table td{
border:1px solid #71ffff;
background-color:black;
}
.otherReviews>table th {
font-weight: bold;
text-align:center;
padding: 2px;
}
.otherReviews>table th.stars {
width: 50px;
}
.otherReviews>table th.author {
width: 130px;
}
.otherReviews>table td.reasons .date {
color: #B0B0B0;
font-size: 65%;
}
.otherReviews>table td{
color:white;
vertical-align: middle;
padding: 2px;
overflow-wrap:break-word;
}
.otherReviews>table td.stars {
text-align:center;
font-size:20px;
}
.div_notification_icons{
position: absolute;
left:0; top:0;
height: 100%;
width: var(--W_SIDE);
overflow-wrap: break-word;
text-align: center;
font-size: 21px;
background-color: #1a5757;
}
.div_notification_icons>.loading{
font-size:27px;
}
.div_notification_icons>.item {
padding-bottom:4px; margin-bottom:6px; line-height:0.92em; background-color:#012020;
}
</style>
`,
};
bs.PostingLoader = {
$el:null,
showCount:0, // in case multiple postings happen simultaneously
init(){
this.$el = $(this.html).hide();
$(document.body).append( this.css, this.$el );
},
show(){
this.showCount++;
this.$el.toggle(this.showCount>0);
},
hide(){
this.showCount--;
this.$el.toggle(this.showCount>0);
},
html:/*html*/`
<div class="bsPostingLoader">
<img class="loader rotating" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAOUlEQVQYlWNgQAX/0TBW8P//QXYUjE0xhiJsijEkkGlkxThNo1BhuBKyIB53hiuhYrw+J0IRwQAHAArxntwkepFwAAAAAElFTkSuQmCC">
<div class="text">posting to Brainstorming...</div>
</div>
`,
css:/*html*/`
<style>
.bsPostingLoader {
position: absolute;
z-index: 999;
top: 0;
height: 50px;
left: 0;
right: 0;
display: flex;
justify-content: center;
align-items: center;
flex-direction: row;
opacity: 0.9;
}
.bsPostingLoader .text{
margin-left: 1em;
}
.bsPostingLoader .loader{
width: 50px;
image-rendering:-moz-crisp-edges; /* Firefox */
image-rendering:-o-crisp-edges; /* Opera */
image-rendering:crisp-edges; /* CSS4 Proposed */
image-rendering:pixelated; /* CSS4 Proposed */
}
.bsPostingLoader .rotating{
animation: rotation 3.3s infinite linear;
}
@keyframes rotation {
from {
transform: rotate(0deg);
}
to {
transform: rotate(359deg);
}
}
</style>
`,
};
bs.init()
.catch( console.error );