This commit is contained in:
Andreas Kristiansen
2024-04-20 11:41:02 +02:00
5 changed files with 50 additions and 37 deletions

View File

@@ -52,6 +52,7 @@
<script type="text/javascript" src="<?php echo base_url() ;?>assets/js/sections/common.js"></script>
<script type="text/javascript" src="<?php echo base_url() ;?>assets/js/sections/eqslcharcounter.js"></script>
<script type="text/javascript" src="<?php echo base_url() ;?>assets/js/sections/version_dialog.js"></script>
<script type="text/javascript" src="<?php echo base_url() ;?>assets/js/showdown.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/htmx.min.js"></script>

View File

@@ -25,44 +25,45 @@
}
if ($versionDialogMode == 'release_notes' || $versionDialogMode == 'both' || $versionDialogMode == 'disabled') {
?>
<div>
<?php
$url = 'https://api.github.com/repos/wavelog/wavelog/releases';
$options = [
'http' => [
'header' => 'User-Agent: Wavelog - Amateur Radio Logbook'
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
<div>
<?php
$url = 'https://api.github.com/repos/wavelog/wavelog/releases';
$options = [
'http' => [
'header' => 'User-Agent: Wavelog - Amateur Radio Logbook'
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
if ($response !== false) {
$data = json_decode($response, true);
if ($response !== false) {
$data = json_decode($response, true);
$current_version=$this->optionslib->get_option('version');
if ($data !== null && !empty($data)) {
foreach ($data as $singledata) {
if ($singledata['tag_name']==$current_version) {
$firstRelease = $singledata;
continue;
}
}
$current_version = $this->optionslib->get_option('version');
if ($data !== null && !empty($data)) {
foreach ($data as $singledata) {
if ($singledata['tag_name'] == $current_version) {
$firstRelease = $singledata;
continue;
}
}
$releaseBody = isset($firstRelease['body']) ? $firstRelease['body'] : 'No release information available';
$htmlReleaseBody = htmlspecialchars($releaseBody);
$htmlReleaseBodyWithLinks = preg_replace('/(https?:\/\/[^\s<]+)/', '<a href="$1" target="_blank">$1</a>', $htmlReleaseBody);
$releaseBody = isset($firstRelease['body']) ? $firstRelease['body'] : 'No release information available';
$htmlReleaseBody = htmlspecialchars($releaseBody);
$htmlReleaseBodyWithLinks = preg_replace('/(https?:\/\/[^\s<]+)/', '<a href="$1" target="_blank">$1</a>', $htmlReleaseBody);
$releaseName = isset($firstRelease['name']) ? $firstRelease['name'] : 'No version name information available';
echo "<h4>".$releaseName."</h4>";
echo nl2br($htmlReleaseBodyWithLinks);
$releaseName = isset($firstRelease['name']) ? $firstRelease['name'] : 'No version name information available';
echo "<h4>" . $releaseName . "</h4>";
echo "<div id='markdownDiv' style='display: none;'>" . $releaseBody . "</div>";
echo "<div id='formattedHTMLDiv'></div>";
} else {
echo 'Error at parsing JSON-Data or got empty result from github.';
}
} else {
echo 'Error at parsing JSON-Data or got empty result from github.';
echo 'Error at getting the data from GitHub.';
}
} else {
echo 'Error at getting the data from GitHub.';
}
?>
</div>
?>
</div>
<?php
}
?>
@@ -71,7 +72,7 @@
<?php
if ($versionDialogMode !== 'disabled') {
?>
<button class="btn btn-secondary" onclick="dismissVersionDialog()" data-bs-dismiss="modal"><?php echo lang('options_version_dialog_dismiss'); ?></button>
<button class="btn btn-secondary" onclick="dismissVersionDialog()" data-bs-dismiss="modal"><?php echo lang('options_version_dialog_dismiss'); ?></button>
<?php
}
?>

View File

@@ -19,7 +19,15 @@ $('#version_dialog_mode').on('change', function () {
showCustomTextarea();
});
// JavaScript-Funktion displayVersionDialog für Bootstrap 5
function markdownToHTML() {
var markdownContent = $('#markdownDiv').text();
var converter = new showdown.Converter({
simplifiedAutoLink: true
});
var html = converter.makeHtml(markdownContent);
$('#formattedHTMLDiv').html(html);
}
function displayVersionDialog() {
$.ajax({
@@ -29,13 +37,12 @@ function displayVersionDialog() {
success: function(data) {
$('body').append(data);
// Aktiviere das Bootstrap-Modal
var versionDialogModal = new bootstrap.Modal(document.getElementById('versionDialogModal'));
versionDialogModal.show();
markdownToHTML();
},
error: function() {
// Behandlung von Fehlern
console.log('Fehler beim Laden der PHP-Datei.');
console.log('Error loading the versiondialog view.');
}
});
}

3
assets/js/showdown.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long