_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://colibrism.terla.pro/native_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 post appears to have no likes yet. To like this post, click below it.");
}
else {
_smc.errorMSG();
}
});
}
}
_smc.edit_post = function(id = false) {
if (_smc.is_logged()) {
if ($.isNumeric(id) && id) {
$.ajax({
url: 'https://colibrism.terla.pro/native_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();
}
});
}
}
else{
_smc.req_auth();
}
}
_smc.donate_post = function(id = false) {
if (_smc.is_logged()) {
if ($.isNumeric(id) && id) {
$.ajax({
url: 'https://colibrism.terla.pro/native_api/donate/get_form',
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="donate-post"]').modal('show');
}
else {
_smc.errorMSG();
}
});
}
}
else{
_smc.req_auth();
}
}
_smc.donate_self = function() {
if (_smc.is_logged()) {
_smc.info("You are not permitted to transfer funds to your own account", "As the creator of this fundraiser, you are not allowed to make contributions to your own cause. However, all other individuals who come across this post are encouraged to support the fundraiser by making donations");
}
else{
_smc.req_auth();
}
}
_smc.pin_profile_post = function(id = false, _self = false) {
if (_smc.is_logged()) {
if ($.isNumeric(id) && id) {
$.ajax({
url: 'https://colibrism.terla.pro/native_api/pin_profile_post/pin_post',
type: 'POST',
dataType: 'json',
data: {id: id}
}).done(function(data) {
if (data.status == 200) {
if (data.status_code == '1') {
cl_bs_notify("Post has been pinned on your profile page", 3000, "info");
$(_self).find('[data-itag]').text("Unpin from my profile");
}
else {
cl_bs_notify("Post has been unpinned from your profile page", 3000, "info");
$(_self).find('[data-itag]').text("Pin to my profile");
}
}
else {
_smc.errorMSG();
}
});
}
}
else {
_smc.req_auth();
}
}
_smc.pin_admin_post = function(id = false, _self = false) {
if (_smc.is_logged()) {
if ($.isNumeric(id) && id) {
$.ajax({
url: 'https://colibrism.terla.pro/native_api/cpanel/pin_feed_post',
type: 'POST',
dataType: 'json',
data: {id: id}
}).done(function(data) {
if (data.status == 200) {
if (data.status_code == '1') {
cl_bs_notify("Post has been pinned on user feed pages", 3000, "info");
$(_self).find('[data-itag]').text("Unpin post from feeds");
}
else {
cl_bs_notify("Post has been unpinned from user feed pages", 3000, "info");
$(_self).find('[data-itag]').text("Pin post to feeds");
}
}
else {
_smc.errorMSG();
}
});
}
}
else {
_smc.req_auth();
}
}
_smc.bookmark_post = function(id = false, _self = false) {
if (_smc.is_logged()) {
if ($.isNumeric(id) && id) {
$.ajax({
url: 'https://colibrism.terla.pro/native_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') {
cl_bs_notify("Post has been bookmarked!", 3000, "info");
$(_self).find('[data-itag]').text("Unbookmark");
}
else {
cl_bs_notify("Post has been deleted from bookmarks!", 3000, "info");
$(_self).find('[data-itag]').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://colibrism.terla.pro/native_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 = SMColibri.confirm_action({
btn_1: "Cancel",
btn_2: "Unfollow",
title: "Please confirm your actions!",
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://colibrism.terla.pro/native_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");
});
cl_bs_notify("You unfollowed @{0}".format(target.data("user-name")), 3000, "success");
});
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://colibrism.terla.pro/native_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);
}
}
}
});
cl_bs_notify("You followed @{0}".format(target.data("user-name")), 3000, "success");
}
}
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 = SMColibri.confirm_action({
btn_1: "Cancel",
btn_2: "Unfollow",
title: "Please confirm your actions!",
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://colibrism.terla.pro/native_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");
});
cl_bs_notify("You unfollowed @{0}".format(target.data("user-name")), 3000, "success");
});
promise.fail(function() {
$("div.confirm-actions-modal").modal("hide");
});
}
else if(target.data('action') == 'cancel') {
var promise = SMColibri.confirm_action({
btn_1: "Cancel",
btn_2: "Cancel request",
title: "Please confirm your actions!",
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://colibrism.terla.pro/native_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");
});
cl_bs_notify("You unfollowed @{0}".format(target.data("user-name")), 3000, "success");
});
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://colibrism.terla.pro/native_api/main/follow',
type: 'POST',
dataType: 'json',
data: {id: target.data('id')},
}).done(function(data) {
if (data.status != 200) {
_smc.errorMSG();
}
});
cl_bs_notify("Follow request sent to @{0}".format(target.data("user-name")), 3000, "info");
}
}
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 = SMColibri.confirm_action({
btn_1: "Cancel",
btn_2: "Block",
title: "Please confirm your actions!",
message: "Blocked users will no longer be able to write a message to you, follow you, or see your profile and publications, 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://colibrism.terla.pro/native_api/main/block',
type: 'POST',
dataType: 'json',
data: {id: target.data('id')},
}).done(function(data) {
if (data.status != 200) {
SMColibri.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 = SMColibri.confirm_action({
btn_1: "Cancel",
btn_2: "Unblock",
title: "Please confirm your actions!",
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://colibrism.terla.pro/native_api/main/block',
type: 'POST',
dataType: 'json',
data: {id: target.data('id')},
}).done(function(data) {
if (data.status != 200) {
SMColibri.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.errorMSG = function() {
cl_bs_notify("An error occurred while processing your request. Please try again later.", 5000, "error");
}
_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://colibrism.terla.pro/native_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, reload = false) {
if (_smc.curr_url == url && reload == false) {
return false;
}
_smc.curr_url = url;
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) {
window.history.pushState({state: "new", back_url: url}, "", url);
}
if (window.mobileCheck()) {
_smc.hide_sb();
}
$.ajax({
url: url,
type: 'GET',
data: {spa_load: '1'},
dataType: 'json',
async: true,
beforeSend: function() {
_smc.user_lbox_rm();
preloader.removeClass('d-none');
_smc.toggleSB("hide");
$(window).scrollTop(0);
cl_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);
if ($('body').hasClass('cl-app-{0}'.format(prevapp))) {
$('body').removeClass('cl-app-{0}'.format(prevapp));
$('body').addClass('cl-app-{0}'.format(json_data.pn));
}
else {
$('body').addClass('cl-app-{0}'.format(json_data.pn));
}
$('body').attr('data-page-tab', json_data.page_tab);
timeline.find('[data-el="timeline-content"]').html($(data.html));
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');
});
}
else if(data.status == 302) {
_smc.spa_load(data.redirect_url);
}
else {
_smc.spa_load("https://colibrism.terla.pro/404");
}
}).always(function() {
if (_smc.timeout !== false) {
clearTimeout(_smc.timeout);
}
_smc.timeout = setTimeout(function() {
preloader.addClass('d-none');
}, 150);
$("div.dropdown-menu.show").each(function(index, el) {
$(el).removeClass("show");
});
});
}
_smc.spa_reload = function() {
if (window.location.href != undefined) {
_smc.spa_load(window.location.href, false, true);
}
else {
_smc.spa_load(data['url'], false, true);
}
return false;
}
_smc.go_back = function() {
history.back();
}
_smc.jump_back = function(step = 1) {
history.go(step);
}
_smc.ad_conversion = function(e = false) {
if (e) {
var _self = $(e);
var id = _self.data('ad-id');
var url = _self.data('ad-url');
if (_self.data('conversed') == undefined) {
$.ajax({
url: 'https://colibrism.terla.pro/native_api/ads/ad_conversion',
type: 'POST',
dataType: 'json',
data: {id: id},
});
_self.data('conversed', 'true');
}
window.open(url, '_blank');
}
}
_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.fbox-media").fancybox({
arrows: true,
openEffect: 'elastic',
closeEffect: false,
hash: false,
i18n: {
en: {
ERROR: "The requested content could not be loaded.
Please try again later.", } } }); } _smc.update_plyr = function() { $("video.plyr").each(function(index, el) { var nocontrols = $(this).data("nocontrols"); var plyr_controls = ["current-time", "progress", "play-large", "play", "fullscreen", "mute"]; if (nocontrols) { plyr_controls = ["play", "fullscreen"]; } if ($(el).parents("div.plyr__video-wrapper").length == 0) { new Plyr(el, { controls: plyr_controls, ratio: "8:6", loadSprite: true, autopause: {enabled: true}, muted: false, resetOnEnd: true, invertTime: false, loop: {active: false}, iconUrl: "https://colibrism.terla.pro/themes/default/statics/js/libs/plyr/plyr-code/plyr.svg" }); } }); $("audio.plyr").each(function(index, el) { if ($(el).parents("div.plyr__audio-wrapper").length == 0) { new Plyr(el, { controls: ["current-time", "progress", "play", "mute"], autopause: {enabled: true}, iconUrl: "https://colibrism.terla.pro/themes/default/statics/js/libs/plyr/plyr-code/plyr.svg" }); } }); } return _smc; } if (window.SMColibri === undefined) { window.SMColibri = _SMColibri(); } })(window); $(document).ready(function($) { SMColibri.init(); var clipboard = new ClipboardJS('.clip-board-copy'); var page_height = $(document).height(); clipboard.on('success', function(event) { cl_bs_notify("Copied to your clipboard!", 3000, "info"); }); clipboard.on('error', function(event) { cl_bs_notify("Failed to copy to clipboard!", 3000, "info"); }); if (navigator.cookieEnabled == false) { $('[data-app="announcement"]').html("
Please try again later.", } } }); } _smc.update_plyr = function() { $("video.plyr").each(function(index, el) { var nocontrols = $(this).data("nocontrols"); var plyr_controls = ["current-time", "progress", "play-large", "play", "fullscreen", "mute"]; if (nocontrols) { plyr_controls = ["play", "fullscreen"]; } if ($(el).parents("div.plyr__video-wrapper").length == 0) { new Plyr(el, { controls: plyr_controls, ratio: "8:6", loadSprite: true, autopause: {enabled: true}, muted: false, resetOnEnd: true, invertTime: false, loop: {active: false}, iconUrl: "https://colibrism.terla.pro/themes/default/statics/js/libs/plyr/plyr-code/plyr.svg" }); } }); $("audio.plyr").each(function(index, el) { if ($(el).parents("div.plyr__audio-wrapper").length == 0) { new Plyr(el, { controls: ["current-time", "progress", "play", "mute"], autopause: {enabled: true}, iconUrl: "https://colibrism.terla.pro/themes/default/statics/js/libs/plyr/plyr-code/plyr.svg" }); } }); } return _smc; } if (window.SMColibri === undefined) { window.SMColibri = _SMColibri(); } })(window); $(document).ready(function($) { SMColibri.init(); var clipboard = new ClipboardJS('.clip-board-copy'); var page_height = $(document).height(); clipboard.on('success', function(event) { cl_bs_notify("Copied to your clipboard!", 3000, "info"); }); clipboard.on('error', function(event) { cl_bs_notify("Failed to copy to clipboard!", 3000, "info"); }); if (navigator.cookieEnabled == false) { $('[data-app="announcement"]').html("
Oops! It looks like you have cookies disabled. For this site to work properly, you need to enable cookies.
");
}
$(document).on('click', 'div[data-app="lsb-back-drop"]', function(event) {
event.preventDefault();
SMColibri.toggleSB();
});
SMColibri.update_plyr();
setInterval(function() {
var new_page_height = $(document).height();
var _lozad_ = lozad();
_lozad_.observe();
if (page_height != new_page_height) {
page_height = new_page_height;
SMColibri.fix_sidebars();
SMColibri.update_ilb();
SMColibri.update_plyr();
}
}, 500);
$("div.publication-text").readmore({
moreLink: 'Read more',
lessLink: 'Read less'
});
$(document).on('click tap', 'a[data-spa]', function(event) {
event.preventDefault();
var page_url_source = $(this).attr('href');
SMColibri.spa_load(page_url_source);
return false;
});
window.addEventListener("popstate", function (event) {
if (event.state) {
if ($.isEmptyObject(event.state.back_url) != true) {
SMColibri.spa_load(event.state.back_url, false);
}
}
return false;
});
$(document).on('click tap', '[data-href]', function(event) {
event.preventDefault();
event.stopPropagation();
window.open($(this).data('href'), '_blank');
return false;
});
if (window.mobileCheck() != true) {
$(document).on('mouseenter', '[data-uinfo-lbox]', function(event) {
event.preventDefault();
var uid = $(this).data("uinfo-lbox");
SMColibri.user_lbox(uid, $(this));
});
$(document).on('mouseleave', '[data-uinfo-lbox]', function(event) {
event.preventDefault();
if (cl_empty(SMColibri.userlbox.status)) {
clearTimeout(SMColibri.userlbox.pre_delay);
SMColibri.userlbox.pre_delay = false;
}
if (cl_empty(SMColibri.userlbox.interv) != true) {
clearInterval(SMColibri.userlbox.interv);
}
SMColibri.userlbox.interv = setInterval(function() {
if (SMColibri.userlbox.lifetm !== "pause" && $.isNumeric(SMColibri.userlbox.lifetm)) {
if (SMColibri.userlbox.lifetm <= 0) {
SMColibri.user_lbox_rm();
clearInterval(SMColibri.userlbox.interv);
}
else{
SMColibri.userlbox.lifetm -= 100;
}
}
}, 100);
});
$(document).on('mouseenter', "[data-app='user-info-lbox']", function() {
SMColibri.userlbox.lifetm = "pause";
});
$(document).on('mouseleave', "[data-app='user-info-lbox']", function() {
SMColibri.userlbox.lifetm = 1000;
});
}
});