use fullname in "view source"

pull/135/head
Aevann 2023-02-27 03:37:53 +02:00
parent 53b31e1ea7
commit 8fa3e7f7cf
5 changed files with 16 additions and 16 deletions

View File

@ -2,13 +2,13 @@ function poll_vote_no_v() {
showToast(false, "Only logged-in users can vote!");
}
function expandMarkdown(id,type) {
const ta = document.getElementById('markdown-'+id);
function expandMarkdown(fullname) {
const ta = document.getElementById('markdown-'+fullname);
ta.classList.toggle('d-none');
document.getElementsByClassName('text-expand-icon-'+id)[0].classList.toggle('fa-expand-alt');
document.getElementsByClassName('text-expand-icon-'+id)[0].classList.toggle('fa-compress-alt');
document.getElementsByClassName('text-expand-icon-'+fullname)[0].classList.toggle('fa-expand-alt');
document.getElementsByClassName('text-expand-icon-'+fullname)[0].classList.toggle('fa-compress-alt');
const items = document.getElementsByClassName(`expand-text-${type}-${id}`)
const items = document.getElementsByClassName(`expand-text-${fullname}`)
for (let i=0; i < items.length; i++)
{
const e = items[i]
@ -36,7 +36,7 @@ function collapse_comment(id) {
vids[i].pause()
}
const ta = document.getElementById('markdown-'+id);
const ta = document.getElementById('markdown-c_'+id);
if (!ta.classList.contains('d-none'))
expandMarkdown(id,'c')
expandMarkdown(`c_${id}`)
};

View File

@ -1,6 +1,6 @@
function expandText(id) {
document.getElementById('post-text-'+id).classList.toggle('d-none');
for (const e of document.getElementsByClassName('text-expand-icon-'+id))
for (const e of document.getElementsByClassName('text-expand-icon-p_'+id))
{
e.classList.toggle('fa-expand-alt');
e.classList.toggle('fa-compress-alt');

View File

@ -408,7 +408,7 @@
<button type="button" id="delete-{{c.id}}" class="btn caction py-0 nobackground px-1 text-muted {% if c.deleted_utc %}d-none{% endif %}" data-bs-toggle="modal" data-bs-target="#deleteCommentModal" data-nonce="{{g.nonce}}" data-onclick="delete_commentModal(this, '{{c.id}}')"><i class="fas fa-trash-alt fa-fw"></i>Delete</button>
{% elif v and c.body %}
<button type="button" class="btn caction py-0 nobackground px-1 text-muted" data-nonce="{{g.nonce}}" data-onclick="expandMarkdown('{{c.id}}','c')"><i class="fas text-expand-icon-{{c.id}} fa-expand-alt"></i><span class="expand-text-c-{{c.id}}">View source</span></button>
<button type="button" class="btn caction py-0 nobackground px-1 text-muted" data-nonce="{{g.nonce}}" data-onclick="expandMarkdown('{{c.fullname}}')"><i class="fas text-expand-icon-{{c.fullname}} fa-expand-alt"></i><span class="expand-text-{{c.fullname}}">View source</span></button>
{% endif %}
{% endif %}
@ -492,7 +492,7 @@
</div>
{% if v and v.id != c.author_id and c.body %}
<div autocomplete="off" class="markdown d-none card border my-2 p-3 comment-box form-control rounded" id="markdown-{{c.id}}" readonly>{{c.body.strip()}}</div>
<div autocomplete="off" class="markdown d-none card border my-2 p-3 comment-box form-control rounded" id="markdown-{{c.fullname}}" readonly>{{c.body.strip()}}</div>
{% endif %}
{% if c.parent_submission or c.wall_user_id %}
@ -596,7 +596,7 @@
<button type="button" id="delete2-{{c.id}}" class="{% if c.deleted_utc %}d-none{% endif %} list-group-item text-danger" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#deleteCommentModal" data-nonce="{{g.nonce}}" data-onclick="delete_commentModal(this, '{{c.id}}')"><i class="far fa-trash-alt text-danger mr-2"></i>Delete</button>
{% else %}
{% if c.body %}
<button type="button" data-bs-dismiss="modal" data-nonce="{{g.nonce}}" data-onclick="expandMarkdown('{{c.id}}','c')" class="list-group-item"><i class="fas text-expand-icon-{{c.id}} fa-expand-alt mr-2"></i><span class="expand-text-c-{{c.id}}">View source</span></button>
<button type="button" data-bs-dismiss="modal" data-nonce="{{g.nonce}}" data-onclick="expandMarkdown('{{c.fullname}}')" class="list-group-item"><i class="fas text-expand-icon-{{c.fullname}} fa-expand-alt mr-2"></i><span class="expand-text-{{c.fullname}}">View source</span></button>
{% endif %}
{% if not c.ghost %}

View File

@ -39,7 +39,7 @@
{% if v.id==p.author_id %}
<button type="button" class="nobackground btn btn-link btn-block btn-lg text-left text-muted" data-bs-dismiss="modal" data-nonce="{{g.nonce}}" data-onclick="togglePostEdit('{{p.id}}')"><i class="far fa-edit text-center text-muted mr-2"></i>Edit</button>
{% elif p.body and v.admin_level < PERMS['POST_EDITING'] %}
<button type="button" class="nobackground btn btn-link btn-block btn-lg text-left text-muted" data-bs-dismiss="modal" data-nonce="{{g.nonce}}" data-onclick="expandMarkdown('{{p.id}}','p')"><i class="fas text-expand-icon-{{p.id}} fa-expand-alt text-center mr-2"></i><span class="expand-text-p-{{p.id}}">View source</span></button>
<button type="button" class="nobackground btn btn-link btn-block btn-lg text-left text-muted" data-bs-dismiss="modal" data-nonce="{{g.nonce}}" data-onclick="expandMarkdown('{{p.fullname}}')"><i class="fas text-expand-icon-{{p.fullname}} fa-expand-alt text-center mr-2"></i><span class="expand-text-{{p.fullname}}">View source</span></button>
{% endif %}
{% include "post_actions_mobile.html" %}
@ -212,7 +212,7 @@
{% if v and v.can_edit(p) %}
<button type="button" class="list-inline-item" data-nonce="{{g.nonce}}" data-onclick="togglePostEdit('{{p.id}}')"><i class="fas fa-edit"></i>Edit</button>
{% elif v and v.id != p.author_id and p.body and not v_forbid_deleted %}
<button type="button" class="list-inline-item" data-nonce="{{g.nonce}}" data-onclick="expandMarkdown('{{p.id}}','p')"><i class="fas text-expand-icon-{{p.id}} fa-expand-alt"></i><span class="expand-text-p-{{p.id}}">View source</span></button>
<button type="button" class="list-inline-item" data-nonce="{{g.nonce}}" data-onclick="expandMarkdown('{{p.fullname}}')"><i class="fas text-expand-icon-{{p.fullname}} fa-expand-alt"></i><span class="expand-text-{{p.fullname}}">View source</span></button>
{% endif %}
{% include 'post_actions.html' %}
@ -292,7 +292,7 @@
</div>
{% if v and v.id != p.author_id and p.body and not v_forbid_deleted %}
<div autocomplete="off" class="markdown d-none card border my-2 p-3 comment-box form-control rounded" id="markdown-{{p.id}}" readonly>{{p.body.strip()}}</div>
<div autocomplete="off" class="markdown d-none card border my-2 p-3 comment-box form-control rounded" id="markdown-{{p.fullname}}" readonly>{{p.body.strip()}}</div>
{% endif %}
<div class="row border-md-0 comment-section pb-3">

View File

@ -116,7 +116,7 @@
<div class="d-flex" style="flex-basis:146px"></div>
<ul class="list-inline text-right d-flex">
{% if p.realbody(v, listing=True) %}
<button type="button" class="list-inline-item ml-2" data-nonce="{{g.nonce}}" data-onclick="expandText('{{p.id}}')"><i class="fas fa-expand-alt mx-0 text-expand-icon-{{p.id}}"></i></button>
<button type="button" class="list-inline-item ml-2" data-nonce="{{g.nonce}}" data-onclick="expandText('{{p.id}}')"><i class="fas fa-expand-alt mx-0 text-expand-icon-{{p.fullname}}"></i></button>
{% endif %}
<a class="list-inline-item" {% if v and v.newtab %}data-target="t" target="_blank"{% endif %} href="{{p.permalink}}">
<i class="fas fa-comment-dots mr-2"></i>{{p.comment_count}}
@ -144,7 +144,7 @@
</li>
{% if p.realbody(v, listing=True) %}
<button type="button" class="list-inline-item ml-2" data-nonce="{{g.nonce}}" data-onclick="expandText('{{p.id}}')"><i class="fas fa-expand-alt mx-0 text-expand-icon-{{p.id}}"></i></button>
<button type="button" class="list-inline-item ml-2" data-nonce="{{g.nonce}}" data-onclick="expandText('{{p.id}}')"><i class="fas fa-expand-alt mx-0 text-expand-icon-{{p.fullname}}"></i></button>
{% endif %}
{% if v %}