From 2346257c47e7b9e05d2f250bcb3226986a6cd789 Mon Sep 17 00:00:00 2001 From: isi07 <65848350+isi07@users.noreply.github.com> Date: Tue, 13 Aug 2024 22:17:08 +0200 Subject: [PATCH] add HTML/monospace options to block add HTML/monospace options to block -none -html=1 -monospace=1 --- admin/blockly.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/admin/blockly.js b/admin/blockly.js index 3d1870c..1856c36 100644 --- a/admin/blockly.js +++ b/admin/blockly.js @@ -32,6 +32,10 @@ Blockly.Words['pushover_high'] = {'en': 'high priority', Blockly.Words['pushover_quiet'] = {'en': 'quiet', 'de': 'Leise', 'ru': 'тихое'}; Blockly.Words['pushover_confirmation'] = {'en': 'with confirmation', 'de': 'Mit Bestätigung', 'ru': 'с подтверждением'}; Blockly.Words['pushover_ttl'] = {'en': 'TTL in seconds (optional)', 'de': 'Dauer in Sekunden (optional)', 'ru': 'время жизни в сек. (не обяз.)'}; +Blockly.Words['pushover_format'] = {'en': 'formatting (optional)', 'de': 'Formatierung (optional)', 'ru': 'форматирование (не обяз.)'}; +Blockly.Words['pushover_format_html'] = {'en': 'HTML', 'de': 'HTML', 'ru': 'HTML'}; +Blockly.Words['pushover_format_mono'] = {'en': 'monospace', 'de': 'monospace', 'ru': 'monospace'}; +Blockly.Words['pushover_format_none'] = {'en': 'none', 'de': 'keine', 'ru': 'никто'}; Blockly.Words['pushover_sound_default'] = {'en': 'default', 'de': 'normal', 'ru': 'по умолчанию'}; Blockly.Words['pushover_sound_pushover'] = {'en': 'pushover', 'de': 'pushover', 'ru': 'pushover'}; @@ -214,6 +218,14 @@ Blockly.Blocks['pushover'] = { input.connection._optional = true; } + this.appendDummyInput('FORMAT') + .appendField(Blockly.Translate('pushover_format')) + .appendField(new Blockly.FieldDropdown([ + [Blockly.Translate('pushover_format_none'), 'none'], + [Blockly.Translate('pushover_format_html'), 'html'], + [Blockly.Translate('pushover_format_mono'), 'monospace'], + ]), 'FORMAT'); + this.setInputsInline(false); this.setPreviousStatement(true, null); this.setNextStatement(true, null); @@ -230,6 +242,7 @@ Blockly.JavaScript['pushover'] = function(block) { const message = Blockly.JavaScript.valueToCode(block, 'MESSAGE', Blockly.JavaScript.ORDER_ATOMIC); const customSound = Blockly.JavaScript.valueToCode(block, 'SOUND_CUSTOM', Blockly.JavaScript.ORDER_ATOMIC); + let text = '{\n'; text += ` message: ${message},\n`; if (customSound && customSound !== "''") { @@ -283,6 +296,18 @@ Blockly.JavaScript['pushover'] = function(block) { text += ` ttl: ${ttl},\n`; } + const format = block.getFieldValue('FORMAT'); + switch (format){ + case 'html': + text += ` html: 1,\n`; + break; + case 'monospace': + text += ` monospace: 1,\n`; + break; + default: + break; + } + text += '}'; let logText = '';