accelerate other view topic entrypoints

This commit is contained in:
Azareal 2020-04-11 07:48:30 +10:00
parent 5a9e0c72d3
commit 3d87ad8895
2 changed files with 46 additions and 44 deletions

View File

@ -6,8 +6,8 @@ var alertCount=0;
var moreTopicCount=0; var moreTopicCount=0;
var conn=false; var conn=false;
var selectedTopics=[]; var selectedTopics=[];
var attachItemCallback=function(){} var attachItemCallback=()=>{}
var quoteItemCallback=function(){} var quoteItemCallback=()=>{}
var baseTitle=document.title; var baseTitle=document.title;
var wsBackoff=0; var wsBackoff=0;
var noAlerts=false; var noAlerts=false;
@ -872,15 +872,13 @@ function mainInit(){
return name.split('?')[0]; return name.split('?')[0];
} }
$(".rowtopic a,a.rowtopic").click(function(ev) { function loadArb(base,href) {
let base = this.getAttribute("href");
let href = base + "?i=1";
fetch(href,{credentials:"same-origin"}) fetch(href,{credentials:"same-origin"})
.then(resp => { .then(resp => {
if(!resp.ok) throw(href+" failed to load"); if(!resp.ok) throw(href+" failed to load");
let xRes = resp.headers.get("x-res") let xr = resp.headers.get("x-res")
if(xRes!=null) { if(xr!=null) {
for(let res of xRes.split(",")) { for(let res of xr.split(",")) {
let pro; let pro;
if(stripQ(getExt(res))=="css") pro = asyncGetSheet("/s/"+res) if(stripQ(getExt(res))=="css") pro = asyncGetSheet("/s/"+res)
else pro = asyncGetScript("/s/"+res) else pro = asyncGetScript("/s/"+res)
@ -893,8 +891,8 @@ function mainInit(){
} }
} }
return resp.text(); return resp.text();
}).then(data => { }).then(dat => {
document.querySelector("#back").outerHTML = data; document.querySelector("#back").outerHTML = dat;
unbindTopic(); unbindTopic();
bindTopic(); bindTopic();
$(".elapsed").remove(); $(".elapsed").remove();
@ -905,7 +903,11 @@ function mainInit(){
console.log("e",e); console.log("e",e);
console.trace(); console.trace();
}); });
}
$(".rowtopic a,a.rowtopic,a.forum_poster").click(function(ev) {
let base = this.getAttribute("href");
loadArb(base,base+"?i=1");
ev.stopPropagation(); ev.stopPropagation();
ev.preventDefault(); ev.preventDefault();
}) })
@ -1012,9 +1014,9 @@ function bindTopic() {
$(bp).find('.hide_on_block_edit').removeClass("edit_opened"); $(bp).find('.hide_on_block_edit').removeClass("edit_opened");
$(bp).find('.show_on_block_edit').removeClass("edit_opened"); $(bp).find('.show_on_block_edit').removeClass("edit_opened");
block.classList.remove("in_edit"); block.classList.remove("in_edit");
let content = block.querySelector('textarea').value; let con = block.querySelector('textarea').value;
block.innerHTML = quickParse(content); block.innerHTML = quickParse(con);
if(srcNode!=null) srcNode.innerText = content; if(srcNode!=null) srcNode.innerText = con;
let formAction = this.closest('a').getAttribute("href"); let formAction = this.closest('a').getAttribute("href");
// TODO: Bounce the parsed post back and set innerHTML to it? // TODO: Bounce the parsed post back and set innerHTML to it?
@ -1022,7 +1024,7 @@ function bindTopic() {
url: formAction, url: formAction,
type:"POST", type:"POST",
dataType:"json", dataType:"json",
data: { js: 1, edit_item: content }, data: { js: 1, edit_item: con },
error: ajaxError, error: ajaxError,
success: (dat,status,xhr) => { success: (dat,status,xhr) => {
if("Content" in dat) block.innerHTML = dat["Content"]; if("Content" in dat) block.innerHTML = dat["Content"];
@ -1035,14 +1037,14 @@ function bindTopic() {
ev.preventDefault(); ev.preventDefault();
ev.stopPropagation(); ev.stopPropagation();
let src = this.closest(".post_item").getElementsByClassName("edit_source")[0]; let src = this.closest(".post_item").getElementsByClassName("edit_source")[0];
let content = document.getElementById("input_content") let con = document.getElementById("input_content")
console.log("content.value",content.value); console.log("con.value",con.value);
let item; let item;
if(content.value=="") item = "<blockquote>"+src.innerHTML+"</blockquote>" if(con.value=="") item = "<blockquote>"+src.innerHTML+"</blockquote>"
else item = "\r\n<blockquote>"+src.innerHTML+"</blockquote>"; else item = "\r\n<blockquote>"+src.innerHTML+"</blockquote>";
content.value = content.value + item; con.value = con.value+item;
console.log("content.value",content.value); console.log("con.value",con.value);
// For custom / third party text editors // For custom / third party text editors
quoteItemCallback(src.innerHTML,item); quoteItemCallback(src.innerHTML,item);
@ -1054,7 +1056,7 @@ function bindTopic() {
$("#poll_results_"+pollID).removeClass("auto_hide"); $("#poll_results_"+pollID).removeClass("auto_hide");
fetch("/poll/results/"+pollID, { fetch("/poll/results/"+pollID, {
credentials: 'same-origin' credentials: 'same-origin'
}).then(resp => resp.text()).catch(er => console.error("er",er)).then(rawData => { }).then(resp => resp.text()).catch(e => console.error("e",e)).then(rawData => {
// TODO: Make sure the received data is actually a list of integers // TODO: Make sure the received data is actually a list of integers
let data = JSON.parse(rawData); let data = JSON.parse(rawData);
let allZero = true; let allZero = true;

View File

@ -18,7 +18,7 @@
<span class="forum_right shift_right"> <span class="forum_right shift_right">
{{if .LastReplyer.MicroAvatar}}<img class="extra_little_row_avatar"src="{{.LastReplyer.MicroAvatar}}"height=64 width=64 alt="Avatar"title="{{.LastReplyer.Name}}'s Avatar"aria-hidden="true">{{end}} {{if .LastReplyer.MicroAvatar}}<img class="extra_little_row_avatar"src="{{.LastReplyer.MicroAvatar}}"height=64 width=64 alt="Avatar"title="{{.LastReplyer.Name}}'s Avatar"aria-hidden="true">{{end}}
<span> <span>
<a {{if .LastTopic.Link}}href="{{.LastTopic.Link}}"{{else}}class="forum_no_poster"{{end}}>{{if .LastTopic.Title}}{{.LastTopic.Title}}{{else}}{{lang "forums_none"}}{{end}}</a> <a {{if .LastTopic.Link}}class="forum_poster"href="{{.LastTopic.Link}}"{{else}}class="forum_no_poster"{{end}}>{{if .LastTopic.Title}}{{.LastTopic.Title}}{{else}}{{lang "forums_none"}}{{end}}</a>
{{if .LastTopicTime}}<br><span class="rowsmall"title="{{abstime .LastTopic.LastReplyAt}}">{{.LastTopicTime}}</span>{{end}} {{if .LastTopicTime}}<br><span class="rowsmall"title="{{abstime .LastTopic.LastReplyAt}}">{{.LastTopicTime}}</span>{{end}}
</span> </span>
</span><div style="clear:both;"></div> </span><div style="clear:both;"></div>