mirror of https://gitgud.io/fatchan/jschan.git
ref #292
parent
781a9a212b
commit
3393d1014a
11 changed files with 95 additions and 27 deletions
@ -0,0 +1,5 @@ |
|||||||
|
function threadwatcher(locals) {var pug_html = "", pug_mixins = {}, pug_interp;pug_mixins["threadwatcher"] = pug_interp = function(){ |
||||||
|
var block = (this && this.block), attributes = (this && this.attributes) || {}; |
||||||
|
pug_html = pug_html + "\u003Cdiv class=\"flex-center\" id=\"threadwatcher\"\u003E\u003Cdiv class=\"row\"\u003E\u003Cdiv class=\"noselect\" id=\"threadwatcher-dragHandle\"\u003EThread Watcher\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E"; |
||||||
|
}; |
||||||
|
pug_mixins["threadwatcher"]();;return pug_html;} |
@ -0,0 +1,14 @@ |
|||||||
|
function pug_escape(e){var a=""+e,t=pug_match_html.exec(a);if(!t)return e;var r,c,n,s="";for(r=t.index,c=0;r<a.length;r++){switch(a.charCodeAt(r)){case 34:n=""";break;case 38:n="&";break;case 60:n="<";break;case 62:n=">";break;default:continue}c!==r&&(s+=a.substring(c,r)),c=r+1,s+=n}return c!==r?s+a.substring(c,r):s} |
||||||
|
var pug_match_html=/["&<>]/;function watchedthread(locals) {var pug_html = "", pug_mixins = {}, pug_interp;; |
||||||
|
var locals_for_with = (locals || {}); |
||||||
|
|
||||||
|
(function (watchedthread) { |
||||||
|
pug_mixins["watchedthread"] = pug_interp = function(thread){ |
||||||
|
var block = (this && this.block), attributes = (this && this.attributes) || {}; |
||||||
|
pug_html = pug_html + "\u003Cdiv\u003E\u003Cdiv class=\"watched-thread\"\u003E\u003Cp\u003E \u003Cb\u003E\u002F" + (pug_escape(null == (pug_interp = thread.board) ? "" : pug_interp)) + "\u002F" + (pug_escape(null == (pug_interp = thread.postId) ? "" : pug_interp)) + "\u003C\u002Fb\u003E - " + (pug_escape(null == (pug_interp = thread.subject) ? "" : pug_interp)) + "\u003C\u002Fp\u003E\u003Ca class=\"close\"\u003EX\u003C\u002Fa\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E"; |
||||||
|
}; |
||||||
|
pug_mixins["watchedthread"](watchedthread); |
||||||
|
}.call(this, "watchedthread" in locals_for_with ? |
||||||
|
locals_for_with.watchedthread : |
||||||
|
typeof watchedthread !== 'undefined' ? watchedthread : undefined)); |
||||||
|
;;return pug_html;} |
@ -1,27 +1,55 @@ |
|||||||
let watchList = new Set(JSON.parse(localStorage.getItem('watchlist'))); |
class ThreadWatcher { |
||||||
window.addEventListener('settingsReady', () => { |
|
||||||
|
|
||||||
const watchListInput = document.getElementById('watchlist-setting'); |
constructor() { |
||||||
watchListInput.value = [...watchList]; |
this.watchListSet = new Set(JSON.parse(localStorage.getItem('watchlist'))); |
||||||
const watchListClearButton = document.getElementById('watchlist-clear'); |
this.settingsInput = document.getElementById('watchlist-setting'); |
||||||
|
this.settingsInput.value = [...this.watchListSet]; |
||||||
|
this.clearButton = document.getElementById('watchlist-clear'); |
||||||
|
this.clearButton.addEventListener('click', this.clear, false); |
||||||
|
this.createListHtml(); |
||||||
|
this.refreshInterval = setInterval(this.refresh, 60 * 1000); |
||||||
|
this.refresh(); |
||||||
|
} |
||||||
|
|
||||||
|
refresh() { |
||||||
|
console.log('refreshing thread watcher'); |
||||||
|
//
|
||||||
|
} |
||||||
|
|
||||||
|
//pause() { }
|
||||||
|
|
||||||
|
//resume() { }
|
||||||
|
|
||||||
|
createListHtml() { |
||||||
|
const threadWatcherHtml = threadwatcher(); |
||||||
|
const footer = document.getElementById('bottom'); |
||||||
|
footer.insertAdjacentHTML('afterend', threadWatcherHtml); |
||||||
|
new Dragable('#threadwatcher-dragHandle', '#threadwatcher'); |
||||||
|
} |
||||||
|
|
||||||
|
add(board, thread) { |
||||||
/* |
/* |
||||||
* todo: use compiled pug to create and/or update watchlist |
const watchListItemHtml = uploaditem({ data }); |
||||||
* similar to live.js, have a separate pug function and the list container, |
.insertAdjacentHTML('beforeend', uploadItemHtml); |
||||||
* and for each entry and add the listeners when inserting one |
const fileElem = this.fileUploadList.lastChild; |
||||||
|
const lastClose = fileElem.querySelector('.close'); |
||||||
|
lastClose.addEventListener('click', () => { |
||||||
|
this.removeFile(fileElem, file.name, file.size); |
||||||
|
}); |
||||||
*/ |
*/ |
||||||
//new Dragable('#watchlist', '#postform'); //make watch list draggable and maintains position
|
} |
||||||
|
|
||||||
const removeWatchList = (board, thread) => { |
remove(board, thread) { |
||||||
watchList.delete(`${board}-${thread}`); |
//
|
||||||
} |
} |
||||||
const clearWatchList = () => { |
|
||||||
|
clear() { |
||||||
watchList = new Set(); |
watchList = new Set(); |
||||||
watchListInput.value = ''; |
watchListInput.value = ''; |
||||||
setLocalStorage('watchlist', '[]'); |
setLocalStorage('watchlist', '[]'); |
||||||
console.log('cleared watchlist'); |
console.log('cleared watchlist'); |
||||||
} |
} |
||||||
watchListClearButton.addEventListener('click', clearWatchList, false); |
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
}); |
window.addEventListener('settingsReady', () => new ThreadWatcher()); |
||||||
|
@ -0,0 +1,2 @@ |
|||||||
|
include ../mixins/threadwatcher.pug |
||||||
|
+threadwatcher() |
@ -0,0 +1,2 @@ |
|||||||
|
include ../mixins/watchedthread.pug |
||||||
|
+watchedthread(watchedthread) |
@ -0,0 +1,4 @@ |
|||||||
|
mixin threadwatcher() |
||||||
|
.flex-center#threadwatcher |
||||||
|
.row |
||||||
|
.noselect#threadwatcher-dragHandle Thread Watcher |
@ -0,0 +1,7 @@ |
|||||||
|
mixin watchedthread(thread) |
||||||
|
div |
||||||
|
.watched-thread |
||||||
|
p |
||||||
|
b /#{thread.board}/#{thread.postId} |
||||||
|
| - #{thread.subject} |
||||||
|
a.close X |
Loading…
Reference in new issue