forked from openiap/opencore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonesignal.html
More file actions
160 lines (153 loc) · 6.3 KB
/
Copy pathonesignal.html
File metadata and controls
160 lines (153 loc) · 6.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<script type="text/x-red" data-template-name="onesignal-credentials">
<div class="form-row">
<label><i class="icon-bookmark"></i> restKey</label>
<input type="text" id="node-config-input-restKey">
</div>
<div class="form-row">
<label><i class="icon-bookmark"></i> appID</label>
<input type="text" id="node-config-input-appID">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('onesignal-credentials', {
category: 'config',
defaults: {
name: { value: "" }
},
credentials: {
restKey: { type: "text" },
appID: { type: "text" }
},
label: function () {
return this.host || "onesignal credentials";
}
});
</script>
<script type="text/x-red" data-template-name="onesignal create notification">
<div class="form-row">
<label for="node-input-config"><i class="fa fa-globe"></i> Config</label>
<input type="text" id="node-input-config">
</div>
<div class="form-row">
<label ><i class="fa fa-tag"></i> Included segments</label>
<input type="text" id="node-input-included_segments" placeholder="Segments diveded by comma">
</div>
<div class="form-row">
<label ><i class="fa fa-tag"></i> Excluded segments</label>
<input type="text" id="node-input-excluded_segments" placeholder="Segments diveded by comma">
</div>
<div class="form-row">
<label ><i class="fa fa-tag"></i> Include player ids</label>
<input type="text" id="node-input-include_player_ids" placeholder="Segments diveded by comma">
</div>
<div class="form-row">
<label ><i class="fa fa-tag"></i> CustomURL</label>
<input type="text" id="node-input-customurl" placeholder="Custom URL">
</div>
<div class="form-row">
<label ><i class="fa fa-tag"></i> URL</label>
<input type="text" id="node-input-url" placeholder="Deeplink URL">
</div>
<div class="form-row" style="margin-bottom: 0px;">
<label for="node-input-contents"><i class="fa fa-wrench"></i> EXAMPLE! payload</label>
<input type="hidden" id="node-input-contents" autofocus="autofocus">
<input type="hidden" id="node-input-noerr-contents">
</div>
<div class="form-row node-text-editor-row" style="position:relative">
<div style="position: absolute; right:0; bottom:calc(100% + 3px);"><button id="node-function-expand-js-contents" class="editor-button editor-button-small"><i class="fa fa-expand"></i></button></div>
<div style="height: 100px; min-height:100px;" class="node-text-editor" id="node-input-contents-editor" ></div>
</div>
<div class="form-row">
<label ><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Node name">
</div>
</script>
<script type="text/x-red" data-help-name="onesignal create notification">
Create notification <a href="https://documentation.onesignal.com/reference#create-notification">documentation</a>
</script>
<script type="text/javascript">
RED.nodes.registerType('onesignal create notification', {
category: 'onesignal',
color: "#a6bbcf",
defaults: {
name: { value: "" },
config: { value: "", type: "onesignal-credentials", required: true },
included_segments: { value: "", required: false },
excluded_segments: { value: "", required: false },
include_player_ids: { value: "", required: false },
url: { value: "", required: false },
customurl: { value: "", required: false },
contents: {
value:
`{ "en": "hi mom" }`, required: true
},
},
inputs: 1,
outputs: 1,
icon: "bridge.png",
label: function () {
return this.name || "create notification";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
oneditprepare: function () {
this.contentseditor = RED.editor.createEditor({
id: 'node-input-contents-editor',
mode: 'ace/mode/json',
value: $("#node-input-contents").val(),
globals: {
msg: false,
context: false,
RED: false,
util: true,
flow: false,
global: false,
console: false,
Buffer: true,
setTimeout: false,
clearTimeout: false,
setInterval: false,
clearInterval: false
}
});
this.contentseditor.focus();
const that = this;
$("#node-function-expand-js-contents").click(function (e) {
e.preventDefault();
const value = that.contentseditor.getValue();
RED.editor.editJavaScript({
value: value,
width: "Infinity",
cursor: that.contentseditor.getCursorPosition(),
mode: "ace/mode/json",
complete: function (v, cursor) {
that.contentseditor.setValue(v, -1);
that.contentseditor.gotoLine(cursor.row + 1, cursor.column, false);
setTimeout(function () {
that.contentseditor.focus();
}, 300);
}
})
});
},
oneditsave: function () {
this.noerr = 0;
const annot = this.contentseditor.getSession().getAnnotations();
$("#node-input-noerr-contents").val(0);
for (let k = 0; k < annot.length; k++) {
if (annot[k].type === "error") {
$("#node-input-noerr-contents").val(annot.length);
this.noerr = annot.length;
}
}
$("#node-input-contents").val(this.contentseditor.getValue());
this.contentseditor.destroy();
delete this.contentseditor;
},
oneditcancel: function () {
this.contentseditor.destroy();
delete this.contentseditor;
},
});
</script>