hover styling for topic list moderation

add megaindex user agent
reduce boilerplate and save bytes
hide elapsed on nox mobile
This commit is contained in:
Azareal 2020-04-09 18:35:43 +10:00
parent 709b0d5541
commit f6c5109fc7
7 changed files with 81 additions and 77 deletions

View File

@ -228,6 +228,7 @@
"dotbot":"DotBot",
"ahrefs":"Ahrefs",
"proximic":"Comscore",
"megaindex":"MegaIndex",
"majestic":"MJ12bot",
"netcraft":"Netcraft",
"blexbot":"BLEXBot",

View File

@ -20,28 +20,28 @@ var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "g
let totalSize = 0;
for(let i=0; i<files.length; i++) {
console.log("files[" + i + "]",files[i]);
console.log("file "+i,files[i]);
totalSize += files[i]["size"];
}
if(totalSize > me.Site.MaxRequestSize) throw("You can't upload this much at once, max: "+me.Site.MaxRequestSize);
for(let i=0; i<files.length; i++) {
let filename = files[i]["name"];
let f = (e) => {
step1(e,filename)
let fname = files[i]["name"];
let f = e => {
step1(e,fname)
let reader = new FileReader();
reader.onload = (e2) => {
reader.onload = e2 => {
crypto.subtle.digest('SHA-256',e2.target.result)
.then((hash) => {
.then(hash => {
const hashArray = Array.from(new Uint8Array(hash))
return hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join('')
}).then(hash => step2(e,hash,filename));
}).then(hash => step2(e,hash,fname));
}
reader.readAsArrayBuffer(files[i]);
};
let ext = getExt(filename);
let ext = getExt(fname);
// TODO: Push ImageFileExts to the client from the server in some sort of gen.js?
let isImage = imageExts.includes(ext);
if(isImage) {
@ -58,7 +58,7 @@ var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "g
let fileDock = this.closest(".attach_edit_bay");
try {
uploadFileHandler(this.files, 5, () => {},
(e,hash,filename) => {
(e,hash,fname) => {
console.log("hash",hash);
let formData = new FormData();
formData.append("s",me.User.S);
@ -70,7 +70,7 @@ var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "g
let data = JSON.parse(req.responseText);
//console.log("rdata",data);
let fileItem = document.createElement("div");
let ext = getExt(filename);
let ext = getExt(fname);
// TODO: Push ImageFileExts to the client from the server in some sort of gen.js?
let isImage = imageExts.includes(ext);
let c = "";
@ -100,13 +100,13 @@ var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "g
// Quick Topic / Quick Reply
function uploadAttachHandler() {
try {
uploadFileHandler(this.files, 5, (e,filename) => {
uploadFileHandler(this.files, 5, (e,fname) => {
// TODO: Use client templates here
let fileDock = document.getElementById("upload_file_dock");
let fileItem = document.createElement("label");
console.log("fileItem",fileItem);
let ext = getExt(filename);
let ext = getExt(fname);
// TODO: Push ImageFileExts to the client from the server in some sort of gen.js?
let isImage = imageExts.includes(ext);
fileItem.innerText = "."+ext;
@ -115,17 +115,17 @@ var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "g
if(isImage) fileItem.style.backgroundImage = "url("+e.target.result+")";
fileDock.appendChild(fileItem);
},(e,hash,filename) => {
},(e,hash,fname) => {
console.log("hash",hash);
let ext = getExt(filename)
let content = document.getElementById("input_content")
console.log("content.value", content.value);
let ext = getExt(fname)
let con = document.getElementById("input_content")
console.log("con.value",con.value);
let attachItem;
if(content.value=="") attachItem = "//" + window.location.host + "/attachs/" + hash + "." + ext;
if(con.value=="") attachItem = "//"+window.location.host+"/attachs/"+hash+"."+ext;
else attachItem = "\r\n//"+window.location.host+"/attachs/"+hash+"."+ext;
content.value = content.value + attachItem;
console.log("content.value", content.value);
con.value = con.value + attachItem;
console.log("con.value",con.value);
// For custom / third party text editors
attachItemCallback(attachItem);
@ -219,6 +219,7 @@ var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "g
ev.preventDefault();
$(".pre_opt").removeClass("auto_hide");
$(".moderate_link").addClass("moderate_open");
$("#topicsItemList,#forumItemList").addClass("topics_moderate");
$(".topic_row").each(function(){
$(this).click(function(){
selectedTopics.push(parseInt($(this).attr("data-tid"),10));
@ -233,10 +234,9 @@ var imageExts = ["png", "jpg", "jpe","jpeg","jif","jfi","jfif", "svg", "bmp", "g
});
});
let bulkActionSender = function(action,selectedTopics,fragBit) {
let url = "/topic/"+action+"/submit/"+fragBit+"?s="+me.User.S;
let bulkActionSender = (action,selectedTopics,fragBit) => {
$.ajax({
url: url,
url: "/topic/"+action+"/submit/"+fragBit+"?s="+me.User.S,
type: "POST",
data: JSON.stringify(selectedTopics),
contentType: "application/json",

View File

@ -11,39 +11,38 @@ import (
)
// TODO: Retire this in favour of an alias for /topics/?
func ViewForum(w http.ResponseWriter, r *http.Request, user *c.User, header *c.Header, sfid string) c.RouteError {
func ViewForum(w http.ResponseWriter, r *http.Request, u *c.User, h *c.Header, sfid string) c.RouteError {
page, _ := strconv.Atoi(r.FormValue("page"))
_, fid, err := ParseSEOURL(sfid)
if err != nil {
return c.SimpleError(p.GetErrorPhrase("url_id_must_be_integer"), w, r, header)
return c.SimpleError(p.GetErrorPhrase("url_id_must_be_integer"), w, r, h)
}
ferr := c.ForumUserCheck(header, w, r, user, fid)
ferr := c.ForumUserCheck(h, w, r, u, fid)
if ferr != nil {
return ferr
}
if !user.Perms.ViewTopic {
return c.NoPermissions(w, r, user)
if !u.Perms.ViewTopic {
return c.NoPermissions(w, r, u)
}
header.Path = "/forums/"
h.Path = "/forums/"
// TODO: Fix this double-check
forum, err := c.Forums.Get(fid)
if err == sql.ErrNoRows {
return c.NotFound(w, r, header)
return c.NotFound(w, r, h)
} else if err != nil {
return c.InternalError(err, w, r)
}
header.Title = forum.Name
header.OGDesc = forum.Desc
h.Title = forum.Name
h.OGDesc = forum.Desc
topicList, pagi, err := c.TopicList.GetListByForum(forum, page, 0)
if err != nil {
return c.InternalError(err, w, r)
}
header.Zone = "view_forum"
header.ZoneID = forum.ID
h.Zone = "view_forum"
h.ZoneID = forum.ID
// TODO: Reduce the amount of boilerplate here
if r.FormValue("js") == "1" {
@ -56,15 +55,15 @@ func ViewForum(w http.ResponseWriter, r *http.Request, user *c.User, header *c.H
}
//pageList := c.Paginate(page, lastPage, 5)
pi := c.ForumPage{header, topicList, forum, pagi}
pi := c.ForumPage{h, topicList, forum, pagi}
tmpl := forum.Tmpl
if tmpl == "" {
ferr = renderTemplate("forum", w, r, header, pi)
ferr = renderTemplate("forum", w, r, h, pi)
} else {
tmpl = "forum_" + tmpl
err = renderTemplate3(tmpl, tmpl, w, r, header, pi)
err = renderTemplate3(tmpl, tmpl, w, r, h, pi)
if err != nil {
ferr = renderTemplate("forum", w, r, header, pi)
ferr = renderTemplate("forum", w, r, h, pi)
}
}
counters.ForumViewCounter.Bump(forum.ID)

View File

@ -13,7 +13,6 @@
--light-text-color: hsl(0,0%,55%);
--lighter-text-color: hsl(0,0%,65%);
/*background-color: hsl(0,0%,97%);*/
--tinted-background-color: hsl(0,0%,98%);
}
@ -908,6 +907,9 @@ textarea {
.topic_sticky .topic_left, .topic_sticky .topic_right {
border-bottom: 2px solid hsl(51, 60%, 70%);
}
.topics_moderate .topic_row:hover .topic_left, .topics_moderate .topic_row:hover .topic_right {
background-color: hsl(81, 60%, 97%);
}
.topic_selected .topic_left, .topic_selected .topic_right {
background-color: hsl(81, 60%, 95%);
}

View File

@ -228,6 +228,9 @@ li a {
.sidebar .rowblock:not(.topic_list):not(.rowhead):not(.opthead) .rowitem, .sidebar .search {
margin-left: 12px;
}
.topics_moderate .topic_row:hover {
background-color: rgb(78, 78, 98);
}
.widget_search:first-child {
margin-top: 36px;
}
@ -782,9 +785,8 @@ button, .formbutton, .panel_right_button:not(.has_inner_button) {
margin-right: 10px;
margin-bottom: 0px;
margin-left: 0px;
margin-left: 0px;
}
.topic_item .submit_edit {
sp.topic_item .submit_edit {
/*margin-right: 16px;*/
}
.zone_view_topic button, .zone_view_topic .formbutton {
@ -1425,7 +1427,7 @@ input[type=checkbox]:not(:checked):hover + label .sel {
width: auto;
padding: 0px;
}
.user_box {
.user_box, .elapsed {
display: none;
}
#back {
@ -1442,9 +1444,6 @@ input[type=checkbox]:not(:checked):hover + label .sel {
font-size: 17px;
line-height: 28px;
}
.elapsed {
display: none;
}
}
@media(min-width: 751px) {

View File

@ -848,6 +848,9 @@ input[type=checkbox]:checked + label.poll_option_label .sel {
.topic_list .topic_row {
display: flex;
}
.topics_moderate .topic_row:hover .rowitem {
background-color: hsla(0, 0%, 27%, 1);
}
.topic_selected .rowitem {
background-color: hsla(0, 0%, 29%, 1);
}