$(window).resize(function() { if($(window).width() < 1200 && responsive_design == false) { responsive_design = true; $(".left_column").append($("
").attr("class","responsive_left").append($(".right_column").children())); $(".right_column").remove(); } else if($(window).width() >= 1200 && responsive_design == true) { responsive_design = false; $(".article_wrap").append($("
").attr("class","right_column").append($(".responsive_left").children())); $(".responsive_left").remove(); } }); $(function() { $('input[type="file"]').val(''); }); $(function() { $(document).on('click','a', function(e) { e.stopPropagation(); }); $(document).on('keypress',"input.disallow_enter[type='text']", function(e) { if((e.which == 13) || (e.keyCode == 13)){ return false; } }); $(document).on('click','.follow_button', function(e) { e.stopPropagation(); if ($(this).attr('mid') !== null) { api.post('accounts/'+$(this).attr('mid')+'/follow', function (data) { }); } else if ($(this).attr('data')!== null) { api.post("follows", {uri:$(this).attr('data')}, function (data) { }); } $(this).toggleClass('follow_button'); $(this).toggleClass('following_button'); $(this).html(''+__('Following')+''); return false; }); $(document).on('click','.following_button', function(e) { e.stopPropagation(); if ($(this).attr('mid') !== null) { api.post('accounts/'+$(this).attr('mid')+'/unfollow', function (data) { }); } $(this).toggleClass('following_button'); $(this).toggleClass('follow_button'); $(this).html(''+__('Follow')+''); return false; }); $(document).on('click','.mute_button', function(e) { e.stopPropagation(); const mid = $(this).attr('mid'); $("#js-overlay_content_wrap .temporary_object").empty(); $('#js-overlay_content_wrap').addClass('view'); $('#js-overlay_content_wrap').addClass('black_08'); $('.overlay_confirm').removeClass('invisible'); $('.overlay_confirm_text').text(__("Are you sure that you want to mute this user?")); $('.overlay_confirm_yes').click(function() { $('.close_button').click(); api.post('accounts/'+mid+'/mute', function (data) { putMessage(__("You'll no longer receive notifications from this user")); return false; }); }); }); $(document).on('click','.muting_button', function(e) { if($(this).attr('mid')!=null) { api.post('accounts/'+$(this).attr('mid')+'/unmute', function (data) { }); } $(this).toggleClass('muting_button'); $(this).toggleClass('follow_button'); $(this).html(''+__('Follow')+''); putMessage(__("Unmuted this user")); return false; }); $(document).on('click','.block_button', function(e) { e.stopPropagation(); const mid = $(this).attr('mid'); $("#js-overlay_content_wrap .temporary_object").empty(); $('#js-overlay_content_wrap').addClass('view'); $('#js-overlay_content_wrap').addClass('black_08'); $('.overlay_confirm').removeClass('invisible'); $('.overlay_confirm_text').text(__("Are you sure that you want to block this user?")); $('.overlay_confirm_yes').click(function() { $('.close_button').click(); api.post('accounts/'+mid+'/block', function (data) { putMessage(__("This user has been blocked")); return false; }); }); }); $(document).on('click','.blocking_button', function(e) { e.stopPropagation(); if ($(this).attr('mid') !== null) { api.post('accounts/'+$(this).attr('mid')+'/unblock', function (data) { }); } $(this).toggleClass('blocking_button'); $(this).toggleClass('follow_button'); $(this).html(''+__('Follow')+''); putMessage(__("Unblocked this user")); return false; }); $(document).on('click','.boost_button', function(e) { e.stopPropagation(); if($(this).attr('reblogged') !== 'true'){ api.post("statuses/"+$(this).attr('tid')+"/reblog", function (data) { }); $(this).attr('reblogged', "true"); $(this).toggleClass('active'); $(".js_current_toots_count").html(++localStorage.current_statuses_count); } else { api.post("statuses/"+$(this).attr('tid')+"/unreblog", function (data) { }); $(this).attr('reblogged', "hold"); $(this).toggleClass('active'); $(".js_current_toots_count").html(--localStorage.current_statuses_count); $(this).mouseout(function(e) { $(this).attr('reblogged', "null"); }); } return false; }); $(document).on('click','.fav_button', function(e) { e.stopPropagation(); if($(this).attr('favourited') !== 'true'){ api.post("statuses/"+$(this).attr('tid')+"/favourite", function (data) { }); $(this).attr('favourited', "true"); $(this).toggleClass('active'); } else { api.post("statuses/"+$(this).attr('tid')+"/unfavourite", function (data) { }); $(this).attr('favourited', "hold"); $(this).toggleClass('active'); $(this).mouseout(function(e) { $(this).attr('favourited', "null"); }); } return false; }); $(document).on('click','.delete_button', function(e) { const sid = $(this).attr('tid'); e.stopPropagation(); $("#js-overlay_content_wrap .temporary_object").empty(); $('#js-overlay_content_wrap').addClass('view'); $('#js-overlay_content_wrap').addClass('black_08'); $('.overlay_confirm').removeClass('invisible'); $('.overlay_confirm_text').text(__("Are you sure that you want to delete this toot?")); $('.overlay_confirm_yes').click(function() { $('.close_button').click(); api.delete("statuses/"+sid, function (data) { if($('.toot_entry[sid="'+sid+'"] .reply_button').attr("privacy") != "direct") $(".js_current_toots_count").html(--localStorage.current_statuses_count); $('.toot_entry[sid="'+sid+'"]').remove(); putMessage(__("Your Toot has been deleted")); }); }); }); $(document).on('click','.pin_button', function(e) { const sid = $(this).attr('tid'); api.post("statuses/"+sid+"/pin", function (data) { $('.toot_entry[sid="'+sid+'"] .pin_button').removeClass("pin_button").addClass("unpin_button").text(__("Unpin Toot")); putMessage(__("Your Toot has been pinned")); }); }); $(document).on('click','.unpin_button', function(e) { const sid = $(this).attr('tid'); api.post("statuses/"+sid+"/unpin", function (data) { $('.toot_entry[sid="'+sid+'"] .unpin_button').removeClass("unpin_button").addClass("pin_button").text(__("Pin Toot")); putMessage(__("Your Toot has been unpinned")); }); }); $(document).on('click','.addlist_button',function(e) { const mid = $(this).attr('mid'); e.stopPropagation(); $("#js-overlay_content_wrap .temporary_object").empty(); $('#js-overlay_content_wrap').addClass('view'); $('#js-overlay_content_wrap').addClass('black_08'); $('.overlay_addlist').removeClass('invisible'); $('.overlay_addlist .overlay_simple_header span').html(__('Add to list')+": "+$(this).attr('display_name')); replace_emoji(); api.get("lists",function(data) { api.get("accounts/"+mid+"/lists",function(data2) { var inlists = new Array(); if(typeof data2 == "object") { for(var i=0;i").addClass("overlay_addlist_item").append( $("").addClass("emoji_poss").text(data[i].title)).append( $(" `).appendTo('.profile_button_box'); $("#js-profile_nav_favourites a").show(); } else { $("#profile_toot_buttons").show(); api.get('accounts/relationships', [{name:'id', data:String(AccountObj.id)}], function(RelationshipObj) { if (RelationshipObj[0].followed_by) { $('#main .profile_username .profile_followed_by').removeClass('invisible'); } if (RelationshipObj[0].blocking) { $(``).appendTo('.profile_button_box'); } else if (RelationshipObj[0].muting) { $(``).appendTo('.profile_button_box'); } else if (RelationshipObj[0].requested) { $(` `).appendTo('.profile_button_box'); } else if(RelationshipObj[0].following){ $(``).appendTo('.profile_button_box'); } else { $(``).appendTo('.profile_button_box'); } }); }; replace_emoji(); } function setRecentImages(mid) { api.get("accounts/"+mid+"/statuses", [{name:'only_media',data:'true'},{name:'limit',data:'6'}], function(statuses) { if (statuses.length) { $('#js_profile_recent_images span').text(`${statuses[0].account.statuses_count} ${__('Photos and toots')}`); $('#js_profile_recent_images a').attr('href', $("#media_link").attr('href')); for (i in statuses) { if(statuses[i].sensitive && localStorage.setting_show_nsfw == "false") { if(statuses[i].media_attachments[0].blurhash) var imgurl = getBlurImage(statuses[i].media_attachments[0].blurhash); else if(statuses[i].pleroma) var imgurl = "https://"+current_instance+"/images/avi.png"; else var imgurl = "https://"+current_instance+"/avatars/original/missing.png"; if(statuses[i].media_attachments[0].type == "image") $(`
`).appendTo('#js_profile_recent_images_box'); else $(`
`).appendTo('#js_profile_recent_images_box'); } else { if(statuses[i].media_attachments[0].remote_url != null) statuses[i].media_attachments[0].url = statuses[i].media_attachments[0].remote_url; if(statuses[i].media_attachments[0].type == "image") $(`
`).appendTo('#js_profile_recent_images_box'); else { if((statuses[i].media_attachments[0].type == "video" || statuses[i].media_attachments[0].type == "gifv") && statuses[i].media_attachments[0].preview_url != statuses[i].media_attachments[0].url) var imgurl = statuses[i].media_attachments[0].preview_url; else if(statuses[i].pleroma) var imgurl = "https://"+current_instance+"/images/avi.png"; else var imgurl = "https://"+current_instance+"/avatars/original/missing.png"; $(`
`).appendTo('#js_profile_recent_images_box'); } } }; } }); }; function setInstance() { api.get("instance",function(data) { $("#instance_title").html(data.title); $("#instance_description").html(data.description); $("#instance_thumbnail").attr("src",data.thumbnail); $("#js-follows_profile").append(follows_template(data.contact_account)); api.get('accounts/relationships',[{name:'id',data:data.contact_account.id}],function(RelationshipsObj) { if(RelationshipsObj[0].following) { const button = $('#js-follows_profile .follow_button[mid="'+RelationshipsObj[0].id+'"]'); button.removeClass("follow_button"); button.addClass("following_button"); button.children("span").text(__('Following')); button.children("i").removeClass("fa-user-plus").addClass("fa-user-times"); } }); $("#instance_users").text(data.stats.user_count); $("#instance_posts").text(data.stats.status_count); $("#instance_domains").text(data.stats.domain_count); $("#instance_version").text(data.version); $("#instance_contact").attr("href","mailto:"+data.email).text(data.email); $("#js-timeline_footer").remove(); }); } function badges_update(){ let current_count = Number(localStorage.getItem("notification_count")); if ( current_count ) { $('#header .header_nav_list .notification_badge').removeClass('invisible'); $('#header .header_nav_list .notification_badge').text( current_count ); } api.stream("user", function(userstream) { if(userstream.event === "update" & location.pathname !== "/") { $('#header .header_nav_list .home_badge').removeClass('invisible'); } else if(userstream.event === "notification" & location.pathname !== "/notifications") { current_count += 1; localStorage.setItem("notification_count",current_count); $('#header .header_nav_list .notification_badge').text(current_count ); if($('#header .header_nav_list .notification_badge').hasClass('invisible')) { $('#header .header_nav_list .notification_badge').removeClass('invisible') } } if(userstream.event === "notification") { if(userstream.payload.account.display_name.length == 0) { userstream.payload.account.display_name = userstream.payload.account.username; } switch(userstream.payload.type) { case "favourite":pushNotification(__("New favourite"),userstream.payload.account.display_name+" "+__("favourited your toot"));break; case "reblog":pushNotification(__("New boost"),userstream.payload.account.display_name+" "+__("boosted your toot"));break; case "follow":pushNotification(__("New follower"),userstream.payload.account.display_name+" "+__("followed you"));$(".js_current_followers_count").html(++localStorage.current_followers_count);break; case "mention":pushNotification(__("New mention"),userstream.payload.account.display_name+" "+__("mentioned you"));break; case "poll":pushNotification(__("Poll finished"),__("A poll you participated in has ended"));break; } } }); if(localStorage.setting_service_worker == "true") { if("serviceWorker" in navigator) { navigator.serviceWorker.register("/assets/js/halcyon/halcyonWorker.js").then(function(worker) { console.log("Service worker successfully registered",worker); if(worker.active) { var translation = new Object(); translation["New favourite"] = __("New favourite"); translation["New boost"] = __("New boost"); translation["New follower"] = __("New follower"); translation["New mention"] = __("New mention"); translation["favourited your toot"] = __("favourited your toot"); translation["boosted your toot"] = __("boosted your toot"); translation["followed you"] = __("followed you"); translation["mentioned you"] = __("mentioned you"); worker.active.postMessage({instance:current_instance,authtoken:authtoken,translation:translation}); } }).catch(function(error) { console.log("There was an error when registering the service worker",error); }); } } } function setOverlayStatus(sid) { if ( !window.getSelection().toString() ) { $("#js-overlay_content .temporary_object").empty(); $('#js-overlay_content_wrap').addClass('view'); $('#js-overlay_content_wrap').addClass('black_05'); api.get('statuses/'+sid+'/', function(status) { $('
').appendTo("#js-overlay_content .temporary_object"); status_template(status, 'main_status').appendTo('#js-overlay_content .toot_detail_wrap'); replaceInternalLink(); replace_emoji(); api.get('statuses/'+sid+'/context', function(status) { if (status.ancestors.length) { status.ancestors.reverse(); for(let i in status.ancestors) { var filterreplystatus = false; for(var a=0;a`; if(f.type.indexOf("video") != -1) var mediaelement = `