<commit_before>/* globals pageDetect, icons */

'use strict';

window.markUnread = (() => {
	function stripHash(url) {
		return url.replace(/#.+$/, '');
	}

	function addMarkUnreadButton() {
		const button = $('<button class="btn btn-sm btn-mark-unread js-mark-unread">Mark as unread</button>');
		$('.js-thread-subscription-status').append(button);
	}

	function markRead(url) {
		const unreadNotifications = JSON.parse(localStorage.unreadNotifications || '[]');
		unreadNotifications.forEach((notification, index) => {
			if (notification.url === url) {
				unreadNotifications.splice(index, 1);
			}
		});

		localStorage.unreadNotifications = JSON.stringify(unreadNotifications);
	}

	function markUnread() {
		$(this).attr('disabled', 'disabled');
		$(this).text('Marked as unread');

		const participants = $('.participant-avatar').toArray().map(el => {
			const $el = $(el);

			return {
				username: $el.attr('aria-label'),
				avatar: $el.find('img').attr('src')
			};
		});

		const {ownerName, repoName} = pageDetect.getOwnerAndRepo();
		const repository = `${ownerName}/${repoName}`;
		const title = $('.js-issue-title').text().trim();
		const type = pageDetect.isPR() ? 'pull-request' : 'issue';
		const url = stripHash(location.href);

		const stateLabel = $('.gh-header-meta .state');
		let state;

		if (stateLabel.hasClass('state-open')) {
			state = 'open';
		}

		if (stateLabel.hasClass('state-merged')) {
			state = 'merged';
		}

		if (stateLabel.hasClass('state-closed')) {
			state = 'closed';
		}

		const lastCommentTime = $('.timeline-comment-header:last relative-time');
		const dateTitle = lastCommentTime.attr('title');
		const date = lastCommentTime.attr('datetime');

		const unreadNotifications = JSON.parse(localStorage.unreadNotifications || '[]');
		unreadNotifications.push({
			participants,
			repository,
			title,
			state,
			type,
			dateTitle,
			date,
			url
		});

		localStorage.unreadNotifications = JSON.stringify(unreadNotifications);
	}<commit_msg>Fix unread "undefined" icon (#426)<commit_after>/* globals pageDetect, icons */

'use strict';

window.markUnread = (() => {
	function stripHash(url) {
		return url.replace(/#.+$/, '');
	}

	function addMarkUnreadButton() {
		const button = $('<button class="btn btn-sm btn-mark-unread js-mark-unread">Mark as unread</button>');
		$('.js-thread-subscription-status').append(button);
	}

	function markRead(url) {
		const unreadNotifications = JSON.parse(localStorage.unreadNotifications || '[]');
		unreadNotifications.forEach((notification, index) => {
			if (notification.url === url) {
				unreadNotifications.splice(index, 1);
			}
		});

		localStorage.unreadNotifications = JSON.stringify(unreadNotifications);
	}

	function markUnread() {
		$(this).attr('disabled', 'disabled');
		$(this).text('Marked as unread');

		const participants = $('.participant-avatar').toArray().map(el => {
			const $el = $(el);

			return {
				username: $el.attr('aria-label'),
				avatar: $el.find('img').attr('src')
			};
		});

		const {ownerName, repoName} = pageDetect.getOwnerAndRepo();
		const repository = `${ownerName}/${repoName}`;
		const title = $('.js-issue-title').text().trim();
		const type = pageDetect.isPR() ? 'pull-request' : 'issue';
		const url = stripHash(location.href);

		const stateLabel = $('.gh-header-meta .State');
		let state;

		if (stateLabel.hasClass('State--green')) {
			state = 'open';
		}

		if (stateLabel.hasClass('State--purple')) {
			state = 'merged';
		}

		if (stateLabel.hasClass('State--red')) {
			state = 'closed';
		}

		const lastCommentTime = $('.timeline-comment-header:last relative-time');
		const dateTitle = lastCommentTime.attr('title');
		const date = lastCommentTime.attr('datetime');

		const unreadNotifications = JSON.parse(localStorage.unreadNotifications || '[]');
		unreadNotifications.push({
			participants,
			repository,
			title,
			state,
			type,
			dateTitle,
			date,
			url
		});

		localStorage.unreadNotifications = JSON.stringify(unreadNotifications);
	}
{'fraction_non_alphanumeric': 0.1790154152163103, 'fraction_numerical': 0.0012431626056688214, 'mean_word_length': 4.1976744186046515, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1171396', 'n_tokens_mistral': 1489, 'n_tokens_neox': 1292, 'n_words': 234}