Add offline-info message

So that visitors will be even less likely to miss the contact list
This commit is contained in:
om 2022-10-15 20:56:27 +02:00
parent 589b1aafbf
commit 97165d10f3
1 changed files with 99 additions and 1 deletions

View File

@ -235,8 +235,89 @@ function ImageChatMessage(symbol_id, is_myself) {
}
}
/// A class for holding a final message that says that the chat partner is offline
///
/// *ChatMessages are owned by a Dialog.
function OfflineChatMessage(dollar_message, _is_myself) {
let offline_message = dollar_message.substring(1);
let container = document.getElementById('messages');
// attributes
this.height = 0; // height on screen when fully visible
this.group = null; // a <g> with a transform=translate(0,y_shift) attribute
this.draw = function(y_offset, y_shift) {
let group = create_svg_node('g', {'transform': `translate(0, ${y_shift})`});
let height_so_far = y_offset;
function post_process(element) {
enable_scrolling(element);
height_so_far += line_height;
group.appendChild(element);
redraw_on_top(element);
}
let x = 101;
let bar = create_svg_node('rect', {
'x': `${x}%`,
'y': `${height_so_far + line_height}`,
'fill': '#CCCCCC',
'width': '90%',
'height': '4px'
});
post_process(bar);
height_so_far += 5; // spacing
let text = create_svg_node('text', {
'x': `${x}%`,
'y': `${height_so_far + line_height}`,
'font-size': `${line_height}px`,
'text-anchor': 'start'
});
text.appendChild(document.createTextNode(offline_message));
post_process(text);
let back_link_text = create_svg_node('text', {
'x': `${x}%`,
'y': `${height_so_far + line_height}`,
'font-size': `${line_height}px`,
'text-anchor': 'start',
'style': 'text-decoration: underline',
'fill': 'blue'
});
let back_link = create_svg_node('a', {
'href': 'javascript: swipe_viewport()',
});
let link_text = 'tilbage til kontaktlisten';
if(current_language == 'en') {
link_text = 'back to the contact list';
}
back_link_text.appendChild(document.createTextNode(link_text));
back_link.appendChild(back_link_text);
post_process(back_link);
container.appendChild(group);
this.height = height_so_far - y_offset;
this.group = group;
}
this.shift_y_pos = function(by) {
redraw_on_top(document.getElementById('contact_name_box'));
this.group.setAttribute('transform', `translate(0, ${by})`);
}
}
function create_chat_message(content, is_myself) {
let constr = (content.startsWith('#'))? ImageChatMessage: TextChatMessage;
let constr = null;
if(content.startsWith('#')) {
constr = ImageChatMessage;
} else if(content.startsWith('$')) {
constr = OfflineChatMessage;
} else {
constr = TextChatMessage;
}
return new constr(content, is_myself);
}
@ -394,9 +475,14 @@ function Dialog() {
release_send_button();
await post_message(this, message, true);
}
this.you = async function(message) {
await post_message(this, message, false);
}
this.end = async function(message) {
await post_message(this, `$${message}`, true);
}
}
async function type_message(dialog, message) {
@ -501,6 +587,7 @@ async function dialog_ven_da() {
await d.me('Alle vores beskeder skal scannes på grund af børn på nettet? Det lyder dumt!', true);
await d.you('Her kan du læse mere om det:');
await d.you('https://chatcontrol.dk');
await d.end('din ven er offline nu');
}
async function dialog_ven_en() {
@ -520,6 +607,7 @@ async function dialog_ven_en() {
await d.me('All of our messages will be scanned because of children on the internet? That sounds really stupid!', true);
await d.you('Here you can read more about it:');
await d.you('https://chatcontrol.dk');
await d.end('Your friend is offline now');
}
async function dialog_mor() {
@ -546,6 +634,7 @@ async function dialog_mor_da() {
await d.me('Det vil ikke være bare os to, som har adgang til vores private billeder');
await d.you('Det overrasker mig. Men så tænker jeg at jeg vil bare give dig en USB-nøgle næste gang du kommer på besøg');
await d.me('God idé. Tak :-)');
await d.end('Din mor er offline nu');
}
async function dialog_mor_en() {
@ -564,6 +653,7 @@ async function dialog_mor_en() {
await d.me('It won\'t be just us two who will have access to our private pictures');
await d.you('That surprises me. But then I think I will give you a USB stick next time you visit me');
await d.me('Good idea! Thanks :-)');
await d.end('Your mom is offline now');
}
async function dialog_kaereste() {
@ -589,6 +679,7 @@ async function dialog_kaereste_da() {
await d.me("Men i fremtiden vil det faktisk blive obligatorisk at scanne beskeder i EU");
await d.me('Og hvis der er beskeder som "ligner" børneporno får politiet en kopi af dem');
await d.you('Jeg vil heller ikke have at politiet får mine nøgenbilleder. Det er min krop og jeg vil selv bestemme over den!');
await d.end('Din kæreste er offline nu');
}
async function dialog_kaereste_en() {
@ -606,6 +697,7 @@ async function dialog_kaereste_en() {
await d.me('But in the future it will also become mandatory to scan chat messages in the EU');
await d.me('And if a message looks like child pornography then the police will get a copy of it');
await d.you("I don't want to share my nudes with the police. This is my body and I decide who I share it with!");
await d.end('Your better half is offline now');
}
async function dialog_politi() {
@ -627,6 +719,7 @@ async function dialog_politi_da() {
await d.you('Jeg vil heller ikke have at mine kolleger se hvad jeg skriver til min kæreste, kun fordi jeg hypotetisk kunne gøre noget illegalt');
await d.you('Tænk bare hvor absurd idén er: Hvorfor aflytter vi ikke bare alle telefoner? Der vil være nogle forbrydelser vi vil opdage!');
await d.you('Men så har vi masseovervågning og ikke længere et frit samfund.');
await d.end('Politibejenten er offline nu');
}
async function dialog_politi_en() {
@ -640,6 +733,7 @@ async function dialog_politi_en() {
await d.you("I don't like that my collegues can potentially see what I write to by partner, just because I could potentially do something illegal while chatting");
await d.you("Just think about how absurd the idea is: Why don't we wiretap all phones? There will be some crimes that we will detect!");
await d.you('But then we have total surveillance and no longer a free society.');
await d.end('The police officer is offline now');
}
async function dialog_support() {
@ -664,6 +758,7 @@ async function dialog_support_da() {
await d.you('Men det er desværre mit job at vedligeholde driften af overvågningen');
await d.me('Det løser ikke mit problem. Men tak for informationen. Jeg vil se hvad jeg kan gøre for at undgå overvågning i fremtiden', true);
await d.you('Beklager at jeg ikke kan gøre mere. Men jeg håber at du forstår situationen');
await d.end('Chatsupporten er offline nu');
}
async function dialog_support_en() {
@ -680,6 +775,7 @@ async function dialog_support_en() {
await d.you('But it is unfortunately my job to keep the surveillance working');
await d.me('That does not solve the problem. But thank you for the information. I will look for ways to avoid the surveillance in the future', true);
await d.you('I apologize that I can not offer something better. But I hope you understand the situation');
await d.end('The chat support is offline now');
}
async function dialog_nabopige() {
@ -710,6 +806,7 @@ async function dialog_nabopige_da() {
await d.you('Det er bedre hvis man har gode voksne venner som man har tillid til, end hvis der er en computer som læser alt hvad man skriver');
await d.me('helt enig');
await d.me('børn har også brug for fortrolighed!');
await d.end('Pigen er afsted nu');
}
async function dialog_nabopige_en() {
@ -732,6 +829,7 @@ async function dialog_nabopige_en() {
await d.you('It is better to have adult friends whom I can trust that a computer who reads everything that I write.');
await d.me('Completely agree');
await d.me('Children also need their secrets and confidentiality');
await d.end('The girl is gone now');
}

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 32 KiB