Some more moves.
This commit is contained in:
parent
3b2114cd10
commit
f109a86c5b
10 changed files with 237 additions and 92 deletions
|
@ -17,6 +17,7 @@
|
|||
"jbbcode/jbbcode": "*",
|
||||
"corneltek/cliframework": "*",
|
||||
"phroute/phroute": "^2.1",
|
||||
"illuminate/database": "5.2.*"
|
||||
"illuminate/database": "5.2.*",
|
||||
"doctrine/dbal": "~2.4"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,10 @@
|
|||
namespace Sakura\Controllers;
|
||||
|
||||
use Sakura\DB;
|
||||
use Sakura\Forum;
|
||||
use Sakura\Forum\Forum;
|
||||
use Sakura\Forum\Thread;
|
||||
use Sakura\Perms\Forum as ForumPerms;
|
||||
use Sakura\Router;
|
||||
use Sakura\Template;
|
||||
use Sakura\User;
|
||||
use Sakura\Users;
|
||||
|
@ -31,7 +33,7 @@ class ForumController extends Controller
|
|||
{
|
||||
// Merge index specific stuff with the global render data
|
||||
Template::vars([
|
||||
'forum' => (new Forum\Forum()),
|
||||
'forum' => (new Forum()),
|
||||
'stats' => [
|
||||
'userCount' => DB::table('users')->where('password_algo', '!=', 'disabled')->whereNotIn('rank_main', [1, 10])->count(),
|
||||
'newestUser' => User::construct(Users::getNewestUserId()),
|
||||
|
@ -54,11 +56,11 @@ class ForumController extends Controller
|
|||
global $currentUser;
|
||||
|
||||
// Get the forum
|
||||
$forum = new Forum\Forum($id);
|
||||
$forum = new Forum($id);
|
||||
|
||||
// Redirect forum id 0 to the main page
|
||||
if ($forum->id === 0) {
|
||||
header('Location: ' . (new \Sakura\Urls)->format('FORUM_INDEX'));
|
||||
header('Location: ' . Router::route('forums.index'));
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -68,6 +70,7 @@ class ForumController extends Controller
|
|||
Template::vars([
|
||||
'page' => [
|
||||
'message' => 'The forum you tried to access does not exist.',
|
||||
'redirect' => Router::route('forums.index'),
|
||||
],
|
||||
]);
|
||||
|
||||
|
@ -81,6 +84,7 @@ class ForumController extends Controller
|
|||
Template::vars([
|
||||
'page' => [
|
||||
'message' => 'You do not have access to this forum.',
|
||||
'redirect' => Router::route('forums.index'),
|
||||
],
|
||||
]);
|
||||
|
||||
|
@ -95,24 +99,7 @@ class ForumController extends Controller
|
|||
'page' => [
|
||||
'message' => 'The forum you tried to access is a link. You\'re being redirected.',
|
||||
'redirect' => $forum->link,
|
||||
]
|
||||
]);
|
||||
|
||||
// Print page contents
|
||||
return Template::render('global/information');
|
||||
}
|
||||
|
||||
// Check if we're marking as read
|
||||
if (isset($_GET['read']) && $_GET['read'] && isset($_GET['session']) && $_GET['session'] == session_id()) {
|
||||
// Run the function
|
||||
$forum->trackUpdateAll($currentUser->id);
|
||||
|
||||
// Set render data
|
||||
Template::vars([
|
||||
'page' => [
|
||||
'message' => 'All threads have been marked as read.',
|
||||
'redirect' => (new \Sakura\Urls)->format('FORUM_SUB', [$forum->id]),
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
// Print page contents
|
||||
|
@ -127,4 +114,148 @@ class ForumController extends Controller
|
|||
// Print page contents
|
||||
return Template::render('forum/viewforum');
|
||||
}
|
||||
|
||||
public function markForumRead($id = 0)
|
||||
{
|
||||
global $currentUser;
|
||||
|
||||
// Check if the session id was supplied
|
||||
if (!isset($_GET['s']) || $_GET['s'] != session_id()) {
|
||||
// Set render data
|
||||
Template::vars([
|
||||
'page' => [
|
||||
'message' => 'Your session expired! Go back and try again.',
|
||||
'redirect' => Router::route('forums.index'),
|
||||
],
|
||||
]);
|
||||
|
||||
// Print page contents
|
||||
return Template::render('global/information');
|
||||
}
|
||||
|
||||
// Get the forum
|
||||
$forum = new Forum($id);
|
||||
|
||||
// Check if the forum exists
|
||||
if ($forum->id < 1) {
|
||||
// Set render data
|
||||
Template::vars([
|
||||
'page' => [
|
||||
'message' => 'The forum you tried to access does not exist.',
|
||||
'redirect' => Router::route('forums.index'),
|
||||
],
|
||||
]);
|
||||
|
||||
// Print page contents
|
||||
return Template::render('global/information');
|
||||
}
|
||||
|
||||
// Check if the user has access to the forum
|
||||
if (!$forum->permission(ForumPerms::VIEW, $currentUser->id)) {
|
||||
// Set render data
|
||||
Template::vars([
|
||||
'page' => [
|
||||
'message' => 'You do not have access to this forum.',
|
||||
'redirect' => Router::route('forums.index'),
|
||||
],
|
||||
]);
|
||||
|
||||
// Print page contents
|
||||
return Template::render('global/information');
|
||||
}
|
||||
|
||||
// Run the function
|
||||
$forum->trackUpdateAll($currentUser->id);
|
||||
|
||||
// Set render data
|
||||
Template::vars([
|
||||
'page' => [
|
||||
'message' => 'All threads have been marked as read.',
|
||||
'redirect' => Router::route('forums.forum', $forum->id),
|
||||
],
|
||||
]);
|
||||
|
||||
// Print page contents
|
||||
return Template::render('global/information');
|
||||
}
|
||||
|
||||
public function thread($id = 0)
|
||||
{
|
||||
global $currentUser;
|
||||
|
||||
// Attempt to get the thread
|
||||
$thread = new Thread($id);
|
||||
|
||||
// And attempt to get the forum
|
||||
$forum = new Forum($thread->forum);
|
||||
|
||||
// Check if the forum exists
|
||||
if ($thread->id == 0 || !$forum->permission(ForumPerms::VIEW, $currentUser->id)) {
|
||||
// Set render data
|
||||
Template::vars([
|
||||
'page' => [
|
||||
'message' => 'This thread doesn\'t exist or you don\'t have access to it!',
|
||||
'redirect' => Router::route('forums.index'),
|
||||
],
|
||||
]);
|
||||
|
||||
// Print page contents
|
||||
return Template::render('global/information');
|
||||
}
|
||||
|
||||
// Update the tracking status
|
||||
$thread->trackUpdate($currentUser->id);
|
||||
|
||||
// Update views
|
||||
$thread->viewsUpdate();
|
||||
|
||||
// Set parse variables
|
||||
Template::vars([
|
||||
'thread' => $thread,
|
||||
'forum' => $forum,
|
||||
]);
|
||||
|
||||
// Print page contents
|
||||
return Template::render('forum/viewtopic');
|
||||
}
|
||||
|
||||
public function threadModerate($id = 0)
|
||||
{
|
||||
global $currentUser;
|
||||
|
||||
// Attempt to get the thread
|
||||
$thread = new Thread($id);
|
||||
|
||||
// And attempt to get the forum
|
||||
$forum = new Forum($thread->forum);
|
||||
|
||||
// Check if the forum exists
|
||||
if ($thread->id == 0 || !$forum->permission(ForumPerms::VIEW, $currentUser->id)) {
|
||||
// Set render data
|
||||
Template::vars([
|
||||
'page' => [
|
||||
'message' => 'This thread doesn\'t exist or you don\'t have access to it!',
|
||||
'redirect' => Router::route('forums.index'),
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
// Take the action
|
||||
$action = isset($_POST['action']) ? $_POST['action'] : null;
|
||||
|
||||
// Switch
|
||||
switch ($action) {
|
||||
default:
|
||||
Template::vars([
|
||||
'page' => [
|
||||
'message' => 'Unknown moderation action.',
|
||||
'redirect' => Router::route('forums.thread', $thread->id),
|
||||
],
|
||||
]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Print page contents
|
||||
return Template::render('global/information');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ class Thread
|
|||
->update([
|
||||
'topic_hidden' => $this->hidden,
|
||||
'topic_title' => $this->title,
|
||||
'topic_limit' => $this->timeLimit,
|
||||
'topic_time_limit' => $this->timeLimit,
|
||||
'topic_status' => $this->status,
|
||||
'topic_status_change' => $this->statusChange,
|
||||
'topic_type' => $this->type,
|
||||
|
|
|
@ -26,7 +26,7 @@ if (!$thread) {
|
|||
// Set render data
|
||||
$renderData['page'] = [
|
||||
'message' => 'The topic you tried to access does not exist.',
|
||||
'redirect' => $urls->format('FORUM_THREAD', [$thread->id]),
|
||||
'redirect' => Router::route('forums.thread', $thread->id),
|
||||
];
|
||||
|
||||
// Set parse variables
|
||||
|
@ -42,7 +42,7 @@ if (!$forum->permission(ForumPerms::VIEW, $currentUser->id)) {
|
|||
// Set render data
|
||||
$renderData['page'] = [
|
||||
'message' => 'You do not have access to this thread.',
|
||||
'redirect' => $urls->format('FORUM_THREAD', [$thread->id]),
|
||||
'redirect' => Router::route('forums.thread', $thread->id),
|
||||
];
|
||||
|
||||
// Set parse variables
|
||||
|
@ -68,7 +68,7 @@ if (isset($_GET['sticky']) && $_GET['sticky'] == session_id() && $forum->permiss
|
|||
// Set render data
|
||||
$renderData['page'] = [
|
||||
'message' => 'Changed the thread type.',
|
||||
'redirect' => $urls->format('FORUM_THREAD', [$thread->id]),
|
||||
'redirect' => Router::route('forums.thread', $thread->id),
|
||||
];
|
||||
|
||||
// Set parse variables
|
||||
|
@ -93,7 +93,7 @@ if (isset($_GET['announce']) && $_GET['announce'] == session_id() && $forum->per
|
|||
// Set render data
|
||||
$renderData['page'] = [
|
||||
'message' => 'Changed the thread type.',
|
||||
'redirect' => $urls->format('FORUM_THREAD', [$thread->id]),
|
||||
'redirect' => Router::route('forums.thread', $thread->id),
|
||||
];
|
||||
|
||||
// Set parse variables
|
||||
|
@ -118,7 +118,7 @@ if (isset($_GET['lock']) && $_GET['lock'] == session_id() && $forum->permission(
|
|||
// Set render data
|
||||
$renderData['page'] = [
|
||||
'message' => 'Changed the thread status.',
|
||||
'redirect' => $urls->format('FORUM_THREAD', [$thread->id]),
|
||||
'redirect' => Router::route('forums.thread', $thread->id),
|
||||
];
|
||||
|
||||
// Set parse variables
|
||||
|
@ -138,13 +138,13 @@ if (isset($_GET['trash']) && $_GET['trash'] == session_id() && $forum->permissio
|
|||
// Set render data
|
||||
$renderData['page'] = [
|
||||
'message' => 'Moved thread to the trash.',
|
||||
'redirect' => $urls->format('FORUM_THREAD', [$thread->id]),
|
||||
'redirect' => Router::route('forums.thread', $thread->id),
|
||||
];
|
||||
} else {
|
||||
// Set render data
|
||||
$renderData['page'] = [
|
||||
'message' => 'This thread is already trashed.',
|
||||
'redirect' => $urls->format('FORUM_THREAD', [$thread->id]),
|
||||
'redirect' => Router::route('forums.thread', $thread->id),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -166,13 +166,13 @@ if (isset($_GET['restore']) && $_GET['restore'] == session_id() && $forum->permi
|
|||
// Set render data
|
||||
$renderData['page'] = [
|
||||
'message' => 'Restored the thread to its previous location.',
|
||||
'redirect' => $urls->format('FORUM_THREAD', [$thread->id]),
|
||||
'redirect' => Router::route('forums.thread', $thread->id),
|
||||
];
|
||||
} else {
|
||||
// Set render data
|
||||
$renderData['page'] = [
|
||||
'message' => 'This thread has never been moved.',
|
||||
'redirect' => $urls->format('FORUM_THREAD', [$thread->id]),
|
||||
'redirect' => Router::route('forums.thread', $thread->id),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -193,13 +193,13 @@ if (isset($_GET['prune']) && $_GET['prune'] == session_id() && $forum->permissio
|
|||
// Set render data
|
||||
$renderData['page'] = [
|
||||
'message' => 'The thread has been pruned.',
|
||||
'redirect' => $urls->format('FORUM_SUB', [$thread->forum]),
|
||||
'redirect' => Router::route('forums.forum', $thread->forum),
|
||||
];
|
||||
} else {
|
||||
// Set render data
|
||||
$renderData['page'] = [
|
||||
'message' => 'You can only prune trashed threads.',
|
||||
'redirect' => $urls->format('FORUM_THREAD', [$thread->id]),
|
||||
'redirect' => Router::route('forums.thread', $thread->id),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -211,20 +211,4 @@ if (isset($_GET['prune']) && $_GET['prune'] == session_id() && $forum->permissio
|
|||
exit;
|
||||
}
|
||||
|
||||
// Update the tracking status
|
||||
$thread->trackUpdate($currentUser->id);
|
||||
|
||||
// Update views
|
||||
$thread->viewsUpdate();
|
||||
|
||||
// Set additional render data
|
||||
$renderData = array_merge($renderData, [
|
||||
'thread' => $thread,
|
||||
'forum' => $forum,
|
||||
]);
|
||||
|
||||
// Set parse variables
|
||||
Template::vars($renderData);
|
||||
|
||||
// Print page contents
|
||||
echo Template::render('forum/viewtopic');
|
||||
header('Location: ' . Router::route('forums.thread', $thread->id));
|
||||
|
|
|
@ -33,8 +33,16 @@ Router::group(['prefix' => 'news'], function () {
|
|||
|
||||
// Forum
|
||||
Router::group(['prefix' => 'forum'], function () {
|
||||
// Thread
|
||||
Router::group(['prefix' => 'thread'], function () {
|
||||
Router::get('/{id}', 'ForumController@thread', 'forums.thread');
|
||||
Router::post('/{id}/mod', 'ForumController@threadModerate', 'forums.mod');
|
||||
});
|
||||
|
||||
// Forum
|
||||
Router::get('/', 'ForumController@index', 'forums.index');
|
||||
Router::get('/{id}', 'ForumController@forum', 'forums.forum');
|
||||
Router::get('/{id}/mark', 'ForumController@markForumRead', 'forums.mark');
|
||||
});
|
||||
|
||||
// Members
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Sakura;
|
||||
|
||||
// Define Sakura version
|
||||
define('SAKURA_VERSION', '20160228');
|
||||
define('SAKURA_VERSION', '20160310');
|
||||
|
||||
// Define Sakura Path
|
||||
define('ROOT', __DIR__ . '/');
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
<div class="fa fa-2x fa-{% if thread.type == 1 %}thumb-tack{% elseif thread.type == 2 %}bullhorn{% elseif thread.status == 1 %}lock{% else %}navicon{% endif %}"></div>
|
||||
</td>
|
||||
<td class="topicTitle{% if thread.type == 2 %} topicAnnouncement{% endif %}">
|
||||
<a href="{{ urls.format('FORUM_THREAD', [thread.id]) }}" class="default">{{ thread.title }}</a>
|
||||
<a href="{{ route('forums.thread', thread.id) }}" class="default">{{ thread.title }}</a>
|
||||
</td>
|
||||
<td class="topicAuthor{% if thread.type == 2 %} topicAnnouncement{% endif %}">
|
||||
{% if thread.firstPost.poster.id %}
|
||||
<a href="{{ urls.format('USER_PROFILE', [thread.firstPost.poster.id]) }}" class="default" style="color: {{ thread.firstPost.poster.colour }}; text-shadow: 0 0 5px {% if thread.firstPost.poster.colour != 'inherit' %}{{ thread.firstPost.poster.colour }}{% else %}#222{% endif %};">{{ thread.firstPost.poster.username }}</a>
|
||||
<a href="{{ route('user.profile', thread.firstPost.poster.id) }}" class="default" style="color: {{ thread.firstPost.poster.colour }}; text-shadow: 0 0 5px {% if thread.firstPost.poster.colour != 'inherit' %}{{ thread.firstPost.poster.colour }}{% else %}#222{% endif %};">{{ thread.firstPost.poster.username }}</a>
|
||||
{% else %}
|
||||
[deleted user]
|
||||
{% endif %}
|
||||
|
@ -18,7 +18,7 @@
|
|||
</td>
|
||||
<td class="topicLast{% if thread.type == 2 %} topicAnnouncement{% endif %}">
|
||||
{% if thread.lastPost.poster.id %}
|
||||
<a href="{{ urls.format('USER_PROFILE', [thread.lastPost.poster.id]) }}" class="default" style="color: {{ thread.lastPost.poster.colour }}; text-shadow: 0 0 5px {% if thread.lastPost.poster.colour != 'inherit' %}{{ thread.lastPost.poster.colour }}{% else %}#222{% endif %};">{{ thread.lastPost.poster.username }}</a>
|
||||
<a href="{{ route('user.profile', thread.lastPost.poster.id) }}" class="default" style="color: {{ thread.lastPost.poster.colour }}; text-shadow: 0 0 5px {% if thread.lastPost.poster.colour != 'inherit' %}{{ thread.lastPost.poster.colour }}{% else %}#222{% endif %};">{{ thread.lastPost.poster.username }}</a>
|
||||
{% else %}
|
||||
[deleted user]
|
||||
{% endif %} <a href="{{ urls.format('FORUM_POST', [thread.lastPost.id]) }}#p{{ thread.lastPost.id }}" class="default fa fa-tag"></a><br />
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
{% set title %}Forums / {{ forum.name }}{% endset %}
|
||||
|
||||
{% set forumBackLink %}{{ urls.format('FORUM_INDEX') }}{% endset %}
|
||||
{% set forumBackLink %}{{ route('forums.index') }}{% endset %}
|
||||
{% set forumNewLink %}{{ urls.format('FORUM_NEW_THREAD', [forum.id]) }}{% endset %}
|
||||
{% set forumMarkRead %}{{ urls.format('FORUM_MARK_READ', [forum.id, php.sessionid]) }}{% endset %}
|
||||
{% set forumMarkRead %}{{ route('forums.mark', forum.id) }}?s={{ php.sessionid }}{% endset %}
|
||||
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
|
||||
|
|
|
@ -84,8 +84,8 @@
|
|||
{% for post in posts[get.page|default(1) - 1] %}
|
||||
<tr class="post" id="p{{ post.id }}">
|
||||
<td class="userpanel">
|
||||
{% if not post.poster.permission(constant('Sakura\\Perms\\Site::DEACTIVATED')) or post.poster.permission(constant('Sakura\\Perms\\Site::RESTRICTED')) %}<a href="{{ urls.format('USER_PROFILE', [post.poster.id]) }}" class="default username" style="color: {{ post.poster.colour }}; text-shadow: 0 0 5px {% if post.poster.colour != 'inherit' %}{{ post.poster.colour }}{% else %}#222{% endif %};" title="Go to {{ post.poster.username }}'s profile">{{ post.poster.username }}</a>
|
||||
<img src="{{ urls.format('IMAGE_AVATAR', [post.poster.id]) }}" alt="{{ post.poster.username }}" class="avatar" style="box-shadow: 0 3px 7px #{% if post.poster.isOnline %}484{% else %}844{% endif %};" />
|
||||
{% if not post.poster.permission(constant('Sakura\\Perms\\Site::DEACTIVATED')) or post.poster.permission(constant('Sakura\\Perms\\Site::RESTRICTED')) %}<a href="{{ route('user.profile', post.poster.id) }}" class="default username" style="color: {{ post.poster.colour }}; text-shadow: 0 0 5px {% if post.poster.colour != 'inherit' %}{{ post.poster.colour }}{% else %}#222{% endif %};" title="Go to {{ post.poster.username }}'s profile">{{ post.poster.username }}</a>
|
||||
<img src="{{ route('file.avatar', post.poster.id) }}" alt="{{ post.poster.username }}" class="avatar" style="box-shadow: 0 3px 7px #{% if post.poster.isOnline %}484{% else %}844{% endif %};" />
|
||||
{% else %}
|
||||
<a class="username">[deleted user]</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -200,7 +200,7 @@
|
|||
<script type="text/javascript">
|
||||
// Parse time elements
|
||||
var timeElems = document.getElementsByTagName('time');
|
||||
|
||||
|
||||
// Iterate over them
|
||||
for (var timeElem in timeElems) {
|
||||
// Attempt to parse it
|
||||
|
@ -213,8 +213,8 @@
|
|||
}
|
||||
}
|
||||
</script>
|
||||
{% if sakura.dev.showChangelog and php.self == '/index.php' and stats %}
|
||||
<script type="text/javascript" src="https://sakura.flash.moe/?get={{ sakura.versionInfo.version|slice(0, 4) }}-{{ sakura.versionInfo.version|slice(4, 2) }}-{{ sakura.versionInfo.version|slice(6, 2) }}&variable=true"></script>
|
||||
{% if sakura.dev.showChangelog and stats %}
|
||||
<script type="text/javascript" src="https://sakura.flash.moe/?get=all&limit=5&variable=true"></script>
|
||||
<script type="text/javascript">
|
||||
// Column colours for actions
|
||||
var changelogColours = [
|
||||
|
@ -227,55 +227,76 @@
|
|||
'#C44' // Revert
|
||||
];
|
||||
|
||||
window.addEventListener("load", function() {
|
||||
window.addEventListener("load", function () {
|
||||
// Check if the changelog variable is an object
|
||||
if(typeof changelog === 'object') {
|
||||
// Grab the index panel
|
||||
var indexPanel = document.getElementById('indexPanel');
|
||||
var _panel = document.getElementById('indexPanel');
|
||||
|
||||
// Create the head container
|
||||
var changelogTitle = document.createElement('div');
|
||||
changelogTitle.className = 'head';
|
||||
changelogTitle.style.marginBottom = '1px';
|
||||
var _cltitle = document.createElement('div');
|
||||
_cltitle.className = 'head';
|
||||
_cltitle.style.marginBottom = '1px';
|
||||
|
||||
// Create a link
|
||||
var changelogLink = document.createElement('a');
|
||||
changelogLink.className = 'underline';
|
||||
changelogLink.target = '_blank';
|
||||
changelogLink.href = 'https://sakura.flash.moe/#r{{ sakura.versionInfo.version }}';
|
||||
|
||||
// Create the text container
|
||||
var changelogTitleText = document.createTextNode('Changelog ({{ sakura.versionInfo.version|slice(0, 4) }}-{{ sakura.versionInfo.version|slice(4, 2) }}-{{ sakura.versionInfo.version|slice(6, 2) }})');
|
||||
var _cllink = document.createElement('a');
|
||||
_cllink.className = 'underline';
|
||||
_cllink.target = '_blank';
|
||||
_cllink.href = 'https://sakura.flash.moe/#r{{ sakura.versionInfo.version }}';
|
||||
|
||||
// Append everything
|
||||
changelogLink.appendChild(changelogTitleText);
|
||||
changelogTitle.appendChild(changelogLink);
|
||||
indexPanel.appendChild(changelogTitle);
|
||||
_cllink.appendChild(document.createTextNode('Changelog'));
|
||||
_cltitle.appendChild(_cllink);
|
||||
_panel.appendChild(_cltitle);
|
||||
|
||||
// Create changelog table
|
||||
var changelogTable = document.createElement('table');
|
||||
changelogTable.className = 'panelTable';
|
||||
var _cltable = document.createElement('table');
|
||||
_cltable.className = 'panelTable';
|
||||
_cltable.style.borderSpacing = '0 1px';
|
||||
|
||||
// Create and append all changelog entries
|
||||
for (var i in changelog) {
|
||||
// Create elements
|
||||
var changelogRow = document.createElement('tr');
|
||||
var changelogColumnAction = document.createElement('td');
|
||||
var changelogColumnMessage = document.createElement('td');
|
||||
for (var _s in changelog) {
|
||||
// Create header
|
||||
var _hr = document.createElement('tr');
|
||||
var _hri = document.createElement('td');
|
||||
|
||||
// Set data
|
||||
changelogColumnAction.appendChild(document.createTextNode(changelog[i]['change_action']['action_name']));
|
||||
changelogColumnAction.style.background = changelogColours[changelog[i]['change_action']['action_id']];
|
||||
changelogColumnMessage.appendChild(document.createTextNode(changelog[i]['change_message']));
|
||||
_hri.appendChild(document.createTextNode(_s));
|
||||
_hri.style.background = '#9475b2';
|
||||
_hri.style.color = '#306';
|
||||
_hri.style.fontWeight = '700';
|
||||
_hri.style.fontSize = '1.2em';
|
||||
_hri.setAttribute('colspan', '2');
|
||||
|
||||
// Append
|
||||
changelogRow.appendChild(changelogColumnAction);
|
||||
changelogRow.appendChild(changelogColumnMessage);
|
||||
changelogTable.appendChild(changelogRow);
|
||||
_hr.appendChild(_hri);
|
||||
_cltable.appendChild(_hr);
|
||||
|
||||
for (var _e in changelog[_s]) {
|
||||
// Reassign _e
|
||||
_e = changelog[_s][_e];
|
||||
|
||||
// Create elements
|
||||
var _clr = document.createElement('tr');
|
||||
var _clca = document.createElement('td');
|
||||
var _clcm = document.createElement('td');
|
||||
|
||||
// Set data
|
||||
_clca.appendChild(document.createTextNode(_e['change_action']['action_name']));
|
||||
_clca.style.background = changelogColours[_e['change_action']['action_id']];
|
||||
_clca.style.borderBottom = '1px solid ' + changelogColours[_e['change_action']['action_id']];
|
||||
_clcm.style.borderBottom = '1px solid ' + changelogColours[_e['change_action']['action_id']];
|
||||
_clcm.appendChild(document.createTextNode(_e['change_message']));
|
||||
|
||||
// Append
|
||||
_clr.appendChild(_clca);
|
||||
_clr.appendChild(_clcm);
|
||||
_cltable.appendChild(_clr);
|
||||
}
|
||||
}
|
||||
|
||||
// Append it to indexPanel
|
||||
indexPanel.appendChild(changelogTable);
|
||||
indexPanel.appendChild(_cltable);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
Reference in a new issue