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