alerts v2, formatting

This commit is contained in:
NunoSempere 2023-06-17 00:29:27 -06:00
parent 1cf68bb1fe
commit 98f6d5630f
8 changed files with 115 additions and 119 deletions

View File

@ -4,4 +4,3 @@ void str_init(char* str, int n)
str[i] = ' ';
str[n] = '\0';
} // could also use <https://manpages.ubuntu.com/manpages/impish/man3/strinit.3pub.html>

View File

@ -2,8 +2,8 @@
#include <stdio.h>
#include <string.h>
#include "../libre_redirect/str_replace_start.h"
#include "../libre_redirect/str_init.h"
#include "../libre_redirect/str_replace_start.h"
#define SHORTCUT_N 41

View File

@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define STYLE_N 3640 + 1
#define STYLE_N 3858 + 1
void read_style_js(char* string)
{

View File

@ -1,7 +1,7 @@
#ifndef STYLE
#define STYLE
#define STYLE_N 3640 + 1
#define STYLE_N 3858 + 1
void read_style_js(char* string);

View File

@ -73,37 +73,19 @@ if(styles != null){
// Replace default alert with new function
// whose style can be changed!
window.alert = function(message) {
// Check if the alert dialog already exists
var alertDiv = document.getElementById('customAlert');
window.alert = (message) => {
let alertDiv = document.getElementById('customAlert');
if (!alertDiv) {
// Create the alert dialog
alertDiv = document.createElement('div');
alertDiv.id = 'customAlert';
alertDiv.className = 'custom-alert hidden';
var contentDiv = document.createElement('div');
contentDiv.className = 'custom-alert-content';
var alertMessage = document.createElement('p');
alertMessage.id = 'alertMessage';
var okButton = document.createElement('button');
okButton.id = 'alertOkButton';
okButton.textContent = 'OK';
okButton.onclick = function() {
alertDiv.classList.add('hidden');
};
contentDiv.appendChild(alertMessage);
contentDiv.appendChild(okButton);
alertDiv.appendChild(contentDiv);
document.body.appendChild(alertDiv);
// Inject CSS
var style = document.createElement('style');
style.innerHTML = `
const html = `
<div id="customAlert" class="custom-alert">
<div class="custom-alert-content">
<p id="alertMessage"></p>
<button id="alertOkButton">OK</button>
</div>
</div>
<style>
.custom-alert {
display: none;
position: fixed;
z-index: 999;
left: 0;
@ -119,17 +101,33 @@ window.alert = function(message) {
padding: 20px;
border: 1px solid #888;
width: 80%;
font-family: monospace; /* Use monospace font */
}
.hidden {
display: none;
}`;
document.head.appendChild(style);
.visible {
display: block;
}
</style>
`;
document.body.insertAdjacentHTML('beforeend', html);
alertDiv = document.getElementById('customAlert');
document.getElementById('alertOkButton').onclick = () => {
alertDiv.classList.remove('visible');
document.removeEventListener('keydown', dismissAlert);
};
}
// Show the alert dialog
document.getElementById('alertMessage').textContent = message;
alertDiv.classList.remove('hidden');
const dismissAlert = (event) => {
if (event.key === 'Enter' /*&& event.ctrlKey*/ && alertDiv.classList.contains('visible')) {
alertDiv.classList.remove('visible');
document.removeEventListener('keydown', dismissAlert);
}
}
document.addEventListener('keydown', dismissAlert);
document.getElementById('alertMessage').textContent = message;
alertDiv.classList.add('visible');
}
// alert("Hello world!")
document.body.style.visibility = "visible"

BIN
rose

Binary file not shown.

1
rose.c
View File

@ -111,7 +111,6 @@ void load_uri(WebKitWebView* view, const char* uri)
snprintf(tmp, sizeof(tmp), SEARCH, uri);
webkit_web_view_load_uri(view, tmp);
}
}
}