Guest User

Untitled

a guest
Feb 6th, 2024
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. "use strict";
  2.  
  3.     (function(window) {
  4.         function _SPTBL_APP() {
  5.             var data = {
  6.                 url: "https://spoutible.com"
  7.             };
  8.  
  9.             var _smc = Object({
  10.                 curr_pn: "start",
  11.                 PS: Object({}),
  12.                 vue: Object({}),
  13.                 is_logged_user: '0',
  14.                 back_url: data.url,
  15.                 timeout: false,
  16.                 msb_upinterval: "50000000",
  17.                 userlbox: {
  18.                     interv: 0,
  19.                     status: false,
  20.                     lifetm: 1000,
  21.                     curr_id: false,
  22.                     curr_el: false,
  23.                     pre_delay: false
  24.                 },
  25.                 previous_url: window.location.pathname
  26.             });
  27.  
  28.             if (_smc.curr_pn != "chat") {
  29.                 // if ($(window).width() > 576 && 'StickySidebar' in window) {
  30.                 //  if ($('[data-app="left-sidebar"]').length) {
  31.                 //      _smc.lsb = new StickySidebar('[data-app="left-sidebar"]', {
  32.                 //          topSpacing: 0,
  33.                 //          bottomSpacing: 0
  34.                 //      });
  35.                 //  }
  36.  
  37.                 //  if ($('[data-app="right-sidebar"]').length) {
  38.                 //      _smc.rsb = new StickySidebar('[data-app="right-sidebar"]', {
  39.                 //          topSpacing: 0,
  40.                 //          bottomSpacing: 0
  41.                 //      });
  42.                 //  }
  43.                 // }
  44.             }
  45.  
  46.             _smc.toggleSB = function(a = false) {
  47.                 var left_sidebar = $('[data-app="left-sidebar"]');
  48.  
  49.                 if (a) {
  50.                     if (a == "show") {
  51.                         left_sidebar.addClass('show');
  52.  
  53.                         $('body').addClass("mobile-sb-open").append($('<div>', {
  54.                             'class': 'sb-open-overlay',
  55.                             'data-app': 'lsb-back-drop'
  56.                         }));
  57.                     }
  58.                     else{
  59.                         left_sidebar.removeClass('show').promise().done(function() {
  60.                             $('body').removeClass("mobile-sb-open").find('div[data-app="lsb-back-drop"]').remove();
  61.                         });
  62.                     }
  63.                 }
  64.  
  65.                 else{
  66.                     if (left_sidebar.hasClass("show")) {
  67.                         left_sidebar.removeClass('show').promise().done(function() {
  68.                             $('body').removeClass("mobile-sb-open").find('div[data-app="lsb-back-drop"]').remove();
  69.                         });
  70.                     }
  71.                     else{
  72.                         left_sidebar.addClass('show');
  73.  
  74.                         $('body').addClass("mobile-sb-open").append($('<div>', {
  75.                             'class': 'sb-open-overlay',
  76.                             'data-app': 'lsb-back-drop'
  77.                         }));
  78.                     }
  79.                 }
  80.             }
  81.  
  82.             _smc.toggleSBMenu = function(e = false) {
  83.                 var left_sidebar = $('[data-app="left-sidebar"]');
  84.  
  85.                 left_sidebar.find("div.sidebar__nav-group_collapse").slideToggle(100);
  86.  
  87.  
  88.                 if (left_sidebar.find("div.sidebar__nav-group_collapse").hasClass("open")) {
  89.                     $(e).find("a").text("More");
  90.                     left_sidebar.find("div.sidebar__nav-group_collapse").removeClass("open");
  91.                 }
  92.                 else{
  93.                     $(e).find("a").text("Less");
  94.                     left_sidebar.find("div.sidebar__nav-group_collapse").addClass("open");
  95.                 }
  96.             }
  97.  
  98.             _smc.init = function() {
  99.                 // _smc.fix_sidebars();
  100.                 // _smc.update_msb_indicators();
  101.                 _smc.update_ilb();
  102.  
  103.                 if (sptbl_empty(window.history.state)) {
  104.                     window.history.pushState({state: "new", back_url: window.location.href}, "", window.location.href);
  105.                 }
  106.             }
  107.  
  108.             _smc.fix_sidebars = function() {
  109.                 // if (_smc.curr_pn != "chat") {
  110.                 //  if ($(window).width() > 576) {
  111.                 //      if (_smc.lsb) {
  112.                 //          _smc.lsb.updateSticky();
  113.                 //      }
  114.  
  115.                 //      if (_smc.rsb) {
  116.                 //          _smc.rsb.updateSticky();
  117.                 //      }
  118.                 //  }
  119.                 // }
  120.             }
  121.  
  122.             _smc.get_cookie = function(name = "") {
  123.                 var matches = document.cookie.match(new RegExp(
  124.                   "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
  125.                 ));
  126.  
  127.                 return (matches ? decodeURIComponent(matches[1]) : undefined);
  128.             }
  129.  
  130.             _smc.is_logged = function(){
  131.                 if (_smc.is_logged_user == '1') {
  132.                     return true;
  133.                 }
  134.  
  135.                 return false;
  136.             }
  137.  
  138.             _smc.user_lbox = function(id = false, el = false) {
  139.                 if ($.isNumeric(id)) {
  140.                     if(sptbl_empty(_smc.userlbox.curr_id) != true && _smc.userlbox.curr_id == id) {
  141.                         return false;
  142.                     }
  143.  
  144.                     else{
  145.  
  146.                         if (_smc.userlbox.pre_delay !== false) {
  147.                             clearTimeout(_smc.userlbox.pre_delay);
  148.  
  149.                             _smc.userlbox.pre_delay = false;
  150.                         }
  151.  
  152.                         _smc.userlbox.pre_delay = setTimeout(function() {
  153.                             $.ajax({
  154.                                 url: 'https://spoutible.com/sptbl_system_api/main/user_lbox',
  155.                                 type: 'GET',
  156.                                 dataType: 'json',
  157.                                 data: {id: id},
  158.                                 beforeSend: function() {
  159.                                     _smc.user_lbox_rm();
  160.  
  161.                                     _smc.userlbox.curr_id = id;
  162.                                     _smc.userlbox.curr_el = el;
  163.                                 }
  164.                             }).done(function(data) {
  165.                                 if (data.status == 200) {
  166.                                     if (_smc.userlbox.curr_id) {
  167.                                         _smc.userlbox.status = true;
  168.                                         _smc.userlbox.lifetm = 1000;
  169.  
  170.                                         el.popover({
  171.                                             html: true,
  172.                                             content: data.html,
  173.                                             placement: "auto"
  174.                                         });
  175.  
  176.                                         el.popover("show");
  177.                                     }
  178.                                 }
  179.                                 else {
  180.                                     _smc.errorMSG();
  181.                                 }
  182.                             });
  183.                         }, 1500);
  184.                     }
  185.                 }
  186.             }
  187.  
  188.             _smc.display_settings = function(a = "show") {
  189.                 $('[data-app="display-settings-app"]').modal(a);
  190.             }
  191.  
  192.             _smc.show_group_chat_modal = function(e, a = "show") {
  193.                 e.preventDefault()
  194.                 $('#chat-group-modal').modal(a);
  195.             }
  196.  
  197.             _smc.display_edit_profile_modal = function(a = "show") {
  198.                 $('[data-app="edit_profile-app"]').modal(a);
  199.             }
  200.  
  201.             _smc.user_lbox_rm = function() {
  202.  
  203.                 if (_smc.userlbox.curr_el) {
  204.                     _smc.userlbox.curr_el.popover("dispose");
  205.                 }
  206.  
  207.                 else {
  208.                     if ($("[data-app='user-info-lbox']").length) {
  209.                         $("div.popover").each(function(index, el) {
  210.                             $(el).popover("dispose");
  211.                         });
  212.                     }
  213.                 }
  214.  
  215.                 _smc.userlbox.curr_id = false;
  216.                 _smc.userlbox.status  = false;
  217.                 _smc.userlbox.curr_el = false;
  218.             }
  219.  
  220.             _smc.max_upload = function(size = 0) {
  221.                 var max_upload_size = "104857600";
  222.  
  223.                 if (size > max_upload_size) {
  224.                     sptbl_bs_notify("The file you selected ({0}) exceeds the maximum file size limit ({1})".format(sptbl_format_bytes(size), sptbl_format_bytes(max_upload_size)), 5000, "danger");
  225.                     return false;
  226.                 }
  227.  
  228.                 else {
  229.                     return true;
  230.                 }
  231.             }
  232.  
  233.             _smc.post_privacy = function(priv = "everyone", id = false) {
  234.                 if ($.isNumeric(id)) {
  235.                     $.ajax({
  236.                         url: 'https://spoutible.com/sptbl_system_api/main/post_privacy',
  237.                         type: 'POST',
  238.                         dataType: 'json',
  239.                         data: {id: id, priv: priv},
  240.                         beforeSend: function() {
  241.                             _smc.progress_bar("show");
  242.                         }
  243.                     }).done(function(data) {
  244.                         if (data.status == 200) {
  245.                             _smc.spa_reload();
  246.                         }
  247.                         else {
  248.                             _smc.errorMSG();
  249.                         }
  250.                     }).always(function() {
  251.                         setTimeout(function() {
  252.                             _smc.progress_bar("end");
  253.                         }, 1500);
  254.                     });
  255.                 }
  256.  
  257.                 else {
  258.                     return false;
  259.                 }
  260.             }
  261.  
  262.             _smc.confirm_action = function(data = {}) {
  263.                 var modal    = "<div class='modal fadeIn confirm-actions-modal' tabindex='-1' data-onclose='remove' role='dialog' aria-hidden='true' data-keyboard='false' data-backdrop='static'><div class='modal-dialog modal-md' role='document'><div class='modal-content'><div class='modal-body'><h4>{0}</h4><p>{1}</p></div><div class='modal-footer'><button id='confirm-actions-confirm' type='button' class='btn btn-custom main-red md btn-block'>{3}</button><button id='confirm-actions-cancel' type='button' class='btn btn-custom main-grey md btn-block'>{2}</button></div></div></div></div>";
  264.                 var title    = data['title'];
  265.                 var message  = data['message'];
  266.                 var btn_1    = data['btn_1'];
  267.                 var btn_2    = data['btn_2'];
  268.                 var modal    = modal.format(title,message,btn_1,btn_2);
  269.                 var deferred = new $.Deferred();
  270.  
  271.                 _smc.user_lbox_rm();
  272.  
  273.                 $(document).on('click', '#confirm-actions-confirm', function(event) {
  274.                     $(this).attr("disabled", true).text("Please wait");
  275.                     deferred.resolve();
  276.                 });
  277.  
  278.                 $(document).on('click', '#confirm-actions-cancel', function(event) {
  279.                     deferred.reject();
  280.                 });
  281.  
  282.                 $('div[data-app="black-hole"]').append($(modal)).find('div.confirm-actions-modal').modal('show');
  283.  
  284.                 return deferred.promise();
  285.             }
  286.  
  287.             _smc.req_auth = function() {
  288.                 var modal = "<div class='modal fadeIn info-popup-modal' tabindex='-1' data-onclose='remove' role='dialog' aria-hidden='true' data-keyboard='false' data-backdrop='static'><div class='modal-dialog modal-md' role='document'><div class='modal-content'><div class='modal-body'><h4>This action requires authorization!</h4><p>Please log in to your account in order to perform this action, or register if you do not already have an account on -<b >Spoutible</b></p></div><div class='modal-footer'><button data-dismiss='modal' type='button' class='btn btn-block btn-custom main-inline lg'>Ok!</button></div></div></div></div>";
  289.  
  290.                 $('div[data-app="black-hole"]').append($(modal)).find('div.info-popup-modal').modal('show');
  291.             }
  292.  
  293.             _smc.show_alt = function(alt) {
  294.                 var modal = $("<div class='modal fadeIn info-popup-modal' tabindex='-1' data-onclose='remove' role='dialog' aria-hidden='true' data-keyboard='false' data-backdrop='static'><div class='modal-dialog modal-md' role='document'><div class='modal-content'><div class='modal-body'><h4>Image Description</h4><p data-alt-text></p></div><div class='modal-footer'><button data-dismiss='modal' type='button' class='btn btn-block btn-custom main-inline lg'>Close</button></div></div></div></div>");
  295.                 modal.find('[data-alt-text]').text(alt).css('white-space','break-spaces')
  296.                 $('div[data-app="black-hole"]').append(modal).find('div.info-popup-modal').modal('show');
  297.             }
  298.  
  299.             _smc.info = function(title = "", body = "") {
  300.                 var modal = "<div class='modal fadeIn info-popup-modal' tabindex='-1' data-onclose='remove' role='dialog' aria-hidden='true' data-keyboard='false' data-backdrop='static'><div class='modal-dialog modal-md' role='document'><div class='modal-content'><div class='modal-body'><h4>{0}</h4><p>{1}</p></div><div class='modal-footer'><button data-dismiss='modal' type='button' class='btn btn-block btn-custom main-inline md btn-block'>Ok!</button></div></div></div></div>";
  301.                 var modal = modal.format(title, body);
  302.  
  303.                 $('div[data-app="black-hole"]').append($(modal)).find('div.info-popup-modal').modal('show');
  304.             }
  305.  
  306.             _smc.vote_poll = function(id = false, index = false) {
  307.                 if (_smc.is_logged()) {
  308.                     if ($.isNumeric(id) && $.isNumeric(index)) {
  309.                         var post_poll = $('[data-post-poll="{0}"]'.format(id));
  310.  
  311.                         if (post_poll.length && post_poll.data("status") != 1) {
  312.                             post_poll.data("status", 1);
  313.  
  314.                             $.ajax({
  315.                                 url: 'https://spoutible.com/sptbl_system_api/main/vote_poll',
  316.                                 type: 'POST',
  317.                                 dataType: 'json',
  318.                                 data: {
  319.                                     id: id,
  320.                                     option: index
  321.                                 }
  322.                             }).done(function(data) {
  323.                                 if (data.status == 200) {
  324.                                     for (var i = 0; i < data.poll.options.length; i++) {
  325.                                         var poll_option = post_poll.find('[data-poll-option="{0}"]'.format(i));
  326.                                         var data_option = data.poll.options[i];
  327.  
  328.                                         if (poll_option && poll_option.length) {
  329.                                             if (data_option.active != undefined) {
  330.                                                 poll_option.addClass("active");
  331.                                             }
  332.  
  333.                                             poll_option.find('b').text("{0}%".format(data_option.percentage));
  334.                                             poll_option.find('span').css("width", "{0}%".format(data_option.percentage));
  335.                                         }
  336.                                     }
  337.  
  338.                                     data.total_str && $('[data-votes-total-id="'+ id +'"]').text(data.total_str);
  339.                                 }
  340.                                 else {
  341.                                     _smc.errorMSG();
  342.                                 }
  343.                             });
  344.                         }
  345.                         else {
  346.                             return false;
  347.                         }
  348.                     }
  349.                 }
  350.  
  351.                 else {
  352.                     _smc.req_auth();
  353.                 }
  354.             }
  355.  
  356.             _smc.spout_reply = function(id = false, thread_reply_id = null, show_is_thread_checbox = false, show_collaborative_thread_options = false) {
  357.                 if (_smc.is_logged()) {
  358.                     if ($.isNumeric(id) && id) {
  359.                         SPTBL_APP.vue.pubbox2.$refs.modalPubbox.post_privacy = false;
  360.                         SPTBL_APP.vue.pubbox2.$refs.modalPubbox.thread_id = id;
  361.                         SPTBL_APP.vue.pubbox2.$refs.modalPubbox.thread_reply_id = thread_reply_id;
  362.                         SPTBL_APP.vue.pubbox2.$refs.modalPubbox.show_is_thread_checbox = show_is_thread_checbox;
  363.                         SPTBL_APP.vue.pubbox2.$refs.modalPubbox.is_thread_reply = show_is_thread_checbox;
  364.                         SPTBL_APP.vue.pubbox2.$refs.modalPubbox.show_collaborative_thread_options = show_collaborative_thread_options;
  365.                         SPTBL_APP.vue.pubbox2.$refs.modalPubbox.hide_threaded_posts()
  366.  
  367.                         $("div#add_new_post").modal('show');
  368.                     }
  369.                 }
  370.                 else {
  371.                     _smc.req_auth();
  372.                 }
  373.             }
  374.  
  375.             _smc.post_news = function(data = {}) {
  376.                 if (!_smc.is_logged()) {
  377.                     return _smc.req_auth();
  378.                 }
  379.  
  380.                 var post = new postModel();
  381.                 post.og_data = {
  382.                     title: data.title,
  383.                     description: data.text,
  384.                     image: data.image,
  385.                     type: 'article',
  386.                     url: data.url,
  387.                     image_loc: true
  388.                 };
  389.                 post.og_imported = true;
  390.  
  391.                 _smc.vue.pubbox2.$children[0].thread_posts = [post];
  392.  
  393.                 $("div#add_new_post").modal('show');
  394.             }
  395.  
  396.             _smc.show_post = function(id = false, type = false, force_override = false) {
  397.                 var IGNORE_SELECTORS = [
  398.                     '.ctrls-item',
  399.                     '[data-an="repost-ctrl"]',
  400.                     '[data-spa]',
  401.                     '[onclick^="SPTBL_APP."]:not([onclick^="SPTBL_APP.show_post"])',
  402.                     '.inline-top-likes',
  403.                     'blockquote.quoted-spout',
  404.                     '[data-ignore-show-post-click]',
  405.                     '.fbox-media',
  406.                     '.gifffer-play-button']
  407.  
  408.                 var target = window.event.target
  409.  
  410.                 if ( target && ! force_override ) {
  411.                     for ( var i=0; i<IGNORE_SELECTORS.length; i++ ) {
  412.                         if ( $(target).is(IGNORE_SELECTORS[i]) )
  413.                             return
  414.  
  415.                         if ( $(target).closest(IGNORE_SELECTORS[i]).length > 0 )
  416.                             return
  417.                     }
  418.                 }
  419.  
  420.                 if ($.isNumeric(id) && id) {
  421.                     var promise
  422.  
  423.                     if (type == "blocked") {
  424.                         promise = SPTBL_APP.confirm_action({
  425.                             btn_1: "Cancel",
  426.                             btn_2: "View",
  427.                             title: "Delete?",
  428.                             message: "Are you sure you want to see the content of this spout? Please note that the owner of the spout is on your blacklist."
  429.                         });
  430.                     }
  431.                     else if(type == "reported") {
  432.                         promise = SPTBL_APP.confirm_action({
  433.                             btn_1: "Cancel",
  434.                             btn_2: "View",
  435.                             title: "Delete?",
  436.                             message: "This spout has been hidden from you due to your complaint, as it may contain inappropriate content for you. Are you sure you want to see the content of this spout?"
  437.                         });
  438.                     }
  439.  
  440.                     if ( promise && promise.done ) {
  441.                         promise.done(function() {
  442.                             $('[data-softhidden-post="{0}"]'.format(id)).remove();
  443.                             $("div.confirm-actions-modal").modal("hide");
  444.                             SPTBL_APP.spa_load('/thread/' + String(id))
  445.                         });
  446.  
  447.                         promise.fail(function() {
  448.                             $("div.confirm-actions-modal").modal("hide");
  449.                         });
  450.                     } else {
  451.                         if (
  452.                             window.getSelection().toString().length > 0 ||
  453.                             target.href
  454.                         ) {
  455.                             return;
  456.                         }
  457.                         SPTBL_APP.spa_load('/thread/' + String(id))
  458.                     }
  459.                 }
  460.             }
  461.  
  462.             _smc.delete_post = function(id = false) {
  463.                 if ($.isNumeric(id) && id) {
  464.                     if (_smc.is_logged()) {
  465.                         var main_left_sb = $('div[data-app="left-sidebar"]');
  466.                         var promise      = SPTBL_APP.confirm_action({
  467.                             btn_1: "Cancel",
  468.                             btn_2: "Delete",
  469.                             title: "Delete?",
  470.                             message: "Deleting this Spout can't be undone and it will no longer be visible on our platform."
  471.                         });
  472.  
  473.                         promise.done(function() {
  474.                             $.ajax({
  475.                                 url: 'https://spoutible.com/sptbl_system_api/main/delete_post',
  476.                                 type: 'POST',
  477.                                 dataType: 'json',
  478.                                 data: {id: id},
  479.                             }).done(function(data) {
  480.                                 if (data.status != 200) {
  481.                                     _smc.errorMSG();
  482.                                 }
  483.                                 else {
  484.                                     if (_smc.curr_pn == 'home') {
  485.                                         var hp_tl_app = $('div[data-app="homepage"]');
  486.  
  487.                                         var item = hp_tl_app.find('div[data-an="entry-list"]').find('div[data-list-item="{0}"]'.format(id))
  488.                                         item.addClass('slideInUp');
  489.                                         item.on('animationend', function() {
  490.                                             $(this).remove();
  491.  
  492.                                             if (hp_tl_app.find('div[data-an="entry-list"]').find('div[data-list-item]').length < 1) {
  493.                                                 $(window).reloadPage(50);
  494.                                             }
  495.                                         });
  496.                                     } else if (_smc.curr_pn == 'profile') {
  497.                                         var profile_app = $('div[data-app="profile"]');
  498.  
  499.                                         var item = profile_app.find('div[data-an="entry-list"]').find('div[data-list-item="{0}"]'.format(id))
  500.                                         item.addClass('slideInUp');
  501.                                         item.on('animationend', function() {
  502.                                             $(this).remove();
  503.  
  504.                                             if (profile_app.find('div[data-an="entry-list"]').find('div[data-list-item]').length < 1) {
  505.                                                 $(window).reloadPage(50);
  506.                                             }
  507.                                         });
  508.                                     } else if(_smc.curr_pn == 'bookmarks') {
  509.                                         var bookmarks_app = $('div[data-app="bookmarks"]');
  510.  
  511.                                         var listItem = bookmarks_app.find('div[data-an="entry-list"]').find('div[data-list-item="{0}"]'.format(id))
  512.                                         listItem.addClass('slideInUp');
  513.                                         listItem.on('animationend', function() {
  514.                                             $(this).remove();
  515.  
  516.                                             if (bookmarks_app.find('div[data-an="entry-list"]').find('div[data-list-item]').length < 1) {
  517.                                                 $(window).reloadPage(50);
  518.                                             }
  519.                                         });
  520.                                     }
  521.                                     else if(_smc.curr_pn == 'search') {
  522.                                         var search_app = $('div[data-app="search"]');
  523.  
  524.                                         var listItem = search_app.find('div[data-an="entry-list"]').find('div[data-list-item="{0}"]'.format(id))
  525.                                         listItem.addClass('slideInUp');
  526.                                         listItem.on('animationend', function() {
  527.                                             $(this).remove();
  528.                                         });
  529.                                     }
  530.                                     else {
  531.                                         sptbl_redirect(data.url);
  532.                                     }
  533.                                 }
  534.                             }).always(function() {
  535.                                 $("div.confirm-actions-modal").modal("hide");
  536.                             });
  537.                         });
  538.  
  539.                         promise.fail(function() {
  540.                             $("div.confirm-actions-modal").modal("hide");
  541.                         });
  542.                     }
  543.                     else{
  544.                         _smc.req_auth();
  545.                     }
  546.                 }
  547.             }
  548.  
  549.             _smc.delete_chat = function(token) {
  550.                 var promise = SPTBL_APP.confirm_action({
  551.                     btn_1: "Cancel",
  552.                     btn_2: "Leave",
  553.                     title: "Delete?",
  554.                     message: 'Do you want to leave this conversation? Please note that this action cannot be undone!',
  555.                 });
  556.  
  557.                 promise.done(function () {
  558.                     $.ajax({
  559.                         url: 'https://spoutible.com/sptbl_system_api/conversation/delete_chat',
  560.                         type: 'POST',
  561.                         headers: {token: token},
  562.                         dataType: 'json',
  563.                         beforeSend: function () {
  564.                             $("div.confirm-actions-modal").modal("hide");
  565.                         }
  566.                     }).done(function (data) {
  567.                         if (data.status != 200) {
  568.                             SPTBL_APP.errorMSG();
  569.                             return;
  570.                         }
  571.  
  572.                         delay(function () {
  573.                             sptbl_redirect('https://spoutible.com/chats');
  574.                         }, 1000);
  575.                     });
  576.                 });
  577.  
  578.                 promise.fail(function () {
  579.                     $("div.confirm-actions-modal").modal("hide");
  580.                 });
  581.             }
  582.  
  583.             _smc.logout = function() {
  584.                 var promise = SPTBL_APP.confirm_action({
  585.                     btn_1: "Cancel",
  586.                     btn_2: "Logout",
  587.                     title: "Leaving already?",
  588.                     message: "Are you sure that you want to log out from your account?"
  589.                 });
  590.  
  591.                 promise.done(function() {
  592.                     sptbl_redirect("https://spoutible.com/logout");
  593.                 });
  594.  
  595.                 promise.fail(function() {
  596.                     $("div.confirm-actions-modal").modal("hide");
  597.                 });
  598.             }
  599.  
  600.             _smc.like_post = function(id = false, event = false) {
  601.                 if (_smc.is_logged()) {
  602.                     if ($.isNumeric(id) && id) {
  603.                         $(event).attr('disabled', 'true');
  604.                         $(event).find('.liked-icon svg').addClass('jiggle');
  605.  
  606.                         $.ajax({
  607.                             url: 'https://spoutible.com/sptbl_system_api/main/like_post',
  608.                             type: 'POST',
  609.                             dataType: 'json',
  610.                             data: {id: id},
  611.                         }).done(function(data) {
  612.                             if (data.status == 200) {
  613.                                 $(event).find('.liked-icon').toggleClass('d-none');
  614.                                 $(event).find('span[data-an="likes-count"]').text(data.likes_count);
  615.                                 $(event).toggleClass('liked').addClass('animated bounceIn').promise().done(function(){
  616.                                     delay(function() {
  617.                                         $(event).removeClass('animated bounceIn');
  618.                                     }, 1000);
  619.                                 });
  620.                             }
  621.                             else {
  622.                                 _smc.errorMSG();
  623.                             }
  624.  
  625.                         }).always(function() {
  626.                             $(event).removeAttr('disabled');
  627.                             $(event).find('.liked-icon svg').removeClass('jiggle');
  628.                         });
  629.                     }
  630.                 }
  631.                 else{
  632.                     _smc.req_auth();
  633.                 }
  634.             }
  635.  
  636.             _smc.repost = function(id = false, event = false) {
  637.                 if (_smc.is_logged()) {
  638.                     if ($.isNumeric(id) && id) {
  639.                         var mainbtn = $(event).closest('.post-action-button').find('.echoes-action-btn')
  640.  
  641.                         $(event).attr('disabled', 'true');
  642.                         mainbtn.find('svg').addClass('jiggle');
  643.  
  644.                         $.ajax({
  645.                             url: 'https://spoutible.com/sptbl_system_api/main/repost',
  646.                             type: 'POST',
  647.                             dataType: 'json',
  648.                             data: {id: id},
  649.                         }).done(function(data) {
  650.                             if (data.status == 200) {
  651.                                 if (mainbtn.hasClass('reposted')) {
  652.                                     mainbtn.removeClass('reposted');
  653.  
  654.                                     mainbtn.removeClass('reposted').addClass('animated bounceIn').promise().done(function(){
  655.                                         delay(function() {
  656.                                             $(event).removeClass('animated bounceIn');
  657.                                         }, 1000);
  658.                                     });
  659.  
  660.                                     $(event).closest('.post-action-button').find('span[data-an="reposts-count"]').text(data.reposts_count);
  661.                                     $(event).closest('.post-action-button').find('span[data-an="quotes-count"]').text(data.quotes_count);
  662.                                     $(event).closest('.post-action-button').find('span[data-an="echoes-count"]').text(data.reposts_count + data.quotes_count);
  663.  
  664.                                     if (_smc.curr_pn == 'home' || _smc.curr_pn == 'profile') {
  665.  
  666.                                         var timeline_app = ((_smc.curr_pn == 'home') ? $('div[data-app="homepage"]') : $('div[data-app="profile"]'));
  667.                                         var orig_post    = timeline_app.find('div[data-an="entry-list"]').find('[data-list-item="{0}"]'.format(id));
  668.                                         var repost       = timeline_app.find('div[data-an="entry-list"]').find('[data-repost="{0}"]'.format(data.repost_id));
  669.  
  670.                                         if (repost.length) {
  671.                                             repost.addClass('slideInUp');
  672.                                             repost.on('animationend', function() {
  673.                                                 $(this).remove();
  674.                                             });
  675.                                         }
  676.  
  677.                                         if (orig_post.length) {
  678.                                             if(orig_post.length > 1){
  679.                                             orig_post.each(function( index ) {
  680.                                             $(this).closest('.post-action-button').find('.echoes-action-btn').removeClass('reposted');
  681.                                             $(this).closest('.post-action-button').find('span[data-an="reposts-count"]').text(data.reposts_count);
  682.                                             $(this).closest('.post-action-button').find('span[data-an="quotes-count"]').text(data.quotes_count);
  683.                                             $(this).closest('.post-action-button').find('span[data-an="echoes-count"]').text(data.reposts_count + data.quotes_count);
  684.                                             $(this).closest('.post-action-button').find('span[data-an="reposts-count"]').addClass('animated bounceIn').promise().done(function(){
  685.                                                 delay(function() {
  686.                                                     $(event).removeClass('animated bounceIn');
  687.                                                 }, 1000);
  688.                                             });
  689.                                           });
  690.                                         }else{
  691.                                             orig_post.find('.echoes-action-btn').removeClass('reposted');
  692.                                             orig_post.closest('.post-action-button').find('span[data-an="reposts-count"]').text(data.reposts_count);
  693.                                             orig_post.closest('.post-action-button').find('span[data-an="quotes-count"]').text(data.quotes_count);
  694.                                             orig_post.closest('.post-action-button').find('span[data-an="echoes-count"]').text(data.reposts_count + data.quotes_count);
  695.                                             orig_post.find('span[data-an="reposts-count"]').addClass('animated bounceIn').promise().done(function(){
  696.                                                 delay(function() {
  697.                                                     $(event).removeClass('animated bounceIn');
  698.                                                 }, 1000);
  699.                                             });
  700.                                         }
  701.  
  702.                                         }
  703.                                     }
  704.                                 }
  705.                                 else {
  706.                                     mainbtn.addClass('reposted').addClass('animated bounceIn').promise().done(function(){
  707.                                         delay(function() {
  708.                                             $(event).removeClass('animated bounceIn');
  709.                                         }, 1000);
  710.                                     });
  711.  
  712.                                     $(event).closest('.post-action-button').find('span[data-an="reposts-count"]').text(data.reposts_count);
  713.                                     $(event).closest('.post-action-button').find('span[data-an="quotes-count"]').text(data.quotes_count);
  714.                                     $(event).closest('.post-action-button').find('span[data-an="echoes-count"]').text(data.reposts_count + data.quotes_count);
  715.                                 }
  716.                             }
  717.                             else {
  718.                                 _smc.errorMSG();
  719.                             }
  720.                         }).always(function() {
  721.                             $(event).removeAttr('disabled');
  722.                             mainbtn.find('svg').removeClass('jiggle');
  723.                         });
  724.                     }
  725.                 }
  726.                 else{
  727.                     _smc.req_auth();
  728.                 }
  729.             }
  730.  
  731.             _smc.quote = function(id = false, event = false, b64html) {
  732.                 if ( ! _smc.is_logged() )
  733.                     return _smc.req_auth()
  734.  
  735.                 _smc.vue.pubbox2.$children[0].is_thread_reply = null;
  736.                 _smc.vue.pubbox2.$children[0].show_threaded_posts = false;
  737.  
  738.                 var decodedString = new TextDecoder("utf-8").decode(new Uint8Array(Array.from(atob(b64html)).map(c => c.charCodeAt(0))));
  739.  
  740.                 $('#add_new_post').find('[name=quoted_spout]').val(String(id))
  741.                 $('#add_new_post').addClass('sptbl-action-quote').find('#quote-hint-text').show().find('.quote-hint').html(decodedString)
  742.             }
  743.  
  744.  
  745.             _smc.share_post = function(url = false, encoded_url = false, embed_data) {
  746.                 if (url && encoded_url) {
  747.                     var modal = "<div class='modal fadeIn share-post-modal' data-an='share-post' tabindex='-1' data-onclose='remove' role='dialog' aria-hidden='true' data-keyboard='false' data-backdrop='static'><div class='modal-dialog modal-md' role='document'><div class='modal-content'><div class='modal-header'><div class='modal-header__inner'><div data-el='timeline-bs-notifs' class='timeline-bs-notifs'></div><h5 class='modal-title'>Share post</h5><span class='dismiss-modal' data-dismiss='modal'><svg class='icon--close' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/close.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/close.svg?v=1.11.8#sptbl-icon'></use></svg></span></div></div><div class='modal-body'><div class='social-media-links'><a href='https://twitter.com/intent/tweet?url={0}' target='_blank' class='link-item twitter'><svg class='icon--logo-twitter' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-twitter.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-twitter.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://www.facebook.com/sharer.php?u={0}' target='_blank' class='link-item facebook'><svg class='icon--logo-facebook' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-facebook.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-facebook.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://www.linkedin.com/shareArticle?mini=true&url={0}' target='_blank' class='link-item linkedin'><svg class='icon--logo-linkedin' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-linkedin.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-linkedin.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://www.pinterest.ru/pin/create/button/?url={0}' target='_blank' class='link-item pinterest'><svg class='icon--logo-pinterest' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-pinterest.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-pinterest.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://www.reddit.com/submit?url={0}' target='_blank' class='link-item reddit'><svg class='icon--logo-reddit' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-reddit.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-reddit.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://api.whatsapp.com/send?text={0}' target='_blank' class='link-item whatsapp'><svg class='icon--logo-whatsapp' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-whatsapp.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-whatsapp.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://telegram.me/share/url?url={0}' target='_blank' class='link-item telegram'><svg class='icon--logo-telegram' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-telegram.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-telegram.svg?v=1.11.8#sptbl-icon'></use></svg></a></div><div class='raw-link'><p>Or copy link</p><div class='link-input'><input type='text' readonly='true' value='{1}' id='copy-link-input'><button data-clipboard-target='#copy-link-input' data-clipboard-action='copy' class='clip-board-copy copy-link'><svg class='icon--content_copy' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/content_copy.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/content_copy.svg?v=1.11.8#sptbl-icon'></use></svg></button></div></div></div></div></div></div>";
  748.  
  749.                     var modal = modal.format(encoded_url, url);
  750.  
  751.                     $('body').find('[data-app="black-hole"]').append($(modal)).promise().done(function() {
  752.                         $('body').find('[data-app="black-hole"]').find('[data-an="share-post"]').modal('show');
  753.                     });
  754.                 }
  755.             }
  756.  
  757.             _smc.read_summary = function(event) {
  758.                 var target = event.target
  759.                 var summary = target.dataset.summary
  760.                 var id = target.dataset.id
  761.  
  762.                 if (summary) {
  763.                     $('#thread-summary-modal .modal-body span').html(atob(summary));
  764.                     $('#thread-summary-modal .modal-body .loading').addClass('d-none');
  765.                     $('#thread-summary-modal').modal('show');
  766.                 } else {
  767.                     $('#thread-summary-modal .modal-body span').html('');
  768.                     $('#thread-summary-modal .modal-body .loading').removeClass('d-none');
  769.                     $('#thread-summary-modal .modal-body .alert-danger').html('').addClass('d-none');
  770.  
  771.                     $('#thread-summary-modal').modal('show');
  772.  
  773.                     $.ajax({
  774.                         url: 'https://spoutible.com/sptbl_system_api/chat_gpt/thread_summary?id=' + id,
  775.                         dataType: 'json',
  776.                     }).done(function(response) {
  777.                         if (response.status == 200) {
  778.                             $('#thread-summary-modal .modal-body span').html(response.summary);
  779.                             $('#thread-summary-modal .modal-body .loading').addClass('d-none');
  780.  
  781.                             target.dataset.summary = btoa(response.summary)
  782.                         } else {
  783.                             $('#thread-summary-modal .modal-body .alert-danger').html(response.error).removeClass('d-none');
  784.                             $('#thread-summary-modal .modal-body .loading').addClass('d-none');
  785.                             $('#thread-summary-modal .modal-body span').html('');
  786.                             _smc.errorMSG(response.error);
  787.                         }
  788.                     }).fail(function() {
  789.                         $('#thread-summary-modal .modal-body .alert-danger').html('Something went wrong!').removeClass('d-none');
  790.                         $('#thread-summary-modal .modal-body .loading').addClass('d-none');
  791.                         $('#thread-summary-modal .modal-body span').html('');
  792.                         _smc.errorMSG();
  793.                     });
  794.                 }
  795.             }
  796.  
  797.             _smc.share_news = function(url = false, encoded_url = false, embed_data) {
  798.                 if (url && encoded_url) {
  799.                     var modal = "<div class='modal fadeIn share-post-modal' data-an='share-news' tabindex='-1' data-onclose='remove' role='dialog' aria-hidden='true' data-keyboard='false' data-backdrop='static'><div class='modal-dialog modal-md' role='document'><div class='modal-content'><div class='modal-header'><div class='modal-header__inner'><div data-el='timeline-bs-notifs' class='timeline-bs-notifs'></div><h5 class='modal-title'>Share News</h5><span class='dismiss-modal' data-dismiss='modal'><svg class='icon--close' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/close.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/close.svg?v=1.11.8#sptbl-icon'></use></svg></span></div></div><div class='modal-body'><div class='social-media-links'><a href='https://twitter.com/intent/tweet?url={0}' target='_blank' class='link-item twitter'><svg class='icon--logo-twitter' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-twitter.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-twitter.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://www.facebook.com/sharer.php?u={0}' target='_blank' class='link-item facebook'><svg class='icon--logo-facebook' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-facebook.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-facebook.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://www.linkedin.com/shareArticle?mini=true&url={0}' target='_blank' class='link-item linkedin'><svg class='icon--logo-linkedin' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-linkedin.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-linkedin.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://www.pinterest.ru/pin/create/button/?url={0}' target='_blank' class='link-item pinterest'><svg class='icon--logo-pinterest' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-pinterest.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-pinterest.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://www.reddit.com/submit?url={0}' target='_blank' class='link-item reddit'><svg class='icon--logo-reddit' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-reddit.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-reddit.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://api.whatsapp.com/send?text={0}' target='_blank' class='link-item whatsapp'><svg class='icon--logo-whatsapp' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-whatsapp.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-whatsapp.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://telegram.me/share/url?url={0}' target='_blank' class='link-item telegram'><svg class='icon--logo-telegram' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-telegram.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-telegram.svg?v=1.11.8#sptbl-icon'></use></svg></a></div><div class='raw-link'><p>Or copy link</p><div class='link-input'><input type='text' readonly='true' value='{1}' id='copy-link-input'><button data-clipboard-target='#copy-link-input' data-clipboard-action='copy' class='clip-board-copy copy-link'><svg class='icon--content_copy' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/content_copy.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/content_copy.svg?v=1.11.8#sptbl-icon'></use></svg></button></div></div></div></div></div></div>";
  800.  
  801.                     var modal = modal.format(encoded_url, url);
  802.  
  803.                     $('body').find('[data-app="black-hole"]').append($(modal)).promise().done(function() {
  804.                         $('body').find('[data-app="black-hole"]').find('[data-an="share-news"]').modal('show');
  805.                     });
  806.                 }
  807.             }
  808.  
  809.             _smc.share_pod = function(url = false, encoded_url = false, embed_data) {
  810.                 if (url && encoded_url) {
  811.                     var modal = "<div class='modal fadeIn share-post-modal' data-an='share-pod' tabindex='-1' data-onclose='remove' role='dialog' aria-hidden='true' data-keyboard='false' data-backdrop='static'><div class='modal-dialog modal-md' role='document'><div class='modal-content'><div class='modal-header'><div class='modal-header__inner'><div data-el='timeline-bs-notifs' class='timeline-bs-notifs'></div><h5 class='modal-title'>Share Pod</h5><span class='dismiss-modal' data-dismiss='modal'><svg class='icon--close' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/close.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/close.svg?v=1.11.8#sptbl-icon'></use></svg></span></div></div><div class='modal-body'><div class='social-media-links'><a href='https://twitter.com/intent/tweet?url={0}' target='_blank' class='link-item twitter'><svg class='icon--logo-twitter' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-twitter.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-twitter.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://www.facebook.com/sharer.php?u={0}' target='_blank' class='link-item facebook'><svg class='icon--logo-facebook' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-facebook.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-facebook.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://www.linkedin.com/shareArticle?mini=true&url={0}' target='_blank' class='link-item linkedin'><svg class='icon--logo-linkedin' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-linkedin.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-linkedin.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://www.pinterest.ru/pin/create/button/?url={0}' target='_blank' class='link-item pinterest'><svg class='icon--logo-pinterest' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-pinterest.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-pinterest.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://www.reddit.com/submit?url={0}' target='_blank' class='link-item reddit'><svg class='icon--logo-reddit' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-reddit.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-reddit.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://api.whatsapp.com/send?text={0}' target='_blank' class='link-item whatsapp'><svg class='icon--logo-whatsapp' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-whatsapp.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-whatsapp.svg?v=1.11.8#sptbl-icon'></use></svg></a><a href='https://telegram.me/share/url?url={0}' target='_blank' class='link-item telegram'><svg class='icon--logo-telegram' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/logos/logo-telegram.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/logos/logo-telegram.svg?v=1.11.8#sptbl-icon'></use></svg></a></div><div class='raw-link'><p>Or copy link</p><div class='link-input'><input type='text' readonly='true' value='{1}' id='copy-link-input'><button data-clipboard-target='#copy-link-input' data-clipboard-action='copy' class='clip-board-copy copy-link'><svg class='icon--content_copy' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/content_copy.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/content_copy.svg?v=1.11.8#sptbl-icon'></use></svg></button></div></div></div></div></div></div>";
  812.  
  813.                     var modal = modal.format(encoded_url, url);
  814.  
  815.                     $('body').find('[data-app="black-hole"]').append($(modal)).promise().done(function() {
  816.                         $('body').find('[data-app="black-hole"]').find('[data-an="share-pod"]').modal('show');
  817.                     });
  818.                 }
  819.             }
  820.  
  821.             _smc.embed_post = function(url, embed_data) {
  822.                 if (url && embed_data) {
  823.                     var modal = "<div class='modal fadeIn share-post-modal' data-an='share-post' tabindex='-1' data-onclose='remove' role='dialog' aria-hidden='true' data-keyboard='false' data-backdrop='static'><div class='modal-dialog modal-md' role='document'><div class='modal-content'><div class='modal-header'><div class='modal-header__inner'><div data-el='timeline-bs-notifs' class='timeline-bs-notifs'></div><h5 class='modal-title'>Embed spout</h5><span class='dismiss-modal' data-dismiss='modal'><svg class='icon--close' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/close.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/close.svg?v=1.11.8#sptbl-icon'></use></svg></span></div></div><div class='modal-body'><div class='raw-link' style='padding-top:5px'><p>Copy embed code</p>"
  824.                         + "<div class='link-input'><input type='text' readonly='true' value='{1}' id='copy-link-input'><button data-clipboard-target='#copy-link-input' data-clipboard-action='copy' class='clip-board-copy copy-link'><svg class='icon--content_copy' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/content_copy.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/content_copy.svg?v=1.11.8#sptbl-icon'></use></svg></button></div>"
  825.                         + "</div></div></div></div></div>";
  826.  
  827.                     var embed_code = '<iframe src="' + url + '?embed=1" border="0" width="600" height="400"></iframe>'
  828.  
  829.                     try {
  830.                         var embed = JSON.parse(atob(embed_data))
  831.                         embed_code = '<blockquote class="sptbl-spout">'
  832.                                + '<p dir="ltr" lang="en">' + embed.html + '</p>'
  833.                                + '— ' + embed.author + ' (@' + embed.author_username + ') '
  834.                                + '<a href="' + url + '">' + embed.date + '</a></blockquote>'
  835.                                + '<script async charset="utf-8" src="https://spoutible.com/embed.js"><\/script>'
  836.  
  837.                     } catch(err) {}
  838.  
  839.                     var modal = modal.format(url, embed_code);
  840.  
  841.                     $('body').find('[data-app="black-hole"]').append($(modal)).promise().done(function() {
  842.                         $('body').find('[data-app="black-hole"]').find('[data-an="share-post"]').modal('show');
  843.                     });
  844.                 }
  845.             }
  846.  
  847.             _smc.pin = function(id, elem) {
  848.                 if ( ! _smc.is_logged() )
  849.                     return _smc.req_auth()
  850.  
  851.                 var unpin = JSON.parse($(elem).attr('data-pinned'))
  852.  
  853.                 $.ajax({
  854.                     url: 'https://spoutible.com/sptbl_system_api/main/pin_spout',
  855.                     type: 'POST',
  856.                     dataType: 'json',
  857.                     data: {
  858.                         id: id,
  859.                         action: unpin ? 'unpin' : 'pin',
  860.                     },
  861.                 }).done(function(data) {
  862.                     if (data.status == 200) {
  863.                         _smc.info( 'Pinned spouts', unpin
  864.                             ? 'Your existing spout was unpinned successfully!'
  865.                             : 'New spout pinned successfully!' );
  866.  
  867.                         $(elem).attr('data-pinned', data.pinned ? 'true' : 'false');
  868.                     } else {
  869.                         _smc.errorMSG();
  870.                     }
  871.                 });
  872.             }
  873.  
  874.             _smc.isURL = function(str = "") {
  875.                 var regex = new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$", "i");
  876.                 return regex.test(str);
  877.             }
  878.  
  879.             _smc.show_likes = function(id = false) {
  880.                 if ($.isNumeric(id) && id) {
  881.                     $.ajax({
  882.                         url: 'https://spoutible.com/sptbl_system_api/main/show_likes',
  883.                         type: 'POST',
  884.                         dataType: 'json',
  885.                         data: {id: id},
  886.                     }).done(function(data) {
  887.                         if (data.status == 200) {
  888.                             $('div[data-app="black-hole"]').append($(data.html)).find('div[data-app="post-likes-list"]').modal('show');
  889.                         }
  890.  
  891.                         else if(data.status == 404) {
  892.                             _smc.info("No likes yet!", "This spout appears to have no likes yet. To like this pspout, click <svg class='icon--sentiment_satisfied' viewBox='0 0 24 24'><use xlink:href='/themes/default/statics/icons/sentiment_satisfied.svg?v=1.11.8#sptbl-icon' href='/themes/default/statics/icons/sentiment_satisfied.svg?v=1.11.8#sptbl-icon'></use></svg> below it.");
  893.                         }
  894.  
  895.                         else {
  896.                             _smc.errorMSG();
  897.                         }
  898.                     });
  899.                 }
  900.             }
  901.  
  902.             _smc.show_embed_modal = function(post) {
  903.                 _smc.reset_embed_post()
  904.  
  905.                 if (typeof post !== 'object') {
  906.                     $.ajax({
  907.                         url: 'https://spoutible.com/sptbl_system_api/spouts/get',
  908.                         data: {id: post},
  909.                         dataType: 'json',
  910.                     }).done(function(data) {
  911.                         if (data.status == 200) {
  912.                             _smc.render_embed_post(data.post)
  913.                         } else {
  914.                             SPTBL_APP.errorMSG();
  915.                         }
  916.                     })
  917.                 } else {
  918.                     _smc.render_embed_post(post)
  919.                 }
  920.             }
  921.  
  922.             _smc.reset_embed_post = function() {
  923.                 $('div[data-app="embed-post-modal"] textarea').val('')
  924.                 $('div[data-app="embed-post-modal"] .spout-avatar').attr('src', '');
  925.                 $('div[data-app="embed-post-modal"] .spout_name').html('');
  926.                 $('div[data-app="embed-post-modal"] .spout_userhandle').html('');
  927.                 $('div[data-app="embed-post-modal"] .spout_text').html('');
  928.                 $('div[data-app="embed-post-modal"] .spout_date').html('');
  929.                 $('div[data-app="embed-post-modal"] .spout_likes span').html('');
  930.                 $('div[data-app="embed-post-modal"] .spout_replies span').html('');
  931.                 $('div[data-app="embed-post-modal"] .spout_reposts span').html('');
  932.                 $('div[data-app="embed-post-modal"] .quoted-spout-container').html('');
  933.                 $('div[data-app="embed-post-modal"] .spout-media').html('')
  934.             }
  935.  
  936.             _smc.render_embed_post = function(post) {
  937.                 const icon_verified = '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg id="sptbl-icon"  viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="none"><g id="SVGRepo_bgCarrier" stroke-width="0"/><g id="SVGRepo_iconCarrier"><path fill="#67c1f4" fill-rule="evenodd" d="M9.166.33a2.25 2.25 0 00-2.332 0l-5.25 3.182A2.25 2.25 0 00.5 5.436v5.128a2.25 2.25 0 001.084 1.924l5.25 3.182a2.25 2.25 0 002.332 0l5.25-3.182a2.25 2.25 0 001.084-1.924V5.436a2.25 2.25 0 00-1.084-1.924L9.166.33zm1.054 5.39a.75.75 0 111.06 1.06l-4 4a.75.75 0 01-1.06 0l-2-2a.75.75 0 011.06-1.06l1.47 1.47 3.47-3.47z" clip-rule="evenodd"/></g></svg>'
  938.                 const icon_echo = '\<\?xml version="1.0" encoding="utf-8"?><svg id="sptbl-icon"  viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M5.636,4.222a1,1,0,0,1,0,1.414,9.01,9.01,0,0,0,0,12.728,1,1,0,1,1-1.414,1.414,11.012,11.012,0,0,1,0-15.556A1,1,0,0,1,5.636,4.222ZM18.364,18.364a1,1,0,1,0,1.414,1.414,11.012,11.012,0,0,0,0-15.556,1,1,0,1,0-1.414,1.414A9.01,9.01,0,0,1,18.364,18.364ZM7.379,17.692l.036.035a.941.941,0,0,0,.65.261,1.018,1.018,0,0,0,.728-.316,1.031,1.031,0,0,0-.036-1.429,6.008,6.008,0,0,1,0-8.486A1,1,0,1,0,7.343,6.343,8.02,8.02,0,0,0,7.379,17.692Zm7.972-11.3A1,1,0,0,0,15.337,7.8a6.019,6.019,0,0,1-.044,8.442,1,1,0,1,0,1.414,1.414A8.025,8.025,0,0,0,16.765,6.4,1,1,0,0,0,15.351,6.387ZM15,12a3,3,0,1,1-3-3A3,3,0,0,1,15,12Zm-2,0a1,1,0,1,0-1,1A1,1,0,0,0,13,12Z"/></svg>'
  939.  
  940.                 $('div[data-app="embed-post-modal"] textarea').val('\<link rel="stylesheet" href="https://static.spoutible.com/spout/embed.css"\>\n\<script async src="https://static.spoutible.com/spout/embed.js"\>\</script\>\n\<div class="sptbl_embed-spout" data-spout-id="'+post.id+'"\>\</div\>')
  941.                 $('div[data-app="embed-post-modal"] .spout-avatar').attr('src', post.owner.avatar);
  942.                 if (post.owner.verified) {
  943.                     $('div[data-app="embed-post-modal"] .spout_name').html(post.owner.name + ' <span class="user-name-holder__badge">' + icon_verified + '</span>');
  944.                 } else {
  945.                     $('div[data-app="embed-post-modal"] .spout_name').html(post.owner.name);
  946.                 }
  947.  
  948.                 $('div[data-app="embed-post-modal"] .spout_userhandle').html('@' + post.owner.username);
  949.                 $('div[data-app="embed-post-modal"] .spout_text').html(post.text);
  950.                 $('div[data-app="embed-post-modal"] .spout_date').html(post.time_formatted);
  951.                 $('div[data-app="embed-post-modal"] .spout_likes span').html(post.likes_count);
  952.                 $('div[data-app="embed-post-modal"] .spout_replies span').html(post.replys_count);
  953.                 $('div[data-app="embed-post-modal"] .spout_reposts span').html(parseInt(post.reposts_count || 0) + parseInt(post.quotes_count || 0));
  954.  
  955.                 if (!!post.quoted_spout_data) {
  956.                     $('div[data-app="embed-post-modal"] .quoted-spout-container').html(`
  957.                         <blockquote class="quoted-spout">
  958.                             <div class="quote-header">
  959.                                 <img src="${post.quoted_spout_data.owner.avatar}" height="20" width="20" />
  960.                                 <div class="quoted-spout-user-details">
  961.                                     <span class="quote-uname">
  962.                                         ${post.quoted_spout_data.owner.name}
  963.                                         ${data.owner.verified == 1 ? '<span class="user-name-holder__badge">' + icon_verified + '</span>' : ''}
  964.                                     </span>
  965.                                     ${post.quoted_spout_data.owner.verified == 1 ? '<span class="user-name-holder__badge">' + verified + '</span>' : ''}
  966.                                     <span class="quote-uuname">@${post.quoted_spout_data.owner.username}</span>
  967.                                 </div>
  968.                             </div>
  969.                             <div class="spout-text">${post.quoted_spout_data.text}</div>
  970.                         </blockquote>
  971.                     `);
  972.                 }
  973.                 if (post.type == 'image' && post.media) {
  974.                     if (post.media.length > 1) {
  975.                         let content = ''
  976.                         for (let index = 0; index < post.media.length; index++) {
  977.                             const element = post.media[index];
  978.  
  979.                             content += `
  980.                                 <div class="spout-image spout-gallery-image">
  981.                                     <img src="https://media.spoutible.com/${post.media[index].src}" alt="${post.media[index].x.alt ?? 'Picture'}">
  982.                                 </div>
  983.                             `;
  984.  
  985.                             $('div[data-app="embed-post-modal"] .spout-media').html(content);
  986.                         }
  987.                     } else {
  988.                         $('div[data-app="embed-post-modal"] .spout-media').html(`<div class="spout-image"><img src="https://media.spoutible.com/${post.media[0].src}" alt="${post.media[0].x.alt ?? 'Picture'}"></div>`);
  989.                     }
  990.                 } else if (post.type == 'gif') {
  991.                     $('div[data-app="embed-post-modal"] .spout-media').html(`<div class="spout-image"><img src="${post.media[0].src}" alt="${post.media[0].x.alt ?? 'GIF'}"></div>`);
  992.                 } else if (post.type == 'video' && post.media) {
  993.                     $('div[data-app="embed-post-modal"] .spout-media').html(`<img src="https://media.spoutible.com/${post.media[0]?.x.poster_thumb}" alt="Video">`);
  994.                 } else if (post.type == 'poll' && post?.media) {
  995.                     let content = '<div class="spout-poll">'
  996.                     for (let index = 0; index < post.poll.options.length; index++) {
  997.                         const pollData = post.poll.options[index];
  998.                         content += `
  999.                         <div class="spout-poll__option">
  1000.                             <div class="bar-icon">
  1001.                             <svg id="sptbl-icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" ><path d="M0 0h24v24H0V0z" fill="none"/><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z"/></svg>
  1002.                             </div>
  1003.                             <div class="bar-text">
  1004.                                 <p>${pollData.option}</p>
  1005.                             </div>
  1006.                             <div class="bar-num">
  1007.                                 <b>${post.poll.has_voted ? pollData.percentage + '%' : ''}</b>
  1008.                             </div>
  1009.  
  1010.                             <span class="bar-slider" style="width: ${pollData.percentage ? pollData.percentage : 0}%"></span>
  1011.                         </div>
  1012.                         `;
  1013.                     }
  1014.                     content += '</div>'
  1015.  
  1016.                     $('div[data-app="embed-post-modal"] .spout-media').html(content);
  1017.                 } else if (post.og_data) {
  1018.                     let content = ''
  1019.                     if (post.og_data.url) {
  1020.                         content = `
  1021.                             <div class="spout-og">
  1022.                                 <a class="spout-og__inner link" href="${post.og_data.url}">
  1023.                                 <div class="spout-og__image">
  1024.                                     <img src="${post.og_data.image}" alt="IMG">
  1025.                                 </div>
  1026.  
  1027.                                 <div class="spout-og__description">
  1028.                                     <h5>${post.og_data.title}</h5>
  1029.                                     <p>${post.og_data.description}</p>
  1030.                                     <a href="${post.og_data.url}" target="_blank" rel="noopener noreferrer"></a>
  1031.                                 </div>
  1032.                                 </a>
  1033.                             </div>
  1034.                         `;
  1035.                     }
  1036.  
  1037.                     $('div[data-app="embed-post-modal"] .spout-media').html(content);
  1038.                 }
  1039.                 $('div[data-app="embed-post-modal"]').modal('show');
  1040.             }
  1041.  
  1042.             _smc.show_edits = function(id = false) {
  1043.                 if ($.isNumeric(id) && id) {
  1044.                     if ( $('.edits--spout-' + id).length ) {
  1045.                         $('div[data-app="black-hole"]').append($('.edits--spout-' + id).html()).find('div[data-app="post-edits"]').modal('show');
  1046.                         return
  1047.                     }
  1048.  
  1049.                     $.ajax({
  1050.                         url: 'https://spoutible.com/sptbl_system_api/main/show_edits',
  1051.                         type: 'POST',
  1052.                         dataType: 'json',
  1053.                         data: {id: id},
  1054.                     }).done(function(data) {
  1055.                         if (data.status == 200) {
  1056.                             $('div[data-app="black-hole"]').append($(data.html)).find('div[data-app="post-edits"]').modal('show');
  1057.                         }
  1058.  
  1059.                         else if(data.status == 404) {
  1060.                             _smc.info("No edits yet!", "This post appears to have edits made yet.");
  1061.                         }
  1062.  
  1063.                         else {
  1064.                             _smc.errorMSG();
  1065.                         }
  1066.                     });
  1067.                 }
  1068.             }
  1069.  
  1070.             _smc.edit_post = function(id = false) {
  1071.                 if ($.isNumeric(id) && id) {
  1072.                     $.ajax({
  1073.                         url: 'https://spoutible.com/sptbl_system_api/edit_post/get_data',
  1074.                         type: 'GET',
  1075.                         dataType: 'json',
  1076.                         data: {id: id},
  1077.                     }).done(function(data) {
  1078.                         if (data.status == 200) {
  1079.                             $('div[data-app="black-hole"]').append($(data.html)).find('div[data-app="post-text-edit"]').modal('show');
  1080.                         }
  1081.                         else {
  1082.                             _smc.errorMSG();
  1083.                         }
  1084.                     });
  1085.                 }
  1086.             }
  1087.  
  1088.             _smc.edit_collaborative_thread_users = function(id = false) {
  1089.                 if ($.isNumeric(id) && id) {
  1090.                     $.ajax({
  1091.                         url: 'https://spoutible.com/sptbl_system_api/edit_post/get_collaborative_thread_users',
  1092.                         type: 'GET',
  1093.                         dataType: 'json',
  1094.                         data: {id: id},
  1095.                     }).done(function(data) {
  1096.                         if (data.status == 200) {
  1097.                             $('div[data-app="black-hole"]').append($(data.html)).find('div[data-app="post-edit_collaborative_thread_users"]').modal('show');
  1098.                         }
  1099.                         else {
  1100.                             _smc.errorMSG();
  1101.                         }
  1102.                     });
  1103.                 }
  1104.             }
  1105.  
  1106.             _smc.bookmark_post = function(id = false, _self = false) {
  1107.                 if (_smc.is_logged()) {
  1108.                     if ($.isNumeric(id) && id) {
  1109.                         $.ajax({
  1110.                             url: 'https://spoutible.com/sptbl_system_api/main/bookmark_post',
  1111.                             type: 'POST',
  1112.                             dataType: 'json',
  1113.                             data: {id: id, a: 'save'},
  1114.                         }).done(function(data) {
  1115.                             if (data.status == 200) {
  1116.                                 if (data.status_code == '1') {
  1117.                                     sptbl_bs_notify("Post has been bookmarked!", 500);
  1118.  
  1119.                                     $(_self).text("Remove Bookmark");
  1120.                                 }
  1121.                                 else {
  1122.                                     sptbl_bs_notify("Post has been deleted from bookmarks!",500);
  1123.                                     $(_self).text("Bookmark");
  1124.                                 }
  1125.                             }
  1126.                             else {
  1127.                                 _smc.errorMSG();
  1128.                             }
  1129.                         });
  1130.                     }
  1131.                 }
  1132.                 else {
  1133.                     _smc.req_auth();
  1134.                 }
  1135.             }
  1136.  
  1137.             _smc.load_likes = function(id = false, event = false) {
  1138.                 if ($.isNumeric(id) && id) {
  1139.                     var _self     = $(event);
  1140.                     var likes_ls  = $('div[data-app="post-likes-list"]');
  1141.                     var last_item = likes_ls.find('div[data-list-item]').last();
  1142.  
  1143.                     if (last_item.length) {
  1144.                         $.ajax({
  1145.                             url: 'https://spoutible.com/sptbl_system_api/main/load_likes',
  1146.                             type: 'GET',
  1147.                             dataType: 'json',
  1148.                             data: {id: id, offset: last_item.data('list-item')},
  1149.                             beforeSend: function() {
  1150.                                 _self.attr('disabled', 'true').text("Please wait");
  1151.                             }
  1152.                         }).done(function(data) {
  1153.                             if (data.status == 200) {
  1154.                                 likes_ls.find('div[data-an="users-ls"]').append($(data.html));
  1155.  
  1156.                                 _self.removeAttr('disabled').text("Show more");
  1157.                             }
  1158.                             else {
  1159.                                 _self.text("That is all for now!");
  1160.                             }
  1161.                         });
  1162.                     }
  1163.                 }
  1164.             }
  1165.  
  1166.             _smc.follow = function(event = false) {
  1167.                 if (event) {
  1168.                     if (_smc.is_logged()) {
  1169.                         var target = $(event);
  1170.  
  1171.                         if(target.data('action') == 'unfollow') {
  1172.                             var promise = SPTBL_APP.confirm_action({
  1173.                                 btn_1: "Cancel",
  1174.                                 btn_2: "Unfollow",
  1175.                                 title: "Delete?",
  1176.                                 message: "Please note that, if you unsubscribe then this user's posts will no longer appear in the feed on your main page.",
  1177.                             });
  1178.  
  1179.                             promise.done(function() {
  1180.                                 target.data('action', 'follow');
  1181.  
  1182.                                 target.text("Follow");
  1183.                                 target.replaceClass('main-inline','main-outline');
  1184.  
  1185.                                 $.ajax({
  1186.                                     url: 'https://spoutible.com/sptbl_system_api/main/follow',
  1187.                                     type: 'POST',
  1188.                                     dataType: 'json',
  1189.                                     data: {id: target.data('id')},
  1190.                                 }).done(function(data) {
  1191.                                     if (data.status != 200) {
  1192.                                         _smc.errorMSG();
  1193.                                     }
  1194.                                     else {
  1195.                                         if (_smc.curr_pn == "profile") {
  1196.                                             if (data.refresh != undefined) {
  1197.                                                 $(window).reloadPage(1000);
  1198.                                             }
  1199.                                         }
  1200.                                     }
  1201.                                 }).always(function() {
  1202.                                     $("div.confirm-actions-modal").modal("hide");
  1203.                                 });
  1204.  
  1205.                                 sptbl_bs_notify("You unfollowed <b>@{0}</b>".format(target.data("user-name")), 1500);
  1206.                             });
  1207.  
  1208.                             promise.fail(function() {
  1209.                                 $("div.confirm-actions-modal").modal("hide");
  1210.                             });
  1211.                         }
  1212.  
  1213.                             else {
  1214.                                 target.data('action', 'unfollow');
  1215.                                 target.text("Following");
  1216.                                 target.replaceClass('main-outline','main-inline');
  1217.  
  1218.                                 delay(function(){
  1219.                                     target.text("Unfollow");
  1220.                                 }, 1500);
  1221.  
  1222.  
  1223.                             $.ajax({
  1224.                                 url: 'https://spoutible.com/sptbl_system_api/main/follow',
  1225.                                 type: 'POST',
  1226.                                 dataType: 'json',
  1227.                                 data: {id: target.data('id')},
  1228.                             }).done(function(data) {
  1229.                                 if (data.status != 200) {
  1230.                                     _smc.errorMSG();
  1231.                                 }
  1232.                                 else {
  1233.                                     if (_smc.curr_pn == "profile") {
  1234.                                         if (data.refresh != undefined) {
  1235.                                             $(window).reloadPage(1000);
  1236.                                         }
  1237.                                     }
  1238.                                 }
  1239.                             });
  1240.  
  1241.                             sptbl_bs_notify("You followed <b>@{0}</b>".format(target.data("user-name")), 1500);
  1242.                         }
  1243.                     }
  1244.                     else{
  1245.                         _smc.req_auth();
  1246.                     }
  1247.                 }
  1248.             }
  1249.  
  1250.             _smc.req_follow = function(event = false) {
  1251.                 if (event) {
  1252.                     if (_smc.is_logged()) {
  1253.                         var target = $(event);
  1254.  
  1255.                         if(target.data('action') == 'unfollow') {
  1256.                             var promise = SPTBL_APP.confirm_action({
  1257.                                 btn_1: "Cancel",
  1258.                                 btn_2: "Unfollow",
  1259.                                 title: "Delete?",
  1260.                                 message: "Please note that, if you unsubscribe then this user's posts will no longer appear in the feed on your main page.",
  1261.                             });
  1262.  
  1263.                             promise.done(function() {
  1264.                                 target.data('action', 'follow');
  1265.                                 target.text("Follow");
  1266.                                 target.replaceClass('main-inline','main-outline');
  1267.  
  1268.                                 $.ajax({
  1269.                                     url: 'https://spoutible.com/sptbl_system_api/main/follow',
  1270.                                     type: 'POST',
  1271.                                     dataType: 'json',
  1272.                                     data: {id: target.data('id')},
  1273.                                 }).done(function(data) {
  1274.                                     if (data.status != 200) {
  1275.                                         _smc.errorMSG();
  1276.                                     }
  1277.                                 }).always(function() {
  1278.                                     $("div.confirm-actions-modal").modal("hide");
  1279.                                 });
  1280.  
  1281.                                 sptbl_bs_notify("You unfollowed <b>@{0}</b>".format(target.data("user-name")), 1500);
  1282.                             });
  1283.  
  1284.                             promise.fail(function() {
  1285.                                 $("div.confirm-actions-modal").modal("hide");
  1286.                             });
  1287.                         }
  1288.                         else if(target.data('action') == 'cancel') {
  1289.                             var promise = SPTBL_APP.confirm_action({
  1290.                                 btn_1: "Cancel",
  1291.                                 btn_2: "Cancel request",
  1292.                                 title: "Delete?",
  1293.                                 message: "This will cancel your pending request and this user will no longer see it.",
  1294.                             });
  1295.  
  1296.                             promise.done(function() {
  1297.                                 target.data('action', 'follow');
  1298.                                 target.text("Follow");
  1299.                                 target.replaceClass('main-inline','main-outline');
  1300.  
  1301.                                 $.ajax({
  1302.                                     url: 'https://spoutible.com/sptbl_system_api/main/follow',
  1303.                                     type: 'POST',
  1304.                                     dataType: 'json',
  1305.                                     data: {id: target.data('id')},
  1306.                                 }).done(function(data) {
  1307.                                     if (data.status != 200) {
  1308.                                         _smc.errorMSG();
  1309.                                     }
  1310.                                 }).always(function() {
  1311.                                     $("div.confirm-actions-modal").modal("hide");
  1312.                                 });
  1313.  
  1314.                                 sptbl_bs_notify("You unfollowed <b>@{0}</b>".format(target.data("user-name")), 1500);
  1315.                             });
  1316.  
  1317.                             promise.fail(function() {
  1318.                                 $("div.confirm-actions-modal").modal("hide");
  1319.                             });
  1320.                         }
  1321.  
  1322.                         else {
  1323.                             target.data('action', 'cancel');
  1324.                             target.text("Requested");
  1325.                             target.replaceClass('main-outline', 'main-inline');
  1326.  
  1327.                             delay(function() {
  1328.                                 target.text("Pending");
  1329.                             }, 1500);
  1330.  
  1331.                             $.ajax({
  1332.                                 url: 'https://spoutible.com/sptbl_system_api/main/follow',
  1333.                                 type: 'POST',
  1334.                                 dataType: 'json',
  1335.                                 data: {id: target.data('id')},
  1336.                             }).done(function(data) {
  1337.                                 if (data.status != 200) {
  1338.                                     _smc.errorMSG();
  1339.                                 }
  1340.                             });
  1341.  
  1342.                             sptbl_bs_notify("Follow request sent to <b>@{0}</b>".format(target.data("user-name")), 1500);
  1343.                         }
  1344.                     }
  1345.                     else{
  1346.                         _smc.req_auth();
  1347.                     }
  1348.                 }
  1349.             }
  1350.  
  1351.             _smc.block = function(event = false) {
  1352.                 if (event) {
  1353.                     if (_smc.is_logged()) {
  1354.                         var target = $(event);
  1355.  
  1356.                         if(target.data('action') == 'block') {
  1357.                             var promise = SPTBL_APP.confirm_action({
  1358.                                 btn_1: "Cancel",
  1359.                                 btn_2: "Block",
  1360.                                 title: "Delete?",
  1361.                                 message: "Blocked users will no longer be able to write a message to you, follow you, or see your profile and spouts, etc.",
  1362.                             });
  1363.  
  1364.                             promise.done(function() {
  1365.                                 target.data('action','unblock');
  1366.                                 target.text("Unblock");
  1367.  
  1368.                                 if (target.hasClass('toggle-class')) {
  1369.                                     target.replaceClass('main-inline', 'main-outline');
  1370.                                 }
  1371.  
  1372.                                 $.ajax({
  1373.                                     url: 'https://spoutible.com/sptbl_system_api/main/block',
  1374.                                     type: 'POST',
  1375.                                     dataType: 'json',
  1376.                                     data: {id: target.data('id')},
  1377.                                 }).done(function(data) {
  1378.                                     if (data.status != 200) {
  1379.                                         SPTBL_APP.errorMSG();
  1380.                                     }
  1381.                                     else {
  1382.                                         if (_smc.curr_pn == 'profile') {
  1383.                                             _smc.spa_reload();
  1384.                                         }
  1385.                                     }
  1386.                                 }).always(function() {
  1387.                                     $("div.confirm-actions-modal").modal("hide");
  1388.                                 });
  1389.                             });
  1390.  
  1391.                             promise.fail(function() {
  1392.                                 $("div.confirm-actions-modal").modal("hide");
  1393.                             });
  1394.                         }
  1395.  
  1396.                         else if(target.data('action') == 'unblock') {
  1397.                             var promise = SPTBL_APP.confirm_action({
  1398.                                 btn_1: "Cancel",
  1399.                                 btn_2: "Unblock",
  1400.                                 title: "Delete?",
  1401.                                 message: "Are you sure you want to unblock this user? Now they can follow you or see your posts, etc.",
  1402.                             });
  1403.  
  1404.                             promise.done(function() {
  1405.                                 target.data('action','block');
  1406.                                 target.text("Block");
  1407.  
  1408.                                 if (target.hasClass('toggle-class')) {
  1409.                                     target.replaceClass('main-outline', 'main-inline');
  1410.                                 }
  1411.  
  1412.                                 $.ajax({
  1413.                                     url: 'https://spoutible.com/sptbl_system_api/main/block',
  1414.                                     type: 'POST',
  1415.                                     dataType: 'json',
  1416.                                     data: {id: target.data('id')},
  1417.                                 }).done(function(data) {
  1418.                                     if (data.status != 200) {
  1419.                                         SPTBL_APP.errorMSG();
  1420.                                     }
  1421.                                     else {
  1422.                                         if (_smc.curr_pn == 'profile') {
  1423.                                             $(window).reloadPage();
  1424.                                         }
  1425.                                     }
  1426.                                 }).always(function() {
  1427.                                     $("div.confirm-actions-modal").modal("hide");
  1428.                                 });
  1429.                             });
  1430.  
  1431.                             promise.fail(function() {
  1432.                                 $("div.confirm-actions-modal").modal("hide");
  1433.                             });
  1434.                         }
  1435.                     }
  1436.                     else{
  1437.                         _smc.req_auth();
  1438.                     }
  1439.                 }
  1440.             }
  1441.  
  1442.             _smc.mute = function(event = false) {
  1443.                 if (event) {
  1444.                     if (_smc.is_logged()) {
  1445.                         var target = $(event);
  1446.  
  1447.                         if(target.data('action') == 'mute') {
  1448.                             var promise = SPTBL_APP.confirm_action({
  1449.                                 btn_1: "Cancel",
  1450.                                 btn_2: "Mute",
  1451.                                 title: "Delete?",
  1452.                                 message: "Are you sure you want to Mute this user? You will not be able to see the Muted user Spouts.",
  1453.                             });
  1454.  
  1455.                             promise.done(function() {
  1456.                                 target.data('action','unmute');
  1457.                                 target.text("Unmute");
  1458.  
  1459.                                 if (target.hasClass('toggle-class')) {
  1460.                                     target.replaceClass('main-inline', 'main-outline');
  1461.                                 }
  1462.  
  1463.                                 $.ajax({
  1464.                                     url: 'https://spoutible.com/sptbl_system_api/main/mute',
  1465.                                     type: 'POST',
  1466.                                     dataType: 'json',
  1467.                                     data: {id: target.data('id')},
  1468.                                 }).done(function(data) {
  1469.                                     if (data.status != 200) {
  1470.                                         SPTBL_APP.errorMSG();
  1471.                                     }
  1472.                                     else {
  1473.                                         sptbl_bs_notify(`You Muted The user!`, 1500);
  1474.                                         if (_smc.curr_pn == 'profile') {
  1475.                                             _smc.spa_reload();
  1476.                                         }
  1477.                                     }
  1478.                                 }).always(function() {
  1479.                                     $("div.confirm-actions-modal").modal("hide");
  1480.                                 });
  1481.                             });
  1482.  
  1483.                             promise.fail(function() {
  1484.                                 $("div.confirm-actions-modal").modal("hide");
  1485.                             });
  1486.                         } else if(target.data('action') == 'unmute') {
  1487.                             var promise = SPTBL_APP.confirm_action({
  1488.                                 btn_1: "Cancel",
  1489.                                 btn_2: "Unmute",
  1490.                                 title: "Delete?",
  1491.                                 message: "Are you sure you want to Unmute this user? Now you will see his spouts.",
  1492.                             });
  1493.  
  1494.                             promise.done(function() {
  1495.                                 target.data('action','mute');
  1496.                                 target.text("Mute");
  1497.  
  1498.                                 if (target.hasClass('toggle-class')) {
  1499.                                     target.replaceClass('main-outline', 'main-inline');
  1500.                                 }
  1501.  
  1502.                                 $.ajax({
  1503.                                     url: 'https://spoutible.com/sptbl_system_api/main/mute',
  1504.                                     type: 'POST',
  1505.                                     dataType: 'json',
  1506.                                     data: {id: target.data('id')},
  1507.                                 }).done(function(data) {
  1508.                                     if (data.status != 200) {
  1509.                                         SPTBL_APP.errorMSG();
  1510.                                     }
  1511.                                     else {
  1512.                                         sptbl_bs_notify(`You Unmuted The user!`, 1500);
  1513.                                         if (_smc.curr_pn == 'profile') {
  1514.                                             $(window).reloadPage();
  1515.                                         }
  1516.                                     }
  1517.                                 }).always(function() {
  1518.                                     $("div.confirm-actions-modal").modal("hide");
  1519.                                 });
  1520.                             });
  1521.  
  1522.                             promise.fail(function() {
  1523.                                 $("div.confirm-actions-modal").modal("hide");
  1524.                             });
  1525.                         }
  1526.                     }
  1527.                     else{
  1528.                         _smc.req_auth();
  1529.                     }
  1530.                 }
  1531.             }
  1532.  
  1533.             _smc.errorMSG = function(error) {
  1534.                 sptbl_bs_notify(error || "An error occurred while processing your request. Please try again later.", 3000, "danger");
  1535.             }
  1536.  
  1537.             _smc.extend_vue = function(app_name = "", vue_instance = {}) {
  1538.                 _smc.vue[app_name] = vue_instance;
  1539.             }
  1540.  
  1541.             _smc.progress_bar = function(a = "show") {
  1542.                 if (a == "show") {
  1543.                     window.waitMe.start();
  1544.                 }
  1545.  
  1546.                 else {
  1547.                     window.waitMe.end();
  1548.                 }
  1549.             }
  1550.  
  1551.             // _smc.update_msb_indicators = function() {
  1552.             //  if (_smc.is_logged()) {
  1553.             //      var main_left_sb   = $('div[data-app="left-sidebar"]');
  1554.             //      var main_bottom_nb = $('div[data-app="mobile-navbar"]');
  1555.             //      var timer_id       = setInterval(function() {
  1556.             //          $.ajax({
  1557.             //              url: 'https://spoutible.com/sptbl_system_api/main/update_msb_indicators',
  1558.             //              type: 'GET',
  1559.             //              dataType: 'json',
  1560.             //          }).done(function(data) {
  1561.             //              if (data.status == 200) {
  1562.             //                  // if (data.notifications > 0) {
  1563.             //                  //  var notifs_total = data.notifications;
  1564.  
  1565.             //                  //  if (data.notifications > 99) {
  1566.             //                  //      notifs_total = "99+";
  1567.             //                  //  }
  1568.  
  1569.             //                  //  main_left_sb.find('[data-an="group-ind"]').addClass("group-ind-active");
  1570.             //                  //  main_left_sb.find('[data-an="new-notifs"]').text($.trim(notifs_total));
  1571.             //                  //  main_bottom_nb.find('[data-an="new-notifs"]').text($.trim(notifs_total));
  1572.             //                  // }
  1573.             //                  // else {
  1574.             //                  //  main_left_sb.find('[data-an="group-ind"]').removeClass("group-ind-active");
  1575.             //                  //  main_left_sb.find('[data-an="new-notifs"]').empty();
  1576.             //                  //  main_bottom_nb.find('[data-an="new-notifs"]').empty();
  1577.             //                  // }
  1578.  
  1579.             //                  // if (data.messages) {
  1580.  
  1581.             //                  //  var messages_total = data.messages;
  1582.  
  1583.             //                  //  if (data.messages > 99) {
  1584.             //                  //      messages_total = "99+";
  1585.             //                  //  }
  1586.  
  1587.             //                  //  main_left_sb.find('[data-an="group-ind"]').addClass("group-ind-active");
  1588.             //                  //  main_left_sb.find('[data-an="new-messages"]').text($.trim(messages_total));
  1589.             //                  //  main_bottom_nb.find('[data-an="new-messages"]').text($.trim(messages_total));
  1590.             //                  // }
  1591.             //                  // else {
  1592.             //                  //  main_left_sb.find('[data-an="group-ind"]').removeClass("group-ind-active");
  1593.             //                  //  main_left_sb.find('[data-an="new-messages"]').empty();
  1594.             //                  //  main_bottom_nb.find('[data-an="new-messages"]').empty();
  1595.             //                  // }
  1596.             //              }
  1597.             //              else {
  1598.             //                  clearInterval(timer_id);
  1599.             //              }
  1600.             //          });
  1601.             //      }, (Number(_smc.msb_upinterval) * 1000));
  1602.             //  }
  1603.             // }
  1604.  
  1605.             _smc.hide_sb = function() {
  1606.                 $('div[data-app="lsb-back-drop"]').trigger('click');
  1607.             }
  1608.  
  1609.             _smc.spa_load = function(url = "", push_state = true) {
  1610.                 var timeline      = $('[data-el="timeline-container-wrapper"]');
  1611.                 var preloader     = timeline.find('[data-el="spa-preloader"]');
  1612.                 var left_sidebar  = $('[data-app="left-sidebar"]');
  1613.                 var mobile_navbar = $('[data-app="mobile-navbar"]');
  1614.  
  1615.                 if (push_state == true) {
  1616.                     var previousRoute = window.location.pathname.replace(/^\/+/, '').split('/')[0];
  1617.                     // if user is going to a single post from timeline,
  1618.                     // then store the scroll height to get back to it when he is back
  1619.                     if ((previousRoute === "" || previousRoute == 'home') && url.includes('thread')) {
  1620.                         var post_ls = $('[data-app="homepage"]').find('[data-an="entry-list"]');
  1621.                     }
  1622.  
  1623.                     if (window.location.pathname.includes('conversation') && window.websocket !== undefined) {
  1624.                         window.websocket.close();
  1625.                         window.websocket = undefined;
  1626.                     }
  1627.  
  1628.                     // if user moving away from pods then float it
  1629.                     if (previousRoute === 'pod' && window.vue_instance.isPodEnabled()) {
  1630.                         window.vue_instance.floatPod()
  1631.                     }
  1632.  
  1633.                     window.history.pushState({state: "new", back_url: url}, "", url);
  1634.                 }
  1635.                 // else if (! push_state && ((window.location.pathname == "/" || window.location.pathname == '/home') && sessionStorage.getItem('dataLimit'))) {
  1636.                 //  data.limit = sessionStorage.getItem('dataLimit');
  1637.                 // }
  1638.  
  1639.                 if (window.mobileCheck()) {
  1640.                     _smc.hide_sb();
  1641.                 }
  1642.  
  1643.                 // after pushing to state we can check the path correctly
  1644.                 // for vue refactor, we set the component name to null to use the old way for SPA (non-refactored components)
  1645.                 var currentRoute = window.location.pathname.replace(/^\/+/, '').split('/')[0];
  1646.                 if (currentRoute === "" || currentRoute === 'home') {
  1647.                     if (window.vue_instance.timelineComponent) {
  1648.                         window.vue_instance.timelineComponent.reset();
  1649.                     }
  1650.                     window.vue_instance.swapComponent('timeline');
  1651.                     window.scrollTo(0, 0);
  1652.  
  1653.                     timeline.find('[data-el="timeline-content"]').html('');
  1654.  
  1655.                     left_sidebar.find('[data-navitem]').each(function(index, el) {
  1656.                         $(el).removeClass('active');
  1657.                     }).promise().done(function() {
  1658.                         left_sidebar.find('[data-navitem="home"]').addClass('active');
  1659.                     });
  1660.  
  1661.                     if (_smc.timeout !== false) {
  1662.                     clearTimeout(_smc.timeout);
  1663.                     }
  1664.  
  1665.                     if ( 'Gifffer' in window && $('img[data-gifffer]').length > 0 ) {
  1666.                         Gifffer()
  1667.                     }
  1668.  
  1669.                     preloader.removeClass('d-none');
  1670.  
  1671.                     $("div.dropdown-menu.show").each(function(index, el) {
  1672.                         $(el).removeClass("show");
  1673.                     });
  1674.  
  1675.                     mobile_navbar.find('[data-navitem]').each(function(index, el) {
  1676.                         $(el).removeClass('active');
  1677.                     }).promise().done(function() {
  1678.                         mobile_navbar.find('[data-navitem="home"]').addClass('active');
  1679.                     });
  1680.  
  1681.                     const body = document.querySelector('body')
  1682.                     body.classList = ''
  1683.                     body.classList.add('sptbl-app-home')
  1684.  
  1685.                     $(".media-slider").each(function() {
  1686.                         $(this).resize()
  1687.                     })
  1688.  
  1689.                     _smc.toggleSB("hide");
  1690.  
  1691.                     this.previous_url = window.location.pathname
  1692.                     return;
  1693.                 } else if (currentRoute === 'search') {
  1694.                     if (window.vue_instance.searchComponent) {
  1695.                         window.vue_instance.searchComponent.reset()
  1696.                     }
  1697.                     window.vue_instance.swapComponent('search')
  1698.                     window.scrollTo(0, 0);
  1699.  
  1700.                     timeline.find('[data-el="timeline-content"]').html('');
  1701.  
  1702.                     left_sidebar.find('[data-navitem]').each(function(index, el) {
  1703.                         $(el).removeClass('active');
  1704.                     }).promise().done(function() {
  1705.                         left_sidebar.find('[data-navitem="search"]').addClass('active');
  1706.                     });
  1707.  
  1708.                     if (_smc.timeout !== false) {
  1709.                         clearTimeout(_smc.timeout);
  1710.                     }
  1711.  
  1712.                     if ( 'Gifffer' in window && $('img[data-gifffer]').length > 0 ) {
  1713.                         Gifffer()
  1714.                     }
  1715.  
  1716.                     preloader.removeClass('d-none');
  1717.  
  1718.                     $("div.dropdown-menu.show").each(function(index, el) {
  1719.                         $(el).removeClass("show");
  1720.                     });
  1721.  
  1722.                     mobile_navbar.find('[data-navitem]').each(function(index, el) {
  1723.                         $(el).removeClass('active');
  1724.                     }).promise().done(function() {
  1725.                         mobile_navbar.find('[data-navitem="search"]').addClass('active');
  1726.                     });
  1727.  
  1728.                     const body = document.querySelector('body')
  1729.                     body.classList = ''
  1730.                     body.classList.add('sptbl-app-search')
  1731.  
  1732.                     $(".media-slider").each(function() {
  1733.                         $(this).resize()
  1734.                     })
  1735.  
  1736.                     _smc.toggleSB("hide");
  1737.  
  1738.                     this.previous_url = window.location.pathname
  1739.                     return;
  1740.                 } else if (currentRoute === 'pod') {
  1741.                     window.vue_instance.createPod()
  1742.                 } else {
  1743.                     window.vue_instance.swapComponent(null)
  1744.                 }
  1745.  
  1746.                 this.previous_url = window.location.pathname
  1747.  
  1748.                 $.ajax({
  1749.                     url: url,
  1750.                     type: 'GET',
  1751.                     data: {spa_load: 1, limit: 160},
  1752.                     dataType: 'json',
  1753.                     async: true,
  1754.                     beforeSend: function() {
  1755.                         _smc.user_lbox_rm();
  1756.  
  1757.                         $("html, body").animate({
  1758.                             scrollTop: 0
  1759.                         }, 10).promise().done(function() {
  1760.                             preloader.removeClass('d-none');
  1761.                         });
  1762.  
  1763.                         _smc.toggleSB("hide");
  1764.  
  1765.                         sptbl_close_all_modals();
  1766.                     }
  1767.                 }).done(function(data = {}) {
  1768.                     if (data.status == 200) {
  1769.                         var prevapp   = _smc.curr_pn;
  1770.                         var json_data = data.json_data;
  1771.                         _smc.curr_pn  = json_data.pn;
  1772.  
  1773.                         $('head').find('title').text(json_data.page_title);
  1774.                         $('head').find('meta[name="title"]').attr('content', json_data.page_title);
  1775.                         $('head').find('meta[name="description"]').attr('content', json_data.page_desc);
  1776.                         $('head').find('meta[name="keywords"]').attr('content', json_data.page_kw);
  1777.  
  1778.                         if (json_data.page_img) {
  1779.                             $('head').find('meta[name="image"]').attr('content', json_data.page_img);
  1780.                         }
  1781.  
  1782.                         if ($('body').hasClass('sptbl-app-{0}'.format(prevapp))) {
  1783.                             $('body').removeClass('sptbl-app-{0}'.format(prevapp));
  1784.                             $('body').addClass('sptbl-app-{0}'.format(json_data.pn));
  1785.                         }
  1786.                         else {
  1787.                             $('body').addClass('sptbl-app-{0}'.format(json_data.pn));
  1788.                         }
  1789.  
  1790.                         $('body').attr('data-page-tab', json_data.page_tab);
  1791.  
  1792.                         timeline.find('[data-el="timeline-content"]').html(data.html);
  1793.  
  1794.                         // if (! push_state && sessionStorage.getItem('scrollHeight') && window.location.pathname == '/') {
  1795.                         //  $("html, body").animate({
  1796.                         //      scrollTop: sessionStorage.getItem('scrollHeight')
  1797.                         //  }, 100);
  1798.  
  1799.                         //  sessionStorage.removeItem('scrollHeight')
  1800.                         // }
  1801.  
  1802.                         left_sidebar.find('[data-navitem]').each(function(index, el) {
  1803.                             $(el).removeClass('active');
  1804.                         }).promise().done(function() {
  1805.  
  1806.                             if (_smc.curr_pn == "profile") {
  1807.                                 if (json_data.page_xdata.is_me) {
  1808.                                     left_sidebar.find('[data-navitem="profile"]').addClass('active');
  1809.                                 }
  1810.                             }
  1811.                             else{
  1812.                                 left_sidebar.find('[data-navitem="{0}"]'.format(_smc.curr_pn)).addClass('active');
  1813.                             }
  1814.                         });
  1815.  
  1816.                         mobile_navbar.find('[data-navitem]').each(function(index, el) {
  1817.                             $(el).removeClass('active');
  1818.                         }).promise().done(function() {
  1819.                             mobile_navbar.find('[data-navitem="{0}"]'.format(_smc.curr_pn)).addClass('active');
  1820.                         });
  1821.  
  1822.                         if ( /\/notifications($|\?|#)/.test(url) ) {
  1823.                             $('[data-an="new-notifs"]').empty()
  1824.                         }
  1825.                     }
  1826.                     else if(data.status == 302) {
  1827.                         _smc.spa_load(data.redirect_url);
  1828.                     }
  1829.  
  1830.                     else {
  1831.                         _smc.spa_load("https://spoutible.com/404");
  1832.                     }
  1833.                 }).always(function() {
  1834.                     if (_smc.timeout !== false) {
  1835.                         clearTimeout(_smc.timeout);
  1836.                     }
  1837.  
  1838.                     if ( 'Gifffer' in window && $('img[data-gifffer]').length > 0 ) {
  1839.                         Gifffer()
  1840.                     }
  1841.  
  1842.                     preloader.addClass('d-none');
  1843.  
  1844.                     $("div.dropdown-menu.show").each(function(index, el) {
  1845.                         $(el).removeClass("show");
  1846.                     });
  1847.  
  1848.                     $(".media-slider").each(function() {
  1849.                         $(this).resize()
  1850.                     })
  1851.  
  1852.  
  1853.  
  1854.                     setTimeout(() => {
  1855.                         window.load_videos()
  1856.                     }, 200);
  1857.                 });
  1858.  
  1859.                 return false;
  1860.             }
  1861.  
  1862.             _smc.spa_reload = function() {
  1863.                 if (window.location.href != undefined) {
  1864.                     _smc.spa_load(window.location.href);
  1865.                 }
  1866.                 else {
  1867.                     _smc.spa_load(data['url']);
  1868.                 }
  1869.  
  1870.                 return false;
  1871.             }
  1872.  
  1873.             _smc.go_back = function() {
  1874.                 history.back();
  1875.             }
  1876.  
  1877.             _smc.jump_back = function(step = 1) {
  1878.                 history.go(step);
  1879.             }
  1880.  
  1881.             _smc.report_post = function(id = false) {
  1882.                 if (_smc.is_logged()) {
  1883.                     if (_smc.vue.report_post != undefined && id) {
  1884.                         _smc.vue.report_post.open(id);
  1885.                     }
  1886.                     else {
  1887.                         _smc.errorMSG();
  1888.                     }
  1889.                 }
  1890.                 else {
  1891.                     _smc.req_auth();
  1892.                 }
  1893.             }
  1894.  
  1895.             _smc.update_ilb = function() {
  1896.                 $('a[href].fbox-media:not(.has-alt-text)').fancybox({
  1897.                     arrows: true,
  1898.                     openEffect: 'elastic',
  1899.                     closeEffect: false,
  1900.                     hash: false,
  1901.                     i18n: {
  1902.                         en: {
  1903.                             ERROR: "The requested content could not be loaded. <br/> Please try again later.",
  1904.                         }
  1905.                     }
  1906.                 });
  1907.             }
  1908.  
  1909.             _smc.add_user_to_list = function(user) {
  1910.                 if (!_smc.is_logged()) {
  1911.                     _smc.req_auth();
  1912.                 }
  1913.  
  1914.                 window.vue_instance.$refs.timelineListsModal.showWithUserLists(user)
  1915.             }
  1916.  
  1917.             return _smc;
  1918.         }
  1919.  
  1920.         if (window.SPTBL_APP === undefined) {
  1921.             window.SPTBL_APP = _SPTBL_APP();
  1922.         }
  1923.     })(window);
  1924.  
  1925.     $(document).ready(function($) {
  1926.  
  1927.         SPTBL_APP.init();
  1928.  
  1929.         var clipboard   = new ClipboardJS('.clip-board-copy');
  1930.         var page_height = $(document).height();
  1931.  
  1932.         clipboard.on('success', function(event) {
  1933.             sptbl_bs_notify("Copied to your clipboard!",500);
  1934.         });
  1935.  
  1936.         clipboard.on('error', function(event) {
  1937.             sptbl_bs_notify("Failed to copy to clipboard!",3000);
  1938.         });
  1939.  
  1940.         if (navigator.cookieEnabled == false) {
  1941.             $('[data-app="announcement"]').html("<div class='announcement-danger'>Oops! It looks like you have cookies disabled. For this site to work properly, you need to enable cookies.</div>");
  1942.         }
  1943.  
  1944.         $(document).on('click', 'div[data-app="lsb-back-drop"]', function(event) {
  1945.             event.preventDefault();
  1946.             SPTBL_APP.toggleSB();
  1947.         });
  1948.  
  1949.         var _lozad_ = lozad();
  1950.  
  1951.         setTimeout(() => {
  1952.             _lozad_.observe();
  1953.         }, 500);
  1954.  
  1955.         $(document).on("ajaxComplete", function(event, request, settings) {
  1956.             setTimeout(() => {
  1957.                 _lozad_.observe();
  1958.                 // SPTBL_APP.fix_sidebars();
  1959.                 SPTBL_APP.update_ilb();
  1960.             }, 500);
  1961.         });
  1962.  
  1963.         // terminated on 30-7-2023 for bad performance
  1964.         // setInterval(function() {
  1965.  
  1966.         //  var new_page_height = $(document).height();
  1967.         //  var _lozad_         = lozad();
  1968.  
  1969.         //  _lozad_.observe();
  1970.  
  1971.         //  if (page_height != new_page_height) {
  1972.         //      page_height = new_page_height;
  1973.         //      SPTBL_APP.fix_sidebars();
  1974.         //      SPTBL_APP.update_ilb();
  1975.         //  }
  1976.  
  1977.             // if ($('video[data-el="sptbl-video"]').length) {
  1978.             //  $('video[data-el="sptbl-video"]').each(function(index, el) {
  1979.             //      if ($(el).hasClass('afterglow') != true) {
  1980.             //          var video_src = $(el).find("source").first().attr("src");
  1981.             //          $(el).width("100%").height("100%").addClass('afterglow');
  1982.  
  1983.             //          $(el).find("source").remove();
  1984.  
  1985.             //          $(el).append($("<source>", {
  1986.             //              type: "video/mp4",
  1987.             //              src: video_src
  1988.             //          }));
  1989.  
  1990.             //          $(el).append($("<source>", {
  1991.             //              type: "video/webm",
  1992.             //              src: video_src
  1993.             //          }));
  1994.  
  1995.             //          $(el).append($("<source>", {
  1996.             //              type: "video/mov",
  1997.             //              src: video_src
  1998.             //          }));
  1999.  
  2000.  
  2001.             //          $(el).append($("<source>", {
  2002.             //              type: "video/3gp",
  2003.             //              src: video_src
  2004.             //          }));
  2005.  
  2006.             //          $(el).append($("<source>", {
  2007.             //              type: "video/ogg",
  2008.             //              src: video_src
  2009.             //          }));
  2010.  
  2011.             //          afterglow.init();
  2012.             //      }
  2013.             //  });
  2014.             // }
  2015.         // }, 500);
  2016.  
  2017.         $(document).on('click tap', 'a[data-spa]', function(event) {
  2018.             event.preventDefault();
  2019.  
  2020.             var page_url_source = $(this).attr('href');
  2021.  
  2022.             SPTBL_APP.spa_load(page_url_source);
  2023.  
  2024.             return false;
  2025.         });
  2026.  
  2027.         $(window).on("popstate", function () {
  2028.             var left_sidebar = $('[data-app="left-sidebar"]');
  2029.             var mobile_navbar = $('[data-app="mobile-navbar"]');
  2030.             var prevRoute = window.SPTBL_APP.previous_url.replace(/^\/+/, '').split('/')[0]
  2031.  
  2032.             if (history.state) {
  2033.                 if (!history.state.back_url.includes('conversation') && window.websocket !== undefined) {
  2034.                     window.websocket.close();
  2035.                     window.websocket = undefined;
  2036.                 }
  2037.  
  2038.                 // if user moving away from pods then float it
  2039.                 if (prevRoute === 'pod' && window.vue_instance.isPodEnabled()) {
  2040.                     window.vue_instance.floatPod()
  2041.                 }
  2042.  
  2043.                 var currentRoute = window.location.pathname.replace(/^\/+/, '').split('/')[0]
  2044.  
  2045.                 // disabled loading timeline on back button because we use vue keep-alive component
  2046.                 if (
  2047.                     $.isEmptyObject(history.state.back_url) != true &&
  2048.                     currentRoute !== '' &&
  2049.                     currentRoute !== 'home' &&
  2050.                     currentRoute !== 'search' &&
  2051.                     currentRoute !== 'pod'
  2052.                 ) {
  2053.                     SPTBL_APP.spa_load(history.state.back_url, false);
  2054.                 } else {
  2055.                     $('[data-el="timeline-container-wrapper"]').find('[data-el="timeline-content"]').html('');
  2056.                 }
  2057.  
  2058.                 if (currentRoute === '' || currentRoute === 'home') {
  2059.                     window.vue_instance.swapComponent('timeline')
  2060.                     var scrollHeight = localStorage.getItem('timeline_scroll_height')
  2061.                     if (scrollHeight) {
  2062.                         window.scrollTo(0, scrollHeight)
  2063.                     }
  2064.                     $('[data-el="timeline-container-wrapper"]').find('[data-el="timeline-content"]').html('');
  2065.  
  2066.                     const body = document.querySelector('body')
  2067.                     body.classList = ''
  2068.                     body.classList.add('sptbl-app-home')
  2069.  
  2070.                     left_sidebar.find('[data-navitem]').each(function(index, el) {
  2071.                         $(el).removeClass('active');
  2072.                     }).promise().done(function() {
  2073.                         left_sidebar.find('[data-navitem="home"]').addClass('active');
  2074.                     });
  2075.  
  2076.                     mobile_navbar.find('[data-navitem]').each(function(index, el) {
  2077.                         $(el).removeClass('active');
  2078.                     }).promise().done(function() {
  2079.                         mobile_navbar.find('[data-navitem="home"]').addClass('active');
  2080.                     });
  2081.                 } else if (currentRoute === 'search') {
  2082.                     window.vue_instance.swapComponent('search')
  2083.                     $('[data-el="timeline-container-wrapper"]').find('[data-el="timeline-content"]').html('');
  2084.  
  2085.                     const body = document.querySelector('body')
  2086.                     body.classList = ''
  2087.                     body.classList.add('sptbl-app-search')
  2088.  
  2089.                     left_sidebar.find('[data-navitem]').each(function(index, el) {
  2090.                         $(el).removeClass('active');
  2091.                     }).promise().done(function() {
  2092.                         left_sidebar.find('[data-navitem="search"]').addClass('active');
  2093.                     });
  2094.  
  2095.                     mobile_navbar.find('[data-navitem]').each(function(index, el) {
  2096.                         $(el).removeClass('active');
  2097.                     }).promise().done(function() {
  2098.                         mobile_navbar.find('[data-navitem="search"]').addClass('active');
  2099.                     });
  2100.  
  2101.                     var scrollHeight = localStorage.getItem('search_scroll_height')
  2102.                     if (scrollHeight) {
  2103.                         window.scrollTo(0, scrollHeight)
  2104.                     }
  2105.                 } else if (currentRoute === 'pod') {
  2106.                     window.vue_instance.createPod()
  2107.                 } else {
  2108.                     window.vue_instance.swapComponent(null)
  2109.                 }
  2110.  
  2111.                 $(".media-slider").each(function() {
  2112.                     $(this).resize()
  2113.                 })
  2114.  
  2115.                 setTimeout(() => {
  2116.                     window.load_videos()
  2117.                 }, 200);
  2118.             }
  2119.  
  2120.             window.SPTBL_APP.previous_url = window.location.pathname
  2121.  
  2122.             return false;
  2123.         });
  2124.  
  2125.         $(document).on('click tap', '[data-href]', function(event) {
  2126.             event.preventDefault();
  2127.             event.stopPropagation();
  2128.  
  2129.             if (window.getSelection().toString().length > 0) {
  2130.                 return;
  2131.             }
  2132.  
  2133.             window.open($(this).data('href'), '_blank');
  2134.  
  2135.             return false;
  2136.         });
  2137.  
  2138.         $(document).on('click tap', '.image-alt-inline', function(e)
  2139.         {
  2140.             e.preventDefault()
  2141.             e.stopPropagation()
  2142.             SPTBL_APP.show_alt(this.dataset.alt)
  2143.         })
  2144.  
  2145.         if (window.mobileCheck() != true) {
  2146.             $(document).on('mouseenter', '[data-uinfo-lbox]', function(event) {
  2147.                 event.preventDefault();
  2148.  
  2149.                 var uid = $(this).data("uinfo-lbox");
  2150.  
  2151.                 SPTBL_APP.user_lbox(uid, $(this));
  2152.             });
  2153.  
  2154.             $(document).on('mouseleave', '[data-uinfo-lbox]', function(event) {
  2155.                 event.preventDefault();
  2156.  
  2157.                 if (sptbl_empty(SPTBL_APP.userlbox.status)) {
  2158.                     clearTimeout(SPTBL_APP.userlbox.pre_delay);
  2159.  
  2160.                     SPTBL_APP.userlbox.pre_delay = false;
  2161.                 }
  2162.  
  2163.                 if (sptbl_empty(SPTBL_APP.userlbox.interv) != true) {
  2164.                     clearInterval(SPTBL_APP.userlbox.interv);
  2165.                 }
  2166.  
  2167.                 SPTBL_APP.userlbox.interv = setInterval(function() {
  2168.                     if (SPTBL_APP.userlbox.lifetm !== "pause" && $.isNumeric(SPTBL_APP.userlbox.lifetm)) {
  2169.                         if (SPTBL_APP.userlbox.lifetm <= 0) {
  2170.                             SPTBL_APP.user_lbox_rm();
  2171.  
  2172.                             clearInterval(SPTBL_APP.userlbox.interv);
  2173.                         }
  2174.                         else{
  2175.                             SPTBL_APP.userlbox.lifetm -= 100;
  2176.                         }
  2177.                     }
  2178.                 }, 100);
  2179.             });
  2180.  
  2181.             $(document).on('mouseenter', "[data-app='user-info-lbox']", function() {
  2182.                 SPTBL_APP.userlbox.lifetm = "pause";
  2183.             });
  2184.  
  2185.             $(document).on('mouseleave', "[data-app='user-info-lbox']", function() {
  2186.                 SPTBL_APP.userlbox.lifetm = 1000;
  2187.             });
  2188.         }
  2189.     });
  2190.  
  2191.     var navbar = document.getElementById("timelineheader");
  2192.  
  2193.     if (navbar) {
  2194.         window.onscroll = function() {
  2195.             myFunction()
  2196.         };
  2197.  
  2198.         var sticky = navbar.offsetTop;
  2199.  
  2200.         function myFunction() {
  2201.             if (window.pageYOffset >= sticky) {
  2202.                 navbar.classList.add("stickyhead")
  2203.             } else {
  2204.                 navbar.classList.remove("stickyhead");
  2205.             }
  2206.         }
  2207.     }
  2208.  
  2209.     $('#add_new_post').on('hidden.bs.modal', function()
  2210.     {
  2211.         $(this).removeClass('sptbl-action-quote').find('#quote-hint-text').hide()
  2212.         $(this).find('[name=quoted_spout]').val('')
  2213.  
  2214.         // close cross posting when modal closes so it forces the users to fetch the new state
  2215.         SPTBL_APP.vue.pubbox2.$refs.modalPubbox.show_cross_posting_settings = false;
  2216.  
  2217.         if (typeof Dialog !== 'undefined') {
  2218.             Dialog.SpoutModalClosed();
  2219.         }
  2220.  
  2221.         if (typeof window.webkit !== 'undefined') {
  2222.             window.webkit.messageHandlers.Dialog.postMessage("SpoutModalClosed");
  2223.         }
  2224.     });
  2225.  
  2226.     $('#add_new_post').on('shown.bs.modal', function()
  2227.     {
  2228.         if (SPTBL_APP.needs_phone_verification) {
  2229.             setTimeout(() => {
  2230.                 $('#add_new_post').modal('hide')
  2231.                 showPhoneVerificationPopup()
  2232.             }, 0);
  2233.         }
  2234.  
  2235.         // TODO: use pinia instead
  2236.         window.vue_instance.timelineComponent.$refs.timelinePubbox.show_cross_posting_settings = false;
  2237.  
  2238.         if (typeof Dialog !== 'undefined') {
  2239.             Dialog.SpoutModalOpened();
  2240.         }
  2241.  
  2242.         if (typeof window.webkit !== 'undefined') {
  2243.             window.webkit.messageHandlers.Dialog.postMessage("SpoutModalOpened");
  2244.         }
  2245.     });
Advertisement
Add Comment
Please, Sign In to add comment