forked from MarseyWorld/MarseyWorld
much better approach to twitter.js
parent
986bcdbc86
commit
78164c754f
|
@ -127,16 +127,7 @@ socket.on('speak', function(json) {
|
|||
register_new_elements(line);
|
||||
bs_trigger(line)
|
||||
|
||||
if (text_html.includes('<blockquote class="twitter-tweet">')) {
|
||||
if (!document.getElementById('twitter-embed-script')) {
|
||||
const script = document.createElement('script');
|
||||
script.id = 'twitter-embed-script'
|
||||
script.src = '/assets/js/vendor/twitter.js?x=11';
|
||||
script.defer = true;
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
embed_twitter()
|
||||
}
|
||||
embed_twitter()
|
||||
|
||||
if (last_user == json.user_id) {
|
||||
box.querySelector('.chat-group:last-child').append(line)
|
||||
|
|
|
@ -351,16 +351,7 @@ function post_comment(fullname, hide) {
|
|||
viewbtn.dataset.ids = viewbtn.dataset.ids.slice(0, -1) + `, ${data['id']}]`
|
||||
}
|
||||
|
||||
if (comment.includes('<blockquote class="twitter-tweet">')) {
|
||||
if (!document.getElementById('twitter-embed-script')) {
|
||||
const script = document.createElement('script');
|
||||
script.id = 'twitter-embed-script'
|
||||
script.src = '/assets/js/vendor/twitter.js?x=11';
|
||||
script.defer = true;
|
||||
comments.insertAdjacentElement('beforeEnd', script);
|
||||
}
|
||||
embed_twitter()
|
||||
}
|
||||
embed_twitter()
|
||||
}
|
||||
else {
|
||||
showToast(false, getMessageFromJsonData(false, data));
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -118,4 +118,9 @@
|
|||
{% if not session.get("GLOBAL") %}
|
||||
<script defer src="{{'js/chat.js' | asset}}"></script>
|
||||
{% endif %}
|
||||
{% if v and v.theme in LIGHT_THEMES %}
|
||||
<script id="twitter-embed-script" defer src="{{'js/vendor/twitterlight.js' | asset}}"></script>
|
||||
{% else %}
|
||||
<script id="twitter-embed-script" defer src="{{'js/vendor/twitter.js' | asset}}"></script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -13,19 +13,7 @@
|
|||
|
||||
{% set disable_votes = (request.path.startswith('/@') and not wall and u != v) and v and v.admin_level < PERMS['ENABLE_VOTE_BUTTONS_ON_USER_PAGE'] %}
|
||||
|
||||
{% set ns = namespace() %}
|
||||
|
||||
{% macro single_comment(c, level=1, collapse=False) %}
|
||||
{% if not request.headers.get("xhr") and not ns.has_twitter_embed %}
|
||||
{% if
|
||||
('<blockquote class="twitter-tweet">' in c.body_html) or
|
||||
(p and p.embed and '<blockquote class="twitter-tweet">' in p.embed) or
|
||||
(p and '<blockquote class="twitter-tweet">' in p.body_html)
|
||||
%}
|
||||
{% set ns.has_twitter_embed = True %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if can_see(v, c) %}
|
||||
{% set ups=c.upvotes %}
|
||||
{% set downs=c.downvotes %}
|
||||
|
@ -863,12 +851,10 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if ns.has_twitter_embed %}
|
||||
{% if v and v.theme in LIGHT_THEMES %}
|
||||
<script id="twitter-embed-script" defer src="{{'js/vendor/twitterlight.js' | asset}}"></script>
|
||||
{% else %}
|
||||
<script id="twitter-embed-script" defer src="{{'js/vendor/twitter.js' | asset}}"></script>
|
||||
{% endif %}
|
||||
{% if v and v.theme in LIGHT_THEMES %}
|
||||
<script id="twitter-embed-script" defer src="{{'js/vendor/twitterlight.js' | asset}}"></script>
|
||||
{% else %}
|
||||
<script id="twitter-embed-script" defer src="{{'js/vendor/twitter.js' | asset}}"></script>
|
||||
{% endif %}
|
||||
|
||||
</body>
|
||||
|
|
|
@ -129,4 +129,9 @@
|
|||
{% if not session.get("GLOBAL") %}
|
||||
<script defer src="{{'js/chat.js' | asset}}"></script>
|
||||
{% endif %}
|
||||
{% if v and v.theme in LIGHT_THEMES %}
|
||||
<script id="twitter-embed-script" defer src="{{'js/vendor/twitterlight.js' | asset}}"></script>
|
||||
{% else %}
|
||||
<script id="twitter-embed-script" defer src="{{'js/vendor/twitter.js' | asset}}"></script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -361,15 +361,10 @@
|
|||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% set ns = namespace() %}
|
||||
|
||||
{% macro chat_window(vlink, group_memberships_names, keyword_notifs_li)%}
|
||||
<div id="chat-window" class="container p-0">
|
||||
{% set messages_list = messages.items()|list %}
|
||||
{% for id, m in messages_list %}
|
||||
{% if '<blockquote class="twitter-tweet">' in m.text_html %}
|
||||
{% set ns.has_twitter_embed = True %}
|
||||
{% endif %}
|
||||
{% set same = loop.index > 1 and m.user_id == messages_list[loop.index-2][1].user_id %}
|
||||
{% if not same %}
|
||||
{% if loop.index > 1 %}
|
||||
|
@ -407,14 +402,6 @@
|
|||
<i id="chatsend" data-nonce="{{g.nonce}}" data-onclick="send()" class="btn btn-secondary fas fa-reply ml-1 my-auto" style="transform:rotateY(180deg)"></i>
|
||||
</div>
|
||||
<div id="ghostdiv-chat" class="ghostdiv" style="display: none"><span></span></div>
|
||||
|
||||
{% if ns.has_twitter_embed %}
|
||||
{% if v and v.theme in LIGHT_THEMES %}
|
||||
<script id="twitter-embed-script" defer src="{{'js/vendor/twitterlight.js' | asset}}"></script>
|
||||
{% else %}
|
||||
<script id="twitter-embed-script" defer src="{{'js/vendor/twitter.js' | asset}}"></script>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro time_filter_buttons() %}
|
||||
|
|
Loading…
Reference in New Issue