<commit_before>/**
 * @name      ElkArte Forum
 * @copyright ElkArte Forum contributors
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause
 *
 * This software is a derived product, based on:
 *
 * Simple Machines Forum (SMF)
 * copyright:	2011 Simple Machines (http://www.simplemachines.org)
 * license:		BSD, See included LICENSE.TXT for terms and conditions.
 *
 * @version 1.0
 *
 * Handle the JavaScript surrounding the admin and moderation center.
 */

/**
 * Admin index class with the following methods
 * elk_AdminIndex(oOptions)
 * {
 *		public init()
 *		public loadAdminIndex()
 *		public setAnnouncements()
 *		public showCurrentVersion()
 *		public checkUpdateAvailable()
 * }
 *
 * @param {object} oOptions
 */
function elk_AdminIndex(oOptions)
{
	this.opt = oOptions;
	this.announcements = [];
	this.current = {};
	this.init_news = false;
	this.init();
}

// Initialize the admin index to handle annoucment, currentversion and updates
elk_AdminIndex.prototype.init = function ()
{
	window.adminIndexInstanceRef = this;

	var fHandlePageLoaded = function () {
		window.adminIndexInstanceRef.loadAdminIndex();
	};

	addLoadEvent(fHandlePageLoaded);
};

elk_AdminIndex.prototype.loadAdminIndex = function ()
{
	// Load the current master and your version numbers.
	if (this.opt.bLoadVersions)
		this.showCurrentVersion();

	// Load the text box that says there's a new version available.
	if (this.opt.bLoadUpdateNotification)
		this.checkUpdateAvailable();
};

// Update the announcement container with news
elk_AdminIndex.prototype.setAnnouncement = function (announcement)
{
	var oElem = document.getElementById(this.opt.sAnnouncementContainerId),
		sMessages = this.init_news ? oElem.innerHTML : '',
		sMessage = '';

	sMessage = this.opt.sAnnouncementMessageTemplate.replace('%href%', announcement.html_url).replace('%subject%', announcement.name).replace('%time%', announcement.published_at.replace(/[TZ]/g, ' ')).replace('%message%', announcement.body);

	oElem.innerHTML = sMessages + this.opt.sAnnouncementTemplate.replace('%content%', sMessage);
	this.init_news = true;
};

// Updates the current version container with the current version found in the repository
elk_AdminIndex.prototype.showCurrentVersion = function ()
{
	var oElkVersionContainer = document.getElementById(this.opt.slatestVersionContainerId),
		oinstalledVersionContainer = document.getElementById(this.opt.sinstalledVersionContainerId),
		sCurrentVersion = oinstalledVersionContainer.innerHTML,
		adminIndex = this,
		elkVersion = '???',
		verCompare = new elk_ViewVersions();
<commit_msg>Make news in the admin panel look good - partially fixes #1852<commit_after>/**
 * @name      ElkArte Forum
 * @copyright ElkArte Forum contributors
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause
 *
 * This software is a derived product, based on:
 *
 * Simple Machines Forum (SMF)
 * copyright:	2011 Simple Machines (http://www.simplemachines.org)
 * license:		BSD, See included LICENSE.TXT for terms and conditions.
 *
 * @version 1.0
 *
 * Handle the JavaScript surrounding the admin and moderation center.
 */

/**
 * Admin index class with the following methods
 * elk_AdminIndex(oOptions)
 * {
 *		public init()
 *		public loadAdminIndex()
 *		public setAnnouncements()
 *		public showCurrentVersion()
 *		public checkUpdateAvailable()
 * }
 *
 * @param {object} oOptions
 */
function elk_AdminIndex(oOptions)
{
	this.opt = oOptions;
	this.announcements = [];
	this.current = {};
	this.init_news = false;
	this.init();
}

// Initialize the admin index to handle annoucment, currentversion and updates
elk_AdminIndex.prototype.init = function ()
{
	window.adminIndexInstanceRef = this;

	var fHandlePageLoaded = function () {
		window.adminIndexInstanceRef.loadAdminIndex();
	};

	addLoadEvent(fHandlePageLoaded);
};

elk_AdminIndex.prototype.loadAdminIndex = function ()
{
	// Load the current master and your version numbers.
	if (this.opt.bLoadVersions)
		this.showCurrentVersion();

	// Load the text box that says there's a new version available.
	if (this.opt.bLoadUpdateNotification)
		this.checkUpdateAvailable();
};

// Update the announcement container with news
elk_AdminIndex.prototype.setAnnouncement = function (announcement)
{
	var oElem = document.getElementById(this.opt.sAnnouncementContainerId),
		sMessages = this.init_news ? oElem.innerHTML : '',
		sMessage = '';

	sMessage = this.opt.sAnnouncementMessageTemplate.replace('%href%', announcement.html_url).replace('%subject%', announcement.name).replace('%time%', announcement.published_at.replace(/[TZ]/g, ' ')).replace('%message%', announcement.body).replace(/\n/g, '<br />').replace(/\r/g, '');

	oElem.innerHTML = sMessages + this.opt.sAnnouncementTemplate.replace('%content%', sMessage);
	this.init_news = true;
};

// Updates the current version container with the current version found in the repository
elk_AdminIndex.prototype.showCurrentVersion = function ()
{
	var oElkVersionContainer = document.getElementById(this.opt.slatestVersionContainerId),
		oinstalledVersionContainer = document.getElementById(this.opt.sinstalledVersionContainerId),
		sCurrentVersion = oinstalledVersionContainer.innerHTML,
		adminIndex = this,
		elkVersion = '???',
		verCompare = new elk_ViewVersions();

{'fraction_non_alphanumeric': 0.1183936351581739, 'fraction_numerical': 0.0034097366925554084, 'mean_word_length': 4.952649379932356, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5373087', 'n_tokens_mistral': 1621, 'n_tokens_neox': 1561, 'n_words': 374}