forked from Offerel/roundcube_primitivenotes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
primitivenotes.js
104 lines (99 loc) · 3.2 KB
/
primitivenotes.js
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
/**
* Roundcube Notes Plugin
*
* @version 1.5.4
* @author Offerel
* @copyright Copyright (c) 2019, Offerel
* @license GNU General Public License, version 3
*/
window.rcmail && rcmail.addEventListener("init", function(a) {
rcmail.register_command("newnote", new_note, !0);
rcmail.register_command("editnote", edit_note, !0);
rcmail.register_command("deletenote", delete_note, !0);
rcmail.register_command("sendnote", send_note, !0);
rcmail.register_command("addnote", add_note, !0);
rcmail.register_command("htmlnote", new_note, !0);
rcmail.register_command("mdnote", new_note, !0);
rcmail.register_command("txtnote", new_note, !0);
});
function add_note() {
document.getElementById("upl").click()
}
function new_note(a) {
format = a ? a : "";
$.ajax({
type: "POST",
url: "plugins/primitivenotes/notes.php",
data: {
editHeader: "1",
filename: ""
},
success: function(a) {
$("#notescontentframe").contents().find("div#main_header").html(a)
}
});
$.ajax({
type: "POST",
url: "plugins/primitivenotes/notes.php",
data: {
editNote: "1",
filename: "",
format: format
},
success: function(a) {
$("#notescontentframe").contents().find("div#main_area").html(a)
}
})
}
function edit_note() {
var a = window.frames.notescontentframe.document.getElementById("fname").value,
b = a.substr(a.lastIndexOf(".") + 1);
$.ajax({
type: "POST",
url: "plugins/primitivenotes/notes.php",
data: {
editHeader: "1",
filename: a
},
success: function(a) {
$("#notescontentframe").contents().find("div#main_header").html(a)
}
});
0 <= ["html", "txt", "md"].indexOf(b) && $.ajax({
type: "POST",
url: "plugins/primitivenotes/notes.php",
data: {
editNote: "1",
filename: a
},
success: function(a) {
$("#notescontentframe").contents().find("div#main_area").html(a)
}
})
}
function delete_note() {
var a = window.frames.notescontentframe.document.getElementById("fname").value,
b = window.frames.notescontentframe.document.getElementById("headerTitle").innerHTML,
c = rcmail.gettext("note_del_note", "primitivenotes").replace("%note%", b);
if (a && b)
if (confirm(c)) $.ajax({
url: "plugins/primitivenotes/notes.php",
type: "post",
data: {
delNote: "1",
mode: "delete",
fileid: a
},
success: function(a) {
document.getElementById("notescontentframe").src = "plugins/primitivenotes/notes.php"
}
});
else return !1
}
function send_note() {
var a = window.frames.notescontentframe.document.getElementById("fname").value,
b = a.substring(a.lastIndexOf(".") + 1); - 1 < "html pdf jpg png md txt".split(" ").indexOf(b) ? rcmail.goto_url("mail/compose", {
_note_type: b,
_note_filename: a
}, !0) : alert(rcmail.gettext("note_inv_format", "primitivenotes"))
};