Mega-hack to remove unwanted whitespace (allowing the page to render

correctly)
This commit is contained in:
Keir Nellyer 2016-08-11 11:30:10 +01:00
parent ebea70d078
commit 09b458af68
2 changed files with 44 additions and 22 deletions

View File

@ -0,0 +1,17 @@
$(document).ready(function() {
/**
* Remove leading and trailing whitespace in username span
*/
$('#log').find("> .log-line > .remove-whitespace > span").filter(function() {
return $(this).text() === ': ';
}).prev().each(function() {
$(this).text($(this).text().trim());
});
/**
* Remove newlines and whitespace in tags with the '.remove-whitespace' class.
*/
$('.remove-whitespace').contents().filter(function() {
return this.nodeType = Node.TEXT_NODE && /\S/.test(this.nodeValue) === false;
}).remove();
});

View File

@ -376,9 +376,7 @@
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link rel="stylesheet" href="css/tiger.css">
<link href='https://fonts.googleapis.com/css?family=Crete+Round' rel='stylesheet' type='text/css'>
@ -461,29 +459,31 @@
$typeId = $message->getType();
$typeDisplayName = Message::$TYPE_DISPLAY_NAMES[$typeId];
$isPM = $typeId == Message::TYPE_PM;
?>
if($isPM): ?>
<span class="label label-primary chat pm"><?= $typeDisplayName ?></span>
<?php elseif($typeId == Message::TYPE_PARTY): ?>
<span class="label label-warning chat"><?= $typeDisplayName ?></span>
<?php else: ?>
<span class="label label-info chat"><?= $typeDisplayName ?></span>
<?php endif; ?>
<span class="log-line">
<?php if($isPM): ?>
<span class="label label-primary chat pm"><?= $typeDisplayName ?></span>
<?php elseif($typeId == Message::TYPE_PARTY): ?>
<span class="label label-warning chat"><?= $typeDisplayName ?></span>
<?php else: ?>
<span class="label label-info chat"><?= $typeDisplayName ?></span>
<?php endif; ?>
<span class="<?= ($message->getSender() == $report->getSuspect() ? 'suspect' : 'text-muted') ?>">
<?= $message->getSender()->getUsername() ?>
<span class="remove-whitespace">
<span class="<?= ($message->getSender() == $report->getSuspect() ? 'suspect' : 'text-muted') ?>"><?= $message->getSender()->getUsername() ?></span>
<?php if ($isPM): ?>
&nbsp;->&nbsp;<?= $message->getRecipients()[0]->getUsername() ?>
<?php endif; ?>
<span class="message-separator black">: </span>
</span>
<span class="text-muted"><?= $message->getMessage() ?></span>
<?php if ($i < $displayAmount - 1): // Don't break on the last element ?>
<br />
<?php endif; ?>
</span>
<?php if ($isPM): ?>
&nbsp;->&nbsp;<?= $message->getRecipients()[0]->getUsername() ?>
<?php endif; ?>
<span class="black">: </span>
<span class="text-muted"><?= $message->getMessage() ?></span>
<?php if ($i < $displayAmount - 1): // Don't break on the last element ?>
<br />
<?php endif; ?>
<?php endfor; ?>
<?php endif; ?>
</div>
@ -550,6 +550,11 @@
</div>
</div>
</body>
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/main.js"></script>
</html>
<?php foreach ($connections as $connection) {
$connection->close();