[BS5] move showWhatsNewModal
This commit is contained in:
@@ -794,61 +794,4 @@ jQuery(function($){
|
||||
$('#add_f2b_regex_row').click(function() {
|
||||
add_table_row($('#f2b_regex_table'), "f2b_regex");
|
||||
});
|
||||
|
||||
// show whats new modal
|
||||
if (mailcow_info.updatedAt > last_login){
|
||||
var parsedSeenTimestamp = parseInt(localStorage.getItem("seenChangelog"));
|
||||
if (!isNaN(parsedSeenTimestamp) && mailcow_info.updatedAt < parsedSeenTimestamp) {
|
||||
console.log("changelog seen");
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: 'https://api.github.com/repos/' + mailcow_info.project_owner + '/' + mailcow_info.project_repo + '/releases/tags/' + mailcow_info.version_tag,
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
var md = window.markdownit();
|
||||
var result = md.render(data.body);
|
||||
result = parseLinks(result);
|
||||
|
||||
$('#showWhatsNew').find(".modal-body").html(`
|
||||
<h3>` + data.name + `</h3>
|
||||
<span class="mt-4">` + result + `</span>
|
||||
`);
|
||||
|
||||
localStorage.setItem("seenChangelog", Math.floor(Date.now() / 1000).toString());
|
||||
}
|
||||
});
|
||||
|
||||
new bootstrap.Modal(document.getElementById("showWhatsNew"), {
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
}).show();
|
||||
}
|
||||
|
||||
function parseLinks(inputText) {
|
||||
var replacedText, replacePattern1;
|
||||
|
||||
replacePattern1 = /(\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
|
||||
replacedText = inputText.replace(replacePattern1, (matched, index, original, input_string) => {
|
||||
if (matched.includes('github.com')){
|
||||
// return short link if it's github link
|
||||
last_uri_path = matched.split('/');
|
||||
last_uri_path = last_uri_path[last_uri_path.length - 1];
|
||||
|
||||
// adjust Full Changelog link to match last git version and new git version, if link is a compare link
|
||||
if (matched.includes('/compare/') && mailcow_info.last_version_tag !== ''){
|
||||
matched = matched.replace(last_uri_path, mailcow_info.last_version_tag + '...' + mailcow_info.version_tag);
|
||||
last_uri_path = mailcow_info.last_version_tag + '...' + mailcow_info.version_tag;
|
||||
}
|
||||
|
||||
return '<a href="' + matched + '" target="_blank">' + last_uri_path + '</a><br>';
|
||||
};
|
||||
|
||||
// if it's not a github link, return complete link
|
||||
return '<a href="' + matched + '" target="_blank">' + matched + '</a>';
|
||||
});
|
||||
|
||||
return replacedText;
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user