Skip to content

Commit

Permalink
Review pages: run JS code per review type; fix #670
Browse files Browse the repository at this point in the history
  • Loading branch information
makyen committed Aug 21, 2019
1 parent dbbbe20 commit 1e64dc7
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions app/javascript/review.js
Expand Up @@ -33,13 +33,26 @@ route(/\/review\/[\w-]+\/?\d*$/i, async () => {
const html = await response.text();
$('.review-item-container').html(html);

const postTitle = $('h4')[0].firstChild.textContent.trim();
const postID = $('h4 a').attr('href').replace(/^\D*(\d+)/, '$1');
const relativeUrl = $('.review-submit-link').first().attr('href').replace(/\?.*/, '');
const reviewID = relativeUrl.match(/\d+/)[0];
const title = `Review ${reviewID}: post ID ${postID}: ${postTitle} - metasmoke`;
document.title = title;
history.pushState({}, title, relativeUrl);
try {
if (window.location.pathname.indexOf('/review/posts') === 0) {
const postTitle = $('h4')[0].firstChild.textContent.trim();
const postID = $('h4 a').attr('href').replace(/^\D*(\d+)/, '$1');
const relativeUrl = $('.review-submit-link').first().attr('href').replace(/\?.*/, '');
const reviewID = relativeUrl.match(/\d+/)[0];
const title = `Posts Review ${reviewID}: post ID ${postID}: ${postTitle} - metasmoke`;
document.title = title;
history.pushState({}, title, relativeUrl);
}
else if (window.location.pathname.indexOf('/review/untagged-domains') === 0) {
document.title = 'Review Untagged Domains - metasmoke';
}
else if (window.location.pathname.indexOf('/review/admin-flags') === 0) {
document.title = 'Review Admin Flags - metasmoke';
}
}
catch (err) {
console.error(err); // eslint-disable-line no-console
}

installSelectpickers();
};
Expand Down

0 comments on commit 1e64dc7

Please sign in to comment.