Files
Testing/templates/messages/message_view.tpl
sean 0e8a8b3028
Some checks failed
deploy-testing / deploy (push) Has been cancelled
Initial testing snapshot
2026-11-17 16:15:01 -05:00

313 lines
8.0 KiB
Smarty

<div class="chat" id="chatContainer-sophie" style="overflow-y: auto;">
{* JAVASCRIPT FOR AUTOGROWING TEXTAREA *}
{literal}
<script type="text/javascript">
<!--
window.addEvent('domready', function() { textarea_autogrow('reply_body'); });
//-->
</script>
{/literal}
{* LOOP THROUGH MESSAGES IN THREAD *}
{section name=pm_loop loop=$pms}
{if $pms[pm_loop].author->user_info.user_id!=$user->user_info.user_id}
<div class="inbox-message-received">
<div class="sender-image">
{if $pms[pm_loop].club==0}
<a href='profile.php?user={$pms[pm_loop].author->user_info.user_username}'>
{else}<a href='club.php?club_id={$pms[pm_loop].author->user_info.user_id}'>{/if}
{if $pms[pm_loop].club==0}
{assign var="profilepicture" value=$pms[pm_loop].author->user_photo("./images/nophoto.png")}
{$pms[pm_loop].author->userprofiledot($profilepicture, "70px", "70px", 1, 1)}
{else}
<img src="{$pms[pm_loop].pm_user->user_info.club_photo}" onerror="this.src='{$cloudcdn1}/images/nophoto.png'" style="max-width:90px;">
{/if}
</a>
</div>
<div class="inbox-message-text">
<div class="info">
<a href='{$url->url_create("profile",$pms[pm_loop].author->user_info.user_username)}'>{$pms[pm_loop].author->user_displayname|truncate:20:"...":true}</a>
{*<a href="profile.php?user={$pms[pm_loop].author->user_info.user_username}">{$pms[pm_loop].author->user_info.user_username}</a>*}<div class="messages_date">{$datetime->cdate("`$setting.setting_timeformat` `$setting.setting_dateformat`", $datetime->timezone($pms[pm_loop].pm_date, $global_timezone))}</div> <a data-toggle="modal" data-target="#myModal" href="user_report.php?return_url={$url->url_current()|escape:url}&user={$pms[pm_loop].author->user_info.user_username}&item=message&objectid={$pms[pm_loop].pm_id}">Report a Problem</a></div>
<div class="text">
{$pms[pm_loop].pm_body|choptext:75:"<br>"} </div>
</div>
</div>
{else}
<div class="inbox-message-sent">
<div class="inbox-message-text">
<div class="info"><div class="messages_date">{$datetime->cdate("`$setting.setting_timeformat` `$setting.setting_dateformat`", $datetime->timezone($pms[pm_loop].pm_date, $global_timezone))}</div><a href="profile.php?user={$pms[pm_loop].pm_user->user_info.user_username}">{$pms[pm_loop].author->user_info.user_username}</a></div>
<div class="text">
{$pms[pm_loop].pm_body|choptext:75:"<br>"}
</div>
</div>
<div class="sender-image">
{if $pms[pm_loop].club==0}
<a href='{$url->url_create("profile",$pms[pm_loop].author->user_info.user_username)}'>
{else}<a href='club.php?club_id={$pms[pm_loop].author->user_info.user_id}'>{/if}
{if $pms[pm_loop].club==0}
{assign var="profilepicture" value=$pms[pm_loop].author->user_photo("./images/nophoto.png")}
{$pms[pm_loop].author->userprofiledot($profilepicture, "90px")}
{else}
<img src="{$pms[pm_loop].pm_user->user_info.club_photo}" onerror="this.src='{$cloudcdn1}/images/nophoto.png'" style="max-width:90px;">
{/if}
</a>
</div>
</div>
{/if}
{/section}
</div>
{* DISPLAY REPLY TO ALL BOX *}
<div class="chatbox">
<a name='reply'></a>
<div id='reply_error' style='display: none;'>{lang_print id=796}</div>
{if $blockerror}<div id='reply_error2' style='display: {$blockerror};'>{lang_print id=1321}</div>{/if}
<form id="chatForm" method='POST' onSubmit="{literal}if(this.reply.value.replace(/ /g, '') == '') { $('reply_error').style.display='block'; return false; } else {jQuery('#submit1').prop( 'disabled', true ); jQuery('#submit1').prop( 'value', 'Sending...' ); jQuery('.emojionearea-editor').html(''); return true; }{/literal}">
{if $userid!=390124}
{* if $collaborators|@count == 1}{lang_print id=802}{else}{lang_print id=803}{/if *}
{if is_array($collaborators) || $collaborators instanceof Countable}
{if $collaborators|@count == 1}
{lang_print id=802}
{else}
{lang_print id=803}
{/if}
{else}
{if strlen($collaborators) == 1}
{lang_print id=802}
{else}
{lang_print id=803}
{/if}
{/if}
<br>
<textarea name='reply' id='reply_body' class="form-control" ></textarea>
<input type="hidden" name="s" value="{$s}">
<div class="typing" style="height:20px;"></div>
<input type='submit' id="submit1" class='button' value='{lang_print id=791}'>
{/if}
{* SHOW BACK TO INBOX *}
<input type='hidden' name='type' value='replymessage'>
<input type='hidden' name='task' value='reply'>
<input type='hidden' name='pmconvo_id' value='{$pmconvo_info.pmconvo_id}'>
</form>
</td>
</tr>
</div>
{literal}
<link rel="stylesheet" type="text/css" href="/include/emojis/emojionearea.min.css" media="screen">
<script type="text/javascript" src="/include/emojis/emojionearea.js"></script>
<script type="text/javascript">
let typingTimeout;
function load_page_content() {
const form = document.getElementById("chatForm");
form.addEventListener("submit", function(e) {
e.preventDefault(); // stop normal HTTP submit
// Collect form data
const formData = new FormData(form);
const payload = {};
formData.forEach((value, key) => {
payload[key] = value;
});
if (socket.readyState === WebSocket.OPEN) {
// Send JSON over WebSocket
socket.send(JSON.stringify({
type: "replymessage",
data: payload
}));
jQuery('#submit1').prop( 'disabled', false ); jQuery('#submit1').prop( 'value', 'Send Message' );
}else{jQuery("#chatForm").submit();}
});
jQuery("#reply_body").emojioneArea({
attributes: {
spellcheck : true,
autocomplete : "on",
autocorrect : "on",
autocapitalize : "on",
},
events: {
keyup: function (editor, event) {
window.socket.send(
JSON.stringify({
type: "typing",
pmconvo_id: "{/literal}{$pmconvo_info.pmconvo_id}{literal}"
}));
if(typingTimeout){
clearTimeout(typingTimeout);
}
typingTimeout = setTimeout(function() {
socket.send(JSON.stringify({
type: "stoptyping",
pmconvo_id: "{/literal}{$pmconvo_info.pmconvo_id}{literal}"
}));
}, 2000);
}
},
// container: "#emojicontainer",
pickerPosition: "left",
tonesStyle: "bullet",
pickerPosition :"bottom"
// saveEmojisAs: "image"
});
if (socket.readyState === WebSocket.OPEN) {
window.socket.send(
JSON.stringify({
type: "connect_to_pm",
pmconvo_id: {/literal}{$pmconvo_info.pmconvo_id}{literal}
}));
}
};
function sendinboxmessage(message)
{
if (socket.readyState === WebSocket.OPEN) {
socket.send(JSON.stringify({
type: "send_message",
pmconvo_id: "{/literal}{$pmconvo_info.pmconvo_id}{literal}",
data: {
text: "Hello there!"
}
}));
} else {
jQuery("#chatForm").submit();
//user_messages_view.php
//alert("Socket not open");
}
}
function mark_as_unread()
{
jQuery.ajax({
type: "POST",
url: "misc_js.php",
data: {
pmconvo_id: "{/literal}{$pmconvo_info.pmconvo_id}{literal}",
task: "mark_as_unread"
}
}).done(function(data) {
jQuery('article[data-id="{/literal}{$pmconvo_info.pmconvo_id}{literal}"]').addClass("unread");
});
}
</script>
{/literal}