Skip to content

Commit

Permalink
Merge pull request #402 from isi07/html
Browse files Browse the repository at this point in the history
add HTML/monospace options to block
  • Loading branch information
GermanBluefox authored Aug 17, 2024
2 parents eb6a140 + 2346257 commit 078d62b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions admin/blockly.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'};
Expand Down Expand Up @@ -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);
Expand All @@ -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 !== "''") {
Expand Down Expand Up @@ -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 = '';
Expand Down

0 comments on commit 078d62b

Please sign in to comment.