forked from MarseyWorld/MarseyWorld
improve the "show more" button
parent
4b6baac968
commit
c560d1d9fe
|
@ -112,6 +112,12 @@ if (reload_page) {
|
|||
}
|
||||
|
||||
function register_new_elements(e) {
|
||||
for (const element of document.getElementsByClassName('showmore')) {
|
||||
element.onclick = () => {
|
||||
showmore(element)
|
||||
};
|
||||
}
|
||||
|
||||
const onclick = e.querySelectorAll('[data-onclick]');
|
||||
for (const element of onclick) {
|
||||
element.onclick = ()=>{execute(element, 'onclick')};
|
||||
|
|
|
@ -282,12 +282,6 @@ function showmore(t) {
|
|||
t.innerHTML = 'SHOW LESS'
|
||||
}
|
||||
|
||||
for (const element of document.getElementsByClassName('showmore')) {
|
||||
element.onclick = () => {
|
||||
showmore(element)
|
||||
};
|
||||
}
|
||||
|
||||
function formatDate(d) {
|
||||
let year = d.getFullYear();
|
||||
let monthAbbr = d.toLocaleDateString('en-us', {month: 'short'});
|
||||
|
|
|
@ -107,7 +107,7 @@ color_regex = re.compile("[a-f0-9]{6}", flags=re.A)
|
|||
|
||||
# lazy match on the {}?, only match if there is trailing stuff
|
||||
# Specifically match Snappy's way of formatting, this might break some losers' comments.
|
||||
showmore_regex = re.compile(r"^(.{3000,}?</p>(?:</li></ul>)?)(\s*<p>.*)", flags=re.A|re.DOTALL)
|
||||
showmore_regex = re.compile(r"^((.{3000,}?|(.*?<.*?){10,})?<\/p>(?:<\/li><\/ul>)?)(\s*<p>.*)", flags=re.A|re.DOTALL)
|
||||
|
||||
search_token_regex = re.compile('"([^"]*)"|(\S+)', flags=re.A)
|
||||
|
||||
|
|
|
@ -410,8 +410,8 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys
|
|||
if '<pre>' not in sanitized and not sidebar:
|
||||
sanitized = sanitized.replace('\n','')
|
||||
|
||||
if showmore and len(sanitized) > 3500:
|
||||
sanitized = showmore_regex.sub(r'\1<p><button class="showmore">SHOW MORE</button></p><d class="d-none">\2</d>', sanitized, count=1)
|
||||
if showmore and len(sanitized) > 3500 or sanitized.count('<') > 15:
|
||||
sanitized = showmore_regex.sub(r'\1<p><button class="showmore">SHOW MORE</button></p><d class="d-none">\4</d>', sanitized, count=1)
|
||||
|
||||
return sanitized.strip()
|
||||
|
||||
|
|
Loading…
Reference in New Issue