footer.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  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. });
  177. $('body').on('click', '#usermenu', function() {
  178. $('.mobilemenu').toggle();
  179. });
  180. $('body').on('click', '.link', function() {
  181. $('.mobilemenu').hide();
  182. });
  183. $('body').on('click', '.account', function() {
  184. $('.switcher').toggle();
  185. $('.account').toggle();
  186. });
  187. $('body').on('click', '.notif .ldr', function(e) {
  188. $('#notifications').find('.container').children().removeClass('new');
  189. $('#notifications').css('display','none');
  190. $('.alert').css('display','none');
  191. var title = document.title;
  192. document.title = title.replace("(*)", "");
  193. });
  194. $('body').on('click', '.nloadmore', function() {
  195. var n = $('#notifications').find('.container').children().last().attr('id');
  196. $('#notifications').find('.container').children().last().after('<span id="loading" class="animate-spin fontello" style="color:black;">&#xe838;</span>');
  197. $.get("action.php?a=true&max=true&notif=" + n, function(data) {
  198. $('#loading').remove();
  199. $('#notifications').find('.container').append(data);
  200. });
  201. });
  202. window.setInterval(function() {
  203. var n = localStorage.getItem("notif");
  204. var f = $("#notifications").find('.container').children().first().attr('id');
  205. var nf;
  206. if (n < f) {
  207. nf = n;
  208. //$("#notifications").html('');
  209. } else {
  210. nf = f;
  211. }
  212. $.get("action.php?a=true&notif=" + f, function(data) {
  213. if (data) {
  214. var title = document.getElementsByTagName("title")[0].innerHTML;
  215. if (title.indexOf("(*)") < 0) {
  216. document.getElementsByTagName("title")[0].innerHTML = "(*) " + title;
  217. }
  218. $('#notifications').find('.container').prepend(data);
  219. var cnt = $('#notifications .container div.new').length;
  220. var notif = $('#hiddenside').children().first().attr('id');
  221. localStorage.setItem("notif", notif);
  222. $.when($('#hiddenside').html('')).then(function() {
  223. $('.alert').css('display','block');
  224. $('#hiddenside').append(data);
  225. $('#hiddenside').children().each(function(index) {
  226. $(this).delay(4000 + (1000 * index)).fadeOut("slow");
  227. });
  228. });
  229. }
  230. });
  231. }, 15000);
  232. function notificaton(message){
  233. 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>";
  234. $('#hiddenside').append(notif);
  235. $('#hiddenside').children().each(function(index) {
  236. $(this).delay(4000 + (1000 * index)).fadeOut("slow");
  237. });
  238. return false;
  239. };
  240. $('body').on('click', '.fav', function(e) {
  241. e.preventDefault;
  242. var id = $(this).parents().eq(1).attr('id');
  243. $("#"+id+".post_buttons .fav").switchClass("fav","unfav",200);
  244. $.get("action.php?a=true&mode=on&fav=" + id, function(data) {
  245. if (data == 'error') {
  246. $("#"+id+".post_buttons .unfav").switchClass("unfav","fav",200);
  247. } else {
  248. $("#"+id+".post_buttons .unfav").children().html(data);
  249. }
  250. });
  251. });
  252. $('body').on('click', '.unfav', function(e) {
  253. e.preventDefault;
  254. var id = $(this).parents().eq(1).attr('id');
  255. $("#"+id+".post_buttons .unfav").switchClass("unfav","fav",200);
  256. $.get("action.php?a=true&mode=off&fav=" + id, function(data) {
  257. if (data == 'error') {
  258. $("#"+id+".post_buttons .fav").switchClass("fav","unfav",200);
  259. } else {
  260. $("#"+id+".post_buttons .fav").children().html(data);
  261. }
  262. });
  263. });
  264. $('body').on('click', '.reblog', function(e) {
  265. e.preventDefault;
  266. var id = $(this).parents().eq(1).attr('id');
  267. $("#"+id+".post_buttons .reblog").switchClass("reblog","unreblog",200);
  268. $.get("action.php?a=true&mode=on&reblog=" + id, function(data) {
  269. if (data == 'error') {
  270. $("#"+id+".post_buttons .unreblog").switchClass("unreblog","reblog",200);
  271. } else {
  272. $("#"+id+".post_buttons .unreblog").children().html(data);
  273. }
  274. });
  275. });
  276. $('body').on('click', '.unreblog', function(e) {
  277. e.preventDefault;
  278. var id = $(this).parents().eq(1).attr('id');
  279. $("#"+id+".post_buttons .unreblog").switchClass("unreblog","reblog",200);
  280. $.get("action.php?a=true&mode=off&reblog=" + id, function(data) {
  281. if (data == 'error') {
  282. $("#"+id+".post_buttons .reblog").switchClass("reblog","unreblog",200);
  283. } else {
  284. $("#"+id+".post_buttons .reblog").children().html(data);
  285. }
  286. });
  287. });
  288. $('body').on('click', '.mute', function() {
  289. var id = $(this).attr('id');
  290. $.get("action.php?a=true&mode=true&mute=" + id, function(data) {
  291. $('#' + id + '.mute').switchClass("mute","unmute",200);
  292. $('#' + id + '.unmute').html('Unmute');
  293. });
  294. });
  295. $('body').on('click', '.unmute', function() {
  296. var id = $(this).attr('id');
  297. $.get("action.php?a=true&mode=off&mute=" + id, function(data) {
  298. $('#' + id + '.unmute').switchClass("unmute","mute",200);
  299. $('#' + id + '.mute').html('Mute');
  300. });
  301. });
  302. $('body').on('click', '.muteconv', function() {
  303. var id = $(this).attr('id');
  304. $.get("action.php?a=true&mode=true&thread=true&mute=" + id, function(data) {
  305. $('#' + id + '.muteconv').switchClass("muteconv","unmuteconv",200);
  306. $('#' + id + '.unmuteconv').html('Unmute Thread');
  307. console.log(data);
  308. });
  309. });
  310. $('body').on('click', '.unmuteconv', function() {
  311. var id = $(this).attr('id');
  312. $.get("action.php?a=true&mode=off&thread=true&mute=" + id, function(data) {
  313. $('#' + id + '.muteconv').switchClass("unmuteconv","muteconv",200);
  314. $('#' + id + '.muteconv').html('Mute Thread');
  315. console.log(data);
  316. });
  317. });
  318. $('body').on('click', '.menu', function(e) {
  319. $(this).next('span').slideToggle('left');
  320. });
  321. $('body').on('click', '.delete', function(e) {
  322. e.preventDefault;
  323. var id = $(this).attr('id');
  324. var post = $('#'+id+'.post').parent();
  325. var reply = $('#'+id+'.reply');
  326. $.get("action.php?a=true&delete=" + id, function(data) {
  327. if (data == '0') {
  328. post.css('opacity','0.5');
  329. reply.css('opacity','0.5');
  330. } else {
  331. $.when(post.fadeOut('slow')).then(function(){
  332. post.remove();
  333. reply.remove();
  334. });
  335. }
  336. });
  337. });
  338. $('body').on('click', '.delete', function(e) {
  339. e.preventDefault;
  340. var id = $(this).attr('id');
  341. $.get("action.php?a=true&bookmark=" + id, function(data) {
  342. notificaton('Post bookmarked!');
  343. });
  344. });
  345. $('body').on('click', '.quote', function(e) {
  346. e.preventDefault;
  347. var id = $(this).closest('.post').attr('id');
  348. console.log(id);
  349. var url = $("#"+id+".post .original").attr("href");
  350. console.log(url);
  351. $("#postform").find('textarea').val("> "+url+"\n\n");
  352. if ($("#postform").is(':visible')) {
  353. location.hash = "#top";
  354. } else {
  355. $('#postform').toggle();
  356. }
  357. });
  358. $('body').on('click', '.delpic', function(e) {
  359. var count = $(this).closest('#files').children().length;
  360. if (count == 1){
  361. $(this).closest('.uploadBox').remove();
  362. } else {
  363. count = count - 1;
  364. $(this).parent().fadeOut();
  365. $(this).parent().remove();
  366. }
  367. });
  368. /* paste to upload */
  369. document.onpaste = function(event){
  370. var items = (event.clipboardData || event.originalEvent.clipboardData).items;
  371. for (var i = 0 ; i < items.length ; i++) {
  372. var item = items[i];
  373. if (item.type.indexOf("image") != -1) {
  374. var file = item.getAsFile();
  375. console.log(file);
  376. upload_file_with_ajax(file,file_uploaded);
  377. }
  378. }
  379. }
  380. function upload_file_with_ajax(file, ajax_callback){
  381. $("#postform .status").html('<span id="loading" class="animate-spin fontello">&#xe838;</span>');
  382. var formData = new FormData();
  383. formData.append('file', file);
  384. $.ajax('./upload.php' , {
  385. type: 'POST',
  386. contentType: false,
  387. processData: false,
  388. data: formData,
  389. error: function() {
  390. console.log("error");
  391. },
  392. success: function (response) {
  393. if (typeof ajax_callback == 'function') {
  394. ajax_callback(response);
  395. } else if (typeof ajax_callback == 'string') {
  396. if (ajax_callback != '') {
  397. eval(ajax_callback + '(response)');
  398. }
  399. }
  400. }
  401. });
  402. }
  403. function file_uploaded(data) {
  404. if ($("#postform .uploadBox").length < 1){
  405. $("#postform #status").before('<div class="uploadBox"><ul id="files" style="margin:0px;"></ul></div>');
  406. $( function() {
  407. $( "#files" ).sortable();
  408. $( "#files" ).disableSelection();
  409. } );
  410. }
  411. var files = JSON.parse(data);
  412. $.each(files, function( index, elem ) {
  413. if (elem[0] == "null" || elem[0] == null){
  414. notificaton("There was an error uploading a file.");
  415. if ($("#postform .uploadBox").length < 1){
  416. $("#postform .uploadBox").remove();
  417. }
  418. } else {
  419. $("ul[id=files]").append('<li class="uploadedImage" id="'+elem[0]+'" style="position:relative; background-image:url('+elem[1]+')"><div class="fontello delpic">&#xe813;</div></li>');
  420. }
  421. });
  422. var nfiles = $("#postform .uploadBox").children().length;
  423. $("#postform .status").html('');
  424. }
  425. function upload_files() {
  426. $("#postform .status").html('<span id="loading" class="animate-spin fontello">&#xe838;</span>');
  427. var fileUpload = $("#files_input_field").get(0);
  428. var files = fileUpload.files;
  429. if (files.length == 0) return;
  430. var data = new FormData();
  431. for (var i = 0; i < files.length; i++) {
  432. data.append(files[i].name, files[i]);
  433. }
  434. $.ajax({
  435. type: "POST",
  436. url: "upload.php",
  437. contentType: false, //default: 'application/x-www-form-urlencoded; charset=UTF-8'
  438. processData: false, //default: data, other DOMDocument
  439. data: data, //Type: PlainObject or String or Array
  440. success: function(data) {
  441. if ($("#postform .uploadBox").length < 1){
  442. $("#postform #status").before('<div class="uploadBox"><ul id="files" style="margin:0px;"></ul></div>');
  443. $( function() {
  444. $( "#files" ).sortable();
  445. $( "#files" ).disableSelection();
  446. } );
  447. }
  448. var files = JSON.parse(data);
  449. $.each(files, function( index, elem ) {
  450. if (elem[0] == "null" || elem[0] == null){
  451. notificaton("There was an error uploading a file.");
  452. if ($("#postform .uploadBox").length < 1){
  453. $("#postform .uploadBox").remove();
  454. }
  455. } else {
  456. $("ul[id=files]").append('<li class="uploadedImage" id="'+elem[0]+'" style="position:relative; background-image:url('+elem[1]+')"><div class="fontello delpic">&#xe813;</div></li>');
  457. }
  458. });
  459. var nfiles = $("#postform .uploadBox").children().length;
  460. $("#postform .status").html('');
  461. },
  462. error: function(jqXHR,e) {
  463. console.log(jqXHR);
  464. alert("There was error uploading files! "+e);
  465. }
  466. });
  467. }
  468. function upload_files_reply() {
  469. $("#replyform .status").html('<span id="loading" class="animate-spin fontello">&#xe838;</span>');
  470. var fileUpload = $("#replyform #files_input_field").get(0);
  471. var files = fileUpload.files;
  472. if (files.length == 0) return;
  473. var data = new FormData();
  474. for (var i = 0; i < files.length; i++) {
  475. data.append(files[i].name, files[i]);
  476. }
  477. $.ajax({
  478. type: "POST",
  479. url: "upload.php",
  480. contentType: false, //default: 'application/x-www-form-urlencoded; charset=UTF-8'
  481. processData: false, //default: data, other DOMDocument
  482. data: data, //Type: PlainObject or String or Array
  483. success: function(data) {
  484. if ($("#replyform .uploadBox").length < 1){
  485. $("#replyform #status").before('<div class="uploadBox"><ul id="files" style="margin:0px;"></ul></div>');
  486. $( function() {
  487. $( "#files" ).sortable();
  488. $( "#files" ).disableSelection();
  489. } );
  490. }
  491. var files = JSON.parse(data);
  492. $.each(files, function( index, elem ) {
  493. $("#replyform #files").append('<li class="uploadedImage" id="'+elem[0]+'" style="position:relative; background-image:url('+elem[1]+')"><div class="fontello delpic">&#xe813;</div></li>');
  494. });
  495. var nfiles = $("#replyform .uploadBox").children().length;
  496. $("#replyform .status").html('');
  497. },
  498. error: function() {
  499. alert("There was error uploading files!");
  500. }
  501. });
  502. }
  503. <?php endif; ?>
  504. </script>
  505. </body>