footer.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. </div>
  2. </div>
  3. <?php include "layout/sidebar.php"; ?>
  4. </div>
  5. </div>
  6. <?php
  7. $query = http_build_query(array_filter(array(
  8. //'instance' => ($instance == true ? $instance : false) ,
  9. 'user' => (isset($tl['user']) == true ? $tl['user'] : false) ,
  10. 'mode' => $tl['mode'],
  11. //'explicit' => ($nocookies == true ? $user_settings['explicit'] : false) ,
  12. )));
  13. ?>
  14. <div class="mobile" style="display:block; height:50px;"></div>
  15. <script src="vendor/jquery.min.js"></script>
  16. <script src="vendor/jqueryui.js"></script>
  17. <script src="js/scripts.js"></script>
  18. <script type="text/javascript">
  19. window.setInterval(function() {
  20. $( ".post > .replies_container" ).each(function() {
  21. var len = $(this).find('.reply').length;
  22. if(len > 0){
  23. var id = $(this).attr('id');
  24. var last = $(this).find('.reply').last().attr('id');
  25. $.get("action.php?a=true&replies=" + id + "&since="+last, function(data) {
  26. if (data !== ''){
  27. $( ".post > #"+id+".replies_container" ).append(data);
  28. }
  29. });
  30. }
  31. });
  32. }, 15000);
  33. window.setInterval(function() {
  34. var thread = getUrlParameter('thread');
  35. if (typeof thread == 'undefined') {
  36. return false;
  37. }
  38. $.get("action.php?a=true&notes=" + thread, function(data) {
  39. thread = getUrlParameter('thread');
  40. if (typeof thread == 'undefined') {
  41. return false;
  42. }
  43. $( ".post_notes" ).html(data);
  44. });
  45. }, 15000);
  46. <?php if ($logedin): ?>
  47. $('body').on('click', '.replyform', function(e) {
  48. e.preventDefault;
  49. $("#replyform").remove();
  50. $(".element").removeClass("element_pad");
  51. $(this).closest(".element").addClass("element_pad");
  52. var id = $(this).parents().eq(1).attr('id');
  53. var type = $(this).parents().eq(3).attr('mode').trim().replace(" ",".");
  54. console.log(type);
  55. $('#replyform').remove();
  56. var data = JSON.parse(document.getElementById('data-' + id).innerHTML);
  57. $.get("action.php?a=true&themefile=templates/replyform.txt", function(result) {
  58. result = result.replace(":content:", data.mentions)
  59. result = result.replace(":id:", data.id)
  60. if(type == 'post'){
  61. $('.'+type).find('#' + id+'.replies_container').prepend(result);
  62. } else {
  63. $('#' + id+'.'+type).after(result);
  64. }
  65. $('#replyform #' + data.scope).prop('selected', true);
  66. $('#' + id).fadeIn(400);
  67. });
  68. });
  69. $('body').on('click', '.compose', function(e) {
  70. $('#postform').toggle();
  71. });
  72. $('body').on('click', '.polloption:not(.fixed)', function(e) {
  73. if (typeof $(this).parent().attr('multiple') == 'undefined'){
  74. $('.polloption').removeClass('voted');
  75. }
  76. $(this).toggleClass('voted');
  77. });
  78. $('body').on('click', '.vote', function(e) {
  79. var id = $(this).attr('id');
  80. var c = 0;
  81. var choice = [];
  82. $('#'+id+'.poll .polloption').each(function(a){
  83. if ($(this).hasClass('voted')){
  84. console.log(c);
  85. choice.push(c);
  86. }
  87. c++;
  88. });
  89. var choices = choice.join(',');
  90. console.log(choices);
  91. $.get("action.php?a=true&vote="+id+"&choices="+choices, function(result) {
  92. $('#'+id+'.poll').html(result);
  93. });
  94. });
  95. $('body').on('click', '.searchform', function(e) {
  96. $(this).prev().toggle();
  97. });
  98. $('body').on('click', '.searchmobiletoggle', function(e) {
  99. $('#usermenu').off('hover');
  100. $('#usermenu').off('active');
  101. $('#searchmobile').toggle();
  102. });
  103. $("body").on("keydown", "form", function (e) {
  104. if (e.ctrlKey && e.keyCode === 13) {
  105. $(this).find('input[type="submit"]').click();
  106. }
  107. });
  108. $('.tlicon').click(function(){
  109. $('.tlicon').each(function(a){
  110. $( this ).removeClass('tiselected')
  111. });
  112. $( this ).addClass('tiselected');
  113. });
  114. $('body').on('click', '#send', function() {
  115. var form = $(this).closest('.form');
  116. $(form).find(".status").html('<span id="loading" class="animate-spin fontello">&#xe838;</span>');
  117. var status = $(form).find('textarea').val()
  118. var sensitive = $(form).find('input[name=sensitive]').prop('checked');
  119. var spoiler = $(form).find('input[name=spoiler]').val();
  120. var scope = $(form).find('select[name=scope]').val();
  121. var thread = $(form).find('input[name=thread]').val();
  122. var IDs = [];
  123. $(form).find(".uploadedImage").each(function(){ IDs.push(this.id); });
  124. var uploaded = IDs.join("|");
  125. $.post("action.php", {
  126. status: status,
  127. scope: scope,
  128. thread: thread,
  129. uploaded: uploaded,
  130. spoiler: spoiler,
  131. sensitive: sensitive
  132. },
  133. function(data) {
  134. $(form).closest('.element').find(".picker").css("display","none");
  135. if($(form).closest('.element').attr('id') == 'postform'){
  136. $(form).find('textarea').val('');
  137. $(form).find('.uploadBox').remove();
  138. $(form).find('input[name=sensitive]').prop('checked', false);
  139. $(form).find(".status").html('');
  140. $(form).find('input[name=spoiler]').val('');
  141. newPosts();
  142. } else {
  143. var parent = $(form).closest('.element').find('.post').first().attr('id');
  144. $('#replyform').remove();
  145. $('#'+parent+'.replies_container').append(data);
  146. }
  147. });
  148. });
  149. $('body').on('click', '.quickreply', function(e) {
  150. $(".notif.form").remove();
  151. $(this).closest('.notif').after('<div class="notif form"><div class="notifContents"><input type="hidden" name="thread" value="'+$(this).attr('id')+'"><input type="hidden" name="mentions" value="'+$(this).attr('data-mentions')+'"><textarea style="width:100%; height100%; border: 1px solid #ddd;"></textarea><input type="submit" id="quicksend" value="Send"></div></div>');
  152. });
  153. $('body').on('click', '#quicksend', function() {
  154. var form = $('#quicksend').closest('.form');
  155. var thread = $(form).find('input[name=thread]').val();
  156. var mentions = $(form).find('input[name=mentions]').val();
  157. var status = mentions + $(form).find('textarea').val();
  158. $(".notif.form").html('<span id="loading" class="animate-spin fontello">&#xe838;</span>');
  159. $.post("action.php", {
  160. status: status,
  161. thread: thread,
  162. },
  163. function(data) {
  164. $(".notif.form").remove();
  165. notificaton('Reply Sent!');
  166. });
  167. });
  168. $('body').on('click', '.badge', function() {
  169. $('#notifications').toggle();
  170. var notif = $('#hiddenside').children().first().attr('id');
  171. localStorage.setItem("notif", notif);
  172. $('#notifications').find('.container').children().removeClass('new');
  173. $('.alert').css('display','none');
  174. var title = document.title;
  175. document.title = title.replace("(*)", "");
  176. $("#favicon").attr("href","favicon.ico");
  177. });
  178. $('body').on('click', '#usermenu', function() {
  179. $('.mobilemenu').toggle();
  180. });
  181. $('body').on('click', '.link', function() {
  182. $('.mobilemenu').hide();
  183. });
  184. $('body').on('click', '.account', function() {
  185. $('.switcher').toggle();
  186. $('.account').toggle();
  187. });
  188. $('body').on('click', '.notif .ldr', function(e) {
  189. $('#notifications').find('.container').children().removeClass('new');
  190. $('#notifications').css('display','none');
  191. $('.alert').css('display','none');
  192. var title = document.title;
  193. document.title = title.replace("(*)", "");
  194. $("#favicon").attr("href","favicon.ico");
  195. });
  196. $('body').on('click', '.nloadmore', function() {
  197. var n = $('#notifications').find('.container').children().last().attr('id');
  198. $('#notifications').find('.container').children().last().after('<span id="loading" class="animate-spin fontello" style="color:black;">&#xe838;</span>');
  199. $.get("action.php?a=true&max=true&notif=" + n, function(data) {
  200. $('#loading').remove();
  201. $('#notifications').find('.container').append(data);
  202. });
  203. });
  204. window.setInterval(function() {
  205. var n = localStorage.getItem("notif");
  206. var f = $("#notifications").find('.container').children().first().attr('id');
  207. var nf;
  208. if (n < f) {
  209. nf = n;
  210. //$("#notifications").html('');
  211. } else {
  212. nf = f;
  213. }
  214. $.get("action.php?a=true&notif=" + f, function(data) {
  215. if (data) {
  216. var title = document.getElementsByTagName("title")[0].innerHTML;
  217. if (title.indexOf("(*)") < 0) {
  218. document.getElementsByTagName("title")[0].innerHTML = "(*) " + title;
  219. $("#favicon").attr("href","nfavicon.ico");
  220. }
  221. $('#notifications').find('.container').prepend(data);
  222. var cnt = $('#notifications .container div.new').length;
  223. var notif = $('#hiddenside').children().first().attr('id');
  224. localStorage.setItem("notif", notif);
  225. $.when($('#hiddenside').html('')).then(function() {
  226. $('.alert').css('display','block');
  227. $('#hiddenside').append(data);
  228. $('#hiddenside').children().each(function(index) {
  229. $(this).delay(4000 + (1000 * index)).fadeOut("slow");
  230. });
  231. });
  232. }
  233. });
  234. }, 15000);
  235. function notificaton(message){
  236. var notif = "<div class='notif error' style='border-left:3px solid red; background-color:pink;'> <div class='notifContents'> <div style='flex: 0 0 60px; background-size:cover; border-radius:5px;'></div> <div style='flex: 1; padding-left:5px; padding-right:5px; word-break: break-all; overflow:hidden;'> <span>"+message+"</span> </div> </div> </div>";
  237. $('#hiddenside').append(notif);
  238. $('#hiddenside').children().each(function(index) {
  239. $(this).delay(4000 + (1000 * index)).fadeOut("slow");
  240. });
  241. return false;
  242. };
  243. $('body').on('click', '.fav', function(e) {
  244. e.preventDefault;
  245. var id = $(this).parents().eq(1).attr('id');
  246. $("#"+id+".post_buttons .fav").switchClass("fav","unfav",200);
  247. $.get("action.php?a=true&mode=on&fav=" + id, function(data) {
  248. if (data == 'error') {
  249. $("#"+id+".post_buttons .unfav").switchClass("unfav","fav",200);
  250. } else {
  251. $("#"+id+".post_buttons .unfav").children().html(data);
  252. }
  253. });
  254. });
  255. $('body').on('click', '.unfav', function(e) {
  256. e.preventDefault;
  257. var id = $(this).parents().eq(1).attr('id');
  258. $("#"+id+".post_buttons .unfav").switchClass("unfav","fav",200);
  259. $.get("action.php?a=true&mode=off&fav=" + id, function(data) {
  260. if (data == 'error') {
  261. $("#"+id+".post_buttons .fav").switchClass("fav","unfav",200);
  262. } else {
  263. $("#"+id+".post_buttons .fav").children().html(data);
  264. }
  265. });
  266. });
  267. $('body').on('click', '.reblog', function(e) {
  268. e.preventDefault;
  269. var id = $(this).parents().eq(1).attr('id');
  270. $("#"+id+".post_buttons .reblog").switchClass("reblog","unreblog",200);
  271. $.get("action.php?a=true&mode=on&reblog=" + id, function(data) {
  272. if (data == 'error') {
  273. $("#"+id+".post_buttons .unreblog").switchClass("unreblog","reblog",200);
  274. } else {
  275. $("#"+id+".post_buttons .unreblog").children().html(data);
  276. }
  277. });
  278. });
  279. $('body').on('click', '.unreblog', function(e) {
  280. e.preventDefault;
  281. var id = $(this).parents().eq(1).attr('id');
  282. $("#"+id+".post_buttons .unreblog").switchClass("unreblog","reblog",200);
  283. $.get("action.php?a=true&mode=off&reblog=" + id, function(data) {
  284. if (data == 'error') {
  285. $("#"+id+".post_buttons .reblog").switchClass("reblog","unreblog",200);
  286. } else {
  287. $("#"+id+".post_buttons .reblog").children().html(data);
  288. }
  289. });
  290. });
  291. $('body').on('click', '.mute', function() {
  292. var id = $(this).attr('id');
  293. $.get("action.php?a=true&mode=true&mute=" + id, function(data) {
  294. $('#' + id + '.mute').switchClass("mute","unmute",200);
  295. $('#' + id + '.unmute').html('Unmute');
  296. });
  297. });
  298. $('body').on('click', '.softmute', function() {
  299. var id = $(this).attr('id');
  300. $.get("action.php?a=true&mode=true&softmute=" + id, function(data) {
  301. notificaton('User added to soft mute list!');
  302. });
  303. });
  304. $('body').on('click', '.unmute', function() {
  305. var id = $(this).attr('id');
  306. $.get("action.php?a=true&mode=off&mute=" + id, function(data) {
  307. $('#' + id + '.unmute').switchClass("unmute","mute",200);
  308. $('#' + id + '.mute').html('Mute');
  309. });
  310. });
  311. $('body').on('click', '.muteconv', function() {
  312. var id = $(this).attr('id');
  313. $.get("action.php?a=true&mode=true&thread=true&mute=" + id, function(data) {
  314. $('#' + id + '.muteconv').switchClass("muteconv","unmuteconv",200);
  315. $('#' + id + '.unmuteconv').html('Unmute Thread');
  316. console.log(data);
  317. });
  318. });
  319. $('body').on('click', '.unmuteconv', function() {
  320. var id = $(this).attr('id');
  321. $.get("action.php?a=true&mode=off&thread=true&mute=" + id, function(data) {
  322. $('#' + id + '.muteconv').switchClass("unmuteconv","muteconv",200);
  323. $('#' + id + '.muteconv').html('Mute Thread');
  324. console.log(data);
  325. });
  326. });
  327. $('body').on('click', '.menu', function(e) {
  328. $(this).next('span').slideToggle('left');
  329. });
  330. $('body').on('click', '.delete', function(e) {
  331. e.preventDefault;
  332. var id = $(this).attr('id');
  333. var post = $('#'+id+'.post').parent();
  334. var reply = $('#'+id+'.reply');
  335. $.get("action.php?a=true&delete=" + id, function(data) {
  336. if (data == '0') {
  337. post.css('opacity','0.5');
  338. reply.css('opacity','0.5');
  339. } else {
  340. $.when(post.fadeOut('slow')).then(function(){
  341. post.remove();
  342. reply.remove();
  343. });
  344. }
  345. });
  346. });
  347. $('body').on('click', '.delete', function(e) {
  348. e.preventDefault;
  349. var id = $(this).attr('id');
  350. $.get("action.php?a=true&bookmark=" + id, function(data) {
  351. notificaton('Post bookmarked!');
  352. });
  353. });
  354. $('body').on('click', '.quote', function(e) {
  355. e.preventDefault;
  356. var id = $(this).closest('.post').attr('id');
  357. console.log(id);
  358. var url = $("#"+id+".post .original").attr("href");
  359. console.log(url);
  360. $("#postform").find('textarea').val("> "+url+"\n\n");
  361. if ($("#postform").is(':visible')) {
  362. location.hash = "#top";
  363. } else {
  364. $('#postform').toggle();
  365. }
  366. });
  367. $('body').on('click', '.delpic', function(e) {
  368. var count = $(this).closest('#files').children().length;
  369. if (count == 1){
  370. $(this).closest('.uploadBox').remove();
  371. } else {
  372. count = count - 1;
  373. $(this).parent().fadeOut();
  374. $(this).parent().remove();
  375. }
  376. });
  377. /* paste to upload */
  378. document.onpaste = function(event){
  379. var items = (event.clipboardData || event.originalEvent.clipboardData).items;
  380. for (var i = 0 ; i < items.length ; i++) {
  381. var item = items[i];
  382. if (item.type.indexOf("image") != -1) {
  383. var file = item.getAsFile();
  384. upload_file_with_ajax(file,file_uploaded);
  385. }
  386. }
  387. }
  388. function upload_file_with_ajax(file, ajax_callback){
  389. $("#postform .status").html('<span id="loading" class="animate-spin fontello">&#xe838;</span>');
  390. $.get("action.php?a=true&info=true", function(data) {
  391. const info = JSON.parse(data);
  392. var formData = new FormData();
  393. formData.append('file', file);
  394. $.ajax("https://"+info[1]+"/api/v2/media" , {
  395. type: 'POST',
  396. headers: {'Authorization': 'Bearer '+info[0]},
  397. contentType: false,
  398. processData: false,
  399. data: formData,
  400. error: function() {
  401. console.log('There was a problem uploading this file. Retrying with legacy mode.');
  402. $.ajax("upload.php" , {
  403. type: 'POST',
  404. headers: {'Authorization': 'Bearer '+info[0]},
  405. contentType: false,
  406. processData: false,
  407. data: formData,
  408. error: function() {
  409. notificaton('There was a problem uploading this file.');
  410. $("#postform .status").html('');
  411. },
  412. success: function (response) {
  413. if (typeof ajax_callback == 'function') {
  414. ajax_callback(JSON.parse(response));
  415. } else if (typeof ajax_callback == 'string') {
  416. if (ajax_callback != '') {
  417. eval(ajax_callback + '(response)');
  418. }
  419. }
  420. }
  421. });
  422. },
  423. success: function (response) {
  424. if (typeof ajax_callback == 'function') {
  425. ajax_callback(response);
  426. } else if (typeof ajax_callback == 'string') {
  427. if (ajax_callback != '') {
  428. eval(ajax_callback + '(response)');
  429. }
  430. }
  431. }
  432. });
  433. });
  434. }
  435. function file_uploaded(data) {
  436. //data = JSON.parse(data);
  437. if ($("#postform .uploadBox").length < 1){
  438. $("#postform #status").before('<div class="uploadBox"><ul id="files" style="margin:0px;"></ul></div>');
  439. $( function() {
  440. $( "#files" ).sortable();
  441. $( "#files" ).disableSelection();
  442. } );
  443. }
  444. let file;
  445. switch (data.type) {
  446. case 'image':
  447. file = data.preview_url;
  448. break;
  449. case 'audio':
  450. file = 'img/aud.png';
  451. break;
  452. case 'video':
  453. file = 'img/vid.png';
  454. break;
  455. default:
  456. file = 'img/doc.png';
  457. break;
  458. }
  459. var nfiles = $("#postform .uploadBox").children().length;
  460. $("ul[id=files]").append('<li class="uploadedImage" id="'+data.id+'" style="position:relative; background-image:url('+file+')"><div class="fontello delpic">&#xe813;</div></li>');
  461. $("#postform .status").html('');
  462. }
  463. function upload_files() {
  464. $("#postform .status").html('<span id="loading" class="animate-spin fontello">&#xe838;</span>');
  465. $.get("action.php?a=true&info=true", function(data) {
  466. const info = JSON.parse(data);
  467. var fileUpload = $("#files_input_field").get(0);
  468. var files = fileUpload.files;
  469. if (files.length == 0) return;
  470. var data;
  471. for (var i = 0; i < files.length; i++) {
  472. data = new FormData();
  473. data.append('file', files[i]);
  474. $.ajax({
  475. type: "POST",
  476. headers: {'Authorization': 'Bearer '+info[0]},
  477. url: "https://"+info[1]+"/api/v2/media",
  478. contentType: false, //default: 'application/x-www-form-urlencoded; charset=UTF-8'
  479. processData: false, //default: data, other DOMDocument
  480. data: data, //Type: PlainObject or String or Array
  481. success: function(data) {
  482. console.log(data);
  483. if ($("#postform .uploadBox").length < 1){
  484. $("#postform #status").before('<div class="uploadBox"><ul id="files" style="margin:0px;"></ul></div>');
  485. $( function() {
  486. $( "#files" ).sortable();
  487. $( "#files" ).disableSelection();
  488. } );
  489. }
  490. let file;
  491. switch (data.type) {
  492. case 'image':
  493. file = data.preview_url;
  494. break;
  495. case 'audio':
  496. file = 'img/aud.png';
  497. break;
  498. case 'video':
  499. file = 'img/vid.png';
  500. break;
  501. default:
  502. file = 'img/doc.png';
  503. break;
  504. }
  505. console.log(data.id);
  506. $("ul[id=files]").append('<li class="uploadedImage" id="'+data.id+'" style="position:relative; background-image:url('+file+')"><div class="fontello delpic">&#xe813;</div></li>');
  507. if(i === files.length){
  508. $("#postform .status").html('');
  509. }
  510. },
  511. error: function(jqXHR, e) {
  512. console.log(jqXHR);
  513. console.log('There was a problem uploading this file, trying again with legacy upload.');
  514. $("#postform .status").html('');
  515. // Attempt the upload again with upload.php
  516. $.ajax({
  517. type: "POST",
  518. headers: {'Authorization': 'Bearer '+info[0]},
  519. url: "upload.php",
  520. contentType: false,
  521. processData: false,
  522. data: data,
  523. success: function(data) {
  524. console.log(data);
  525. data = JSON.parse(data);
  526. if ($("#postform .uploadBox").length < 1){
  527. $("#postform #status").before('<div class="uploadBox"><ul id="files" style="margin:0px;"></ul></div>');
  528. $( function() {
  529. $( "#files" ).sortable();
  530. $( "#files" ).disableSelection();
  531. } );
  532. }
  533. let file;
  534. switch (data.type) {
  535. case 'image':
  536. file = data.preview_url;
  537. break;
  538. case 'audio':
  539. file = 'img/aud.png';
  540. break;
  541. case 'video':
  542. file = 'img/vid.png';
  543. break;
  544. default:
  545. file = 'img/doc.png';
  546. break;
  547. }
  548. console.log(data.id);
  549. $("ul[id=files]").append('<li class="uploadedImage" id="'+data.id+'" style="position:relative; background-image:url('+file+')"><div class="fontello delpic">&#xe813;</div></li>');
  550. if(i === files.length){
  551. $("#postform .status").html('');
  552. }
  553. },
  554. error: function(jqXHR, e) {
  555. console.log(jqXHR);
  556. notificaton('There was a problem uploading this file.');
  557. }
  558. });
  559. }
  560. });
  561. }
  562. });
  563. }
  564. function upload_files_reply() {
  565. $("#replyform .status").html('<span id="loading" class="animate-spin fontello">&#xe838;</span>');
  566. $.get("action.php?a=true&info=true", function(data) {
  567. const info = JSON.parse(data);
  568. var fileUpload = $("#replyform #files_input_field").get(0);
  569. var files = fileUpload.files;
  570. if (files.length == 0) return;
  571. var data;
  572. for (var i = 0; i < files.length; i++) {
  573. data = new FormData();
  574. data.append('file', files[i]);
  575. $.ajax({
  576. type: "POST",
  577. headers: {'Authorization': 'Bearer '+info[0]},
  578. url: "https://"+info[1]+"/api/v2/media",
  579. contentType: false, //default: 'application/x-www-form-urlencoded; charset=UTF-8'
  580. processData: false, //default: data, other DOMDocument
  581. data: data, //Type: PlainObject or String or Array
  582. success: function(data) {
  583. console.log(data);
  584. if ($("#replyform .uploadBox").length < 1){
  585. $("#replyform #status").before('<div class="uploadBox"><ul id="files" style="margin:0px;"></ul></div>');
  586. $( function() {
  587. $( "#files" ).sortable();
  588. $( "#files" ).disableSelection();
  589. } );
  590. }
  591. let file;
  592. switch (data.type) {
  593. case 'image':
  594. file = data.preview_url;
  595. break;
  596. case 'audio':
  597. file = 'img/aud.png';
  598. break;
  599. case 'video':
  600. file = 'img/vid.png';
  601. break;
  602. default:
  603. file = 'img/doc.png';
  604. break;
  605. }
  606. console.log(data.id);
  607. $("#replyform #files").append('<li class="uploadedImage" id="'+data.id+'" style="position:relative; background-image:url('+file+')"><div class="fontello delpic">&#xe813;</div></li>');
  608. if(i === files.length){
  609. $("#postform .status").html('');
  610. }
  611. },
  612. error: function(jqXHR,e) {
  613. console.log(jqXHR);
  614. notificaton('There was a problem uploading this file.');
  615. $("#replyform .status").html('');
  616. }
  617. });
  618. }
  619. });
  620. }
  621. <?php endif; ?>
  622. </script>
  623. </body>