Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "use strict";
- (function(window) {
- function _SPTBL_APP() {
- var data = {
- url: "https://spoutible.com"
- };
- var _smc = Object({
- curr_pn: "start",
- PS: Object({}),
- vue: Object({}),
- is_logged_user: '0',
- back_url: data.url,
- timeout: false,
- msb_upinterval: "50000000",
- userlbox: {
- interv: 0,
- status: false,
- lifetm: 1000,
- curr_id: false,
- curr_el: false,
- pre_delay: false
- },
- previous_url: window.location.pathname
- });
- if (_smc.curr_pn != "chat") {
- // if ($(window).width() > 576 && 'StickySidebar' in window) {
- // if ($('[data-app="left-sidebar"]').length) {
- // _smc.lsb = new StickySidebar('[data-app="left-sidebar"]', {
- // topSpacing: 0,
- // bottomSpacing: 0
- // });
- // }
- // if ($('[data-app="right-sidebar"]').length) {
- // _smc.rsb = new StickySidebar('[data-app="right-sidebar"]', {
- // topSpacing: 0,
- // bottomSpacing: 0
- // });
- // }
- // }
- }
- _smc.toggleSB = function(a = false) {
- var left_sidebar = $('[data-app="left-sidebar"]');
- if (a) {
- if (a == "show") {
- left_sidebar.addClass('show');
- $('body').addClass("mobile-sb-open").append($('<div>', {
- 'class': 'sb-open-overlay',
- 'data-app': 'lsb-back-drop'
- }));
- }
- else{
- left_sidebar.removeClass('show').promise().done(function() {
- $('body').removeClass("mobile-sb-open").find('div[data-app="lsb-back-drop"]').remove();
- });
- }
- }
- else{
- if (left_sidebar.hasClass("show")) {
- left_sidebar.removeClass('show').promise().done(function() {
- $('body').removeClass("mobile-sb-open").find('div[data-app="lsb-back-drop"]').remove();
- });
- }
- else{
- left_sidebar.addClass('show');
- $('body').addClass("mobile-sb-open").append($('<div>', {
- 'class': 'sb-open-overlay',
- 'data-app': 'lsb-back-drop'
- }));
- }
- }
- }
- _smc.toggleSBMenu = function(e = false) {
- var left_sidebar = $('[data-app="left-sidebar"]');
- left_sidebar.find("div.sidebar__nav-group_collapse").slideToggle(100);
- if (left_sidebar.find("div.sidebar__nav-group_collapse").hasClass("open")) {
- $(e).find("a").text("More");
- left_sidebar.find("div.sidebar__nav-group_collapse").removeClass("open");
- }
- else{
- $(e).find("a").text("Less");
- left_sidebar.find("div.sidebar__nav-group_collapse").addClass("open");
- }
- }
- _smc.init = function() {
- // _smc.fix_sidebars();
- // _smc.update_msb_indicators();
- _smc.update_ilb();
- if (sptbl_empty(window.history.state)) {
- window.history.pushState({state: "new", back_url: window.location.href}, "", window.location.href);
- }
- }
- _smc.fix_sidebars = function() {
- // if (_smc.curr_pn != "chat") {
- // if ($(window).width() > 576) {
- // if (_smc.lsb) {
- // _smc.lsb.updateSticky();
- // }
- // if (_smc.rsb) {
- // _smc.rsb.updateSticky();
- // }
- // }
- // }
- }
- _smc.get_cookie = function(name = "") {
- var matches = document.cookie.match(new RegExp(
- "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
- ));
- return (matches ? decodeURIComponent(matches[1]) : undefined);
- }
- _smc.is_logged = function(){
- if (_smc.is_logged_user == '1') {
- return true;
- }
- return false;
- }
- _smc.user_lbox = function(id = false, el = false) {
- if ($.isNumeric(id)) {
- if(sptbl_empty(_smc.userlbox.curr_id) != true && _smc.userlbox.curr_id == id) {
- return false;
- }
- else{
- if (_smc.userlbox.pre_delay !== false) {
- clearTimeout(_smc.userlbox.pre_delay);
- _smc.userlbox.pre_delay = false;
- }
- _smc.userlbox.pre_delay = setTimeout(function() {
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/user_lbox',
- type: 'GET',
- dataType: 'json',
- data: {id: id},
- beforeSend: function() {
- _smc.user_lbox_rm();
- _smc.userlbox.curr_id = id;
- _smc.userlbox.curr_el = el;
- }
- }).done(function(data) {
- if (data.status == 200) {
- if (_smc.userlbox.curr_id) {
- _smc.userlbox.status = true;
- _smc.userlbox.lifetm = 1000;
- el.popover({
- html: true,
- content: data.html,
- placement: "auto"
- });
- el.popover("show");
- }
- }
- else {
- _smc.errorMSG();
- }
- });
- }, 1500);
- }
- }
- }
- _smc.display_settings = function(a = "show") {
- $('[data-app="display-settings-app"]').modal(a);
- }
- _smc.show_group_chat_modal = function(e, a = "show") {
- e.preventDefault()
- $('#chat-group-modal').modal(a);
- }
- _smc.display_edit_profile_modal = function(a = "show") {
- $('[data-app="edit_profile-app"]').modal(a);
- }
- _smc.user_lbox_rm = function() {
- if (_smc.userlbox.curr_el) {
- _smc.userlbox.curr_el.popover("dispose");
- }
- else {
- if ($("[data-app='user-info-lbox']").length) {
- $("div.popover").each(function(index, el) {
- $(el).popover("dispose");
- });
- }
- }
- _smc.userlbox.curr_id = false;
- _smc.userlbox.status = false;
- _smc.userlbox.curr_el = false;
- }
- _smc.max_upload = function(size = 0) {
- var max_upload_size = "104857600";
- if (size > max_upload_size) {
- 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");
- return false;
- }
- else {
- return true;
- }
- }
- _smc.post_privacy = function(priv = "everyone", id = false) {
- if ($.isNumeric(id)) {
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/post_privacy',
- type: 'POST',
- dataType: 'json',
- data: {id: id, priv: priv},
- beforeSend: function() {
- _smc.progress_bar("show");
- }
- }).done(function(data) {
- if (data.status == 200) {
- _smc.spa_reload();
- }
- else {
- _smc.errorMSG();
- }
- }).always(function() {
- setTimeout(function() {
- _smc.progress_bar("end");
- }, 1500);
- });
- }
- else {
- return false;
- }
- }
- _smc.confirm_action = function(data = {}) {
- 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>";
- var title = data['title'];
- var message = data['message'];
- var btn_1 = data['btn_1'];
- var btn_2 = data['btn_2'];
- var modal = modal.format(title,message,btn_1,btn_2);
- var deferred = new $.Deferred();
- _smc.user_lbox_rm();
- $(document).on('click', '#confirm-actions-confirm', function(event) {
- $(this).attr("disabled", true).text("Please wait");
- deferred.resolve();
- });
- $(document).on('click', '#confirm-actions-cancel', function(event) {
- deferred.reject();
- });
- $('div[data-app="black-hole"]').append($(modal)).find('div.confirm-actions-modal').modal('show');
- return deferred.promise();
- }
- _smc.req_auth = function() {
- 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>";
- $('div[data-app="black-hole"]').append($(modal)).find('div.info-popup-modal').modal('show');
- }
- _smc.show_alt = function(alt) {
- 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>");
- modal.find('[data-alt-text]').text(alt).css('white-space','break-spaces')
- $('div[data-app="black-hole"]').append(modal).find('div.info-popup-modal').modal('show');
- }
- _smc.info = function(title = "", body = "") {
- 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>";
- var modal = modal.format(title, body);
- $('div[data-app="black-hole"]').append($(modal)).find('div.info-popup-modal').modal('show');
- }
- _smc.vote_poll = function(id = false, index = false) {
- if (_smc.is_logged()) {
- if ($.isNumeric(id) && $.isNumeric(index)) {
- var post_poll = $('[data-post-poll="{0}"]'.format(id));
- if (post_poll.length && post_poll.data("status") != 1) {
- post_poll.data("status", 1);
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/vote_poll',
- type: 'POST',
- dataType: 'json',
- data: {
- id: id,
- option: index
- }
- }).done(function(data) {
- if (data.status == 200) {
- for (var i = 0; i < data.poll.options.length; i++) {
- var poll_option = post_poll.find('[data-poll-option="{0}"]'.format(i));
- var data_option = data.poll.options[i];
- if (poll_option && poll_option.length) {
- if (data_option.active != undefined) {
- poll_option.addClass("active");
- }
- poll_option.find('b').text("{0}%".format(data_option.percentage));
- poll_option.find('span').css("width", "{0}%".format(data_option.percentage));
- }
- }
- data.total_str && $('[data-votes-total-id="'+ id +'"]').text(data.total_str);
- }
- else {
- _smc.errorMSG();
- }
- });
- }
- else {
- return false;
- }
- }
- }
- else {
- _smc.req_auth();
- }
- }
- _smc.spout_reply = function(id = false, thread_reply_id = null, show_is_thread_checbox = false, show_collaborative_thread_options = false) {
- if (_smc.is_logged()) {
- if ($.isNumeric(id) && id) {
- SPTBL_APP.vue.pubbox2.$refs.modalPubbox.post_privacy = false;
- SPTBL_APP.vue.pubbox2.$refs.modalPubbox.thread_id = id;
- SPTBL_APP.vue.pubbox2.$refs.modalPubbox.thread_reply_id = thread_reply_id;
- SPTBL_APP.vue.pubbox2.$refs.modalPubbox.show_is_thread_checbox = show_is_thread_checbox;
- SPTBL_APP.vue.pubbox2.$refs.modalPubbox.is_thread_reply = show_is_thread_checbox;
- SPTBL_APP.vue.pubbox2.$refs.modalPubbox.show_collaborative_thread_options = show_collaborative_thread_options;
- SPTBL_APP.vue.pubbox2.$refs.modalPubbox.hide_threaded_posts()
- $("div#add_new_post").modal('show');
- }
- }
- else {
- _smc.req_auth();
- }
- }
- _smc.post_news = function(data = {}) {
- if (!_smc.is_logged()) {
- return _smc.req_auth();
- }
- var post = new postModel();
- post.og_data = {
- title: data.title,
- description: data.text,
- image: data.image,
- type: 'article',
- url: data.url,
- image_loc: true
- };
- post.og_imported = true;
- _smc.vue.pubbox2.$children[0].thread_posts = [post];
- $("div#add_new_post").modal('show');
- }
- _smc.show_post = function(id = false, type = false, force_override = false) {
- var IGNORE_SELECTORS = [
- '.ctrls-item',
- '[data-an="repost-ctrl"]',
- '[data-spa]',
- '[onclick^="SPTBL_APP."]:not([onclick^="SPTBL_APP.show_post"])',
- '.inline-top-likes',
- 'blockquote.quoted-spout',
- '[data-ignore-show-post-click]',
- '.fbox-media',
- '.gifffer-play-button']
- var target = window.event.target
- if ( target && ! force_override ) {
- for ( var i=0; i<IGNORE_SELECTORS.length; i++ ) {
- if ( $(target).is(IGNORE_SELECTORS[i]) )
- return
- if ( $(target).closest(IGNORE_SELECTORS[i]).length > 0 )
- return
- }
- }
- if ($.isNumeric(id) && id) {
- var promise
- if (type == "blocked") {
- promise = SPTBL_APP.confirm_action({
- btn_1: "Cancel",
- btn_2: "View",
- title: "Delete?",
- 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."
- });
- }
- else if(type == "reported") {
- promise = SPTBL_APP.confirm_action({
- btn_1: "Cancel",
- btn_2: "View",
- title: "Delete?",
- 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?"
- });
- }
- if ( promise && promise.done ) {
- promise.done(function() {
- $('[data-softhidden-post="{0}"]'.format(id)).remove();
- $("div.confirm-actions-modal").modal("hide");
- SPTBL_APP.spa_load('/thread/' + String(id))
- });
- promise.fail(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- } else {
- if (
- window.getSelection().toString().length > 0 ||
- target.href
- ) {
- return;
- }
- SPTBL_APP.spa_load('/thread/' + String(id))
- }
- }
- }
- _smc.delete_post = function(id = false) {
- if ($.isNumeric(id) && id) {
- if (_smc.is_logged()) {
- var main_left_sb = $('div[data-app="left-sidebar"]');
- var promise = SPTBL_APP.confirm_action({
- btn_1: "Cancel",
- btn_2: "Delete",
- title: "Delete?",
- message: "Deleting this Spout can't be undone and it will no longer be visible on our platform."
- });
- promise.done(function() {
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/delete_post',
- type: 'POST',
- dataType: 'json',
- data: {id: id},
- }).done(function(data) {
- if (data.status != 200) {
- _smc.errorMSG();
- }
- else {
- if (_smc.curr_pn == 'home') {
- var hp_tl_app = $('div[data-app="homepage"]');
- var item = hp_tl_app.find('div[data-an="entry-list"]').find('div[data-list-item="{0}"]'.format(id))
- item.addClass('slideInUp');
- item.on('animationend', function() {
- $(this).remove();
- if (hp_tl_app.find('div[data-an="entry-list"]').find('div[data-list-item]').length < 1) {
- $(window).reloadPage(50);
- }
- });
- } else if (_smc.curr_pn == 'profile') {
- var profile_app = $('div[data-app="profile"]');
- var item = profile_app.find('div[data-an="entry-list"]').find('div[data-list-item="{0}"]'.format(id))
- item.addClass('slideInUp');
- item.on('animationend', function() {
- $(this).remove();
- if (profile_app.find('div[data-an="entry-list"]').find('div[data-list-item]').length < 1) {
- $(window).reloadPage(50);
- }
- });
- } else if(_smc.curr_pn == 'bookmarks') {
- var bookmarks_app = $('div[data-app="bookmarks"]');
- var listItem = bookmarks_app.find('div[data-an="entry-list"]').find('div[data-list-item="{0}"]'.format(id))
- listItem.addClass('slideInUp');
- listItem.on('animationend', function() {
- $(this).remove();
- if (bookmarks_app.find('div[data-an="entry-list"]').find('div[data-list-item]').length < 1) {
- $(window).reloadPage(50);
- }
- });
- }
- else if(_smc.curr_pn == 'search') {
- var search_app = $('div[data-app="search"]');
- var listItem = search_app.find('div[data-an="entry-list"]').find('div[data-list-item="{0}"]'.format(id))
- listItem.addClass('slideInUp');
- listItem.on('animationend', function() {
- $(this).remove();
- });
- }
- else {
- sptbl_redirect(data.url);
- }
- }
- }).always(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- });
- promise.fail(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- }
- else{
- _smc.req_auth();
- }
- }
- }
- _smc.delete_chat = function(token) {
- var promise = SPTBL_APP.confirm_action({
- btn_1: "Cancel",
- btn_2: "Leave",
- title: "Delete?",
- message: 'Do you want to leave this conversation? Please note that this action cannot be undone!',
- });
- promise.done(function () {
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/conversation/delete_chat',
- type: 'POST',
- headers: {token: token},
- dataType: 'json',
- beforeSend: function () {
- $("div.confirm-actions-modal").modal("hide");
- }
- }).done(function (data) {
- if (data.status != 200) {
- SPTBL_APP.errorMSG();
- return;
- }
- delay(function () {
- sptbl_redirect('https://spoutible.com/chats');
- }, 1000);
- });
- });
- promise.fail(function () {
- $("div.confirm-actions-modal").modal("hide");
- });
- }
- _smc.logout = function() {
- var promise = SPTBL_APP.confirm_action({
- btn_1: "Cancel",
- btn_2: "Logout",
- title: "Leaving already?",
- message: "Are you sure that you want to log out from your account?"
- });
- promise.done(function() {
- sptbl_redirect("https://spoutible.com/logout");
- });
- promise.fail(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- }
- _smc.like_post = function(id = false, event = false) {
- if (_smc.is_logged()) {
- if ($.isNumeric(id) && id) {
- $(event).attr('disabled', 'true');
- $(event).find('.liked-icon svg').addClass('jiggle');
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/like_post',
- type: 'POST',
- dataType: 'json',
- data: {id: id},
- }).done(function(data) {
- if (data.status == 200) {
- $(event).find('.liked-icon').toggleClass('d-none');
- $(event).find('span[data-an="likes-count"]').text(data.likes_count);
- $(event).toggleClass('liked').addClass('animated bounceIn').promise().done(function(){
- delay(function() {
- $(event).removeClass('animated bounceIn');
- }, 1000);
- });
- }
- else {
- _smc.errorMSG();
- }
- }).always(function() {
- $(event).removeAttr('disabled');
- $(event).find('.liked-icon svg').removeClass('jiggle');
- });
- }
- }
- else{
- _smc.req_auth();
- }
- }
- _smc.repost = function(id = false, event = false) {
- if (_smc.is_logged()) {
- if ($.isNumeric(id) && id) {
- var mainbtn = $(event).closest('.post-action-button').find('.echoes-action-btn')
- $(event).attr('disabled', 'true');
- mainbtn.find('svg').addClass('jiggle');
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/repost',
- type: 'POST',
- dataType: 'json',
- data: {id: id},
- }).done(function(data) {
- if (data.status == 200) {
- if (mainbtn.hasClass('reposted')) {
- mainbtn.removeClass('reposted');
- mainbtn.removeClass('reposted').addClass('animated bounceIn').promise().done(function(){
- delay(function() {
- $(event).removeClass('animated bounceIn');
- }, 1000);
- });
- $(event).closest('.post-action-button').find('span[data-an="reposts-count"]').text(data.reposts_count);
- $(event).closest('.post-action-button').find('span[data-an="quotes-count"]').text(data.quotes_count);
- $(event).closest('.post-action-button').find('span[data-an="echoes-count"]').text(data.reposts_count + data.quotes_count);
- if (_smc.curr_pn == 'home' || _smc.curr_pn == 'profile') {
- var timeline_app = ((_smc.curr_pn == 'home') ? $('div[data-app="homepage"]') : $('div[data-app="profile"]'));
- var orig_post = timeline_app.find('div[data-an="entry-list"]').find('[data-list-item="{0}"]'.format(id));
- var repost = timeline_app.find('div[data-an="entry-list"]').find('[data-repost="{0}"]'.format(data.repost_id));
- if (repost.length) {
- repost.addClass('slideInUp');
- repost.on('animationend', function() {
- $(this).remove();
- });
- }
- if (orig_post.length) {
- if(orig_post.length > 1){
- orig_post.each(function( index ) {
- $(this).closest('.post-action-button').find('.echoes-action-btn').removeClass('reposted');
- $(this).closest('.post-action-button').find('span[data-an="reposts-count"]').text(data.reposts_count);
- $(this).closest('.post-action-button').find('span[data-an="quotes-count"]').text(data.quotes_count);
- $(this).closest('.post-action-button').find('span[data-an="echoes-count"]').text(data.reposts_count + data.quotes_count);
- $(this).closest('.post-action-button').find('span[data-an="reposts-count"]').addClass('animated bounceIn').promise().done(function(){
- delay(function() {
- $(event).removeClass('animated bounceIn');
- }, 1000);
- });
- });
- }else{
- orig_post.find('.echoes-action-btn').removeClass('reposted');
- orig_post.closest('.post-action-button').find('span[data-an="reposts-count"]').text(data.reposts_count);
- orig_post.closest('.post-action-button').find('span[data-an="quotes-count"]').text(data.quotes_count);
- orig_post.closest('.post-action-button').find('span[data-an="echoes-count"]').text(data.reposts_count + data.quotes_count);
- orig_post.find('span[data-an="reposts-count"]').addClass('animated bounceIn').promise().done(function(){
- delay(function() {
- $(event).removeClass('animated bounceIn');
- }, 1000);
- });
- }
- }
- }
- }
- else {
- mainbtn.addClass('reposted').addClass('animated bounceIn').promise().done(function(){
- delay(function() {
- $(event).removeClass('animated bounceIn');
- }, 1000);
- });
- $(event).closest('.post-action-button').find('span[data-an="reposts-count"]').text(data.reposts_count);
- $(event).closest('.post-action-button').find('span[data-an="quotes-count"]').text(data.quotes_count);
- $(event).closest('.post-action-button').find('span[data-an="echoes-count"]').text(data.reposts_count + data.quotes_count);
- }
- }
- else {
- _smc.errorMSG();
- }
- }).always(function() {
- $(event).removeAttr('disabled');
- mainbtn.find('svg').removeClass('jiggle');
- });
- }
- }
- else{
- _smc.req_auth();
- }
- }
- _smc.quote = function(id = false, event = false, b64html) {
- if ( ! _smc.is_logged() )
- return _smc.req_auth()
- _smc.vue.pubbox2.$children[0].is_thread_reply = null;
- _smc.vue.pubbox2.$children[0].show_threaded_posts = false;
- var decodedString = new TextDecoder("utf-8").decode(new Uint8Array(Array.from(atob(b64html)).map(c => c.charCodeAt(0))));
- $('#add_new_post').find('[name=quoted_spout]').val(String(id))
- $('#add_new_post').addClass('sptbl-action-quote').find('#quote-hint-text').show().find('.quote-hint').html(decodedString)
- }
- _smc.share_post = function(url = false, encoded_url = false, embed_data) {
- if (url && encoded_url) {
- 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>";
- var modal = modal.format(encoded_url, url);
- $('body').find('[data-app="black-hole"]').append($(modal)).promise().done(function() {
- $('body').find('[data-app="black-hole"]').find('[data-an="share-post"]').modal('show');
- });
- }
- }
- _smc.read_summary = function(event) {
- var target = event.target
- var summary = target.dataset.summary
- var id = target.dataset.id
- if (summary) {
- $('#thread-summary-modal .modal-body span').html(atob(summary));
- $('#thread-summary-modal .modal-body .loading').addClass('d-none');
- $('#thread-summary-modal').modal('show');
- } else {
- $('#thread-summary-modal .modal-body span').html('');
- $('#thread-summary-modal .modal-body .loading').removeClass('d-none');
- $('#thread-summary-modal .modal-body .alert-danger').html('').addClass('d-none');
- $('#thread-summary-modal').modal('show');
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/chat_gpt/thread_summary?id=' + id,
- dataType: 'json',
- }).done(function(response) {
- if (response.status == 200) {
- $('#thread-summary-modal .modal-body span').html(response.summary);
- $('#thread-summary-modal .modal-body .loading').addClass('d-none');
- target.dataset.summary = btoa(response.summary)
- } else {
- $('#thread-summary-modal .modal-body .alert-danger').html(response.error).removeClass('d-none');
- $('#thread-summary-modal .modal-body .loading').addClass('d-none');
- $('#thread-summary-modal .modal-body span').html('');
- _smc.errorMSG(response.error);
- }
- }).fail(function() {
- $('#thread-summary-modal .modal-body .alert-danger').html('Something went wrong!').removeClass('d-none');
- $('#thread-summary-modal .modal-body .loading').addClass('d-none');
- $('#thread-summary-modal .modal-body span').html('');
- _smc.errorMSG();
- });
- }
- }
- _smc.share_news = function(url = false, encoded_url = false, embed_data) {
- if (url && encoded_url) {
- 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>";
- var modal = modal.format(encoded_url, url);
- $('body').find('[data-app="black-hole"]').append($(modal)).promise().done(function() {
- $('body').find('[data-app="black-hole"]').find('[data-an="share-news"]').modal('show');
- });
- }
- }
- _smc.share_pod = function(url = false, encoded_url = false, embed_data) {
- if (url && encoded_url) {
- 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>";
- var modal = modal.format(encoded_url, url);
- $('body').find('[data-app="black-hole"]').append($(modal)).promise().done(function() {
- $('body').find('[data-app="black-hole"]').find('[data-an="share-pod"]').modal('show');
- });
- }
- }
- _smc.embed_post = function(url, embed_data) {
- if (url && embed_data) {
- 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>"
- + "<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>";
- var embed_code = '<iframe src="' + url + '?embed=1" border="0" width="600" height="400"></iframe>'
- try {
- var embed = JSON.parse(atob(embed_data))
- embed_code = '<blockquote class="sptbl-spout">'
- + '<p dir="ltr" lang="en">' + embed.html + '</p>'
- + '— ' + embed.author + ' (@' + embed.author_username + ') '
- + '<a href="' + url + '">' + embed.date + '</a></blockquote>'
- + '<script async charset="utf-8" src="https://spoutible.com/embed.js"><\/script>'
- } catch(err) {}
- var modal = modal.format(url, embed_code);
- $('body').find('[data-app="black-hole"]').append($(modal)).promise().done(function() {
- $('body').find('[data-app="black-hole"]').find('[data-an="share-post"]').modal('show');
- });
- }
- }
- _smc.pin = function(id, elem) {
- if ( ! _smc.is_logged() )
- return _smc.req_auth()
- var unpin = JSON.parse($(elem).attr('data-pinned'))
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/pin_spout',
- type: 'POST',
- dataType: 'json',
- data: {
- id: id,
- action: unpin ? 'unpin' : 'pin',
- },
- }).done(function(data) {
- if (data.status == 200) {
- _smc.info( 'Pinned spouts', unpin
- ? 'Your existing spout was unpinned successfully!'
- : 'New spout pinned successfully!' );
- $(elem).attr('data-pinned', data.pinned ? 'true' : 'false');
- } else {
- _smc.errorMSG();
- }
- });
- }
- _smc.isURL = function(str = "") {
- 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");
- return regex.test(str);
- }
- _smc.show_likes = function(id = false) {
- if ($.isNumeric(id) && id) {
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/show_likes',
- type: 'POST',
- dataType: 'json',
- data: {id: id},
- }).done(function(data) {
- if (data.status == 200) {
- $('div[data-app="black-hole"]').append($(data.html)).find('div[data-app="post-likes-list"]').modal('show');
- }
- else if(data.status == 404) {
- _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.");
- }
- else {
- _smc.errorMSG();
- }
- });
- }
- }
- _smc.show_embed_modal = function(post) {
- _smc.reset_embed_post()
- if (typeof post !== 'object') {
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/spouts/get',
- data: {id: post},
- dataType: 'json',
- }).done(function(data) {
- if (data.status == 200) {
- _smc.render_embed_post(data.post)
- } else {
- SPTBL_APP.errorMSG();
- }
- })
- } else {
- _smc.render_embed_post(post)
- }
- }
- _smc.reset_embed_post = function() {
- $('div[data-app="embed-post-modal"] textarea').val('')
- $('div[data-app="embed-post-modal"] .spout-avatar').attr('src', '');
- $('div[data-app="embed-post-modal"] .spout_name').html('');
- $('div[data-app="embed-post-modal"] .spout_userhandle').html('');
- $('div[data-app="embed-post-modal"] .spout_text').html('');
- $('div[data-app="embed-post-modal"] .spout_date').html('');
- $('div[data-app="embed-post-modal"] .spout_likes span').html('');
- $('div[data-app="embed-post-modal"] .spout_replies span').html('');
- $('div[data-app="embed-post-modal"] .spout_reposts span').html('');
- $('div[data-app="embed-post-modal"] .quoted-spout-container').html('');
- $('div[data-app="embed-post-modal"] .spout-media').html('')
- }
- _smc.render_embed_post = function(post) {
- 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>'
- 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>'
- $('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\>')
- $('div[data-app="embed-post-modal"] .spout-avatar').attr('src', post.owner.avatar);
- if (post.owner.verified) {
- $('div[data-app="embed-post-modal"] .spout_name').html(post.owner.name + ' <span class="user-name-holder__badge">' + icon_verified + '</span>');
- } else {
- $('div[data-app="embed-post-modal"] .spout_name').html(post.owner.name);
- }
- $('div[data-app="embed-post-modal"] .spout_userhandle').html('@' + post.owner.username);
- $('div[data-app="embed-post-modal"] .spout_text').html(post.text);
- $('div[data-app="embed-post-modal"] .spout_date').html(post.time_formatted);
- $('div[data-app="embed-post-modal"] .spout_likes span').html(post.likes_count);
- $('div[data-app="embed-post-modal"] .spout_replies span').html(post.replys_count);
- $('div[data-app="embed-post-modal"] .spout_reposts span').html(parseInt(post.reposts_count || 0) + parseInt(post.quotes_count || 0));
- if (!!post.quoted_spout_data) {
- $('div[data-app="embed-post-modal"] .quoted-spout-container').html(`
- <blockquote class="quoted-spout">
- <div class="quote-header">
- <img src="${post.quoted_spout_data.owner.avatar}" height="20" width="20" />
- <div class="quoted-spout-user-details">
- <span class="quote-uname">
- ${post.quoted_spout_data.owner.name}
- ${data.owner.verified == 1 ? '<span class="user-name-holder__badge">' + icon_verified + '</span>' : ''}
- </span>
- ${post.quoted_spout_data.owner.verified == 1 ? '<span class="user-name-holder__badge">' + verified + '</span>' : ''}
- <span class="quote-uuname">@${post.quoted_spout_data.owner.username}</span>
- </div>
- </div>
- <div class="spout-text">${post.quoted_spout_data.text}</div>
- </blockquote>
- `);
- }
- if (post.type == 'image' && post.media) {
- if (post.media.length > 1) {
- let content = ''
- for (let index = 0; index < post.media.length; index++) {
- const element = post.media[index];
- content += `
- <div class="spout-image spout-gallery-image">
- <img src="https://media.spoutible.com/${post.media[index].src}" alt="${post.media[index].x.alt ?? 'Picture'}">
- </div>
- `;
- $('div[data-app="embed-post-modal"] .spout-media').html(content);
- }
- } else {
- $('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>`);
- }
- } else if (post.type == 'gif') {
- $('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>`);
- } else if (post.type == 'video' && post.media) {
- $('div[data-app="embed-post-modal"] .spout-media').html(`<img src="https://media.spoutible.com/${post.media[0]?.x.poster_thumb}" alt="Video">`);
- } else if (post.type == 'poll' && post?.media) {
- let content = '<div class="spout-poll">'
- for (let index = 0; index < post.poll.options.length; index++) {
- const pollData = post.poll.options[index];
- content += `
- <div class="spout-poll__option">
- <div class="bar-icon">
- <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>
- </div>
- <div class="bar-text">
- <p>${pollData.option}</p>
- </div>
- <div class="bar-num">
- <b>${post.poll.has_voted ? pollData.percentage + '%' : ''}</b>
- </div>
- <span class="bar-slider" style="width: ${pollData.percentage ? pollData.percentage : 0}%"></span>
- </div>
- `;
- }
- content += '</div>'
- $('div[data-app="embed-post-modal"] .spout-media').html(content);
- } else if (post.og_data) {
- let content = ''
- if (post.og_data.url) {
- content = `
- <div class="spout-og">
- <a class="spout-og__inner link" href="${post.og_data.url}">
- <div class="spout-og__image">
- <img src="${post.og_data.image}" alt="IMG">
- </div>
- <div class="spout-og__description">
- <h5>${post.og_data.title}</h5>
- <p>${post.og_data.description}</p>
- <a href="${post.og_data.url}" target="_blank" rel="noopener noreferrer"></a>
- </div>
- </a>
- </div>
- `;
- }
- $('div[data-app="embed-post-modal"] .spout-media').html(content);
- }
- $('div[data-app="embed-post-modal"]').modal('show');
- }
- _smc.show_edits = function(id = false) {
- if ($.isNumeric(id) && id) {
- if ( $('.edits--spout-' + id).length ) {
- $('div[data-app="black-hole"]').append($('.edits--spout-' + id).html()).find('div[data-app="post-edits"]').modal('show');
- return
- }
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/show_edits',
- type: 'POST',
- dataType: 'json',
- data: {id: id},
- }).done(function(data) {
- if (data.status == 200) {
- $('div[data-app="black-hole"]').append($(data.html)).find('div[data-app="post-edits"]').modal('show');
- }
- else if(data.status == 404) {
- _smc.info("No edits yet!", "This post appears to have edits made yet.");
- }
- else {
- _smc.errorMSG();
- }
- });
- }
- }
- _smc.edit_post = function(id = false) {
- if ($.isNumeric(id) && id) {
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/edit_post/get_data',
- type: 'GET',
- dataType: 'json',
- data: {id: id},
- }).done(function(data) {
- if (data.status == 200) {
- $('div[data-app="black-hole"]').append($(data.html)).find('div[data-app="post-text-edit"]').modal('show');
- }
- else {
- _smc.errorMSG();
- }
- });
- }
- }
- _smc.edit_collaborative_thread_users = function(id = false) {
- if ($.isNumeric(id) && id) {
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/edit_post/get_collaborative_thread_users',
- type: 'GET',
- dataType: 'json',
- data: {id: id},
- }).done(function(data) {
- if (data.status == 200) {
- $('div[data-app="black-hole"]').append($(data.html)).find('div[data-app="post-edit_collaborative_thread_users"]').modal('show');
- }
- else {
- _smc.errorMSG();
- }
- });
- }
- }
- _smc.bookmark_post = function(id = false, _self = false) {
- if (_smc.is_logged()) {
- if ($.isNumeric(id) && id) {
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/bookmark_post',
- type: 'POST',
- dataType: 'json',
- data: {id: id, a: 'save'},
- }).done(function(data) {
- if (data.status == 200) {
- if (data.status_code == '1') {
- sptbl_bs_notify("Post has been bookmarked!", 500);
- $(_self).text("Remove Bookmark");
- }
- else {
- sptbl_bs_notify("Post has been deleted from bookmarks!",500);
- $(_self).text("Bookmark");
- }
- }
- else {
- _smc.errorMSG();
- }
- });
- }
- }
- else {
- _smc.req_auth();
- }
- }
- _smc.load_likes = function(id = false, event = false) {
- if ($.isNumeric(id) && id) {
- var _self = $(event);
- var likes_ls = $('div[data-app="post-likes-list"]');
- var last_item = likes_ls.find('div[data-list-item]').last();
- if (last_item.length) {
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/load_likes',
- type: 'GET',
- dataType: 'json',
- data: {id: id, offset: last_item.data('list-item')},
- beforeSend: function() {
- _self.attr('disabled', 'true').text("Please wait");
- }
- }).done(function(data) {
- if (data.status == 200) {
- likes_ls.find('div[data-an="users-ls"]').append($(data.html));
- _self.removeAttr('disabled').text("Show more");
- }
- else {
- _self.text("That is all for now!");
- }
- });
- }
- }
- }
- _smc.follow = function(event = false) {
- if (event) {
- if (_smc.is_logged()) {
- var target = $(event);
- if(target.data('action') == 'unfollow') {
- var promise = SPTBL_APP.confirm_action({
- btn_1: "Cancel",
- btn_2: "Unfollow",
- title: "Delete?",
- message: "Please note that, if you unsubscribe then this user's posts will no longer appear in the feed on your main page.",
- });
- promise.done(function() {
- target.data('action', 'follow');
- target.text("Follow");
- target.replaceClass('main-inline','main-outline');
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/follow',
- type: 'POST',
- dataType: 'json',
- data: {id: target.data('id')},
- }).done(function(data) {
- if (data.status != 200) {
- _smc.errorMSG();
- }
- else {
- if (_smc.curr_pn == "profile") {
- if (data.refresh != undefined) {
- $(window).reloadPage(1000);
- }
- }
- }
- }).always(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- sptbl_bs_notify("You unfollowed <b>@{0}</b>".format(target.data("user-name")), 1500);
- });
- promise.fail(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- }
- else {
- target.data('action', 'unfollow');
- target.text("Following");
- target.replaceClass('main-outline','main-inline');
- delay(function(){
- target.text("Unfollow");
- }, 1500);
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/follow',
- type: 'POST',
- dataType: 'json',
- data: {id: target.data('id')},
- }).done(function(data) {
- if (data.status != 200) {
- _smc.errorMSG();
- }
- else {
- if (_smc.curr_pn == "profile") {
- if (data.refresh != undefined) {
- $(window).reloadPage(1000);
- }
- }
- }
- });
- sptbl_bs_notify("You followed <b>@{0}</b>".format(target.data("user-name")), 1500);
- }
- }
- else{
- _smc.req_auth();
- }
- }
- }
- _smc.req_follow = function(event = false) {
- if (event) {
- if (_smc.is_logged()) {
- var target = $(event);
- if(target.data('action') == 'unfollow') {
- var promise = SPTBL_APP.confirm_action({
- btn_1: "Cancel",
- btn_2: "Unfollow",
- title: "Delete?",
- message: "Please note that, if you unsubscribe then this user's posts will no longer appear in the feed on your main page.",
- });
- promise.done(function() {
- target.data('action', 'follow');
- target.text("Follow");
- target.replaceClass('main-inline','main-outline');
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/follow',
- type: 'POST',
- dataType: 'json',
- data: {id: target.data('id')},
- }).done(function(data) {
- if (data.status != 200) {
- _smc.errorMSG();
- }
- }).always(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- sptbl_bs_notify("You unfollowed <b>@{0}</b>".format(target.data("user-name")), 1500);
- });
- promise.fail(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- }
- else if(target.data('action') == 'cancel') {
- var promise = SPTBL_APP.confirm_action({
- btn_1: "Cancel",
- btn_2: "Cancel request",
- title: "Delete?",
- message: "This will cancel your pending request and this user will no longer see it.",
- });
- promise.done(function() {
- target.data('action', 'follow');
- target.text("Follow");
- target.replaceClass('main-inline','main-outline');
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/follow',
- type: 'POST',
- dataType: 'json',
- data: {id: target.data('id')},
- }).done(function(data) {
- if (data.status != 200) {
- _smc.errorMSG();
- }
- }).always(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- sptbl_bs_notify("You unfollowed <b>@{0}</b>".format(target.data("user-name")), 1500);
- });
- promise.fail(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- }
- else {
- target.data('action', 'cancel');
- target.text("Requested");
- target.replaceClass('main-outline', 'main-inline');
- delay(function() {
- target.text("Pending");
- }, 1500);
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/follow',
- type: 'POST',
- dataType: 'json',
- data: {id: target.data('id')},
- }).done(function(data) {
- if (data.status != 200) {
- _smc.errorMSG();
- }
- });
- sptbl_bs_notify("Follow request sent to <b>@{0}</b>".format(target.data("user-name")), 1500);
- }
- }
- else{
- _smc.req_auth();
- }
- }
- }
- _smc.block = function(event = false) {
- if (event) {
- if (_smc.is_logged()) {
- var target = $(event);
- if(target.data('action') == 'block') {
- var promise = SPTBL_APP.confirm_action({
- btn_1: "Cancel",
- btn_2: "Block",
- title: "Delete?",
- message: "Blocked users will no longer be able to write a message to you, follow you, or see your profile and spouts, etc.",
- });
- promise.done(function() {
- target.data('action','unblock');
- target.text("Unblock");
- if (target.hasClass('toggle-class')) {
- target.replaceClass('main-inline', 'main-outline');
- }
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/block',
- type: 'POST',
- dataType: 'json',
- data: {id: target.data('id')},
- }).done(function(data) {
- if (data.status != 200) {
- SPTBL_APP.errorMSG();
- }
- else {
- if (_smc.curr_pn == 'profile') {
- _smc.spa_reload();
- }
- }
- }).always(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- });
- promise.fail(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- }
- else if(target.data('action') == 'unblock') {
- var promise = SPTBL_APP.confirm_action({
- btn_1: "Cancel",
- btn_2: "Unblock",
- title: "Delete?",
- message: "Are you sure you want to unblock this user? Now they can follow you or see your posts, etc.",
- });
- promise.done(function() {
- target.data('action','block');
- target.text("Block");
- if (target.hasClass('toggle-class')) {
- target.replaceClass('main-outline', 'main-inline');
- }
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/block',
- type: 'POST',
- dataType: 'json',
- data: {id: target.data('id')},
- }).done(function(data) {
- if (data.status != 200) {
- SPTBL_APP.errorMSG();
- }
- else {
- if (_smc.curr_pn == 'profile') {
- $(window).reloadPage();
- }
- }
- }).always(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- });
- promise.fail(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- }
- }
- else{
- _smc.req_auth();
- }
- }
- }
- _smc.mute = function(event = false) {
- if (event) {
- if (_smc.is_logged()) {
- var target = $(event);
- if(target.data('action') == 'mute') {
- var promise = SPTBL_APP.confirm_action({
- btn_1: "Cancel",
- btn_2: "Mute",
- title: "Delete?",
- message: "Are you sure you want to Mute this user? You will not be able to see the Muted user Spouts.",
- });
- promise.done(function() {
- target.data('action','unmute');
- target.text("Unmute");
- if (target.hasClass('toggle-class')) {
- target.replaceClass('main-inline', 'main-outline');
- }
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/mute',
- type: 'POST',
- dataType: 'json',
- data: {id: target.data('id')},
- }).done(function(data) {
- if (data.status != 200) {
- SPTBL_APP.errorMSG();
- }
- else {
- sptbl_bs_notify(`You Muted The user!`, 1500);
- if (_smc.curr_pn == 'profile') {
- _smc.spa_reload();
- }
- }
- }).always(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- });
- promise.fail(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- } else if(target.data('action') == 'unmute') {
- var promise = SPTBL_APP.confirm_action({
- btn_1: "Cancel",
- btn_2: "Unmute",
- title: "Delete?",
- message: "Are you sure you want to Unmute this user? Now you will see his spouts.",
- });
- promise.done(function() {
- target.data('action','mute');
- target.text("Mute");
- if (target.hasClass('toggle-class')) {
- target.replaceClass('main-outline', 'main-inline');
- }
- $.ajax({
- url: 'https://spoutible.com/sptbl_system_api/main/mute',
- type: 'POST',
- dataType: 'json',
- data: {id: target.data('id')},
- }).done(function(data) {
- if (data.status != 200) {
- SPTBL_APP.errorMSG();
- }
- else {
- sptbl_bs_notify(`You Unmuted The user!`, 1500);
- if (_smc.curr_pn == 'profile') {
- $(window).reloadPage();
- }
- }
- }).always(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- });
- promise.fail(function() {
- $("div.confirm-actions-modal").modal("hide");
- });
- }
- }
- else{
- _smc.req_auth();
- }
- }
- }
- _smc.errorMSG = function(error) {
- sptbl_bs_notify(error || "An error occurred while processing your request. Please try again later.", 3000, "danger");
- }
- _smc.extend_vue = function(app_name = "", vue_instance = {}) {
- _smc.vue[app_name] = vue_instance;
- }
- _smc.progress_bar = function(a = "show") {
- if (a == "show") {
- window.waitMe.start();
- }
- else {
- window.waitMe.end();
- }
- }
- // _smc.update_msb_indicators = function() {
- // if (_smc.is_logged()) {
- // var main_left_sb = $('div[data-app="left-sidebar"]');
- // var main_bottom_nb = $('div[data-app="mobile-navbar"]');
- // var timer_id = setInterval(function() {
- // $.ajax({
- // url: 'https://spoutible.com/sptbl_system_api/main/update_msb_indicators',
- // type: 'GET',
- // dataType: 'json',
- // }).done(function(data) {
- // if (data.status == 200) {
- // // if (data.notifications > 0) {
- // // var notifs_total = data.notifications;
- // // if (data.notifications > 99) {
- // // notifs_total = "99+";
- // // }
- // // main_left_sb.find('[data-an="group-ind"]').addClass("group-ind-active");
- // // main_left_sb.find('[data-an="new-notifs"]').text($.trim(notifs_total));
- // // main_bottom_nb.find('[data-an="new-notifs"]').text($.trim(notifs_total));
- // // }
- // // else {
- // // main_left_sb.find('[data-an="group-ind"]').removeClass("group-ind-active");
- // // main_left_sb.find('[data-an="new-notifs"]').empty();
- // // main_bottom_nb.find('[data-an="new-notifs"]').empty();
- // // }
- // // if (data.messages) {
- // // var messages_total = data.messages;
- // // if (data.messages > 99) {
- // // messages_total = "99+";
- // // }
- // // main_left_sb.find('[data-an="group-ind"]').addClass("group-ind-active");
- // // main_left_sb.find('[data-an="new-messages"]').text($.trim(messages_total));
- // // main_bottom_nb.find('[data-an="new-messages"]').text($.trim(messages_total));
- // // }
- // // else {
- // // main_left_sb.find('[data-an="group-ind"]').removeClass("group-ind-active");
- // // main_left_sb.find('[data-an="new-messages"]').empty();
- // // main_bottom_nb.find('[data-an="new-messages"]').empty();
- // // }
- // }
- // else {
- // clearInterval(timer_id);
- // }
- // });
- // }, (Number(_smc.msb_upinterval) * 1000));
- // }
- // }
- _smc.hide_sb = function() {
- $('div[data-app="lsb-back-drop"]').trigger('click');
- }
- _smc.spa_load = function(url = "", push_state = true) {
- var timeline = $('[data-el="timeline-container-wrapper"]');
- var preloader = timeline.find('[data-el="spa-preloader"]');
- var left_sidebar = $('[data-app="left-sidebar"]');
- var mobile_navbar = $('[data-app="mobile-navbar"]');
- if (push_state == true) {
- var previousRoute = window.location.pathname.replace(/^\/+/, '').split('/')[0];
- // if user is going to a single post from timeline,
- // then store the scroll height to get back to it when he is back
- if ((previousRoute === "" || previousRoute == 'home') && url.includes('thread')) {
- var post_ls = $('[data-app="homepage"]').find('[data-an="entry-list"]');
- }
- if (window.location.pathname.includes('conversation') && window.websocket !== undefined) {
- window.websocket.close();
- window.websocket = undefined;
- }
- // if user moving away from pods then float it
- if (previousRoute === 'pod' && window.vue_instance.isPodEnabled()) {
- window.vue_instance.floatPod()
- }
- window.history.pushState({state: "new", back_url: url}, "", url);
- }
- // else if (! push_state && ((window.location.pathname == "/" || window.location.pathname == '/home') && sessionStorage.getItem('dataLimit'))) {
- // data.limit = sessionStorage.getItem('dataLimit');
- // }
- if (window.mobileCheck()) {
- _smc.hide_sb();
- }
- // after pushing to state we can check the path correctly
- // for vue refactor, we set the component name to null to use the old way for SPA (non-refactored components)
- var currentRoute = window.location.pathname.replace(/^\/+/, '').split('/')[0];
- if (currentRoute === "" || currentRoute === 'home') {
- if (window.vue_instance.timelineComponent) {
- window.vue_instance.timelineComponent.reset();
- }
- window.vue_instance.swapComponent('timeline');
- window.scrollTo(0, 0);
- timeline.find('[data-el="timeline-content"]').html('');
- left_sidebar.find('[data-navitem]').each(function(index, el) {
- $(el).removeClass('active');
- }).promise().done(function() {
- left_sidebar.find('[data-navitem="home"]').addClass('active');
- });
- if (_smc.timeout !== false) {
- clearTimeout(_smc.timeout);
- }
- if ( 'Gifffer' in window && $('img[data-gifffer]').length > 0 ) {
- Gifffer()
- }
- preloader.removeClass('d-none');
- $("div.dropdown-menu.show").each(function(index, el) {
- $(el).removeClass("show");
- });
- mobile_navbar.find('[data-navitem]').each(function(index, el) {
- $(el).removeClass('active');
- }).promise().done(function() {
- mobile_navbar.find('[data-navitem="home"]').addClass('active');
- });
- const body = document.querySelector('body')
- body.classList = ''
- body.classList.add('sptbl-app-home')
- $(".media-slider").each(function() {
- $(this).resize()
- })
- _smc.toggleSB("hide");
- this.previous_url = window.location.pathname
- return;
- } else if (currentRoute === 'search') {
- if (window.vue_instance.searchComponent) {
- window.vue_instance.searchComponent.reset()
- }
- window.vue_instance.swapComponent('search')
- window.scrollTo(0, 0);
- timeline.find('[data-el="timeline-content"]').html('');
- left_sidebar.find('[data-navitem]').each(function(index, el) {
- $(el).removeClass('active');
- }).promise().done(function() {
- left_sidebar.find('[data-navitem="search"]').addClass('active');
- });
- if (_smc.timeout !== false) {
- clearTimeout(_smc.timeout);
- }
- if ( 'Gifffer' in window && $('img[data-gifffer]').length > 0 ) {
- Gifffer()
- }
- preloader.removeClass('d-none');
- $("div.dropdown-menu.show").each(function(index, el) {
- $(el).removeClass("show");
- });
- mobile_navbar.find('[data-navitem]').each(function(index, el) {
- $(el).removeClass('active');
- }).promise().done(function() {
- mobile_navbar.find('[data-navitem="search"]').addClass('active');
- });
- const body = document.querySelector('body')
- body.classList = ''
- body.classList.add('sptbl-app-search')
- $(".media-slider").each(function() {
- $(this).resize()
- })
- _smc.toggleSB("hide");
- this.previous_url = window.location.pathname
- return;
- } else if (currentRoute === 'pod') {
- window.vue_instance.createPod()
- } else {
- window.vue_instance.swapComponent(null)
- }
- this.previous_url = window.location.pathname
- $.ajax({
- url: url,
- type: 'GET',
- data: {spa_load: 1, limit: 160},
- dataType: 'json',
- async: true,
- beforeSend: function() {
- _smc.user_lbox_rm();
- $("html, body").animate({
- scrollTop: 0
- }, 10).promise().done(function() {
- preloader.removeClass('d-none');
- });
- _smc.toggleSB("hide");
- sptbl_close_all_modals();
- }
- }).done(function(data = {}) {
- if (data.status == 200) {
- var prevapp = _smc.curr_pn;
- var json_data = data.json_data;
- _smc.curr_pn = json_data.pn;
- $('head').find('title').text(json_data.page_title);
- $('head').find('meta[name="title"]').attr('content', json_data.page_title);
- $('head').find('meta[name="description"]').attr('content', json_data.page_desc);
- $('head').find('meta[name="keywords"]').attr('content', json_data.page_kw);
- if (json_data.page_img) {
- $('head').find('meta[name="image"]').attr('content', json_data.page_img);
- }
- if ($('body').hasClass('sptbl-app-{0}'.format(prevapp))) {
- $('body').removeClass('sptbl-app-{0}'.format(prevapp));
- $('body').addClass('sptbl-app-{0}'.format(json_data.pn));
- }
- else {
- $('body').addClass('sptbl-app-{0}'.format(json_data.pn));
- }
- $('body').attr('data-page-tab', json_data.page_tab);
- timeline.find('[data-el="timeline-content"]').html(data.html);
- // if (! push_state && sessionStorage.getItem('scrollHeight') && window.location.pathname == '/') {
- // $("html, body").animate({
- // scrollTop: sessionStorage.getItem('scrollHeight')
- // }, 100);
- // sessionStorage.removeItem('scrollHeight')
- // }
- left_sidebar.find('[data-navitem]').each(function(index, el) {
- $(el).removeClass('active');
- }).promise().done(function() {
- if (_smc.curr_pn == "profile") {
- if (json_data.page_xdata.is_me) {
- left_sidebar.find('[data-navitem="profile"]').addClass('active');
- }
- }
- else{
- left_sidebar.find('[data-navitem="{0}"]'.format(_smc.curr_pn)).addClass('active');
- }
- });
- mobile_navbar.find('[data-navitem]').each(function(index, el) {
- $(el).removeClass('active');
- }).promise().done(function() {
- mobile_navbar.find('[data-navitem="{0}"]'.format(_smc.curr_pn)).addClass('active');
- });
- if ( /\/notifications($|\?|#)/.test(url) ) {
- $('[data-an="new-notifs"]').empty()
- }
- }
- else if(data.status == 302) {
- _smc.spa_load(data.redirect_url);
- }
- else {
- _smc.spa_load("https://spoutible.com/404");
- }
- }).always(function() {
- if (_smc.timeout !== false) {
- clearTimeout(_smc.timeout);
- }
- if ( 'Gifffer' in window && $('img[data-gifffer]').length > 0 ) {
- Gifffer()
- }
- preloader.addClass('d-none');
- $("div.dropdown-menu.show").each(function(index, el) {
- $(el).removeClass("show");
- });
- $(".media-slider").each(function() {
- $(this).resize()
- })
- setTimeout(() => {
- window.load_videos()
- }, 200);
- });
- return false;
- }
- _smc.spa_reload = function() {
- if (window.location.href != undefined) {
- _smc.spa_load(window.location.href);
- }
- else {
- _smc.spa_load(data['url']);
- }
- return false;
- }
- _smc.go_back = function() {
- history.back();
- }
- _smc.jump_back = function(step = 1) {
- history.go(step);
- }
- _smc.report_post = function(id = false) {
- if (_smc.is_logged()) {
- if (_smc.vue.report_post != undefined && id) {
- _smc.vue.report_post.open(id);
- }
- else {
- _smc.errorMSG();
- }
- }
- else {
- _smc.req_auth();
- }
- }
- _smc.update_ilb = function() {
- $('a[href].fbox-media:not(.has-alt-text)').fancybox({
- arrows: true,
- openEffect: 'elastic',
- closeEffect: false,
- hash: false,
- i18n: {
- en: {
- ERROR: "The requested content could not be loaded. <br/> Please try again later.",
- }
- }
- });
- }
- _smc.add_user_to_list = function(user) {
- if (!_smc.is_logged()) {
- _smc.req_auth();
- }
- window.vue_instance.$refs.timelineListsModal.showWithUserLists(user)
- }
- return _smc;
- }
- if (window.SPTBL_APP === undefined) {
- window.SPTBL_APP = _SPTBL_APP();
- }
- })(window);
- $(document).ready(function($) {
- SPTBL_APP.init();
- var clipboard = new ClipboardJS('.clip-board-copy');
- var page_height = $(document).height();
- clipboard.on('success', function(event) {
- sptbl_bs_notify("Copied to your clipboard!",500);
- });
- clipboard.on('error', function(event) {
- sptbl_bs_notify("Failed to copy to clipboard!",3000);
- });
- if (navigator.cookieEnabled == false) {
- $('[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>");
- }
- $(document).on('click', 'div[data-app="lsb-back-drop"]', function(event) {
- event.preventDefault();
- SPTBL_APP.toggleSB();
- });
- var _lozad_ = lozad();
- setTimeout(() => {
- _lozad_.observe();
- }, 500);
- $(document).on("ajaxComplete", function(event, request, settings) {
- setTimeout(() => {
- _lozad_.observe();
- // SPTBL_APP.fix_sidebars();
- SPTBL_APP.update_ilb();
- }, 500);
- });
- // terminated on 30-7-2023 for bad performance
- // setInterval(function() {
- // var new_page_height = $(document).height();
- // var _lozad_ = lozad();
- // _lozad_.observe();
- // if (page_height != new_page_height) {
- // page_height = new_page_height;
- // SPTBL_APP.fix_sidebars();
- // SPTBL_APP.update_ilb();
- // }
- // if ($('video[data-el="sptbl-video"]').length) {
- // $('video[data-el="sptbl-video"]').each(function(index, el) {
- // if ($(el).hasClass('afterglow') != true) {
- // var video_src = $(el).find("source").first().attr("src");
- // $(el).width("100%").height("100%").addClass('afterglow');
- // $(el).find("source").remove();
- // $(el).append($("<source>", {
- // type: "video/mp4",
- // src: video_src
- // }));
- // $(el).append($("<source>", {
- // type: "video/webm",
- // src: video_src
- // }));
- // $(el).append($("<source>", {
- // type: "video/mov",
- // src: video_src
- // }));
- // $(el).append($("<source>", {
- // type: "video/3gp",
- // src: video_src
- // }));
- // $(el).append($("<source>", {
- // type: "video/ogg",
- // src: video_src
- // }));
- // afterglow.init();
- // }
- // });
- // }
- // }, 500);
- $(document).on('click tap', 'a[data-spa]', function(event) {
- event.preventDefault();
- var page_url_source = $(this).attr('href');
- SPTBL_APP.spa_load(page_url_source);
- return false;
- });
- $(window).on("popstate", function () {
- var left_sidebar = $('[data-app="left-sidebar"]');
- var mobile_navbar = $('[data-app="mobile-navbar"]');
- var prevRoute = window.SPTBL_APP.previous_url.replace(/^\/+/, '').split('/')[0]
- if (history.state) {
- if (!history.state.back_url.includes('conversation') && window.websocket !== undefined) {
- window.websocket.close();
- window.websocket = undefined;
- }
- // if user moving away from pods then float it
- if (prevRoute === 'pod' && window.vue_instance.isPodEnabled()) {
- window.vue_instance.floatPod()
- }
- var currentRoute = window.location.pathname.replace(/^\/+/, '').split('/')[0]
- // disabled loading timeline on back button because we use vue keep-alive component
- if (
- $.isEmptyObject(history.state.back_url) != true &&
- currentRoute !== '' &&
- currentRoute !== 'home' &&
- currentRoute !== 'search' &&
- currentRoute !== 'pod'
- ) {
- SPTBL_APP.spa_load(history.state.back_url, false);
- } else {
- $('[data-el="timeline-container-wrapper"]').find('[data-el="timeline-content"]').html('');
- }
- if (currentRoute === '' || currentRoute === 'home') {
- window.vue_instance.swapComponent('timeline')
- var scrollHeight = localStorage.getItem('timeline_scroll_height')
- if (scrollHeight) {
- window.scrollTo(0, scrollHeight)
- }
- $('[data-el="timeline-container-wrapper"]').find('[data-el="timeline-content"]').html('');
- const body = document.querySelector('body')
- body.classList = ''
- body.classList.add('sptbl-app-home')
- left_sidebar.find('[data-navitem]').each(function(index, el) {
- $(el).removeClass('active');
- }).promise().done(function() {
- left_sidebar.find('[data-navitem="home"]').addClass('active');
- });
- mobile_navbar.find('[data-navitem]').each(function(index, el) {
- $(el).removeClass('active');
- }).promise().done(function() {
- mobile_navbar.find('[data-navitem="home"]').addClass('active');
- });
- } else if (currentRoute === 'search') {
- window.vue_instance.swapComponent('search')
- $('[data-el="timeline-container-wrapper"]').find('[data-el="timeline-content"]').html('');
- const body = document.querySelector('body')
- body.classList = ''
- body.classList.add('sptbl-app-search')
- left_sidebar.find('[data-navitem]').each(function(index, el) {
- $(el).removeClass('active');
- }).promise().done(function() {
- left_sidebar.find('[data-navitem="search"]').addClass('active');
- });
- mobile_navbar.find('[data-navitem]').each(function(index, el) {
- $(el).removeClass('active');
- }).promise().done(function() {
- mobile_navbar.find('[data-navitem="search"]').addClass('active');
- });
- var scrollHeight = localStorage.getItem('search_scroll_height')
- if (scrollHeight) {
- window.scrollTo(0, scrollHeight)
- }
- } else if (currentRoute === 'pod') {
- window.vue_instance.createPod()
- } else {
- window.vue_instance.swapComponent(null)
- }
- $(".media-slider").each(function() {
- $(this).resize()
- })
- setTimeout(() => {
- window.load_videos()
- }, 200);
- }
- window.SPTBL_APP.previous_url = window.location.pathname
- return false;
- });
- $(document).on('click tap', '[data-href]', function(event) {
- event.preventDefault();
- event.stopPropagation();
- if (window.getSelection().toString().length > 0) {
- return;
- }
- window.open($(this).data('href'), '_blank');
- return false;
- });
- $(document).on('click tap', '.image-alt-inline', function(e)
- {
- e.preventDefault()
- e.stopPropagation()
- SPTBL_APP.show_alt(this.dataset.alt)
- })
- if (window.mobileCheck() != true) {
- $(document).on('mouseenter', '[data-uinfo-lbox]', function(event) {
- event.preventDefault();
- var uid = $(this).data("uinfo-lbox");
- SPTBL_APP.user_lbox(uid, $(this));
- });
- $(document).on('mouseleave', '[data-uinfo-lbox]', function(event) {
- event.preventDefault();
- if (sptbl_empty(SPTBL_APP.userlbox.status)) {
- clearTimeout(SPTBL_APP.userlbox.pre_delay);
- SPTBL_APP.userlbox.pre_delay = false;
- }
- if (sptbl_empty(SPTBL_APP.userlbox.interv) != true) {
- clearInterval(SPTBL_APP.userlbox.interv);
- }
- SPTBL_APP.userlbox.interv = setInterval(function() {
- if (SPTBL_APP.userlbox.lifetm !== "pause" && $.isNumeric(SPTBL_APP.userlbox.lifetm)) {
- if (SPTBL_APP.userlbox.lifetm <= 0) {
- SPTBL_APP.user_lbox_rm();
- clearInterval(SPTBL_APP.userlbox.interv);
- }
- else{
- SPTBL_APP.userlbox.lifetm -= 100;
- }
- }
- }, 100);
- });
- $(document).on('mouseenter', "[data-app='user-info-lbox']", function() {
- SPTBL_APP.userlbox.lifetm = "pause";
- });
- $(document).on('mouseleave', "[data-app='user-info-lbox']", function() {
- SPTBL_APP.userlbox.lifetm = 1000;
- });
- }
- });
- var navbar = document.getElementById("timelineheader");
- if (navbar) {
- window.onscroll = function() {
- myFunction()
- };
- var sticky = navbar.offsetTop;
- function myFunction() {
- if (window.pageYOffset >= sticky) {
- navbar.classList.add("stickyhead")
- } else {
- navbar.classList.remove("stickyhead");
- }
- }
- }
- $('#add_new_post').on('hidden.bs.modal', function()
- {
- $(this).removeClass('sptbl-action-quote').find('#quote-hint-text').hide()
- $(this).find('[name=quoted_spout]').val('')
- // close cross posting when modal closes so it forces the users to fetch the new state
- SPTBL_APP.vue.pubbox2.$refs.modalPubbox.show_cross_posting_settings = false;
- if (typeof Dialog !== 'undefined') {
- Dialog.SpoutModalClosed();
- }
- if (typeof window.webkit !== 'undefined') {
- window.webkit.messageHandlers.Dialog.postMessage("SpoutModalClosed");
- }
- });
- $('#add_new_post').on('shown.bs.modal', function()
- {
- if (SPTBL_APP.needs_phone_verification) {
- setTimeout(() => {
- $('#add_new_post').modal('hide')
- showPhoneVerificationPopup()
- }, 0);
- }
- // TODO: use pinia instead
- window.vue_instance.timelineComponent.$refs.timelinePubbox.show_cross_posting_settings = false;
- if (typeof Dialog !== 'undefined') {
- Dialog.SpoutModalOpened();
- }
- if (typeof window.webkit !== 'undefined') {
- window.webkit.messageHandlers.Dialog.postMessage("SpoutModalOpened");
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment