|
24 | 24 | }); |
25 | 25 | } |
26 | 26 |
|
| 27 | + function ocUrl(url) { |
| 28 | + var newurl = OC.linkTo("ownnote",url).replace("apps/ownnote","index.php/apps/ownnote"); |
| 29 | + return newurl; |
| 30 | + } |
| 31 | + |
| 32 | + function ocVar(val) { |
| 33 | + var newval = encodeURIComponent(val); |
| 34 | + return newval; |
| 35 | + } |
| 36 | + |
27 | 37 | function resizeFont(s) { |
28 | 38 | $('#editable_ifr').contents().find("head").append($("<style type='text/css'> body{font-size:"+s+"px;} </style>")); |
29 | 39 | } |
30 | 40 |
|
31 | 41 | function deleteNote(id) { |
32 | | - var url = OC.linkTo("ownnote","ajax/delete.php"); |
33 | | - url += "?id=" + $(this).attr('id'); |
34 | | - $.get(url, function(data) { |
| 42 | + var n = ocVar($(this).attr('id')); |
| 43 | + $.post(ocUrl("api/v0.2/ownnote/del"), { note: n }, function (data) { |
35 | 44 | loadListing(); |
36 | 45 | }); |
37 | 46 | } |
|
43 | 52 | if (f[0] == '[') { |
44 | 53 | g = f.match(/\[(.*?)\]/i)[1]; |
45 | 54 | } |
46 | | - var url = OC.linkTo("ownnote","ajax/edit.php"); |
47 | | - url += "?id=" + f; |
48 | | - $.get(url, function(data) { |
| 55 | + $.post(ocUrl("api/v0.2/ownnote/edit"), { note: f }, function (data) { |
49 | 56 | buildEdit(t, g, data); |
50 | 57 | }); |
51 | 58 | } |
|
108 | 115 | editfilename = '['+editgroup+'] '+editfilename; |
109 | 116 | if (originalgroup != '') |
110 | 117 | originalfilename = '['+originalgroup+'] '+originalfilename; |
111 | | - $.post(OC.linkTo("ownnote","ajax/rename.php"), { originalfilename: originalfilename, editfilename: editfilename }, function (data) { |
| 118 | + $.post(ocUrl("api/v0.2/ownnote/ren"), { note: originalfilename, newnote: editfilename }, function (data) { |
112 | 119 | if (data == "SUCCESS") { |
113 | | - $.post(OC.linkTo("ownnote","ajax/save.php"), { content: content, editfilename: editfilename }, function (data) { |
| 120 | + $.post(ocUrl("api/v0.2/ownnote/save"), { content: content, note: editfilename }, function (data) { |
114 | 121 | loadListing(); |
115 | 122 | }); |
116 | 123 | } |
117 | 124 | }); |
118 | 125 | } else { |
119 | 126 | if (editgroup != '') |
120 | 127 | editfilename = '['+editgroup+'] '+editfilename; |
121 | | - $.post(OC.linkTo("ownnote","ajax/save.php"), { content: content, editfilename: editfilename }, function (data) { |
| 128 | + $.post(ocUrl("api/v0.2/ownnote/save"), { content: content, note: editfilename }, function (data) { |
122 | 129 | loadListing(); |
123 | 130 | }); |
124 | 131 | } |
|
131 | 138 | var sortorder = "ascending"; |
132 | 139 |
|
133 | 140 | function loadListing() { |
134 | | - $.get(OC.linkTo("ownnote","ajax/listing.php"), function(data) { |
| 141 | + var url = ocUrl("api/v0.2/ownnote"); |
| 142 | + $.get(url, function(data) { |
135 | 143 | filelist = data; |
136 | 144 | listing = jQuery.parseJSON(filelist); |
137 | 145 | buildNav('All'); |
|
220 | 228 | if (listing[i].timediff < 30) |
221 | 229 | fileclass = 'modified latestfile'; |
222 | 230 | html += "<div class='listing'>"; |
223 | | - html += " <div id='"+listing[i].file+"' title='"+listing[i].filename+"' class='file pointer'>"+listing[i].filename+"</div>"; |
| 231 | + html += " <div id='"+listing[i].file.replace('.htm','')+"' title='"+listing[i].filename+"' class='file pointer'>"+listing[i].filename+"</div>"; |
224 | 232 | html += " <div class='info'>"; |
225 | 233 | if (listing[i].timestring != '') |
226 | 234 | html += " <div class='"+fileclass+"'>"+listing[i].timestring+" ago</div>"; |
227 | 235 | else |
228 | 236 | html += " <div class='"+fileclass+"'>Just now</div>"; |
229 | | - html += " <div id='"+listing[i].file+"' class='buttons delete delete-note pointer'><br></div>"; |
| 237 | + html += " <div id='"+listing[i].filename+"' class='buttons delete delete-note pointer'><br></div>"; |
230 | 238 | html += " </div>"; |
231 | 239 | html += "</div>"; |
232 | 240 | } |
|
256 | 264 | } |
257 | 265 |
|
258 | 266 | function createNote() { |
259 | | - var url = OC.linkTo("ownnote","ajax/create.php"); |
260 | | - url += "?id=" + $('#newfilename').val(); |
| 267 | + var n = $('#newfilename').val(); |
261 | 268 | cancelNote(); |
262 | | - $.get(url, function(data) { |
| 269 | + $.post(ocUrl("api/v0.2/ownnote/create"), { note: n }, function (data) { |
263 | 270 | loadListing(); |
264 | 271 | }); |
265 | 272 | } |
|
395 | 402 |
|
396 | 403 | function deleteGroup() { |
397 | 404 | var g = $(this).attr('group'); |
398 | | - $.post(OC.linkTo("ownnote","ajax/deletegroup.php"), { group: g }, function (data) { |
| 405 | + $.post(ocUrl("api/v0.2/ownnote/delgroup"), { group: g }, function (data) { |
399 | 406 | switchgroup = "All"; |
400 | 407 | loadListing(); |
401 | 408 | }); |
|
415 | 422 | function saveGroup() { |
416 | 423 | var v = $("[id='"+this.id+"-text']").val(); |
417 | 424 | if (v != cg && v.toLowerCase() != "all" && v.toLowerCase() != "not grouped") { |
418 | | - $.post(OC.linkTo("ownnote","ajax/renamegroup.php"), { originalgroupname: cg, editgroupname: v }, function (data) { |
| 425 | + $.post(ocUrl("api/v0.2/ownnote/rengroup"), { group: cg, newgroup: v }, function (data) { |
419 | 426 | switchgroup = v; |
420 | 427 | cg = ""; |
421 | 428 | loadListing(); |
|
0 commit comments