2018-09-03 17:04:14 +02:00
$ ( window ) . resize ( function ( ) {
if ( $ ( window ) . width ( ) < 1200 && responsive _design == false ) {
responsive _design = true ;
$ ( ".left_column" ) . append ( $ ( "<div>" ) . 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 ( $ ( "<div>" ) . attr ( "class" , "right_column" ) . append ( $ ( ".responsive_left" ) . children ( ) ) ) ;
$ ( ".responsive_left" ) . remove ( ) ;
}
} ) ;
2018-03-11 12:07:57 +01:00
$ ( 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' ) ;
2018-08-04 15:52:34 +02:00
$ ( this ) . html ( '<span>' + _ _ ( 'Following' ) + '</span>' ) ;
2018-03-11 12:07:57 +01:00
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' ) ;
2018-08-04 15:52:34 +02:00
$ ( this ) . html ( '<i class="fa fa-fw fa-user-plus"></i><span>' + _ _ ( 'Follow' ) + '</span>' ) ;
2018-03-11 12:07:57 +01:00
return false ;
} ) ;
$ ( document ) . on ( 'click' , '.mute_button' , function ( e ) {
2018-09-23 16:14:28 +02:00
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 ) {
2018-08-04 15:52:34 +02:00
putMessage ( _ _ ( "You'll no longer receive notifications from this user" ) ) ;
2018-03-11 12:07:57 +01:00
return false ;
} ) ;
2018-09-23 16:14:28 +02:00
} ) ;
} ) ;
2018-03-11 12:07:57 +01:00
$ ( 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' ) ;
2018-08-04 15:52:34 +02:00
$ ( this ) . html ( '<i class="fa fa-fw fa-user-plus"></i><span>' + _ _ ( 'Follow' ) + '</span>' ) ;
putMessage ( _ _ ( "Unmuted this user" ) ) ;
2018-03-11 12:07:57 +01:00
return false ;
} ) ;
$ ( document ) . on ( 'click' , '.block_button' , function ( e ) {
2018-09-23 16:14:28 +02:00
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 ) {
2018-08-04 15:52:34 +02:00
putMessage ( _ _ ( "This user has been blocked" ) ) ;
2018-03-11 12:07:57 +01:00
return false ;
} ) ;
2018-09-23 16:14:28 +02:00
} ) ;
} ) ;
2018-03-11 12:07:57 +01:00
$ ( 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' ) ;
2018-08-04 15:52:34 +02:00
$ ( this ) . html ( '<i class="fa fa-fw fa-user-plus"></i><span>' + _ _ ( 'Follow' ) + '</span>' ) ;
putMessage ( _ _ ( "Unblocked this user" ) ) ;
2018-03-11 12:07:57 +01:00
return false ;
} ) ;
2020-03-29 20:17:40 +02:00
$ ( document ) . on ( 'click' , '.boost_button' , function ( e ) {
2018-03-11 12:07:57 +01:00
e . stopPropagation ( ) ;
if ( $ ( this ) . attr ( 'reblogged' ) !== 'true' ) {
2020-03-29 20:17:40 +02:00
api . post ( "statuses/" + $ ( this ) . attr ( 'tid' ) + "/reblog" , function ( data ) {
2018-03-11 12:07:57 +01:00
} ) ;
2020-03-29 20:17:40 +02:00
$ ( this ) . attr ( 'reblogged' , "true" ) ;
$ ( this ) . addClass ( 'active' ) ;
2019-04-15 16:40:57 +02:00
$ ( ".js_current_toots_count" ) . html ( ++ localStorage . current _statuses _count ) ;
2020-03-29 20:17:40 +02:00
}
else {
api . post ( "statuses/" + $ ( this ) . attr ( 'tid' ) + "/unreblog" , function ( data ) {
2018-03-11 12:07:57 +01:00
} ) ;
2020-03-29 20:17:40 +02:00
$ ( this ) . attr ( 'reblogged' , "null" ) ;
$ ( this ) . removeClass ( 'active' ) ;
2019-04-15 16:40:57 +02:00
$ ( ".js_current_toots_count" ) . html ( -- localStorage . current _statuses _count ) ;
2018-03-11 12:07:57 +01:00
}
return false ;
} ) ;
2020-03-29 20:17:40 +02:00
$ ( document ) . on ( 'click' , '.fav_button' , function ( e ) {
2018-03-11 12:07:57 +01:00
e . stopPropagation ( ) ;
if ( $ ( this ) . attr ( 'favourited' ) !== 'true' ) {
2020-03-29 20:17:40 +02:00
api . post ( "statuses/" + $ ( this ) . attr ( 'tid' ) + "/favourite" , function ( data ) {
2018-03-11 12:07:57 +01:00
} ) ;
2020-03-29 20:17:40 +02:00
$ ( this ) . attr ( 'favourited' , "true" ) ;
$ ( this ) . addClass ( 'active' ) ;
}
else {
api . post ( "statuses/" + $ ( this ) . attr ( 'tid' ) + "/unfavourite" , function ( data ) {
} ) ;
$ ( this ) . attr ( 'favourited' , "null" ) ;
$ ( this ) . removeClass ( 'active' ) ;
}
return false ;
} ) ;
$ ( document ) . on ( 'click' , '.bookmark_button' , function ( e ) {
e . stopPropagation ( ) ;
if ( $ ( this ) . attr ( 'bookmarked' ) !== 'true' ) {
api . post ( "statuses/" + $ ( this ) . attr ( 'tid' ) + "/bookmark" , function ( data ) {
} ) ;
$ ( this ) . attr ( 'bookmarked' , "true" ) ;
$ ( this ) . addClass ( 'active' ) ;
}
else {
api . post ( "statuses/" + $ ( this ) . attr ( 'tid' ) + "/unbookmark" , function ( data ) {
} ) ;
$ ( this ) . attr ( 'bookmarked' , "null" ) ;
$ ( this ) . removeClass ( 'active' ) ;
}
return false ;
} ) ;
$ ( document ) . on ( 'click' , '.announcement .emoreact' , function ( e ) {
e . stopPropagation ( ) ;
if ( $ ( this ) . hasClass ( 'active' ) ) {
( function ( that ) {
api . delete ( "announcements/" + $ ( that ) . closest ( '.announcement' ) . attr ( "aid" ) + "/reactions/" + $ ( that ) . attr ( "emoji" ) , function ( data ) {
$ ( that ) . removeClass ( 'active' ) ;
} ) ;
} ) ( this ) ;
}
else {
( function ( that ) {
api . put ( "announcements/" + $ ( that ) . closest ( '.announcement' ) . attr ( "aid" ) + "/reactions/" + $ ( that ) . attr ( "emoji" ) , function ( data ) {
$ ( that ) . addClass ( 'active' ) ;
} ) ;
} ) ( this ) ;
}
return false ;
} ) ;
$ ( document ) . on ( 'click' , '.status_reactions .emoreact' , function ( e ) {
e . stopPropagation ( ) ;
if ( $ ( this ) . hasClass ( 'active' ) ) {
( function ( that ) {
if ( $ ( that ) . closest ( '.toot_detail.main_status' ) . length == 1 ) var sid = $ ( that ) . closest ( '.toot_detail.main_status' ) . attr ( "sid" ) ;
else var sid = $ ( that ) . closest ( '.toot_entry' ) . attr ( "sid" ) ;
api . delete ( "pleroma/statuses/" + sid + "/reactions/" + $ ( that ) . attr ( "emoji" ) , function ( status ) {
$ ( ".toot_entry[sid=" + sid + "]" ) . find ( ".status_reactions" ) . children ( ) . remove ( ) ;
$ ( ".toot_entry[sid=" + sid + "]" ) . find ( ".status_reactions" ) . append ( parse _reactions ( status . pleroma . emoji _reactions ) ) ;
$ ( ".toot_detail.main_status[sid=" + sid + "]" ) . find ( ".status_reactions" ) . children ( ) . remove ( ) ;
$ ( ".toot_detail.main_status[sid=" + sid + "]" ) . find ( ".status_reactions" ) . append ( parse _reactions ( status . pleroma . emoji _reactions ) ) ;
replace _emoji ( ) ;
2018-03-11 12:07:57 +01:00
} ) ;
2020-03-29 20:17:40 +02:00
} ) ( this ) ;
}
else {
( function ( that ) {
if ( $ ( that ) . closest ( '.toot_detail.main_status' ) . length == 1 ) var sid = $ ( that ) . closest ( '.toot_detail.main_status' ) . attr ( "sid" ) ;
else var sid = $ ( that ) . closest ( '.toot_entry' ) . attr ( "sid" ) ;
api . put ( "pleroma/statuses/" + sid + "/reactions/" + $ ( that ) . attr ( "emoji" ) , function ( status ) {
$ ( ".toot_entry[sid=" + sid + "]" ) . find ( ".status_reactions" ) . children ( ) . remove ( ) ;
$ ( ".toot_entry[sid=" + sid + "]" ) . find ( ".status_reactions" ) . append ( parse _reactions ( status . pleroma . emoji _reactions ) ) ;
$ ( ".toot_detail.main_status[sid=" + sid + "]" ) . find ( ".status_reactions" ) . children ( ) . remove ( ) ;
$ ( ".toot_detail.main_status[sid=" + sid + "]" ) . find ( ".status_reactions" ) . append ( parse _reactions ( status . pleroma . emoji _reactions ) ) ;
replace _emoji ( ) ;
2018-03-11 12:07:57 +01:00
} ) ;
2020-03-29 20:17:40 +02:00
} ) ( this ) ;
2018-03-11 12:07:57 +01:00
}
return false ;
} ) ;
2020-03-29 20:17:40 +02:00
$ ( document ) . on ( 'click' , '.status_reactions .emoreact_add' , function ( e ) {
e . stopPropagation ( ) ;
} ) ;
$ ( document ) . on ( 'click' , '.status_reactions .emoreact_add:not(.active)' , function ( ) {
$ ( this ) . addClass ( "active" ) ;
( function ( that ) {
if ( $ ( that ) . closest ( '.toot_detail.main_status' ) . length == 1 ) var sid = $ ( that ) . closest ( '.toot_detail.main_status' ) . attr ( "sid" ) ;
else var sid = $ ( that ) . closest ( '.toot_entry' ) . attr ( "sid" ) ;
$ ( that ) . lsxEmojiPicker ( {
closeOnSelect : true ,
customEmojis : false ,
twemoji : ! checkEmojiSupport ( ) ,
onSelect : function ( emoji ) {
api . put ( "pleroma/statuses/" + sid + "/reactions/" + emoji . value , function ( status ) {
$ ( ".toot_entry[sid=" + sid + "]" ) . find ( ".status_reactions" ) . children ( ) . remove ( ) ;
$ ( ".toot_entry[sid=" + sid + "]" ) . find ( ".status_reactions" ) . append ( parse _reactions ( status . pleroma . emoji _reactions ) ) ;
$ ( ".toot_detail.main_status[sid=" + sid + "]" ) . find ( ".status_reactions" ) . children ( ) . remove ( ) ;
$ ( ".toot_detail.main_status[sid=" + sid + "]" ) . find ( ".status_reactions" ) . append ( parse _reactions ( status . pleroma . emoji _reactions ) ) ;
replace _emoji ( ) ;
} ) ;
} ,
onClose : function ( ) {
$ ( that ) . lsxEmojiPicker ( "destroy" ) ;
setTimeout ( function ( ) { $ ( that ) . removeClass ( "active" ) } , 0 ) ;
}
} ) . click ( ) ;
} ) ( this ) ;
} ) ;
2018-03-11 12:07:57 +01:00
$ ( document ) . on ( 'click' , '.delete_button' , function ( e ) {
const sid = $ ( this ) . attr ( 'tid' ) ;
2018-09-23 16:14:28 +02:00
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 ( ) ;
2018-03-11 12:07:57 +01:00
api . delete ( "statuses/" + sid , function ( data ) {
2019-04-15 16:40:57 +02:00
if ( $ ( '.toot_entry[sid="' + sid + '"] .reply_button' ) . attr ( "privacy" ) != "direct" ) $ ( ".js_current_toots_count" ) . html ( -- localStorage . current _statuses _count ) ;
2018-03-11 12:07:57 +01:00
$ ( '.toot_entry[sid="' + sid + '"]' ) . remove ( ) ;
2018-08-04 15:52:34 +02:00
putMessage ( _ _ ( "Your Toot has been deleted" ) ) ;
2018-03-11 12:07:57 +01:00
} ) ;
} ) ;
2018-09-23 16:14:28 +02:00
} ) ;
2018-07-13 19:37:22 +02:00
$ ( document ) . on ( 'click' , '.pin_button' , function ( e ) {
const sid = $ ( this ) . attr ( 'tid' ) ;
api . post ( "statuses/" + sid + "/pin" , function ( data ) {
2018-08-04 15:52:34 +02:00
$ ( '.toot_entry[sid="' + sid + '"] .pin_button' ) . removeClass ( "pin_button" ) . addClass ( "unpin_button" ) . text ( _ _ ( "Unpin Toot" ) ) ;
putMessage ( _ _ ( "Your Toot has been pinned" ) ) ;
2018-07-13 19:37:22 +02:00
} ) ;
} ) ;
$ ( document ) . on ( 'click' , '.unpin_button' , function ( e ) {
const sid = $ ( this ) . attr ( 'tid' ) ;
api . post ( "statuses/" + sid + "/unpin" , function ( data ) {
2018-08-04 15:52:34 +02:00
$ ( '.toot_entry[sid="' + sid + '"] .unpin_button' ) . removeClass ( "unpin_button" ) . addClass ( "pin_button" ) . text ( _ _ ( "Pin Toot" ) ) ;
putMessage ( _ _ ( "Your Toot has been unpinned" ) ) ;
2018-07-13 19:37:22 +02:00
} ) ;
} ) ;
2018-09-23 16:14:28 +02:00
$ ( 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 < data2 . length ; i ++ ) {
inlists . push ( data2 [ i ] . id ) ;
}
}
for ( var i = 0 ; i < data . length ; i ++ ) {
var list _id = data [ i ] . id ;
( function ( i , list _id ) {
if ( inlists . indexOf ( data [ i ] . id ) == - 1 ) {
$ ( ".overlay_addlist_body" ) . append (
$ ( "<div>" ) . addClass ( "overlay_addlist_item" ) . append (
$ ( "<span>" ) . addClass ( "emoji_poss" ) . text ( data [ i ] . title ) ) . append (
$ ( "<button>" ) . addClass ( "halcyon_button" ) . append (
$ ( "<i>" ) . addClass ( "fa" ) . addClass ( "fa-fw" ) . addClass ( "fa-user-plus" ) ) . append (
$ ( "<span>" ) . text ( _ _ ( 'Add' ) ) ) . click ( function ( e ) {
api . post ( "lists/" + list _id + "/accounts?account_ids[]=" + mid , "" , function ( ) {
putMessage ( _ _ ( 'Added this account to the list' ) ) ;
} , function ( xhr ) {
if ( xhr . status == 422 ) {
$ ( "#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 ( _ _ ( "You need to follow this user to add him/her to the list. Do you want to do that now?" ) ) ;
$ ( '.overlay_confirm_yes' ) . click ( function ( ) {
$ ( '.close_button' ) . click ( ) ;
api . post ( 'accounts/' + mid + '/follow' , function ( data ) {
putMessage ( _ _ ( "You successfully followed this user." ) ) ;
api . post ( "lists/" + list _id + "/accounts?account_ids[]=" + mid , "" , function ( ) {
putMessage ( _ _ ( 'Added this account to the list' ) ) ;
} ) ;
} ) ;
} ) ;
}
} ) ;
$ ( ".close_button" ) . click ( ) ;
} ) ) ) ;
}
else {
$ ( ".overlay_addlist_body" ) . append (
$ ( "<div>" ) . addClass ( "overlay_addlist_item" ) . append (
$ ( "<span>" ) . addClass ( "emoji_poss" ) . text ( data [ i ] . title ) ) . append (
$ ( "<button>" ) . addClass ( "halcyon_button" ) . append (
$ ( "<i>" ) . addClass ( "fa" ) . addClass ( "fa-fw" ) . addClass ( "fa-user-times" ) ) . append (
$ ( "<span>" ) . text ( _ _ ( 'Remove' ) ) ) . click ( function ( e ) {
api . delete ( "lists/" + list _id + "/accounts?account_ids[]=" + mid , function ( ) {
putMessage ( _ _ ( 'Removed this account from the list' ) ) ;
} ) ;
$ ( ".close_button" ) . click ( ) ;
} ) ) ) ;
}
} ) ( i , list _id ) ;
}
replace _emoji ( ) ;
} ) ;
} ) ;
} ) ;
2018-03-11 12:07:57 +01:00
$ ( document ) . on ( 'click' , '.cw_button' , function ( e ) {
e . stopPropagation ( ) ;
const article = $ ( this ) . parent ( ) ;
if ( article . hasClass ( 'content_warning' ) ) {
2018-08-04 15:52:34 +02:00
$ ( this ) . text ( _ _ ( 'SHOW LESS' ) ) ;
2018-03-11 12:07:57 +01:00
article . removeClass ( 'content_warning' ) ;
} else {
2018-08-04 15:52:34 +02:00
$ ( this ) . text ( _ _ ( 'SHOW MORE' ) ) ;
2018-03-11 12:07:57 +01:00
article . addClass ( 'content_warning' ) ;
}
return false ;
} ) ;
2019-07-17 17:52:20 +02:00
$ ( document ) . on ( 'click' , '.sensitive_alert' , function ( e ) {
2018-03-11 12:07:57 +01:00
e . stopPropagation ( ) ;
$ ( this ) . toggleClass ( 'invisible' ) ;
return false ;
} ) ;
$ ( document ) . on ( 'click' , '.header_account_avatar' , function ( e ) {
e . stopPropagation ( ) ;
$ ( this ) . next ( '.header_my_account_nav' ) . toggleClass ( 'invisible' ) ;
} ) ;
$ ( document ) . on ( 'click' , '.expand_button' , function ( e ) {
e . stopPropagation ( ) ;
$ ( this ) . next ( '.expand_menu' ) . toggleClass ( 'invisible' ) ;
return false ;
} ) ;
$ ( document ) . on ( 'click' , '.status_form.ready .active_submit_button' , function ( e ) {
e . stopImmediatePropagation ( )
return false ;
} ) ;
} ) ;
$ ( function ( ) {
$ ( document ) . on ( 'click' , function ( e ) {
$ ( '.header_my_account_nav' ) . addClass ( 'invisible' ) ;
$ ( '.expand_menu' ) . addClass ( 'invisible' ) ;
} ) ;
2018-03-27 19:26:03 +02:00
} ) ;
2018-06-23 16:58:06 +02:00
function setTimeline ( level , load _options , show _replies ) {
if ( show _replies === undefined ) {
2018-06-09 17:29:25 +02:00
var show _replies = localStorage . setting _show _replies ;
2018-06-23 16:58:06 +02:00
}
2018-03-11 12:07:57 +01:00
let isSyncing = true ;
2018-06-09 17:29:25 +02:00
if ( load _options === undefined ) {
2018-03-11 12:07:57 +01:00
var load _options = [ ] ;
}
api . get ( level , load _options , function ( statuses ) {
2019-03-01 16:17:03 +01:00
timeline _hide _status = new Array ;
2019-12-23 14:58:06 +01:00
renderTimeline ( statuses , show _replies , level ) ;
2018-03-11 12:07:57 +01:00
links = getLinkFromXHRHeader ( responce _headers ) ;
replaceInternalLink ( ) ;
replace _emoji ( ) ;
if ( ! statuses . length ) {
$ ( '#js-timeline_footer > i' ) . css ( { "display" : "none" } ) ;
}
isSyncing = false ;
} ) ;
$ ( window ) . scroll ( function ( ) {
if ( $ ( window ) . scrollTop ( ) + window . innerHeight >= $ ( document ) . height ( ) - 700 ) {
if ( ! isSyncing ) {
isSyncing = true ;
2019-08-21 18:25:27 +02:00
if ( links && links [ 'next' ] ) {
load _options . unshift ( { name : "max_id" , data : links [ 'next' ] . match ( /max_id=(.+)&?/ ) [ 1 ] } ) ;
2018-03-11 12:07:57 +01:00
api . get ( level , load _options , function ( statuses ) {
if ( statuses . length ) {
2019-12-23 14:58:06 +01:00
renderTimeline ( statuses , show _replies , level ) ;
links = getLinkFromXHRHeader ( responce _headers ) ;
replaceInternalLink ( ) ;
replace _emoji ( ) ;
isSyncing = false ;
} else {
$ ( '.timeline_footer > i' ) . css ( { "display" : "none" } ) ;
$ ( '.timeline_footer' ) . append ( '<img style="width: 30%;opacity: .3;" src="/assets/images/halcyon.png">' ) ;
isSyncing = true ;
2018-11-25 19:14:16 +01:00
}
2019-12-23 14:58:06 +01:00
} ) ;
load _options . shift ( ) ;
2018-11-25 19:14:16 +01:00
}
else {
2019-12-23 14:58:06 +01:00
$ ( '.timeline_footer > i' ) . css ( { "display" : "none" } ) ;
$ ( '.timeline_footer' ) . append ( '<img style="width: 30%;opacity: .3;" src="/assets/images/halcyon.png">' ) ;
isSyncing = true ;
2018-11-25 19:14:16 +01:00
}
2019-12-23 14:58:06 +01:00
} ;
} ;
} ) ;
startStreaming ( level , load _options , show _replies ) ;
2018-11-25 19:14:16 +01:00
}
2019-12-23 14:58:06 +01:00
function setDirectTimeline ( ) {
var show _replies = localStorage . setting _show _replies ;
let isSyncing = true ;
var load _options = [ ] ;
var statuses = new Array ( ) ;
var requests = 0 ;
api . get ( "conversations" , load _options , function ( conversations ) {
links = getLinkFromXHRHeader ( responce _headers ) ;
for ( var a = 0 ; a < conversations . length ; a ++ ) {
if ( conversations [ a ] . last _status . account . id != current _id ) statuses . push ( conversations [ a ] . last _status ) ;
requests ++ ;
api . get ( "statuses/" + conversations [ a ] . last _status . id + "/context" , load _options , function ( contexts ) {
requests -- ;
for ( var b = 0 ; b < contexts . ancestors . length ; b ++ ) {
if ( contexts . ancestors [ b ] . account . id != current _id && contexts . ancestors [ b ] . visibility == "direct" ) statuses . push ( contexts . ancestors [ b ] ) ;
}
for ( var b = 0 ; b < contexts . descendants . length ; b ++ ) {
if ( contexts . descendants [ b ] . account . id != current _id && contexts . descendants [ b ] . visibility == "direct" ) statuses . push ( contexts . descendants [ b ] ) ;
}
if ( requests == 0 ) {
statuses . sort ( function ( one , two ) {
var dateone = Date . parse ( one . created _at ) ;
var datetwo = Date . parse ( two . created _at ) ;
return datetwo - dateone ;
} ) ;
timeline _hide _status = new Array ;
renderTimeline ( statuses , show _replies , "timelines/direct" ) ;
replaceInternalLink ( ) ;
2018-03-11 12:07:57 +01:00
replace _emoji ( ) ;
2019-12-23 14:58:06 +01:00
if ( ! statuses . length ) {
$ ( '#js-timeline_footer > i' ) . css ( { "display" : "none" } ) ;
2018-11-25 19:14:16 +01:00
}
2019-12-23 14:58:06 +01:00
isSyncing = false ;
2019-03-01 16:17:03 +01:00
}
2018-03-11 12:07:57 +01:00
} ) ;
2018-06-09 17:29:25 +02:00
}
2019-12-23 14:58:06 +01:00
} ) ;
$ ( window ) . scroll ( function ( ) {
if ( $ ( window ) . scrollTop ( ) + window . innerHeight >= $ ( document ) . height ( ) - 700 ) {
if ( ! isSyncing ) {
isSyncing = true ;
var statuses = new Array ( ) ;
if ( links && links [ 'next' ] ) {
load _options . unshift ( { name : "max_id" , data : links [ 'next' ] . match ( /max_id=(.+)&?/ ) [ 1 ] } ) ;
api . get ( "conversations" , load _options , function ( conversations ) {
2018-03-11 12:07:57 +01:00
links = getLinkFromXHRHeader ( responce _headers ) ;
2019-12-23 14:58:06 +01:00
if ( conversations . length ) {
for ( var a = 0 ; a < conversations . length ; a ++ ) {
if ( conversations [ a ] . last _status . account . id != current _id ) statuses . push ( conversations [ a ] . last _status ) ;
requests ++ ;
api . get ( "statuses/" + conversations [ a ] . last _status . id + "/context" , load _options , function ( contexts ) {
requests -- ;
for ( var b = 0 ; b < contexts . ancestors . length ; b ++ ) {
if ( contexts . ancestors [ b ] . account . id != current _id && contexts . ancestors [ b ] . visibility == "direct" ) statuses . push ( contexts . ancestors [ b ] ) ;
}
for ( var b = 0 ; b < contexts . descendants . length ; b ++ ) {
if ( contexts . descendants [ b ] . account . id != current _id && contexts . descendants [ b ] . visibility == "direct" ) statuses . push ( contexts . descendants [ b ] ) ;
}
if ( requests == 0 ) {
statuses . sort ( function ( one , two ) {
var dateone = Date . parse ( one . created _at ) ;
var datetwo = Date . parse ( two . created _at ) ;
return datetwo - dateone ;
} ) ;
timeline _hide _status = new Array ;
renderTimeline ( statuses , show _replies , "timelines/direct" ) ;
2018-03-11 12:07:57 +01:00
replaceInternalLink ( ) ;
replace _emoji ( ) ;
2019-12-23 14:58:06 +01:00
if ( ! statuses . length ) {
$ ( '#js-timeline_footer > i' ) . css ( { "display" : "none" } ) ;
}
2018-03-11 12:07:57 +01:00
isSyncing = false ;
2019-12-23 14:58:06 +01:00
}
} ) ;
}
}
else {
2018-03-11 12:07:57 +01:00
$ ( '.timeline_footer > i' ) . css ( { "display" : "none" } ) ;
2018-06-09 17:29:25 +02:00
$ ( '.timeline_footer' ) . append ( '<img style="width: 30%;opacity: .3;" src="/assets/images/halcyon.png">' ) ;
2018-03-11 12:07:57 +01:00
isSyncing = true ;
}
} ) ;
load _options . shift ( ) ;
2019-08-21 18:25:27 +02:00
}
else {
$ ( '.timeline_footer > i' ) . css ( { "display" : "none" } ) ;
$ ( '.timeline_footer' ) . append ( '<img style="width: 30%;opacity: .3;" src="/assets/images/halcyon.png">' ) ;
isSyncing = true ;
}
2018-03-11 12:07:57 +01:00
} ;
} ;
} ) ;
2019-12-23 14:58:06 +01:00
startStreaming ( "timelines/direct" , load _options , show _replies ) ;
}
function startStreaming ( level , load _options , show _replies ) {
2018-03-11 12:07:57 +01:00
$ ( function ( ) {
2018-07-20 14:27:29 +02:00
if ( level === "timelines/home" ) {
2018-03-11 12:07:57 +01:00
var streamscope = "user" ,
scope = "home" ;
2018-07-20 14:27:29 +02:00
}
else if ( level === "timelines/public" & load _options . length ) {
2018-03-11 12:07:57 +01:00
var streamscope = "public:local" ,
scope = "local" ;
2018-07-20 14:27:29 +02:00
}
else if ( level === "timelines/public" & ! load _options . length ) {
2018-03-11 12:07:57 +01:00
var streamscope = "public" ,
scope = "federated" ;
}
2018-09-23 16:14:28 +02:00
else if ( level === "timelines/direct" ) {
var streamscope = "direct" ,
scope = "direct" ;
}
2018-07-20 14:27:29 +02:00
else if ( level . indexOf ( "timelines/tag/" ) != - 1 ) {
var streamscope = "hashtag&tag=" + level . substr ( 14 ) ,
2018-09-23 16:14:28 +02:00
scope = "hashtag" ;
}
else if ( level . indexOf ( "timelines/list/" ) != - 1 ) {
var streamscope = "list&list=" + level . substr ( 15 ) ,
scope = "lists" ;
2018-07-20 14:27:29 +02:00
}
2018-03-11 12:07:57 +01:00
let statuses = [ ] ;
const original _title = $ ( 'title' ) . text ( ) ;
2018-05-22 19:00:08 +02:00
if ( streamscope ) {
2018-03-11 12:07:57 +01:00
api . stream ( streamscope , function ( userstream ) {
const streaming _option = localStorage . getItem ( "setting_post_stream" ) ;
2018-09-03 17:04:14 +02:00
if ( userstream . event === "update" ) {
2018-06-09 17:29:25 +02:00
if ( streaming _option === "manual" ) {
if ( ! $ ( '.toot_entry[sid="' + userstream . payload . id + '"]' ) . length ) {
2018-11-25 19:14:16 +01:00
var filterstatus = false ;
2019-12-23 14:58:06 +01:00
if ( scope == "direct" && userstream . payload . account . id == current _id ) filterstatus = true ;
2018-11-25 19:14:16 +01:00
for ( var a = 0 ; a < current _filters . length ; a ++ ) {
if ( ( ( level == "timelines/home" || level . indexOf ( "timelines/list/" ) != - 1 ) && current _filters [ a ] . context . indexOf ( "home" ) != - 1 && current _filters [ a ] . irreversible == false ) || ( ! ( level == "timelines/home" || level . indexOf ( "timelines/list/" ) != - 1 ) && current _filters [ a ] . context . indexOf ( "public" ) != - 1 ) ) {
if ( current _filters [ a ] . whole _word == false ) {
if ( userstream . payload . content . match ( new RegExp ( current _filters [ a ] . phrase ) ) ) filterstatus = true ;
}
else {
if ( userstream . payload . content . match ( new RegExp ( "[^a-zA-Z1-9]" + current _filters [ a ] . phrase + "[^a-zA-Z1-9]" ) ) ) filterstatus = true ;
}
}
}
if ( filterstatus == false && ! ( show _replies == "false" && userstream . payload . in _reply _to _id ) && ! ( localStorage . setting _show _bots == "false" && userstream . payload . account . bot == true && ! level . match ( /accounts\/\d+\/statuses/ ) ) && ! ( userstream . payload . visibility == "direct" && level == "timelines/home" ) ) {
2018-03-11 12:07:57 +01:00
$ ( '#js-stream_update' ) . css ( { 'display' : 'block' , 'height' : 'auto' , 'padding' : '10px' } ) ;
statuses . unshift ( userstream . payload ) ;
$ ( '#js-stream_update > button > span' ) . text ( statuses . length ) ;
$ ( 'title' ) . text ( "(" + statuses . length + ") " + original _title ) ;
$ ( '#header .header_nav_list .' + scope + '_badge' ) . removeClass ( 'invisible' ) ;
}
2018-06-09 17:29:25 +02:00
}
}
else if ( streaming _option === "auto" ) {
2019-06-20 16:50:42 +02:00
var scrollTop = window . pageYOffset || document . documentElement . scrollTop ;
2018-06-09 17:29:25 +02:00
if ( ! $ ( '.toot_entry[sid="' + userstream . payload . id + '"]' ) . length ) {
2018-11-25 19:14:16 +01:00
var filterstatus = false ;
2019-12-23 14:58:06 +01:00
if ( scope == "direct" && userstream . payload . account . id == current _id ) filterstatus = true ;
2018-11-25 19:14:16 +01:00
for ( var a = 0 ; a < current _filters . length ; a ++ ) {
if ( ( ( level == "timelines/home" || level . indexOf ( "timelines/list/" ) != - 1 ) && current _filters [ a ] . context . indexOf ( "home" ) != - 1 && current _filters [ a ] . irreversible == false ) || ( ! ( level == "timelines/home" || level . indexOf ( "timelines/list/" ) != - 1 ) && current _filters [ a ] . context . indexOf ( "public" ) != - 1 ) ) {
if ( current _filters [ a ] . whole _word == false ) {
if ( userstream . payload . content . match ( new RegExp ( current _filters [ a ] . phrase ) ) ) filterstatus = true ;
}
else {
if ( userstream . payload . content . match ( new RegExp ( "[^a-zA-Z1-9]" + current _filters [ a ] . phrase + "[^a-zA-Z1-9]" ) ) ) filterstatus = true ;
}
}
}
if ( filterstatus == false && ! ( show _replies == "false" && userstream . payload . in _reply _to _id ) && ! ( localStorage . setting _show _bots == "false" && userstream . payload . account . bot == true && ! level . match ( /accounts\/\d+\/statuses/ ) ) && ! ( userstream . payload . visibility == "direct" && level == "timelines/home" ) ) {
2018-03-11 12:07:57 +01:00
timeline _template ( userstream . payload ) . prependTo ( "#js-timeline" ) ;
2019-06-20 16:50:42 +02:00
if ( scrollTop != 0 ) {
window . scrollBy ( 0 , $ ( "#js-timeline .toot_entry[sid='" + userstream . payload . id + "']" ) . height ( ) ) ;
}
2018-03-11 12:07:57 +01:00
replaceInternalLink ( ) ;
replace _emoji ( ) ;
2018-06-09 17:29:25 +02:00
if ( level === "timelines/home" | level === "timelines/public" ) {
if ( userstream . payload . in _reply _to _id & ! $ ( ".toot_entry[sid='" + userstream . in _reply _to _id + "']" ) . length ) {
2018-03-11 12:07:57 +01:00
let reply _source = userstream . payload . id ;
api . get ( 'statuses/' + userstream . payload . in _reply _to _id , function ( in _reply _statuses ) {
2018-11-25 19:14:16 +01:00
var filterreplystatus = false ;
for ( var a = 0 ; a < current _filters . length ; a ++ ) {
if ( current _filters [ a ] . context . indexOf ( "thread" ) != - 1 ) {
if ( current _filters [ a ] . whole _word == false ) {
if ( in _reply _statuses . content . match ( new RegExp ( current _filters [ a ] . phrase ) ) ) filterreplystatus = true ;
}
else {
if ( in _reply _statuses . content . match ( new RegExp ( "[^a-zA-Z1-9]" + current _filters [ a ] . phrase + "[^a-zA-Z1-9]" ) ) ) filterreplystatus = true ;
}
}
}
if ( filterreplystatus == false ) {
2018-03-11 12:07:57 +01:00
$ ( "#js-timeline .toot_entry[sid='" + reply _source + "']" ) . before ( context _template ( in _reply _statuses , 'ancestors_status default_padding' ) ) ;
2019-06-20 16:50:42 +02:00
if ( scrollTop != 0 ) {
window . scrollBy ( 0 , $ ( "#js-timeline .toot_entry[sid='" + in _reply _statuses . id + "']" ) . height ( ) ) ;
}
2018-03-11 12:07:57 +01:00
replaceInternalLink ( ) ;
replace _emoji ( ) ;
2018-11-25 19:14:16 +01:00
}
2018-03-11 12:07:57 +01:00
} ) ;
}
}
}
}
}
2018-09-03 17:04:14 +02:00
else if ( streaming _option == "ontop" ) {
var scrollTop = window . pageYOffset || document . documentElement . scrollTop ;
if ( scrollTop == 0 ) {
if ( ! $ ( '.toot_entry[sid="' + userstream . payload . id + '"]' ) . length ) {
2018-11-25 19:14:16 +01:00
var filterstatus = false ;
2019-12-23 14:58:06 +01:00
if ( scope == "direct" && userstream . payload . account . id == current _id ) filterstatus = true ;
2018-11-25 19:14:16 +01:00
for ( var a = 0 ; a < current _filters . length ; a ++ ) {
if ( ( ( level == "timelines/home" || level . indexOf ( "timelines/list/" ) != - 1 ) && current _filters [ a ] . context . indexOf ( "home" ) != - 1 && current _filters [ a ] . irreversible == false ) || ( ! ( level == "timelines/home" || level . indexOf ( "timelines/list/" ) != - 1 ) && current _filters [ a ] . context . indexOf ( "public" ) != - 1 ) ) {
if ( current _filters [ a ] . whole _word == false ) {
if ( userstream . payload . content . match ( new RegExp ( current _filters [ a ] . phrase ) ) ) filterstatus = true ;
}
else {
if ( userstream . payload . content . match ( new RegExp ( "[^a-zA-Z1-9]" + current _filters [ a ] . phrase + "[^a-zA-Z1-9]" ) ) ) filterstatus = true ;
}
}
}
if ( filterstatus == false && ! ( show _replies == "false" && userstream . payload . in _reply _to _id ) && ! ( localStorage . setting _show _bots == "false" && userstream . payload . account . bot == true && ! level . match ( /accounts\/\d+\/statuses/ ) ) && ! ( userstream . payload . visibility == "direct" && level == "timelines/home" ) ) {
2018-09-03 17:04:14 +02:00
timeline _template ( userstream . payload ) . prependTo ( "#js-timeline" ) ;
replaceInternalLink ( ) ;
replace _emoji ( ) ;
if ( level === "timelines/home" | level === "timelines/public" ) {
if ( userstream . payload . in _reply _to _id & ! $ ( ".toot_entry[sid='" + userstream . in _reply _to _id + "']" ) . length ) {
let reply _source = userstream . payload . id ;
api . get ( 'statuses/' + userstream . payload . in _reply _to _id , function ( in _reply _statuses ) {
2018-11-25 19:14:16 +01:00
var filterreplystatus = false ;
for ( var a = 0 ; a < current _filters . length ; a ++ ) {
if ( current _filters [ a ] . context . indexOf ( "thread" ) != - 1 ) {
if ( current _filters [ a ] . whole _word == false ) {
if ( in _reply _statuses . content . match ( new RegExp ( current _filters [ a ] . phrase ) ) ) filterreplystatus = true ;
}
else {
if ( in _reply _statuses . content . match ( new RegExp ( "[^a-zA-Z1-9]" + current _filters [ a ] . phrase + "[^a-zA-Z1-9]" ) ) ) filterreplystatus = true ;
}
}
}
if ( filterreplystatus == false ) {
2018-09-03 17:04:14 +02:00
$ ( "#js-timeline .toot_entry[sid='" + reply _source + "']" ) . before ( context _template ( in _reply _statuses , 'ancestors_status default_padding' ) ) ;
replaceInternalLink ( ) ;
replace _emoji ( ) ;
2018-11-25 19:14:16 +01:00
}
2018-09-03 17:04:14 +02:00
} ) ;
}
}
}
}
}
else {
if ( ! $ ( '.toot_entry[sid="' + userstream . payload . id + '"]' ) . length ) {
2018-09-23 16:14:28 +02:00
if ( ! ( show _replies == "false" && userstream . payload . in _reply _to _id ) && ! ( userstream . payload . visibility == "direct" && scope == "home" ) ) {
2018-09-03 17:04:14 +02:00
statuses . unshift ( userstream . payload ) ;
$ ( 'title' ) . text ( "(" + statuses . length + ") " + original _title ) ;
}
}
}
}
}
else if ( userstream . event === "delete" ) {
$ ( '.toot_entry[sid="' + userstream . payload + '"]' ) . remove ( ) ;
if ( streaming _option == "manual" ) {
for ( var i = 0 ; i < statuses . length ; i ++ ) {
if ( statuses [ i ] . id == userstream . payload ) {
statuses . splice ( i , 1 ) ;
if ( statuses . length == 0 ) {
$ ( '#js-stream_update' ) . css ( { 'display' : 'none' , 'height' : '0' , 'padding' : '0px' } ) ;
$ ( 'title' ) . text ( original _title ) ;
}
else {
$ ( '#js-stream_update > button > span' ) . text ( statuses . length ) ;
$ ( 'title' ) . text ( "(" + statuses . length + ") " + original _title ) ;
}
}
}
}
else if ( streaming _option == "ontop" ) {
for ( var i = 0 ; i < statuses . length ; i ++ ) {
if ( statuses [ i ] . id == userstream . payload ) {
statuses . splice ( i , 1 ) ;
if ( statuses . length == 0 ) {
$ ( 'title' ) . text ( original _title ) ;
}
else {
$ ( 'title' ) . text ( "(" + statuses . length + ") " + original _title ) ;
}
}
}
}
}
} ) ;
}
if ( localStorage . getItem ( "setting_post_stream" ) == "ontop" ) {
$ ( document ) . scroll ( function ( ) {
var scrollTop = window . pageYOffset || document . documentElement . scrollTop ;
if ( scrollTop == 0 ) {
statuses . reverse ( ) ;
for ( let i in statuses ) {
timeline _template ( statuses [ i ] ) . prependTo ( "#js-timeline" ) ;
replace _emoji ( ) ;
if ( level === "timelines/home" | level === "timelines/public" ) {
if ( statuses [ i ] . in _reply _to _id ) {
const reply _source = statuses [ i ] . id ;
api . get ( 'statuses/' + statuses [ i ] . in _reply _to _id , function ( in _reply _statuses ) {
$ ( "#js-timeline .toot_entry[sid='" + reply _source + "']" ) . before ( context _template ( in _reply _statuses , 'ancestors_status default_padding' ) ) ;
replace _emoji ( ) ;
} ) ;
}
}
$ ( 'title' ) . text ( original _title ) ;
} ;
statuses = [ ] ;
2018-06-09 17:29:25 +02:00
}
2018-03-11 12:07:57 +01:00
} ) ;
2018-05-22 19:00:08 +02:00
}
2018-03-11 12:07:57 +01:00
$ ( document ) . on ( 'click' , '#js-stream_update' , function ( e ) {
$ ( '#header .header_nav_list .' + scope + '_badge' ) . addClass ( 'invisible' ) ;
$ ( '#js-stream_update' ) . css ( { 'display' : 'none' , 'height' : '0' , 'padding' : '0px' } ) ;
statuses . reverse ( ) ;
2018-06-09 17:29:25 +02:00
for ( let i in statuses ) {
2018-03-11 12:07:57 +01:00
timeline _template ( statuses [ i ] ) . prependTo ( "#js-timeline" ) ;
replace _emoji ( ) ;
if ( level === "timelines/home" | level === "timelines/public" ) {
if ( statuses [ i ] . in _reply _to _id ) {
const reply _source = statuses [ i ] . id ;
api . get ( 'statuses/' + statuses [ i ] . in _reply _to _id , function ( in _reply _statuses ) {
2018-11-25 19:14:16 +01:00
var filterreplystatus = false ;
for ( var a = 0 ; a < current _filters . length ; a ++ ) {
if ( current _filters [ a ] . context . indexOf ( "thread" ) != - 1 ) {
if ( current _filters [ a ] . whole _word == false ) {
if ( in _reply _statuses . content . match ( new RegExp ( current _filters [ a ] . phrase ) ) ) filterreplystatus = true ;
}
else {
if ( in _reply _statuses . content . match ( new RegExp ( "[^a-zA-Z1-9]" + current _filters [ a ] . phrase + "[^a-zA-Z1-9]" ) ) ) filterreplystatus = true ;
}
}
}
if ( filterreplystatus == false ) {
2018-03-11 12:07:57 +01:00
$ ( "#js-timeline .toot_entry[sid='" + reply _source + "']" ) . before ( context _template ( in _reply _statuses , 'ancestors_status default_padding' ) ) ;
replace _emoji ( ) ;
2018-11-25 19:14:16 +01:00
}
2018-03-11 12:07:57 +01:00
} ) ;
}
}
$ ( 'title' ) . text ( original _title ) ;
} ;
statuses = [ ] ;
} ) ;
} ) ;
} ;
function setOtherTimeline ( instance , load _options ) {
2018-06-09 17:29:25 +02:00
var show _replies = localStorage . setting _show _replies ;
2018-03-11 12:07:57 +01:00
let isSyncing = true ;
2018-06-09 17:29:25 +02:00
if ( load _options === undefined ) {
2018-03-11 12:07:57 +01:00
var load _options = [ ] ;
}
const loadstatus = instance + "timelines/public"
api . getOther ( loadstatus , load _options , function ( statuses ) {
let reply _sources = { } ;
2018-06-09 17:29:25 +02:00
for ( let i in statuses ) {
2018-11-25 19:14:16 +01:00
var filterstatus = false ;
for ( var a = 0 ; a < current _filters . length ; a ++ ) {
if ( ( ( level == "timelines/home" || level . indexOf ( "timelines/list/" ) != - 1 ) && current _filters [ a ] . context . indexOf ( "home" ) != - 1 && current _filters [ a ] . irreversible == false ) || ( ! ( level == "timelines/home" || level . indexOf ( "timelines/list/" ) != - 1 ) && current _filters [ a ] . context . indexOf ( "public" ) != - 1 ) ) {
if ( current _filters [ a ] . whole _word == false ) {
if ( statuses [ i ] . content . match ( new RegExp ( current _filters [ a ] . phrase ) ) ) filterstatus = true ;
}
else {
if ( statuses [ i ] . content . match ( new RegExp ( "[^a-zA-Z1-9]" + current _filters [ a ] . phrase + "[^a-zA-Z1-9]" ) ) ) filterstatus = true ;
}
}
}
if ( filterstatus == false && ! ( show _replies == "false" && statuses [ i ] . in _reply _to _id ) && ! ( localStorage . setting _show _bots == "false" && statuses [ i ] . account . bot == true ) ) {
2018-03-11 12:07:57 +01:00
timeline _template ( statuses [ i ] ) . appendTo ( "#js-timeline" ) ;
2018-06-09 17:29:25 +02:00
if ( statuses [ i ] . in _reply _to _id ) {
if ( ! reply _sources [ statuses [ i ] . in _reply _to _id ] ) {
2018-03-11 12:07:57 +01:00
reply _sources [ statuses [ i ] . in _reply _to _id ] = statuses [ i ] . id ;
api . getOther ( instance + 'statuses/' + statuses [ i ] . in _reply _to _id , function ( in _reply _statuses ) {
2018-11-25 19:14:16 +01:00
var filterreplystatus = false ;
for ( var a = 0 ; a < current _filters . length ; a ++ ) {
if ( current _filters [ a ] . context . indexOf ( "thread" ) != - 1 ) {
if ( current _filters [ a ] . whole _word == false ) {
if ( in _reply _statuses . content . match ( new RegExp ( current _filters [ a ] . phrase ) ) ) filterreplystatus = true ;
}
else {
if ( in _reply _statuses . content . match ( new RegExp ( "[^a-zA-Z1-9]" + current _filters [ a ] . phrase + "[^a-zA-Z1-9]" ) ) ) filterreplystatus = true ;
}
}
}
if ( filterreplystatus == false ) {
2018-03-11 12:07:57 +01:00
$ ( "#js-timeline .toot_entry[sid='" + reply _sources [ in _reply _statuses . id ] + "']" ) . before ( context _template ( in _reply _statuses , 'ancestors_status default_padding' ) ) ;
replace _emoji ( ) ;
2018-11-25 19:14:16 +01:00
}
2018-03-11 12:07:57 +01:00
} ) ;
}
}
2018-06-09 17:29:25 +02:00
}
}
2018-03-11 12:07:57 +01:00
$ ( '.toot_entry .toot_footer' ) . addClass ( 'invisible' ) ;
links = getLinkFromXHRHeader ( responce _headers ) ;
replaceInternalLink ( ) ;
replace _emoji ( ) ;
if ( ! statuses . length ) {
$ ( '#js-timeline_footer > i' ) . css ( { "display" : "none" } ) ;
}
isSyncing = false ;
} ) ;
$ ( window ) . scroll ( function ( ) {
2018-06-09 17:29:25 +02:00
if ( $ ( window ) . scrollTop ( ) + window . innerHeight >= $ ( document ) . height ( ) - 700 ) {
if ( ! isSyncing ) {
2018-03-11 12:07:57 +01:00
isSyncing = true ;
load _options . unshift ( { name : "max_id" , data : links [ 'next' ] . match ( /max_id=(.+)&?/ ) [ 1 ] } ) ;
api . getOther ( loadstatus , load _options , function ( statuses ) {
2018-06-09 17:29:25 +02:00
if ( statuses . length ) {
2018-03-11 12:07:57 +01:00
let reply _sources = { } ;
2018-06-09 17:29:25 +02:00
for ( let i in statuses ) {
2018-11-25 19:14:16 +01:00
var filterstatus = false ;
for ( var a = 0 ; a < current _filters . length ; a ++ ) {
if ( ( ( level == "timelines/home" || level . indexOf ( "timelines/list/" ) != - 1 ) && current _filters [ a ] . context . indexOf ( "home" ) != - 1 && current _filters [ a ] . irreversible == false ) || ( ! ( level == "timelines/home" || level . indexOf ( "timelines/list/" ) != - 1 ) && current _filters [ a ] . context . indexOf ( "public" ) != - 1 ) ) {
if ( current _filters [ a ] . whole _word == false ) {
if ( statuses [ i ] . content . match ( new RegExp ( current _filters [ a ] . phrase ) ) ) filterstatus = true ;
}
else {
if ( statuses [ i ] . content . match ( new RegExp ( "[^a-zA-Z1-9]" + current _filters [ a ] . phrase + "[^a-zA-Z1-9]" ) ) ) filterstatus = true ;
}
}
}
if ( filterstatus == false && ! ( show _replies == "false" && statuses [ i ] . in _reply _to _id ) && ! ( localStorage . setting _show _bots == "false" && statuses [ i ] . account . bot == true ) ) {
2018-03-11 12:07:57 +01:00
timeline _template ( statuses [ i ] ) . appendTo ( "#js-timeline" ) ;
2018-06-09 17:29:25 +02:00
if ( statuses [ i ] . in _reply _to _id ) {
if ( ! reply _sources [ statuses [ i ] . in _reply _to _id ] ) {
2018-03-11 12:07:57 +01:00
reply _sources [ statuses [ i ] . in _reply _to _id ] = statuses [ i ] . id ;
api . getOther ( instance + 'statuses/' + statuses [ i ] . in _reply _to _id , function ( in _reply _statuses ) {
2018-11-25 19:14:16 +01:00
var filterreplystatus = false ;
for ( var a = 0 ; a < current _filters . length ; a ++ ) {
if ( current _filters [ a ] . context . indexOf ( "thread" ) != - 1 ) {
if ( current _filters [ a ] . whole _word == false ) {
if ( in _reply _statuses . content . match ( new RegExp ( current _filters [ a ] . phrase ) ) ) filterreplystatus = true ;
}
else {
if ( in _reply _statuses . content . match ( new RegExp ( "[^a-zA-Z1-9]" + current _filters [ a ] . phrase + "[^a-zA-Z1-9]" ) ) ) filterreplystatus = true ;
}
}
}
if ( filterreplystatus == false ) {
2018-03-11 12:07:57 +01:00
$ ( "#js-timeline .toot_entry[sid='" + reply _sources [ in _reply _statuses . id ] + "']" ) . before ( context _template ( in _reply _statuses , 'ancestors_status default_padding' ) ) ;
replace _emoji ( ) ;
2018-11-25 19:14:16 +01:00
}
2018-03-11 12:07:57 +01:00
} ) ;
}
}
2018-06-09 17:29:25 +02:00
}
}
2018-03-11 12:07:57 +01:00
$ ( '.toot_entry .toot_footer' ) . addClass ( 'invisible' ) ;
links = getLinkFromXHRHeader ( responce _headers ) ;
replaceInternalLink ( ) ;
replace _emoji ( ) ;
isSyncing = false ;
2018-06-09 17:29:25 +02:00
}
else {
2018-03-11 12:07:57 +01:00
$ ( '.timeline_footer > i' ) . css ( { "display" : "none" } ) ;
2018-06-09 17:29:25 +02:00
$ ( '.timeline_footer' ) . append ( '<img style="width: 30%;opacity: .3;" src="/assets/images/halcyon.png">' ) ;
2018-03-11 12:07:57 +01:00
isSyncing = true ;
}
} ) ;
load _options . shift ( ) ;
} ;
} ;
} ) ;
} ;
function setNotifications ( load _options ) {
let isSyncing = true ;
if ( load _options === undefined ) {
var load _options = [ ] ;
}
api . get ( 'notifications' , load _options , function ( NotificationObj ) {
2018-11-25 19:14:16 +01:00
for ( let i in NotificationObj ) {
var filterstatus = false ;
if ( NotificationObj [ i ] . type == "mention" ) {
for ( var a = 0 ; a < current _filters . length ; a ++ ) {
if ( current _filters [ a ] . context . indexOf ( "notifications" ) != - 1 && current _filters [ a ] . irreversible == false ) {
if ( current _filters [ a ] . whole _word == false ) {
if ( NotificationObj [ i ] . status . content . match ( new RegExp ( current _filters [ a ] . phrase ) ) ) filterstatus = true ;
}
else {
if ( NotificationObj [ i ] . status . content . match ( new RegExp ( "[^a-zA-Z1-9]" + current _filters [ a ] . phrase + "[^a-zA-Z1-9]" ) ) ) filterstatus = true ;
}
}
}
}
if ( filterstatus == false ) notifications _template ( NotificationObj [ i ] ) . appendTo ( "#js-timeline" ) ;
2018-03-11 12:07:57 +01:00
} ;
links = getLinkFromXHRHeader ( responce _headers ) ;
replaceInternalLink ( ) ;
replace _emoji ( ) ;
if ( ! NotificationObj . length ) {
$ ( '#js-timeline_footer > i' ) . css ( { "display" : "none" } ) ;
}
isSyncing = false ;
} ) ;
$ ( window ) . scroll ( function ( ) {
if ( $ ( window ) . scrollTop ( ) + window . innerHeight >= $ ( document ) . height ( ) - 700 ) {
if ( ! isSyncing ) {
isSyncing = true ;
load _options . unshift ( { name : "max_id" , data : links [ 'next' ] . match ( /max_id=(.+)&?/ ) [ 1 ] } ) ;
api . get ( 'notifications' , load _options , function ( NotificationObj ) {
if ( NotificationObj . length ) {
for ( let i in NotificationObj ) {
2018-11-25 19:14:16 +01:00
var filterstatus = false ;
if ( NotificationObj [ i ] . type == "mention" ) {
for ( var a = 0 ; a < current _filters . length ; a ++ ) {
if ( current _filters [ a ] . context . indexOf ( "notifications" ) != - 1 && current _filters [ a ] . irreversible == false ) {
if ( current _filters [ a ] . whole _word == false ) {
if ( NotificationObj [ i ] . status . content . match ( new RegExp ( current _filters [ a ] . phrase ) ) ) filterstatus = true ;
}
else {
if ( NotificationObj [ i ] . status . content . match ( new RegExp ( "[^a-zA-Z1-9]" + current _filters [ a ] . phrase + "[^a-zA-Z1-9]" ) ) ) filterstatus = true ;
}
}
}
}
if ( filterstatus == false ) notifications _template ( NotificationObj [ i ] ) . appendTo ( "#js-timeline" ) ;
2018-03-11 12:07:57 +01:00
} ;
links = getLinkFromXHRHeader ( responce _headers ) ;
replaceInternalLink ( ) ;
replace _emoji ( ) ;
isSyncing = false ;
} else {
$ ( '.timeline_footer > i' ) . css ( { "display" : "none" } ) ;
$ ( '.timeline_footer' ) . append ( '<img style="width: 30%;opacity: .3;" src="/assets/images/halcyon.png" />' ) ;
isSyncing = true ;
}
} ) ;
load _options . shift ( ) ;
} ;
} ;
} ) ;
api . stream ( "user" , function ( userstream ) {
const original _title = $ ( 'title' ) . text ( ) ;
if ( userstream . event === "notification" ) {
const streaming _option = localStorage . getItem ( "setting_post_stream" ) ;
if ( streaming _option === "manual" ) {
} else if ( streaming _option === "auto" ) {
2018-11-25 19:14:16 +01:00
var filterstatus = false ;
if ( userstream . payload . type == "mention" ) {
for ( var a = 0 ; a < current _filters . length ; a ++ ) {
if ( current _filters [ a ] . context . indexOf ( "notifications" ) != - 1 && current _filters [ a ] . irreversible == false ) {
if ( current _filters [ a ] . whole _word == false ) {
if ( userstream . payload . status . content . match ( new RegExp ( current _filters [ a ] . phrase ) ) ) filterstatus = true ;
}
else {
if ( userstream . payload . status . content . match ( new RegExp ( "[^a-zA-Z1-9]" + current _filters [ a ] . phrase + "[^a-zA-Z1-9]" ) ) ) filterstatus = true ;
}
}
}
}
if ( filterstatus == false ) notifications _template ( userstream . payload ) . prependTo ( "#js-timeline" ) ;
2018-03-11 12:07:57 +01:00
replaceInternalLink ( ) ;
replace _emoji ( ) ;
}
}
} ) ;
}
function setFollows ( mid , param , load _options ) {
let isSyncing = true ,
followsList = [ ] ;
api . get ( 'accounts/' + mid + '/' + param , load _options , function ( follows ) {
for ( let i in follows ) {
follows _template ( follows [ i ] ) . appendTo ( "#js-follows_profile" ) ;
followsList . unshift ( follows [ i ] . id ) ;
} ;
api . getArray ( 'accounts/relationships' , [ { name : 'id' , data : followsList } ] , function ( RelationshipsObj ) {
for ( let i in RelationshipsObj ) {
if ( RelationshipsObj [ i ] . following ) {
const button = $ ( '#js-follows_profile .follow_button[mid="' + RelationshipsObj [ i ] . id + '"]' ) ;
button . removeClass ( "follow_button" ) ;
button . addClass ( "following_button" ) ;
2018-09-23 16:14:28 +02:00
button . children ( "span" ) . text ( _ _ ( 'Following' ) ) ;
button . children ( "i" ) . removeClass ( "fa-user-plus" ) . addClass ( "fa-user-times" ) ;
2018-03-11 12:07:57 +01:00
}
}
} ) ;
links = getLinkFromXHRHeader ( responce _headers ) ;
replace _emoji ( ) ;
$ ( "#js-follows_footer > i" ) . css ( { "display" : "none" } ) ;
isSyncing = false ;
} ) ;
$ ( window ) . scroll ( function ( ) {
if ( $ ( window ) . scrollTop ( ) + window . innerHeight >= $ ( document ) . height ( ) - 700 ) {
if ( ! isSyncing ) {
isSyncing = true ;
load _options . unshift ( { name : "max_id" , data : links [ 'next' ] . match ( /max_id=(.+)&?/ ) [ 1 ] } ) ;
api . get ( 'accounts/' + mid + '/' + param , load _options , function ( follows ) {
let followsList = [ ] ;
if ( follows . length ) {
for ( let i in follows ) {
follows _template ( follows [ i ] ) . appendTo ( "#js-follows_profile" ) ;
followsList . unshift ( follows [ i ] . id ) ;
} ;
api . getArray ( 'accounts/relationships' , [ { name : 'id' , data : followsList } ] , function ( RelationshipsObj ) {
for ( let i in RelationshipsObj ) {
if ( RelationshipsObj [ i ] . following ) {
const button = $ ( '#js-follows_profile .follow_button[mid="' + RelationshipsObj [ i ] . id + '"]' ) ;
button . removeClass ( "follow_button" ) ;
button . addClass ( "following_button" ) ;
2018-09-23 16:14:28 +02:00
button . children ( "span" ) . text ( _ _ ( 'Following' ) ) ;
button . children ( "i" ) . removeClass ( "fa-user-plus" ) . addClass ( "fa-user-times" ) ;
2018-03-11 12:07:57 +01:00
}
}
} ) ;
links = getLinkFromXHRHeader ( responce _headers ) ;
replace _emoji ( ) ;
isSyncing = false ;
} else {
isSyncing = true ;
}
} ) ;
load _options . shift ( ) ;
} ;
} ;
} ) ;
} ;
function setUserSearch ( query ) {
2019-12-23 14:58:06 +01:00
api . search ( 'q=' + encodeURIComponent ( query ) + "&resolve=true" , function ( search ) {
2018-03-11 12:07:57 +01:00
for ( let i in search . accounts ) {
follows _template ( search . accounts [ i ] ) . appendTo ( "#js-follows_profile" ) ; ;
}
$ ( "#js-follows_footer > i" ) . css ( { "display" : "none" } ) ;
replace _emoji ( ) ;
} ) ;
} ;
function setAccount ( AccountObj ) {
2018-07-13 19:37:22 +02:00
if ( AccountObj . display _name . length == 0 ) {
AccountObj . display _name = AccountObj . username ;
}
AccountObj . display _name = htmlEscape ( AccountObj . display _name ) ;
for ( i = 0 ; i < AccountObj . emojis . length ; i ++ ) {
AccountObj . display _name = AccountObj . display _name . replace ( new RegExp ( ":" + AccountObj . emojis [ i ] . shortcode + ":" , "g" ) , "<img src='" + AccountObj . emojis [ i ] . url + "' class='emoji'>" ) ;
}
2018-09-23 16:14:28 +02:00
const calendar = [ _ _ ( "Jan" ) , _ _ ( "Feb" ) , _ _ ( "Mar" ) , _ _ ( "Apr" ) , _ _ ( "May" ) , _ _ ( "Jun" ) , _ _ ( "Jul" ) , _ _ ( "Aug" ) , _ _ ( "Sep" ) , _ _ ( "Oct" ) , _ _ ( "Nov" ) , _ _ ( "Dec" ) ] ;
var creation _date = new Date ( AccountObj . created _at ) ;
creation _date = calendar [ creation _date . getUTCMonth ( ) ] + " " + creation _date . getUTCFullYear ( ) ;
2018-11-25 19:14:16 +01:00
var account _state _icons = "" ;
if ( AccountObj . locked == true ) account _state _icons += " <i class='fa fa-lock'></i>" ;
if ( AccountObj . bot == true ) account _state _icons += " <img src='/assets/images/robot.svg' class='emoji'>" ;
2018-03-11 12:07:57 +01:00
$ ( "#js_header_image" ) . attr ( 'src' , AccountObj . header ) ;
$ ( "#js_profile_image" ) . attr ( 'src' , AccountObj . avatar ) ;
$ ( "#js_toots_count" ) . text ( AccountObj . statuses _count ) ;
$ ( "#js_following_count" ) . text ( AccountObj . following _count ) ;
$ ( "#js_followers_count" ) . text ( AccountObj . followers _count ) ;
2018-07-13 19:37:22 +02:00
$ ( "#js_profile_displayname" ) . addClass ( "emoji_poss" ) . html ( AccountObj . display _name ) ;
2018-11-25 19:14:16 +01:00
$ ( "#js_profile_username" ) . html ( AccountObj . acct + account _state _icons ) ;
2018-07-01 17:07:18 +02:00
$ ( "#js_profile_bio" ) . addClass ( "emoji_poss" ) . html ( AccountObj . note ) ;
2018-07-13 19:37:22 +02:00
$ ( "#js_profile_bio .emojione" ) . removeClass ( "emojione" ) . addClass ( "emoji" ) ;
2018-09-23 16:14:28 +02:00
$ ( '#js_profile_public_link a' ) . attr ( 'href' , AccountObj . url ) ;
2018-10-02 19:50:54 +02:00
$ ( '#js_profile_joined_date span span' ) . text ( _ _ ( "Joined at" ) + " " + creation _date ) ;
2018-11-16 19:14:32 +01:00
for ( var i = 0 ; i < AccountObj . fields . length ; i ++ ) {
if ( AccountObj . fields [ i ] . verified _at != null ) var verified = $ ( "<i>" ) . addClass ( "fa fa-check-circle" ) . addClass ( "profile_field_verified" ) ;
else var verified = "" ;
$ ( "#js_profile_fields" ) . append (
$ ( "<div>" ) . addClass ( "profile_field" ) . append (
$ ( "<span>" ) . addClass ( "profile_field_header" ) . addClass ( "emoji_poss" ) . text ( AccountObj . fields [ i ] . name ) . prepend ( verified ) ) . append ( $ ( "<br>" ) ) . append (
$ ( "<span>" ) . addClass ( "profile_field_value" ) . addClass ( "emoji_poss" ) . html ( AccountObj . fields [ i ] . value ) ) ) ;
}
2018-03-19 19:42:49 +01:00
console . log ( AccountObj . id ) ;
console . log ( current _id ) ;
2018-09-23 16:14:28 +02:00
if ( AccountObj . acct . indexOf ( "@" ) != - 1 ) {
$ ( '#js_profile_public_link' ) . removeClass ( "invisible" ) ;
}
2018-03-19 19:42:49 +01:00
if ( AccountObj . id == current _id ) {
2018-06-09 17:29:25 +02:00
$ ( ` <a href="/settings/profile">
2018-03-11 12:07:57 +01:00
< button class = "profile_edit_button relationship_button" >
2018-08-04 15:52:34 +02:00
< span > $ { _ _ ( 'Edit profile' ) } < / s p a n >
2019-06-20 16:50:42 +02:00
< / b u t t o n >
2018-03-11 12:07:57 +01:00
< / a > ` ) . a p p e n d T o ( ' . p r o f i l e _ b u t t o n _ b o x ' ) ;
2019-06-20 16:50:42 +02:00
$ ( "#js-profile_nav_favourites a" ) . show ( ) ;
2018-03-11 12:07:57 +01:00
} else {
2018-10-14 15:37:55 +02:00
$ ( "#profile_toot_buttons" ) . show ( ) ;
2018-03-11 12:07:57 +01:00
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 ) {
$ ( ` <button class="blocking_button relationship_button" mid=" ${ AccountObj . id } ">
2018-08-04 15:52:34 +02:00
< span > $ { _ _ ( 'Blocking' ) } < / s p a n >
2018-03-11 12:07:57 +01:00
< / b u t t o n > ` ) . a p p e n d T o ( ' . p r o f i l e _ b u t t o n _ b o x ' ) ;
} else if ( RelationshipObj [ 0 ] . muting ) {
$ ( ` <button class="muting_button relationship_button" mid=" ${ AccountObj . id } ">
2018-08-04 15:52:34 +02:00
< span > $ { _ _ ( 'Muting' ) } < / s p a n >
2018-03-11 12:07:57 +01:00
< / b u t t o n > ` ) . a p p e n d T o ( ' . p r o f i l e _ b u t t o n _ b o x ' ) ;
} else if ( RelationshipObj [ 0 ] . requested ) {
$ ( ` <!-- wont work -->
< button class = "requested_button relationship_button" mid = "${AccountObj.id}" >
2018-08-04 15:52:34 +02:00
< span > $ { _ _ ( 'Requested' ) } < / s p a n >
2018-03-11 12:07:57 +01:00
< / b u t t o n > ` ) . a p p e n d T o ( ' . p r o f i l e _ b u t t o n _ b o x ' ) ;
} else if ( RelationshipObj [ 0 ] . following ) {
$ ( ` <button class="following_button relationship_button" mid=" ${ AccountObj . id } ">
2018-08-04 15:52:34 +02:00
< span > $ { _ _ ( 'Following' ) } < / s p a n >
2018-03-11 12:07:57 +01:00
< / b u t t o n > ` ) . a p p e n d T o ( ' . p r o f i l e _ b u t t o n _ b o x ' ) ;
} else {
$ ( ` <button class="follow_button relationship_button" mid=" ${ AccountObj . id } ">
< i class = "fa fa-fw fa-user-plus" > < / i >
2018-08-04 15:52:34 +02:00
< span > $ { _ _ ( 'Follow' ) } < / s p a n >
2018-03-11 12:07:57 +01:00
< / b u t t o n > ` ) . a p p e n d T o ( ' . p r o f i l e _ b u t t o n _ b o x ' ) ;
}
} ) ;
} ;
replace _emoji ( ) ;
}
function setRecentImages ( mid ) {
api . get ( "accounts/" + mid + "/statuses" , [ { name : 'only_media' , data : 'true' } , { name : 'limit' , data : '6' } ] , function ( statuses ) {
2019-06-06 19:13:53 +02:00
if ( statuses . length ) {
2018-08-04 15:52:34 +02:00
$ ( '#js_profile_recent_images span' ) . text ( ` ${ statuses [ 0 ] . account . statuses _count } ${ _ _ ( 'Photos and toots' ) } ` ) ;
2018-03-11 12:07:57 +01:00
$ ( '#js_profile_recent_images a' ) . attr ( 'href' , $ ( "#media_link" ) . attr ( 'href' ) ) ;
2019-06-06 19:13:53 +02:00
for ( i in statuses ) {
2019-07-17 17:52:20 +02:00
if ( statuses [ i ] . sensitive && localStorage . setting _show _nsfw == "false" ) {
2019-06-06 19:13:53 +02:00
if ( statuses [ i ] . media _attachments [ 0 ] . blurhash ) var imgurl = getBlurImage ( statuses [ i ] . media _attachments [ 0 ] . blurhash ) ;
2019-07-17 17:52:20 +02:00
else if ( statuses [ i ] . pleroma ) var imgurl = "https://" + current _instance + "/images/avi.png" ;
2019-06-06 19:13:53 +02:00
else var imgurl = "https://" + current _instance + "/avatars/original/missing.png" ;
2019-07-17 17:52:20 +02:00
if ( statuses [ i ] . media _attachments [ 0 ] . type == "image" )
$ ( ` <div class="profile_recent_images_item media_attachment" otype="image" sid=" ${ statuses [ i ] . id } " oid=" ${ statuses [ i ] . media _attachments [ 0 ] . id } " url=" ${ imgurl } " mediacount="0">
< img src = "${imgurl}" >
< / d i v > ` ) . a p p e n d T o ( ' # j s _ p r o f i l e _ r e c e n t _ i m a g e s _ b o x ' ) ;
else
$ ( ` <div class="profile_recent_images_item media_attachment">
< img src = "${imgurl}" >
< / d i v > ` ) . a p p e n d T o ( ' # j s _ p r o f i l e _ r e c e n t _ i m a g e s _ b o x ' ) ;
2019-06-06 19:13:53 +02:00
}
else {
if ( statuses [ i ] . media _attachments [ 0 ] . remote _url != null ) statuses [ i ] . media _attachments [ 0 ] . url = statuses [ i ] . media _attachments [ 0 ] . remote _url ;
2019-07-17 17:52:20 +02:00
if ( statuses [ i ] . media _attachments [ 0 ] . type == "image" )
$ ( ` <div class="profile_recent_images_item media_attachment" otype="image" sid=" ${ statuses [ i ] . id } " oid=" ${ statuses [ i ] . media _attachments [ 0 ] . id } " url=" ${ statuses [ i ] . media _attachments [ 0 ] . url } " mediacount="0">
< img src = "${statuses[i].media_attachments[0].url}" >
< / d i v > ` ) . a p p e n d T o ( ' # j s _ p r o f i l e _ r e c e n t _ i m a g e s _ b o x ' ) ;
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" ;
2019-06-06 19:13:53 +02:00
else var imgurl = "https://" + current _instance + "/avatars/original/missing.png" ;
2019-07-17 17:52:20 +02:00
$ ( ` <div class="profile_recent_images_item media_attachment">
2019-06-06 19:13:53 +02:00
< img src = "${imgurl}" >
2018-03-11 12:07:57 +01:00
< / d i v > ` ) . a p p e n d T o ( ' # j s _ p r o f i l e _ r e c e n t _ i m a g e s _ b o x ' ) ;
2019-07-17 17:52:20 +02:00
}
}
2018-03-11 12:07:57 +01:00
} ;
}
} ) ;
} ;
2018-12-02 15:01:21 +01:00
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 ( ) ;
} ) ;
}
2018-03-11 12:07:57 +01:00
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 ) ;
}
2020-03-29 20:17:40 +02:00
api . stream ( "user" , function ( userstream ) {
if ( userstream . event == "filters_changed" ) {
api . get ( "filters" , function ( data ) {
localStorage . setItem ( "current_filters" , JSON . stringify ( data ) ) ;
current _filters = data ;
} ) ;
}
else if ( userstream . event == "announcement.reaction" ) {
if ( $ ( ".announcement[aid=" + userstream . payload . announcement _id + "]" ) . find ( ".emoreact[emoji=" + userstream . payload . name + "]" ) . length == 1 ) {
if ( userstream . payload . count == 0 ) $ ( ".announcement[aid=" + userstream . payload . announcement _id + "]" ) . find ( ".emoreact[emoji=" + userstream . payload . name + "]" ) . remove ( ) ;
else $ ( ".announcement[aid=" + userstream . payload . announcement _id + "]" ) . find ( ".emoreact[emoji=" + userstream . payload . name + "]" ) . find ( ".emoreact_count" ) . text ( userstream . payload . count ) ;
}
else {
var emoji ;
if ( userstream . payload . url ) emoji = ( ` <span><img class="emoji" src=" ${ userstream . payload . url } "></span> ` ) ;
else emoji = ( ` <span class="emoji_poss"> ${ userstream . payload . name } </span> ` ) ;
var reaction = ( ` <span class="emoreact" emoji=" ${ userstream . payload . name } "> ${ emoji } <span class="emoreact_count"> ${ userstream . payload . count } </span></span> ` ) ;
$ ( ".announcement[aid=" + userstream . payload . announcement _id + "]" ) . find ( ".emoreact_add" ) . before ( reaction ) ;
replace _emoji ( ) ;
}
}
else if ( userstream . event === "update" & location . pathname !== "/" ) {
2018-03-11 12:07:57 +01:00
$ ( '#header .header_nav_list .home_badge' ) . removeClass ( 'invisible' ) ;
2018-05-01 18:51:00 +02:00
}
2018-07-01 17:07:18 +02:00
else if ( userstream . event === "notification" & location . pathname !== "/notifications" ) {
2018-03-11 12:07:57 +01:00
current _count += 1 ;
2018-07-01 17:07:18 +02:00
localStorage . setItem ( "notification_count" , current _count ) ;
$ ( '#header .header_nav_list .notification_badge' ) . text ( current _count ) ;
if ( $ ( '#header .header_nav_list .notification_badge' ) . hasClass ( 'invisible' ) ) {
2018-03-11 12:07:57 +01:00
$ ( '#header .header_nav_list .notification_badge' ) . removeClass ( 'invisible' )
}
2018-07-01 17:07:18 +02:00
}
if ( userstream . event === "notification" ) {
2018-05-01 18:51:00 +02:00
if ( userstream . payload . account . display _name . length == 0 ) {
userstream . payload . account . display _name = userstream . payload . account . username ;
}
switch ( userstream . payload . type ) {
2018-10-14 15:37:55 +02:00
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 ;
2020-03-29 20:17:40 +02:00
case "pleroma:emoji_reaction" : pushNotification ( _ _ ( "New reaction" ) , userstream . payload . account . display _name + " " + _ _ ( "reacted to your toot" ) ) ; break ;
2018-10-14 15:37:55 +02:00
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 ;
2019-04-15 16:40:57 +02:00
case "poll" : pushNotification ( _ _ ( "Poll finished" ) , _ _ ( "A poll you participated in has ended" ) ) ; break ;
2018-10-14 15:37:55 +02:00
}
2018-05-01 18:51:00 +02:00
}
2018-10-14 15:37:55 +02:00
} ) ;
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 } ) ;
2018-03-11 12:07:57 +01:00
}
2018-10-14 15:37:55 +02:00
} ) . catch ( function ( error ) {
console . log ( "There was an error when registering the service worker" , error ) ;
2018-03-11 12:07:57 +01:00
} ) ;
}
2018-10-14 15:37:55 +02:00
}
}
2018-03-11 12:07:57 +01:00
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 ) {
$ ( '<div class="toot_detail_wrap"></div>' ) . 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 ( ) ;
2018-11-25 19:14:16 +01:00
for ( let i in status . ancestors ) {
var filterreplystatus = false ;
for ( var a = 0 ; a < current _filters . length ; a ++ ) {
if ( current _filters [ a ] . context . indexOf ( "thread" ) != - 1 ) {
if ( current _filters [ a ] . whole _word == false ) {
if ( status . ancestors [ i ] . content . match ( new RegExp ( current _filters [ a ] . phrase ) ) ) filterreplystatus = true ;
}
else {
if ( status . ancestors [ i ] . content . match ( new RegExp ( "[^a-zA-Z1-9]" + current _filters [ a ] . phrase + "[^a-zA-Z1-9]" ) ) ) filterreplystatus = true ;
2018-03-11 12:07:57 +01:00
}
}
2018-11-25 19:14:16 +01:00
}
if ( filterreplystatus == false ) context _template ( status . ancestors [ i ] , 'ancestors_status' ) . prependTo ( "#js-overlay_content .temporary_object .toot_detail_wrap" ) ;
}
}
if ( status . descendants . length ) {
for ( let i in status . descendants ) {
var filterreplystatus = false ;
for ( var a = 0 ; a < current _filters . length ; a ++ ) {
if ( current _filters [ a ] . context . indexOf ( "thread" ) != - 1 ) {
if ( current _filters [ a ] . whole _word == false ) {
if ( status . descendants [ i ] . content . match ( new RegExp ( current _filters [ a ] . phrase ) ) ) filterreplystatus = true ;
}
else {
if ( status . descendants [ i ] . content . match ( new RegExp ( "[^a-zA-Z1-9]" + current _filters [ a ] . phrase + "[^a-zA-Z1-9]" ) ) ) filterreplystatus = true ;
}
}
}
2019-03-01 16:17:03 +01:00
if ( filterreplystatus == false ) {
if ( i < status . descendants . length - 1 && status . descendants [ i ] . id == status . descendants [ parseInt ( i ) + 1 ] . in _reply _to _id ) {
context _template ( status . descendants [ i ] , 'descendants_status direct_answer' ) . appendTo ( "#js-overlay_content .temporary_object .toot_detail_wrap" ) ;
}
else context _template ( status . descendants [ i ] , 'descendants_status' ) . appendTo ( "#js-overlay_content .temporary_object .toot_detail_wrap" ) ;
}
2018-03-11 12:07:57 +01:00
}
}
replaceInternalLink ( ) ;
replace _emoji ( ) ;
} ) ;
} ) ;
}
}
$ ( function ( ) {
$ ( document ) . on ( 'click' , '.toot_entry.ancestors_status, .toot_entry.descendants_status' , function ( e ) {
$ ( "#js-overlay_content .temporary_object" ) . empty ( ) ;
} ) ;
2019-01-13 19:02:16 +01:00
$ ( document ) . on ( 'click' , '.player' , function ( e ) {
e . stopPropagation ( ) ;
} ) ;
2018-03-11 12:07:57 +01:00
$ ( document ) . on ( 'click' , '.toot_entry' , function ( e ) {
2020-07-22 18:11:54 +02:00
if ( $ ( this ) . attr ( 'sid' ) ) setOverlayStatus ( $ ( this ) . attr ( 'sid' ) ) ;
2018-03-11 12:07:57 +01:00
} ) ;
} )
2019-03-01 16:17:03 +01:00
function setOverlayMedia ( sid , mediacount ) {
2018-03-11 12:07:57 +01:00
$ ( "#js-overlay_content .temporary_object" ) . empty ( ) ;
$ ( '#js-overlay_content_wrap' ) . addClass ( 'view' ) ;
$ ( '#js-overlay_content_wrap' ) . addClass ( 'black_08' ) ;
$ ( '#js-overlay_content .temporary_object' ) . addClass ( 'visible' ) ;
api . get ( "statuses/" + sid , function ( status ) {
2019-03-01 16:17:03 +01:00
if ( ! status . reblog ) {
media _template ( status , mediacount ) . appendTo ( "#js-overlay_content .temporary_object" ) ;
2018-03-11 12:07:57 +01:00
replaceInternalLink ( ) ;
replace _emoji ( ) ;
2019-03-01 16:17:03 +01:00
}
else {
media _template ( status . reblog , mediacount ) . appendTo ( "#js-overlay_content .temporary_object" ) ;
2018-03-11 12:07:57 +01:00
replaceInternalLink ( ) ;
replace _emoji ( ) ;
}
} ) ;
}
$ ( function ( ) {
2019-09-21 17:13:45 +02:00
$ ( document ) . on ( 'click' , '.media_attachment.with_overlay' , function ( e ) {
2018-03-11 12:07:57 +01:00
e . stopPropagation ( ) ;
2019-03-01 16:17:03 +01:00
setOverlayMedia ( $ ( this ) . attr ( 'sid' ) , $ ( this ) . attr ( 'mediacount' ) ) ;
2018-03-11 12:07:57 +01:00
$ ( '.media_detail .toot_entry .media_views' ) . addClass ( 'invisible' ) ;
} ) ;
} )
function setOverlayMediaWithoutStatus ( url ) {
$ ( "#js-overlay_content .temporary_object" ) . empty ( ) ;
$ ( '#js-overlay_content_wrap' ) . addClass ( 'view' ) ;
$ ( '#js-overlay_content_wrap' ) . addClass ( 'black_05' ) ;
media _template ( null , url ) . appendTo ( "#js-overlay_content .temporary_object" ) ;
}
2018-11-01 18:45:46 +01:00
var actEmojiData = new Array ( ) ;
for ( var i = 0 ; i < lsxEmojiData . activity . length ; i ++ ) {
var emoji = new Object ( ) ;
emoji . name = lsxEmojiData . activity [ i ] . name ;
emoji . value = lsxEmojiData . activity [ i ] . value ;
actEmojiData . push ( emoji ) ;
}
for ( var i = 0 ; i < lsxEmojiData . flags . length ; i ++ ) {
var emoji = new Object ( ) ;
emoji . name = lsxEmojiData . flags [ i ] . name ;
emoji . value = lsxEmojiData . flags [ i ] . value ;
actEmojiData . push ( emoji ) ;
}
for ( var i = 0 ; i < lsxEmojiData . foods . length ; i ++ ) {
var emoji = new Object ( ) ;
emoji . name = lsxEmojiData . foods [ i ] . name ;
emoji . value = lsxEmojiData . foods [ i ] . value ;
actEmojiData . push ( emoji ) ;
}
for ( var i = 0 ; i < lsxEmojiData . nature . length ; i ++ ) {
var emoji = new Object ( ) ;
emoji . name = lsxEmojiData . nature [ i ] . name ;
emoji . value = lsxEmojiData . nature [ i ] . value ;
actEmojiData . push ( emoji ) ;
}
for ( var i = 0 ; i < lsxEmojiData . objects . length ; i ++ ) {
var emoji = new Object ( ) ;
emoji . name = lsxEmojiData . objects [ i ] . name ;
emoji . value = lsxEmojiData . objects [ i ] . value ;
actEmojiData . push ( emoji ) ;
}
for ( var i = 0 ; i < lsxEmojiData . people . length ; i ++ ) {
var emoji = new Object ( ) ;
emoji . name = lsxEmojiData . people [ i ] . name ;
emoji . value = lsxEmojiData . people [ i ] . value ;
actEmojiData . push ( emoji ) ;
}
for ( var i = 0 ; i < lsxEmojiData . places . length ; i ++ ) {
var emoji = new Object ( ) ;
emoji . name = lsxEmojiData . places [ i ] . name ;
emoji . value = lsxEmojiData . places [ i ] . value ;
actEmojiData . push ( emoji ) ;
}
for ( var i = 0 ; i < lsxEmojiData . symbols . length ; i ++ ) {
var emoji = new Object ( ) ;
emoji . name = lsxEmojiData . symbols [ i ] . name ;
emoji . value = lsxEmojiData . symbols [ i ] . value ;
actEmojiData . push ( emoji ) ;
}
2019-02-25 18:18:21 +01:00
$ ( document ) . on ( "emojiready" , function ( ) {
2018-11-01 18:45:46 +01:00
var customemojis = JSON . parse ( localStorage . current _custom _emojis ) ;
for ( var i = 0 ; i < customemojis . length ; i ++ ) {
var emoji = new Object ( ) ;
emoji . name = customemojis [ i ] . code ;
emoji . url = customemojis [ i ] . url ;
actEmojiData . push ( emoji ) ;
}
2019-02-25 18:18:21 +01:00
} ) ;
2018-03-11 12:07:57 +01:00
$ ( function ( ) {
$ ( document ) . on ( 'click' , 'img[mediaaccess="true"]' , function ( e ) {
e . stopPropagation ( ) ;
setOverlayMediaWithoutStatus ( $ ( this ) . attr ( 'src' ) ) ;
} ) ;
2018-07-01 17:07:18 +02:00
} ) ;
2019-05-29 16:18:32 +02:00
function handleMediaUpload ( place , f ) {
if ( $ ( '#' + place + '_status_form .media_attachments_preview_area' ) . children ( ) . length == 4 ) {
putMessage ( _ _ ( "You can only add four pictures to one post!" ) ) ;
2018-03-19 19:42:49 +01:00
}
2019-05-29 16:18:32 +02:00
else if ( $ ( '#' + place + '_status_form .status_media_attachment' ) . hasClass ( "disabled" ) ) {
putMessage ( _ _ ( "You can not add media files to posts with polls!" ) ) ;
2019-05-07 19:19:29 +02:00
}
2019-05-29 16:18:32 +02:00
else {
if ( $ ( '#' + place + '_status_form .media_attachments_preview_area' ) . children ( ) . length == 0 ) {
$ ( '#' + place + '_status_form .status_textarea .media_attachments_preview_area' ) . removeClass ( 'invisible' ) ;
$ ( '#' + place + '_status_form .status_poll' ) . addClass ( 'disabled' ) ;
2018-07-01 17:07:18 +02:00
}
2019-05-29 16:18:32 +02:00
let reader = new FileReader ( ) ;
reader . readAsDataURL ( f ) ;
reader . onloadend = ( function ( ) {
return function ( e ) {
var imgrandom = Math . round ( Math . random ( ) * 100000 ) ;
image _uploads [ place ] [ imgrandom ] = new Object ( ) ;
image _uploads [ place ] [ imgrandom ] . upload = f ;
if ( f . type . indexOf ( "image" ) != - 1 ) var mediaelement = ` <img src=" ${ e . target . result } " class="media_element" data-random=" ${ imgrandom } "> ` ;
if ( f . type . indexOf ( "video" ) != - 1 ) var mediaelement = ` <video src=" ${ e . target . result } " muted class="media_element" data-random=" ${ imgrandom } "> ` ;
if ( f . type . indexOf ( "audio" ) != - 1 ) var mediaelement = ` <span class="media_element" data-random=" ${ imgrandom } "><center><i class="fa fa-file-audio-o" style="font-size:7em"></i></center></span> ` ;
const html = ( ` <div class="media_attachments_preview" draggable="true">
< div class = "media_attachments_caption_button" > < i class = "fa fa-pencil" > < / i > < / d i v >
< div class = "media_attachments_delete_button" > < i class = "fa fa-trash" > < / i > < / d i v >
$ { mediaelement }
< / d i v > ` ) ;
$ ( html ) . appendTo ( '#' + place + '_status_form .media_attachments_preview_area' ) ;
2018-06-09 17:29:25 +02:00
}
2019-05-29 16:18:32 +02:00
} ) ( f ) ;
}
}
var image _uploads = new Object ( ) ;
function initStatusEditor ( place ) {
image _uploads [ place ] = new Object ( ) ;
$ ( 'label[for=' + place + '_status_emoji]' ) . click ( function ( e ) { $ ( '#' + place + '_status_emoji' ) . trigger ( 'click' , e ) } ) ;
$ ( document ) . on ( 'change keyup' , '#' + place + '_status_form textarea,#' + place + '_status_form .status_spoiler,#' + place + '_status_form .poll_days,#' + place + '_status_form .poll_hours,#' + place + '_status_form .poll_mins' , function ( e ) {
2019-04-15 16:40:57 +02:00
var is _ready ;
2018-07-01 17:07:18 +02:00
if ( e . keyCode !== 224 & e . keyCode !== 17 ) {
2019-04-15 16:40:57 +02:00
if ( e . key == ":" ) {
replace _emoji _textarea ( this ) ;
}
2019-05-29 16:18:32 +02:00
if ( $ ( '#' + place + '_status_form textarea' ) . length == 1 ) {
const textCount = $ ( '#' + place + '_status_form textarea' ) . val ( ) . length + $ ( '#' + place + '_status_form .status_spoiler' ) . val ( ) . length ;
2018-04-01 19:30:47 +02:00
let textLen = ( current _instance _charlimit - textCount ) ;
2019-04-15 16:40:57 +02:00
if ( textLen <= - 1 ) {
2019-05-29 16:18:32 +02:00
$ ( '#' + place + '_status_form .character_count' ) . addClass ( 'red' ) ;
2019-04-15 16:40:57 +02:00
is _ready = true ;
} else if ( textLen === current _instance _charlimit ) {
is _ready = true ;
2018-03-11 12:07:57 +01:00
} else {
2019-05-29 16:18:32 +02:00
$ ( '#' + place + '_status_form .character_count' ) . removeClass ( 'red' ) ;
2019-04-15 16:40:57 +02:00
is _ready = false ;
2018-07-10 19:12:22 +02:00
}
2019-05-29 16:18:32 +02:00
$ ( '#' + place + '_status_form .character_count' ) . text ( textLen ) ;
2018-03-11 12:07:57 +01:00
}
2019-05-07 19:19:29 +02:00
else {
is _ready = false ;
2019-05-29 16:18:32 +02:00
$ ( '#' + place + '_status_form .character_count' ) . removeClass ( 'red' ) ;
$ ( '#' + place + '_status_form textarea' ) . each ( function ( ) {
const textCount = $ ( this ) . val ( ) . length + $ ( '#' + place + '_status_form .status_spoiler' ) . val ( ) . length ;
2019-05-07 19:19:29 +02:00
let textLen = ( current _instance _charlimit - textCount ) ;
if ( textLen <= - 1 ) {
2019-05-29 16:18:32 +02:00
$ ( '#' + place + '_status_form .character_count' ) . addClass ( 'red' ) ;
2019-05-07 19:19:29 +02:00
is _ready = true ;
} else if ( textLen === current _instance _charlimit ) {
is _ready = true ;
}
if ( $ ( this ) . is ( ":focus" ) ) {
2019-05-29 16:18:32 +02:00
$ ( '#' + place + '_status_form .character_count' ) . text ( textLen ) ;
2019-05-07 19:19:29 +02:00
}
} ) ;
}
2019-07-17 17:52:20 +02:00
if ( $ ( '#' + place + '_status_form .poll_days' ) . val ( ) != "" || $ ( '#' + place + '_status_form .poll_hours' ) . val ( ) != "" || $ ( '#' + place + '_status_form .poll_mins' ) . val ( ) != "" ) {
if ( $ ( '#' + place + '_status_form .poll_days' ) . val ( ) * 86400 + $ ( '#' + place + '_status_form .poll_hours' ) . val ( ) * 3600 + $ ( '#' + place + '_status_form .poll_mins' ) . val ( ) * 60 > current _instance _poll _limits . max _expiration ) {
is _ready = true ;
var pl _days = Math . floor ( current _instance _poll _limits . max _expiration / 86400 ) ;
var pl _hours = Math . floor ( current _instance _poll _limits . max _expiration / 3600 - pl _days * 24 ) ;
var pl _minutes = Math . floor ( current _instance _poll _limits . max _expiration / 60 - pl _hours * 60 - pl _days * 1440 ) ;
$ ( '#' + place + '_status_form .poll_time_warning' ) . removeClass ( "invisible" ) . text ( _ _ ( "The maximum poll time limit is:" ) + " " + pl _days + " " + _ _ ( "Days" ) + ", " + pl _hours + " " + _ _ ( "Hours" ) + " " + _ _ ( "and" ) + " " + pl _minutes + " " + _ _ ( "Minutes" ) ) ;
}
else if ( $ ( '#' + place + '_status_form .poll_days' ) . val ( ) * 86400 + $ ( '#' + place + '_status_form .poll_hours' ) . val ( ) * 3600 + $ ( '#' + place + '_status_form .poll_mins' ) . val ( ) * 60 < current _instance _poll _limits . min _expiration ) {
is _ready = true ;
var pl _days = Math . floor ( current _instance _poll _limits . min _expiration / 86400 ) ;
var pl _hours = Math . floor ( current _instance _poll _limits . min _expiration / 3600 - pl _days * 24 ) ;
var pl _minutes = Math . floor ( current _instance _poll _limits . min _expiration / 60 - pl _hours * 60 - pl _days * 1440 ) ;
var plt _days = "" ;
var plt _hours = "" ;
if ( pl _days > 0 ) plt _days = pl _days + " " + _ _ ( "Days" ) + ", " + pl _hours + " " + _ _ ( "Hours" ) + " " + _ _ ( "and" ) + " " ;
else if ( pl _hours > 0 ) plt _hours = pl _hours + " " + _ _ ( "Hours" ) + " " + _ _ ( "and" ) + " " ;
$ ( '#' + place + '_status_form .poll_time_warning' ) . removeClass ( "invisible" ) . text ( _ _ ( "The minimum poll time limit is:" ) + " " + plt _days + plt _hours + pl _minutes + " " + _ _ ( "Minutes" ) ) ;
}
else $ ( '#' + place + '_status_form .poll_time_warning' ) . addClass ( "invisible" ) ;
}
else $ ( '#' + place + '_status_form .poll_time_warning' ) . addClass ( "invisible" ) ;
2019-05-07 19:19:29 +02:00
}
2019-05-29 16:18:32 +02:00
if ( $ ( '#' + place + '_status_form .status_poll_editor' ) . hasClass ( "invisible" ) ) {
if ( is _ready ) $ ( '#' + place + '_status_form' ) . addClass ( 'ready' ) ;
else $ ( '#' + place + '_status_form' ) . removeClass ( 'ready' ) ;
2019-04-15 16:40:57 +02:00
}
else {
2019-05-29 16:18:32 +02:00
if ( $ ( '#' + place + '_status_form .poll_days' ) . is ( ":valid" ) && $ ( '#' + place + '_status_form .poll_hours' ) . is ( ":valid" ) && $ ( '#' + place + '_status_form .poll_mins' ) . is ( ":valid" ) ) {
if ( is _ready ) $ ( '#' + place + '_status_form' ) . addClass ( 'ready' ) ;
else $ ( '#' + place + '_status_form' ) . removeClass ( 'ready' ) ;
2019-04-15 16:40:57 +02:00
}
2019-05-29 16:18:32 +02:00
else $ ( '#' + place + '_status_form' ) . addClass ( 'ready' ) ;
2019-04-15 16:40:57 +02:00
}
2018-03-11 12:07:57 +01:00
} ) ;
2019-07-17 17:52:20 +02:00
$ ( document ) . on ( 'change keyup' , '#' + place + '_status_form .poll_field' , function ( ) {
if ( $ ( '#' + place + '_status_form .poll_field:blank' ) . length == 0 && $ ( '#' + place + '_status_form .poll_field' ) . length < current _instance _poll _limits . max _options )
$ ( '#' + place + '_status_form .poll_field:last' ) . after (
$ ( "<input>" ) . addClass ( "disallow_enter" ) . addClass ( "textfield" ) . addClass ( "poll_field" ) . attr ( "name" , "options[]" ) . attr ( "type" , "text" ) . attr ( "maxlength" , current _instance _poll _limits . max _option _chars ) ) . after ( " " ) . after (
$ ( "<i>" ) . addClass ( "fa" ) . addClass ( "fa-circle-o" ) ) . after ( $ ( "<br>" ) ) ;
} ) ;
2019-05-29 16:18:32 +02:00
$ ( document ) . on ( 'click' , '#' + place + '_status_form .status_CW' , function ( e ) {
$ ( '#' + place + '_status_form .status_spoiler' ) . toggleClass ( 'invisible' ) ;
$ ( '#' + place + '_status_form .status_textarea' ) . toggleClass ( 'status_has_cw' ) ;
2018-03-11 12:07:57 +01:00
} ) ;
2019-05-29 16:18:32 +02:00
$ ( document ) . on ( 'click' , '#' + place + '_status_form .status_poll' , function ( e ) {
$ ( '#' + place + '_status_form .status_poll_editor' ) . toggleClass ( 'invisible' ) ;
$ ( '#' + place + '_status_form .status_media_attachment' ) . toggleClass ( 'disabled' ) ;
$ ( '#' + place + '_status_form textarea' ) . keyup ( ) ;
2019-04-15 16:40:57 +02:00
} ) ;
2019-05-29 16:18:32 +02:00
$ ( document ) . on ( 'click' , '#' + place + '_status_form .expand_privacy_menu_button' , function ( e ) {
$ ( '#' + place + '_status_form .expand_privacy_menu' ) . removeClass ( 'invisible' ) ;
2018-03-11 12:07:57 +01:00
} ) ;
2019-05-29 16:18:32 +02:00
$ ( document ) . on ( 'click' , '#' + place + '_status_form .status_addfield' , function ( e ) {
2019-05-07 19:19:29 +02:00
var new _textarea = $ ( "<textarea>" ) . addClass ( "focus" ) . addClass ( "additional_textarea" ) . attr ( "name" , "status_textarea" ) . data ( "random" , Math . round ( Math . random ( ) * 1000 ) ) ;
autosize ( new _textarea ) ;
enableAutoComplete ( new _textarea ) ;
2019-05-29 16:18:32 +02:00
$ ( '#' + place + '_status_form textarea' ) . last ( ) . after ( new _textarea ) ;
2019-05-07 19:19:29 +02:00
} ) ;
2019-05-29 16:18:32 +02:00
$ ( document ) . on ( 'click' , '#' + place + '_status_form .status_privacy.select_privacy' , function ( e ) {
2018-03-11 12:07:57 +01:00
e . stopPropagation ( ) ;
2019-05-29 16:18:32 +02:00
$ ( '#' + place + '_status_form .expand_privacy_menu_button > i' ) . attr ( 'class' , $ ( this ) . attr ( 'privacyicon' ) ) ;
$ ( '#' + place + '_status_form .expand_privacy_menu' ) . addClass ( 'invisible' ) ;
2018-03-11 12:07:57 +01:00
} ) ;
2019-05-29 16:18:32 +02:00
$ ( document ) . on ( 'change' , '#' + place + '_status_media_atta' , function ( e ) {
for ( let i = 0 , f ; f = e . target . files [ i ] ; i ++ ) {
if ( f . type . indexOf ( "image" ) != - 1 || f . type . indexOf ( "video" ) != - 1 || f . type . indexOf ( "audio" ) != - 1 ) handleMediaUpload ( place , f ) ;
2018-03-11 12:07:57 +01:00
}
2019-05-29 16:18:32 +02:00
} ) ;
$ ( document ) . on ( 'click' , '#' + place + '_status_form .status_NSFW' , function ( e ) {
$ ( '#' + place + '_status_form .media_attachments_preview_area' ) . toggleClass ( 'nsfw' ) ;
} ) ;
$ ( document ) . on ( 'click' , '#' + place + '_status_form .media_attachments_delete_button' , function ( e ) {
e . stopPropagation ( ) ;
delete image _uploads [ place ] [ $ ( this ) . parent ( ) . children ( ".media_element" ) . data ( "random" ) ] ;
$ ( this ) . parent ( ) . remove ( ) ;
if ( $ ( '#' + place + '_status_form .media_attachments_preview_area' ) . children ( ) . length == 0 ) {
$ ( '#' + place + '_status_form .status_textarea .media_attachments_preview_area' ) . addClass ( 'invisible' ) ;
$ ( '#' + place + '_status_form .status_poll' ) . removeClass ( 'disabled' ) ;
}
} ) ;
$ ( document ) . on ( 'click' , '#' + place + '_status_form .media_attachments_caption_button' , function ( e ) {
e . stopPropagation ( ) ;
$ ( "#caption_status_form" ) . data ( "place" , place ) ;
$ ( "#caption_status_form" ) . data ( "random" , $ ( this ) . parent ( ) . children ( ".media_element" ) . data ( "random" ) ) ;
if ( image _uploads [ place ] [ $ ( this ) . parent ( ) . children ( ".media_element" ) . data ( "random" ) ] . caption ) $ ( "#caption_status_form .status_textarea textarea" ) . val ( image _uploads [ place ] [ $ ( this ) . parent ( ) . children ( ".media_element" ) . data ( "random" ) ] . caption ) ;
if ( place == "reply" ) $ ( ".toot_detail_wrap" ) . addClass ( "invisible" ) ;
else if ( place != "header" ) $ ( "." + place + "_status" ) . addClass ( "invisible" ) ;
$ ( '.caption_status' ) . removeClass ( 'invisible' ) ;
$ ( ".caption_status .status_preview" ) . empty ( ) ;
$ ( '#js-overlay_content_wrap' ) . addClass ( 'view' ) ;
$ ( '#js-overlay_content_wrap' ) . addClass ( 'black_08' ) ;
$ ( '.caption_status .submit_status_label' ) . addClass ( 'active_submit_button' ) ;
$ ( '#caption_status_form .status_textarea textarea' ) . addClass ( 'focus' ) ;
$ ( '#caption_status_form .status_textarea textarea' ) . focus ( ) ;
autosize ( $ ( '#caption_status_form .status_textarea textarea' ) ) ;
$ ( '#caption_status_form' ) . attr ( 'random' , $ ( this ) . parent ( ) . children ( ".media_element" ) . data ( "random" ) ) ;
$ ( '.caption_status .report_status_header span' ) . addClass ( "emoji_poss" ) . html ( _ _ ( "Add a caption to the media file" ) ) ;
$ ( '#caption_status_form textarea' ) . empty ( ) ;
$ ( '#caption_status_form .character_count' ) . html ( "420" ) ;
replace _emoji ( ) ;
return false ;
} ) ;
$ ( document ) . on ( 'paste' , '#' + place + '_status_form .status_textarea' , function ( e ) {
e = e . originalEvent ;
for ( var i = 0 ; i < e . clipboardData . items . length ; i ++ ) {
var item = e . clipboardData . items [ i ] ;
if ( item . type . indexOf ( "image" ) != - 1 || item . type . indexOf ( "video" ) != - 1 || item . type . indexOf ( "audio" ) != - 1 ) {
handleMediaUpload ( place , item . getAsFile ( ) ) ;
}
}
} ) ;
$ ( document ) . on ( 'drop' , '#' + place + '_status_form .status_textarea' , function ( e ) {
e = e . originalEvent ;
for ( var i = 0 ; i < e . dataTransfer . files . length ; i ++ ) {
var item = e . dataTransfer . files [ i ] ;
if ( item . type . indexOf ( "image" ) != - 1 || item . type . indexOf ( "video" ) != - 1 || item . type . indexOf ( "audio" ) != - 1 ) {
e . preventDefault ( ) ;
handleMediaUpload ( place , item ) ;
2018-03-11 12:07:57 +01:00
}
2019-05-29 16:18:32 +02:00
}
} ) ;
var dragsourceelement = null ;
$ ( document ) . on ( "dragstart" , '#' + place + '_status_form .media_attachments_preview' , function ( e ) {
e . originalEvent . dataTransfer . effectAllowed = 'move' ;
e . originalEvent . dataTransfer . setData ( 'text/html' , $ ( this ) . html ( ) ) ;
dragsourceelement = this ;
$ ( this ) . addClass ( "moving" ) ;
} ) ;
$ ( document ) . on ( "dragenter" , '#' + place + '_status_form .media_attachments_preview' , function ( e ) {
if ( dragsourceelement != null ) {
$ ( this ) . addClass ( "over" ) ;
}
} ) ;
$ ( document ) . on ( "dragover" , '#' + place + '_status_form .media_attachments_preview' , function ( e ) {
if ( dragsourceelement != null ) {
e . preventDefault ( ) ;
e . originalEvent . dataTransfer . dropEffect = 'move' ;
}
return false ;
2018-03-11 12:07:57 +01:00
} ) ;
2019-05-29 16:18:32 +02:00
$ ( document ) . on ( "dragleave" , '#' + place + '_status_form .media_attachments_preview' , function ( e ) {
$ ( this ) . removeClass ( "over" ) ;
2018-03-11 12:07:57 +01:00
} ) ;
2019-05-29 16:18:32 +02:00
$ ( document ) . on ( "drop" , '#' + place + '_status_form .media_attachments_preview' , function ( e ) {
e . stopPropagation ( ) ;
if ( dragsourceelement != this && dragsourceelement != null ) {
$ ( dragsourceelement ) . html ( $ ( this ) . html ( ) ) ;
$ ( this ) . html ( e . originalEvent . dataTransfer . getData ( 'text/html' ) ) ;
}
dragsourceelement = null ;
$ ( '#' + place + '_status_form .media_attachments_preview' ) . removeClass ( "over" ) ;
$ ( '#' + place + '_status_form .media_attachments_preview' ) . removeClass ( "moving" ) ;
return false ;
} ) ;
$ ( document ) . on ( "dragend" , '#' + place + '_status_form .media_attachments_preview' , function ( e ) {
dragsourceelement = null ;
$ ( '#' + place + '_status_form .media_attachments_preview' ) . removeClass ( "over" ) ;
$ ( '#' + place + '_status_form .media_attachments_preview' ) . removeClass ( "moving" ) ;
} ) ;
$ ( document ) . on ( 'click' , '#' + place + '_status_form .submit_status_label' , function ( e ) {
2019-12-23 14:58:06 +01:00
setTimeout ( function ( ) {
2019-05-29 16:18:32 +02:00
$ ( '#' + place + '_status_form' ) . addClass ( 'ready' ) ;
$ ( '#' + place + '_status_form .status_textarea' ) . addClass ( 'disallow_select' ) ;
$ ( '#' + place + '_status_form .character_count' ) . html ( '<i class="fa fa-circle-o-notch fa-spin" aria-hidden="true"></i>' ) ;
2019-12-23 14:58:06 +01:00
} , 0 ) ;
2019-05-29 16:18:32 +02:00
const form = document . forms [ place + "_status_form" ] ;
if ( ! Object . keys ( image _uploads [ place ] ) . length || ! $ ( '#' + place + '_status_form .status_poll_editor' ) . hasClass ( "invisible" ) ) {
2018-03-11 12:07:57 +01:00
const params = {
2019-05-29 16:18:32 +02:00
status : $ ( '#' + place + '_status_form textarea' ) ,
2018-03-11 12:07:57 +01:00
sensitive : form . status _nsfw . checked ,
spoiler _text : form . status _spoiler . value ,
visibility : form . privacy _option . value
}
2019-05-30 13:34:51 +02:00
if ( place == "reply" ) params . in _reply _to _id = $ ( '#reply_status_form' ) . attr ( 'sid' ) ;
else if ( place == "single_reply" ) params . in _reply _to _id = $ ( '#single_reply_status_form' ) . attr ( 'tid' ) ;
2019-05-29 16:18:32 +02:00
if ( ! $ ( '#' + place + '_status_form .status_poll_editor' ) . hasClass ( "invisible" ) ) {
2019-04-15 16:40:57 +02:00
params . poll = new Object ;
params . poll . options = new Array ;
2019-05-29 16:18:32 +02:00
for ( var i = 0 ; i < $ ( '#' + place + '_status_form .poll_field' ) . length ; i ++ ) {
if ( $ ( '#' + place + '_status_form .poll_field' ) . eq ( i ) . val ( ) . length > 0 ) params . poll . options . push ( $ ( '#' + place + '_status_form .poll_field' ) . eq ( i ) . val ( ) ) ;
2019-04-15 16:40:57 +02:00
}
if ( params . poll . options . length > 0 ) {
2019-05-29 16:18:32 +02:00
params . poll . expires _in = $ ( '#' + place + '_status_form .poll_days' ) . val ( ) * 86400 + $ ( '#' + place + '_status_form .poll_hours' ) . val ( ) * 3600 + $ ( '#' + place + '_status_form .poll_mins' ) . val ( ) * 60 ;
if ( $ ( '#' + place + '_status_form .poll_multiple_choice' ) [ 0 ] . checked ) params . poll . multiple = "On" ;
2019-04-15 16:40:57 +02:00
}
}
2019-05-07 19:19:29 +02:00
submitStatusArray ( params , function ( data ) {
2019-05-29 16:18:32 +02:00
$ ( '#' + place + '_status_form .media_attachments_preview_area' ) . empty ( ) ;
$ ( '#' + place + '_status_form .status_spoiler' ) . addClass ( 'invisible' ) ;
$ ( '#' + place + '_status_form .status_textarea .media_attachments_preview_area' ) . addClass ( 'invisible' ) ;
$ ( '#' + place + '_status_form .status_poll' ) . removeClass ( 'disabled' ) ;
2018-03-11 12:07:57 +01:00
form . reset ( ) ;
2019-05-29 16:18:32 +02:00
$ ( '#' + place + '_status_form' ) . removeClass ( 'ready' ) ;
$ ( '#' + place + '_status_form .status_textarea' ) . removeClass ( 'disallow_select' ) ;
$ ( '#' + place + '_status_form .character_count' ) . html ( current _instance _charlimit ) ;
$ ( '.' + place + '_status .submit_status_label' ) . removeClass ( 'active_submit_button' ) ;
$ ( '.' + place + '_status' ) . addClass ( 'invisible' ) ;
2018-03-11 12:07:57 +01:00
$ ( '#js-overlay_content_wrap' ) . removeClass ( 'view' ) ;
$ ( '#js-overlay_content_wrap' ) . removeClass ( 'black_05' ) ;
2018-08-04 15:52:34 +02:00
putMessage ( _ _ ( 'Your Toot was posted!' ) ) ;
2018-03-11 12:07:57 +01:00
} ) ;
} else {
2019-05-29 16:18:32 +02:00
const filesLen = Object . keys ( image _uploads [ place ] ) . length - 1 ;
2018-03-11 12:07:57 +01:00
let media _array = [ ] ;
2019-05-29 16:18:32 +02:00
var count = 0 ;
for ( var i in image _uploads [ place ] ) {
2018-03-11 12:07:57 +01:00
let formData = new FormData ( ) ;
2019-05-29 16:18:32 +02:00
formData . append ( 'file' , image _uploads [ place ] [ i ] . upload ) ;
if ( image _uploads [ place ] [ i ] . caption ) formData . append ( 'description' , image _uploads [ place ] [ i ] . caption ) ;
if ( count === 3 || count === filesLen ) {
api . postMedia ( "media" , formData , function ( postMedia ) {
2018-03-11 12:07:57 +01:00
media _array . unshift ( postMedia . id ) ;
const params = {
2019-05-29 16:18:32 +02:00
status : $ ( '#' + place + '_status_form textarea' ) ,
2018-03-11 12:07:57 +01:00
sensitive : form . status _nsfw . checked ,
spoiler _text : form . status _spoiler . value ,
visibility : form . privacy _option . value ,
media _ids : media _array
}
2019-05-30 13:34:51 +02:00
if ( place == "reply" ) params . in _reply _to _id = $ ( '#reply_status_form' ) . attr ( 'sid' ) ;
else if ( place == "single_reply" ) params . in _reply _to _id = $ ( '#single_reply_status_form' ) . attr ( 'tid' ) ;
2019-05-07 19:19:29 +02:00
submitStatusArray ( params , function ( data ) {
2019-05-29 16:18:32 +02:00
$ ( '#' + place + '_status_form .media_attachments_preview_area' ) . empty ( ) ;
$ ( '#' + place + '_status_form .status_spoiler' ) . addClass ( 'invisible' ) ;
$ ( '#' + place + '_status_form .status_textarea .media_attachments_preview_area' ) . addClass ( 'invisible' ) ;
$ ( '#' + place + '_status_form .status_poll' ) . removeClass ( 'disabled' ) ;
2018-03-11 12:07:57 +01:00
form . reset ( ) ;
2019-05-29 16:18:32 +02:00
delete image _uploads [ place ] ;
image _uploads [ place ] = new Object ( ) ;
$ ( '#' + place + '_status_form' ) . removeClass ( 'ready' ) ;
$ ( '#' + place + '_status_form .status_textarea' ) . removeClass ( 'disallow_select' ) ;
$ ( '#' + place + '_status_form .character_count' ) . html ( current _instance _charlimit ) ;
$ ( '.' + place + '_status .submit_status_label' ) . removeClass ( 'active_submit_button' ) ;
$ ( '.' + place + '_status' ) . addClass ( 'invisible' ) ;
autosize . destroy ( $ ( '#' + place + '_status_form .status_textarea textarea' ) ) ;
$ ( '#' + place + '_status_emoji' ) . lsxEmojiPicker ( "destroy" ) ;
2018-03-11 12:07:57 +01:00
$ ( '#js-overlay_content_wrap' ) . removeClass ( 'view' ) ;
$ ( '#js-overlay_content_wrap' ) . removeClass ( 'black_05' ) ;
2018-08-04 15:52:34 +02:00
putMessage ( _ _ ( 'Your Toot was posted!' ) ) ;
2018-03-11 12:07:57 +01:00
} ) ;
} ) ;
break ;
2019-05-07 19:19:29 +02:00
}
2019-05-29 16:18:32 +02:00
else if ( count < filesLen ) {
api . postMedia ( "media" , formData , function ( postMedia ) {
media _array . unshift ( postMedia . id ) ;
2019-05-07 19:19:29 +02:00
} ) ;
}
2019-05-29 16:18:32 +02:00
count ++ ;
2019-05-07 19:19:29 +02:00
}
2019-04-15 16:40:57 +02:00
}
2019-05-07 19:19:29 +02:00
} ) ;
2018-03-19 19:42:49 +01:00
}
2019-05-29 16:18:32 +02:00
function openStatusEditor ( place ) {
$ ( '#' + place + '_status_form .status_textarea textarea' ) . addClass ( 'focus' ) ;
autosize ( $ ( '#' + place + '_status_form .status_textarea textarea' ) ) ;
enableAutoComplete ( $ ( '#' + place + '_status_form .status_top .status_spoiler' ) ) ;
enableAutoComplete ( $ ( '#' + place + '_status_form .status_textarea textarea' ) ) ;
$ ( '#' + place + '_status_form .status_bottom' ) . removeClass ( 'invisible' ) ;
$ ( '#' + place + '_status_form .submit_status_label' ) . addClass ( 'active_submit_button' ) ;
2019-07-17 17:52:20 +02:00
$ ( '#' + place + '_status_form .poll_field' ) . attr ( "maxlength" , current _instance _poll _limits . max _option _chars ) ;
$ ( '#' + place + '_status_form .poll_days' ) . attr ( "max" , Math . floor ( current _instance _poll _limits . max _expiration / 86400 ) ) ;
$ ( '#' + place + '_status_form .poll_days' ) . attr ( "placeholder" , "0-" + Math . floor ( current _instance _poll _limits . max _expiration / 86400 ) ) ;
2019-05-29 16:18:32 +02:00
const textCount = $ ( '#' + place + '_status_form textarea' ) . val ( ) . length + $ ( '#' + place + '_status_form .status_spoiler' ) . val ( ) . length ;
2019-03-01 16:17:03 +01:00
let textLen = ( current _instance _charlimit - textCount ) ;
2019-05-29 16:18:32 +02:00
$ ( '#' + place + '_status_form .character_count' ) . html ( textLen ) ;
$ ( '#' + place + '_status_emoji' ) . lsxEmojiPicker ( {
2018-07-01 17:07:18 +02:00
closeOnSelect : true ,
twemoji : ! checkEmojiSupport ( ) ,
onSelect : function ( emoji ) {
2019-05-29 16:18:32 +02:00
$ ( '#' + place + '_status_form .status_top .status_spoiler,#' + place + '_status_form .status_textarea textarea' ) . each ( function ( ) {
2019-05-07 19:19:29 +02:00
if ( global _focus _textfield == $ ( this ) . data ( "random" ) ) {
$ ( this ) . insertText ( ":" + emoji . name + ":" ) ;
$ ( this ) . trigger ( { "type" : "keyup" , "key" : ":" } ) ;
}
} ) ;
2018-07-01 17:07:18 +02:00
}
} ) ;
2018-06-09 17:29:25 +02:00
if ( localStorage . setting _post _sensitive == "true" ) {
2019-05-29 16:18:32 +02:00
$ ( '#' + place + '_status_nsfw' ) [ 0 ] . checked = true ;
$ ( '#' + place + '_status_form .media_attachments_preview_area' ) . addClass ( 'nsfw' ) ;
2019-04-15 16:40:57 +02:00
}
2019-05-29 16:18:32 +02:00
$ ( '#' + place + '_status_form .status_textarea textarea' ) . focus ( ) ;
replace _emoji ( ) ;
2019-04-15 16:40:57 +02:00
}
2019-05-29 16:18:32 +02:00
$ ( function ( ) {
$ ( document ) . on ( 'click' , function ( e ) {
if ( ! $ ( e . target ) . closest ( '#creat_status' ) . length && ! $ ( e . target ) . closest ( '.overlay_status' ) . length ) {
$ ( '#overlay_status_emoji' ) . lsxEmojiPicker ( "destroy" ) ;
$ ( '#overlay_status_form .status_top .status_spoiler' ) . autoCompleteToken ( "destroy" ) ;
$ ( '#overlay_status_form .status_textarea textarea' ) . autoCompleteToken ( "destroy" ) ;
2018-03-11 12:07:57 +01:00
}
} ) ;
2019-05-29 16:18:32 +02:00
$ ( document ) . on ( 'click' , '#creat_status,.profile_sendto' , function ( e ) {
if ( $ ( this ) . attr ( "privacy" ) ) privacy _mode = $ ( this ) . attr ( "privacy" )
else privacy _mode = localStorage . getItem ( "setting_post_privacy" )
switch ( privacy _mode ) {
case "public" : picon = "globe" ; break ;
case "unlisted" : picon = "unlock-alt" ; break ;
case "private" : picon = "lock" ; break ;
case "direct" : picon = "envelope" ; break ;
2018-03-11 12:07:57 +01:00
}
2019-05-29 16:18:32 +02:00
$ ( '.overlay_status' ) . removeClass ( 'invisible' ) ;
$ ( "#js-overlay_content_wrap .temporary_object" ) . empty ( ) ;
$ ( '#js-overlay_content_wrap' ) . addClass ( 'view' ) ;
$ ( '#js-overlay_content_wrap' ) . addClass ( 'black_08' ) ;
$ ( '#overlay_status_form .media_attachments_preview_area' ) . empty ( ) ;
$ ( '#overlay_status_form .status_spoiler' ) . addClass ( 'invisible' ) ;
$ ( '#overlay_status_form .status_textarea .media_attachments_preview_area' ) . addClass ( 'invisible' ) ;
$ ( '#overlay_status_form .status_poll' ) . removeClass ( 'disabled' ) ;
document . forms . overlay _status _form . reset ( ) ;
delete image _uploads . overlay ;
image _uploads . overlay = new Object ( ) ;
$ ( '#overlay_status_form input[name="privacy_option"]' ) . val ( [ privacy _mode ] ) ;
$ ( '#overlay_status_form .expand_privacy_menu_button > i' ) . attr ( 'class' , "fa fa-" + picon ) ;
if ( $ ( this ) . attr ( "display_name" ) ) $ ( '.overlay_status .overlay_status_header span' ) . addClass ( "emoji_poss" ) . html ( _ _ ( "Toot to" ) + " " + $ ( this ) . attr ( "display_name" ) ) ;
else $ ( '.overlay_status .overlay_status_header span' ) . html ( _ _ ( "Compose new Toot" ) ) ;
if ( $ ( this ) . attr ( "acct" ) ) $ ( '#overlay_status_form textarea' ) . val ( $ ( this ) . attr ( "acct" ) + " " ) ;
else $ ( '#overlay_status_form textarea' ) . val ( "" ) ;
openStatusEditor ( "overlay" ) ;
2018-03-11 12:07:57 +01:00
} ) ;
2019-05-29 16:18:32 +02:00
initStatusEditor ( "overlay" ) ;
2018-03-11 12:07:57 +01:00
$ ( document ) . on ( 'click' , function ( e ) {
if ( ! $ ( e . target ) . closest ( '#reply_status_form' ) . length ) {
2018-07-01 17:07:18 +02:00
$ ( '#reply_status_emoji' ) . lsxEmojiPicker ( "destroy" ) ;
2019-05-07 19:19:29 +02:00
$ ( '#reply_status_form .status_top .status_spoiler' ) . autoCompleteToken ( "destroy" ) ;
$ ( '#reply_status_form .status_textarea textarea' ) . autoCompleteToken ( "destroy" ) ;
2018-03-11 12:07:57 +01:00
}
} ) ;
$ ( document ) . on ( 'click' , '#reply_status_form' , function ( e ) {
if ( ! $ ( '#reply_status_form .status_textarea textarea' ) . hasClass ( 'focus' ) ) {
2018-08-21 17:51:40 +02:00
var mentions = JSON . parse ( $ ( '#reply_status_form' ) . attr ( 'mentions' ) ) ;
2018-09-03 17:04:14 +02:00
mentions . reverse ( ) ;
2018-08-21 17:51:40 +02:00
var replyto = "" ;
for ( var i = 0 ; i < mentions . length ; i ++ ) {
if ( mentions [ i ] . acct != current _acct ) {
replyto += "@" + mentions [ i ] . acct + " " ;
}
}
$ ( '#reply_status_form textarea' ) . val ( replyto ) ;
2019-08-21 18:25:27 +02:00
if ( $ ( "#reply_status_form .status_spoiler:blank" ) . length == 0 ) {
$ ( '#reply_status_form .status_spoiler' ) . removeClass ( 'invisible' ) ;
$ ( '#reply_status_form .status_textarea' ) . addClass ( 'status_has_cw' ) ;
}
2019-05-29 16:18:32 +02:00
delete image _uploads . reply ;
image _uploads . reply = new Object ( ) ;
openStatusEditor ( "reply" ) ;
2018-03-11 12:07:57 +01:00
}
} ) ;
2019-05-29 16:18:32 +02:00
initStatusEditor ( "reply" ) ;
$ ( document ) . on ( 'click' , function ( e ) {
2018-07-01 17:07:18 +02:00
if ( ! $ ( e . target ) . closest ( '.reply_button' ) . length && ! $ ( e . target ) . closest ( '.single_reply_status' ) . length ) {
$ ( '#single_reply_status_emoji' ) . lsxEmojiPicker ( "destroy" ) ;
2019-05-07 19:19:29 +02:00
$ ( '#single_status_form .status_top .status_spoiler' ) . autoCompleteToken ( "destroy" ) ;
$ ( '#single_status_form .status_textarea textarea' ) . autoCompleteToken ( "destroy" ) ;
2018-07-01 17:07:18 +02:00
}
} ) ;
2019-05-29 16:18:32 +02:00
$ ( document ) . on ( 'click' , 'single_reply_status_header, #single_reply_status_form' , function ( e ) {
2018-03-11 12:07:57 +01:00
e . stopPropagation ( ) ;
} ) ;
2019-05-29 16:18:32 +02:00
$ ( document ) . on ( 'click' , '.reply_button' , function ( e ) {
2018-03-11 12:07:57 +01:00
e . stopPropagation ( ) ;
const sid = $ ( this ) . attr ( 'tid' ) ,
2018-08-21 17:51:40 +02:00
mentions = JSON . parse ( $ ( this ) . attr ( 'mentions' ) ) ;
2018-09-03 17:04:14 +02:00
mentions . reverse ( ) ;
2018-08-21 17:51:40 +02:00
var replyto = "" ;
for ( var i = 0 ; i < mentions . length ; i ++ ) {
if ( mentions [ i ] . acct != current _acct ) {
replyto += "@" + mentions [ i ] . acct + " " ;
}
}
2018-03-11 12:07:57 +01:00
display _name = $ ( this ) . attr ( 'display_name' ) ;
2018-04-21 17:15:13 +02:00
privacy _mode = $ ( this ) . attr ( "privacy" ) ;
switch ( privacy _mode ) {
2018-03-19 19:42:49 +01:00
case "public" : picon = "globe" ; break ;
case "unlisted" : picon = "unlock-alt" ; break ;
case "private" : picon = "lock" ; break ;
case "direct" : picon = "envelope" ; break ;
}
2018-03-11 12:07:57 +01:00
$ ( '.single_reply_status' ) . removeClass ( 'invisible' ) ;
$ ( "#js-overlay_content_wrap .temporary_object" ) . empty ( ) ;
$ ( ".single_reply_status .status_preview" ) . empty ( ) ;
$ ( '#js-overlay_content_wrap' ) . addClass ( 'view' ) ;
$ ( '#js-overlay_content_wrap' ) . addClass ( 'black_08' ) ;
2019-05-29 16:18:32 +02:00
$ ( '#single_reply_status_form .media_attachments_preview_area' ) . empty ( ) ;
$ ( '#single_reply_status_form .status_spoiler' ) . addClass ( 'invisible' ) ;
$ ( '#single_reply_status_form .status_textarea .media_attachments_preview_area' ) . addClass ( 'invisible' ) ;
$ ( '#single_reply_status_form .status_poll' ) . removeClass ( 'disabled' ) ;
document . forms . single _reply _status _form . reset ( ) ;
delete image _uploads . single _reply ;
image _uploads . single _reply = new Object ( ) ;
2018-04-21 17:15:13 +02:00
$ ( '#single_reply_status_form input[name="privacy_option"]' ) . val ( [ privacy _mode ] ) ;
2018-03-19 19:42:49 +01:00
$ ( '#single_reply_status_form .expand_privacy_menu_button > i' ) . attr ( 'class' , "fa fa-" + picon ) ;
2018-03-11 12:07:57 +01:00
$ ( '#single_reply_status_form' ) . attr ( 'tid' , sid ) ;
2018-08-04 15:52:34 +02:00
$ ( '.single_reply_status .single_reply_status_header span' ) . addClass ( "emoji_poss" ) . html ( _ _ ( "Reply to" ) + " " + display _name ) ;
2018-08-21 17:51:40 +02:00
$ ( '#single_reply_status_form textarea' ) . val ( replyto ) ;
2019-08-21 18:25:27 +02:00
$ ( '#single_reply_status_form .status_spoiler' ) . val ( $ ( this ) . attr ( "content_warning" ) ) ;
if ( $ ( this ) . attr ( "content_warning" ) != "" ) {
$ ( '#single_reply_status_form .status_spoiler' ) . removeClass ( 'invisible' ) ;
$ ( '#single_reply_status_form .status_textarea' ) . addClass ( 'status_has_cw' ) ;
}
2019-05-29 16:18:32 +02:00
openStatusEditor ( "single_reply" )
2018-03-11 12:07:57 +01:00
api . get ( 'statuses/' + sid + '/' , function ( status ) {
timeline _template ( status ) . appendTo ( ".single_reply_status .status_preview" ) ;
replace _emoji ( ) ;
} ) ;
} ) ;
2019-05-29 16:18:32 +02:00
initStatusEditor ( "single_reply" ) ;
$ ( document ) . on ( 'click' , function ( e ) {
2019-10-13 18:34:02 +02:00
if ( ! $ ( e . target ) . closest ( '#header_status_form' ) . length && ! $ ( e . target ) . closest ( '.close_button' ) . length ) {
2019-05-29 16:18:32 +02:00
$ ( '#header_status_form .submit_status_label' ) . removeClass ( 'active_submit_button' ) ;
$ ( '#header_status_form .expand_privacy_menu' ) . addClass ( 'invisible' ) ;
$ ( '#header_status_form .status_textarea textarea' ) . removeClass ( 'focus' ) ;
$ ( '#header_status_form .status_bottom' ) . addClass ( 'invisible' ) ;
autosize . destroy ( $ ( '#header_status_form .status_textarea textarea' ) ) ;
$ ( '#header_status_emoji' ) . lsxEmojiPicker ( "destroy" ) ;
$ ( '#header_status_form .status_top .status_spoiler' ) . autoCompleteToken ( "destroy" ) ;
$ ( '#header_status_form .status_textarea textarea' ) . autoCompleteToken ( "destroy" ) ;
$ ( '#header_status_form .status_textarea' ) . addClass ( "closed" ) ;
2019-05-07 19:19:29 +02:00
}
} ) ;
2019-05-29 16:18:32 +02:00
$ ( document ) . on ( 'click' , '#header_status_form' , function ( e ) {
switch ( localStorage . getItem ( "setting_post_privacy" ) ) {
case "public" : picon = "globe" ; break ;
case "unlisted" : picon = "unlock-alt" ; break ;
case "private" : picon = "lock" ; break ;
case "direct" : picon = "envelope" ; break ;
2019-05-07 19:19:29 +02:00
}
2019-05-29 16:18:32 +02:00
if ( ! $ ( '#header_status_form .status_textarea textarea' ) . hasClass ( 'focus' ) ) {
$ ( '#header_status_form .status_textarea' ) . removeClass ( "closed" ) ;
$ ( '#header_status_form input[name="privacy_option"]' ) . val ( [ localStorage . getItem ( "setting_post_privacy" ) ] ) ;
$ ( '#header_status_form .expand_privacy_menu_button > i' ) . attr ( 'class' , "fa fa-" + picon ) ;
openStatusEditor ( "header" ) ;
2019-04-15 16:40:57 +02:00
}
2018-03-11 12:07:57 +01:00
} ) ;
2019-05-29 16:18:32 +02:00
initStatusEditor ( "header" ) ;
2018-03-11 12:07:57 +01:00
} ) ;
2019-05-29 16:18:32 +02:00
$ ( function ( ) {
$ ( document ) . on ( 'click' , 'caption_status_header, #caption_status_form' , function ( e ) {
2018-03-11 12:07:57 +01:00
e . stopPropagation ( ) ;
} ) ;
2019-05-29 16:18:32 +02:00
$ ( document ) . on ( 'change keyup' , '#caption_status_form textarea' , function ( e ) {
if ( e . keyCode !== 224 & e . keyCode !== 17 ) {
const textCount = $ ( '#caption_status_form textarea' ) . val ( ) . length ;
let textLen = ( 420 - textCount ) ;
if ( textLen <= - 1 ) {
$ ( '#caption_status_form .character_count' ) . addClass ( 'red' ) ;
$ ( '#caption_status_form' ) . addClass ( 'ready' ) ;
2018-03-11 12:07:57 +01:00
}
2019-05-29 16:18:32 +02:00
else if ( textLen === 1000 ) {
$ ( '#caption_status_form' ) . addClass ( 'ready' ) ;
2019-04-15 16:40:57 +02:00
}
2019-05-29 16:18:32 +02:00
else {
$ ( '#caption_status_form .character_count' ) . removeClass ( 'red' ) ;
$ ( '#caption_status_form' ) . removeClass ( 'ready' ) ;
2019-04-15 16:40:57 +02:00
}
2019-05-29 16:18:32 +02:00
$ ( '#caption_status_form .character_count' ) . text ( textLen ) ;
2019-04-15 16:40:57 +02:00
}
2018-03-11 12:07:57 +01:00
} ) ;
2019-05-29 16:18:32 +02:00
$ ( document ) . on ( 'click' , '#caption_status_form .submit_status_label' , function ( e ) {
image _uploads [ $ ( "#caption_status_form" ) . data ( "place" ) ] [ $ ( "#caption_status_form" ) . data ( "random" ) ] . caption = $ ( "#caption_status_form .status_textarea textarea" ) . val ( ) ;
document . forms . caption _status _form . reset ( ) ;
$ ( '#caption_status_form .character_count' ) . html ( "420" ) ;
$ ( '.caption_status .submit_status_label' ) . removeClass ( 'active_submit_button' ) ;
$ ( '.caption_status' ) . addClass ( 'invisible' ) ;
autosize . destroy ( $ ( '#caption_status_form .status_textarea textarea' ) ) ;
if ( $ ( "#caption_status_form" ) . data ( "place" ) == "header" ) {
2018-03-11 12:07:57 +01:00
$ ( '#js-overlay_content_wrap' ) . removeClass ( 'view' ) ;
$ ( '#js-overlay_content_wrap' ) . removeClass ( 'black_05' ) ;
}
2019-05-29 16:18:32 +02:00
else if ( $ ( "#caption_status_form" ) . data ( "place" ) == "reply" ) $ ( ".toot_detail_wrap" ) . removeClass ( "invisible" ) ;
else $ ( "." + $ ( "#caption_status_form" ) . data ( "place" ) + "_status" ) . removeClass ( "invisible" ) ;
putMessage ( _ _ ( 'Caption added successfully!' ) ) ;
2018-03-11 12:07:57 +01:00
} ) ;
2018-07-25 17:31:54 +02:00
} ) ;
$ ( function ( ) {
$ ( document ) . on ( 'click' , 'report_status_header, #report_status_form' , function ( e ) {
e . stopPropagation ( ) ;
} ) ;
$ ( document ) . on ( 'click' , '.report_button' , function ( e ) {
e . stopPropagation ( ) ;
const sid = $ ( this ) . attr ( 'sid' ) ,
mid = $ ( this ) . attr ( 'mid' ) ,
display _name = $ ( this ) . attr ( 'display_name' ) ;
$ ( '.report_status' ) . removeClass ( 'invisible' ) ;
$ ( "#js-overlay_content_wrap .temporary_object" ) . empty ( ) ;
$ ( ".report_status .status_preview" ) . empty ( ) ;
$ ( '#js-overlay_content_wrap' ) . addClass ( 'view' ) ;
$ ( '#js-overlay_content_wrap' ) . addClass ( 'black_08' ) ;
$ ( '.report_status .submit_status_label' ) . addClass ( 'active_submit_button' ) ;
$ ( '#report_status_form .status_textarea textarea' ) . addClass ( 'focus' ) ;
$ ( '#report_status_form .status_textarea textarea' ) . focus ( ) ;
2019-05-29 16:18:32 +02:00
autosize ( $ ( '#report_status_form .status_textarea textarea' ) ) ;
2018-07-25 17:31:54 +02:00
$ ( '#report_status_form' ) . attr ( 'tid' , sid ) ;
$ ( '#report_status_form' ) . attr ( 'mid' , mid ) ;
2018-08-04 15:52:34 +02:00
$ ( '.report_status .report_status_header span' ) . addClass ( "emoji_poss" ) . html ( _ _ ( "Report a Toot of" ) + " " + display _name ) ;
2018-07-25 17:31:54 +02:00
$ ( '#report_status_form textarea' ) . empty ( ) ;
$ ( '#report_status_form .character_count' ) . html ( "1000" ) ;
replace _emoji ( ) ;
api . get ( 'statuses/' + sid + '/' , function ( status ) {
timeline _template ( status ) . appendTo ( ".report_status .status_preview" ) ;
replace _emoji ( ) ;
} ) ;
return false ;
} ) ;
2019-05-29 16:18:32 +02:00
$ ( document ) . on ( 'change keyup' , '#report_status_form textarea' , function ( e ) {
2018-07-25 17:31:54 +02:00
if ( e . keyCode !== 224 & e . keyCode !== 17 ) {
2019-05-29 16:18:32 +02:00
const textCount = $ ( '#report_status_form textarea' ) . val ( ) . length ;
2018-07-25 17:31:54 +02:00
let textLen = ( 1000 - textCount ) ;
if ( textLen <= - 1 ) {
$ ( '#report_status_form .character_count' ) . addClass ( 'red' ) ;
$ ( '#report_status_form' ) . addClass ( 'ready' ) ;
}
else if ( textLen === 1000 ) {
$ ( '#report_status_form' ) . addClass ( 'ready' ) ;
}
else {
$ ( '#report_status_form .character_count' ) . removeClass ( 'red' ) ;
$ ( '#report_status_form' ) . removeClass ( 'ready' ) ;
}
$ ( '#report_status_form .character_count' ) . text ( textLen ) ;
}
} ) ;
$ ( document ) . on ( 'click' , '#report_status_form .submit_status_label' , function ( e ) {
$ ( '#report_status_form' ) . addClass ( 'ready' ) ;
$ ( '#report_status_form .status_textarea' ) . addClass ( 'disallow_select' ) ;
$ ( '#report_status_form .character_count' ) . html ( '<i class="fa fa-circle-o-notch fa-spin" aria-hidden="true"></i>' ) ;
let form = document . forms . report _status _form ;
const params = {
account _id : $ ( '#report_status_form' ) . attr ( 'mid' ) ,
status _ids : $ ( '#report_status_form' ) . attr ( 'tid' ) ,
comment : form . status _textarea . value ,
}
api . post ( "reports" , params , function ( data ) {
form . reset ( ) ;
$ ( '#report_status_form' ) . removeClass ( 'ready' ) ;
$ ( '#report_status_form .status_textarea' ) . removeClass ( 'disallow_select' ) ;
$ ( '#report_status_form .character_count' ) . html ( "1000" ) ;
$ ( '.report_status .submit_status_label' ) . removeClass ( 'active_submit_button' ) ;
$ ( '.report_status' ) . addClass ( 'invisible' ) ;
autosize . destroy ( $ ( '#report_status_form .status_textarea textarea' ) ) ;
$ ( '#js-overlay_content_wrap' ) . removeClass ( 'view' ) ;
$ ( '#js-overlay_content_wrap' ) . removeClass ( 'black_05' ) ;
$ ( "#js-overlay_content_wrap .report_status .status_preview" ) . empty ( ) ;
2018-08-04 15:52:34 +02:00
putMessage ( _ _ ( 'Toot reported successfully!' ) ) ;
2018-07-25 17:31:54 +02:00
} ) ;
} ) ;
} ) ;
2018-03-11 12:07:57 +01:00
$ ( function ( ) {
$ ( document ) . on ( 'click' , '.copylink_button' , function ( e ) {
2018-07-20 14:27:29 +02:00
if ( ClipboardJS . isSupported ( ) ) {
var cbelem = $ ( "<button>" ) . attr ( "data-clipboard-text" , $ ( this ) . attr ( "url" ) ) ;
var clipboard = new ClipboardJS ( cbelem [ 0 ] ) ;
clipboard . on ( 'success' , function ( e ) {
2018-08-04 15:52:34 +02:00
putMessage ( _ _ ( "Link successfully copied!" ) ) ;
2018-07-20 14:27:29 +02:00
e . clearSelection ( ) ;
} ) ;
clipboard . on ( 'error' , function ( e ) {
$ ( "#js-overlay_content_wrap .temporary_object" ) . empty ( ) ;
$ ( '#js-overlay_content_wrap' ) . addClass ( 'view' ) ;
$ ( '#js-overlay_content_wrap' ) . addClass ( 'black_08' ) ;
$ ( '.overlay_copy_link' ) . removeClass ( 'invisible' ) ;
2018-09-23 16:14:28 +02:00
$ ( '.overlay_copy_link input' ) . val ( $ ( this ) . attr ( 'url' ) ) ;
2018-07-20 14:27:29 +02:00
return false ;
} ) ;
cbelem . click ( ) ;
}
else {
2018-03-11 12:07:57 +01:00
e . stopPropagation ( ) ;
$ ( "#js-overlay_content_wrap .temporary_object" ) . empty ( ) ;
$ ( '#js-overlay_content_wrap' ) . addClass ( 'view' ) ;
$ ( '#js-overlay_content_wrap' ) . addClass ( 'black_08' ) ;
$ ( '.overlay_copy_link' ) . removeClass ( 'invisible' ) ;
2018-09-23 16:14:28 +02:00
$ ( '.overlay_copy_link input' ) . val ( $ ( this ) . attr ( 'url' ) ) ;
2018-03-11 12:07:57 +01:00
return false ;
2018-07-20 14:27:29 +02:00
}
2018-03-11 12:07:57 +01:00
} ) ;
} )
$ ( function ( ) {
$ ( document ) . on ( 'click' , '.temporary_object > *, .parmanent_object > *' , function ( e ) {
e . stopPropagation ( ) ;
} ) ;
2019-02-03 19:56:49 +01:00
$ ( document ) . on ( 'click' , '#js-overlay_content_wrap' , function ( e ) {
2019-05-29 16:18:32 +02:00
if ( ( ! $ ( '#js-overlay_content_wrap .overlay_status' ) . hasClass ( "invisible" ) && ( $ ( '#js-overlay_content_wrap .overlay_status textarea' ) . val ( ) . length > 0 || $ ( '#overlay_status_form .media_attachments_preview_area' ) . children ( ) . length > 0 ) )
|| ( ! $ ( '#js-overlay_content_wrap .single_reply_status' ) . hasClass ( "invisible" ) && ( $ ( '#js-overlay_content_wrap .single_reply_status textarea' ) . val ( ) . length > 0 || $ ( '#single_reply_status_form .media_attachments_preview_area' ) . children ( ) . length > 0 ) )
2019-02-03 19:56:49 +01:00
|| ( ! $ ( '#js-overlay_content_wrap .report_status' ) . hasClass ( "invisible" ) && $ ( '#js-overlay_content_wrap .report_status textarea' ) . val ( ) . length > 0 )
2019-05-29 16:18:32 +02:00
|| ( ! $ ( '#js-overlay_content_wrap .caption_status' ) . hasClass ( "invisible" ) && $ ( '#js-overlay_content_wrap .caption_status textarea' ) . val ( ) . length > 0 )
|| ( $ ( '#js-overlay_content_wrap #reply_status_form' ) . length == 1 && ! $ ( ".toot_detail_wrap" ) . hasClass ( "invisible" ) && ( $ ( '#js-overlay_content_wrap #reply_status_form textarea' ) . val ( ) . length > 0 || $ ( '#reply_status_form .media_attachments_preview_area' ) . children ( ) . length > 0 ) ) ) {
2019-02-03 19:56:49 +01:00
$ ( document . body ) . append ( $ ( ` <div id="overlay_close_warning" style="position:fixed;z-index:1001;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,0.8)">
< div class = "overlay_simple overlay_close" >
< header class = "overlay_simple_header" >
< span class = "emoji_poss" > $ { _ _ ( 'Confirmation' ) } < / s p a n >
< / h e a d e r >
< div class = "overlay_simple_body" >
< div class = "overlay_close_text" style = "margin-bottom:10px" > $ { _ _ ( "If you close the overlay, your text will get deleted! Are you sure you want to close it?" ) } < / d i v >
< div class = "overlay_simple_controls" >
< button class = "overlay_confirm_yes toot_button" style = "float:right" > < div class = "toot_button_label" > < i class = "fa fa-fw fa-check" > < / i > < s p a n > $ { _ _ ( ' Y e s ' ) } < / s p a n > < / d i v > < / b u t t o n >
< a href = "javascript:$('#overlay_close_warning').remove();void(0)" class = "overlay_confirm_cancel halcyon_link" style = "float:right;margin-top:5px;margin-right:10px" > < i class = "fa fa-times" > < / i > $ { _ _ ( ' C a n c e l ' ) } < / a >
< / d i v >
< / d i v >
< / d i v >
< / d i v > ` ) ) ;
$ ( ".overlay_close .overlay_confirm_yes" ) . click ( function ( ) {
$ ( '#overlay_close_warning' ) . remove ( ) ;
2019-05-29 16:18:32 +02:00
if ( ! $ ( '#js-overlay_content_wrap .caption_status' ) . hasClass ( "invisible" ) && $ ( "#caption_status_form" ) . data ( "place" ) != "header" ) {
$ ( ".caption_status" ) . addClass ( "invisible" ) ;
$ ( ".caption_status textarea" ) . val ( "" ) ;
if ( $ ( "#caption_status_form" ) . data ( "place" ) == "reply" ) $ ( ".toot_detail_wrap" ) . removeClass ( "invisible" ) ;
else $ ( "." + $ ( "#caption_status_form" ) . data ( "place" ) + "_status" ) . removeClass ( "invisible" ) ;
}
else closeOverlay ( ) ;
2019-02-03 19:56:49 +01:00
} ) ;
}
2019-05-29 16:18:32 +02:00
else if ( ! $ ( '#js-overlay_content_wrap .caption_status' ) . hasClass ( "invisible" ) && $ ( "#caption_status_form" ) . data ( "place" ) != "header" ) {
$ ( ".caption_status" ) . addClass ( "invisible" ) ;
$ ( ".caption_status textarea" ) . val ( "" ) ;
if ( $ ( "#caption_status_form" ) . data ( "place" ) == "reply" ) $ ( ".toot_detail_wrap" ) . removeClass ( "invisible" ) ;
else $ ( "." + $ ( "#caption_status_form" ) . data ( "place" ) + "_status" ) . removeClass ( "invisible" ) ;
}
2019-02-03 19:56:49 +01:00
else closeOverlay ( ) ;
} ) ;
function closeOverlay ( ) {
$ ( "#js-overlay_content_wrap" ) . removeClass ( 'view' ) ;
2018-03-11 12:07:57 +01:00
$ ( "#js-overlay_content_wrap .temporary_object" ) . empty ( ) ;
$ ( "#js-overlay_content_wrap .single_reply_status .status_preview" ) . empty ( ) ;
$ ( '#js-overlay_content_wrap .overlay_status' ) . addClass ( 'invisible' ) ;
$ ( '#js-overlay_content_wrap .single_reply_status' ) . addClass ( 'invisible' ) ;
2018-09-23 16:14:28 +02:00
$ ( '#js-overlay_content_wrap .report_status' ) . addClass ( 'invisible' ) ;
2019-05-29 16:18:32 +02:00
$ ( '#js-overlay_content_wrap .caption_status' ) . addClass ( 'invisible' ) ;
2018-03-11 12:07:57 +01:00
$ ( '#js-overlay_content_wrap .overlay_copy_link' ) . addClass ( 'invisible' ) ;
2018-09-23 16:14:28 +02:00
$ ( '#js-overlay_content_wrap .overlay_confirm' ) . addClass ( 'invisible' ) ;
$ ( '#js-overlay_content_wrap .overlay_prompt' ) . addClass ( 'invisible' ) ;
$ ( '#js-overlay_content_wrap .overlay_addlist' ) . addClass ( 'invisible' ) ;
2018-11-25 19:14:16 +01:00
$ ( '#js-overlay_content_wrap .overlay_filter' ) . addClass ( 'invisible' ) ;
2019-10-13 18:34:02 +02:00
$ ( '#js-overlay_content_wrap .overlay_redirect_invidious' ) . addClass ( 'invisible' ) ;
$ ( '#js-overlay_content_wrap .overlay_redirect_nitter' ) . addClass ( 'invisible' ) ;
2020-02-09 19:26:29 +01:00
$ ( '#js-overlay_content_wrap .overlay_redirect_bibliogram' ) . addClass ( 'invisible' ) ;
$ ( '#js-overlay_content_wrap .overlay_redirect_nofb' ) . addClass ( 'invisible' ) ;
2019-10-13 18:34:02 +02:00
$ ( '#js-overlay_content_wrap .overlay_rewrite_invidious' ) . addClass ( 'invisible' ) ;
$ ( '#js-overlay_content_wrap .overlay_rewrite_nitter' ) . addClass ( 'invisible' ) ;
2020-02-09 19:26:29 +01:00
$ ( '#js-overlay_content_wrap .overlay_rewrite_bibliogram' ) . addClass ( 'invisible' ) ;
$ ( '#js-overlay_content_wrap .overlay_rewrite_nofb' ) . addClass ( 'invisible' ) ;
2018-03-11 12:07:57 +01:00
$ ( '#js-overlay_content .temporary_object, #js-overlay_content .parmanent_object' ) . removeClass ( 'visible' ) ;
$ ( '#js-overlay_content_wrap .overlay_status.submit_status_label' ) . removeClass ( 'active_submit_button' ) ;
$ ( '#js-overlay_content_wrap .single_reply_status .submit_status_label' ) . removeClass ( 'active_submit_button' ) ;
$ ( '#js-overlay_content_wrap #reply_status_form .submit_status_label' ) . removeClass ( 'active_submit_button' ) ;
2019-05-07 19:19:29 +02:00
$ ( '#js-overlay_content_wrap #header_status_form .submit_status_label' ) . removeClass ( 'active_submit_button' ) ;
2018-03-11 12:07:57 +01:00
$ ( '#js-overlay_content_wrap' ) . removeClass ( 'black_05' ) ;
$ ( '#js-overlay_content_wrap' ) . removeClass ( 'black_08' ) ;
2018-09-23 16:14:28 +02:00
$ ( '#js-overlay_content_wrap .overlay_confirm_yes' ) . off ( 'click' ) ;
$ ( '#js-overlay_content_wrap .overlay_prompt_ok' ) . off ( 'click' ) ;
$ ( '#js-overlay_content_wrap .overlay_prompt_text' ) . val ( "" ) ;
2019-05-29 16:18:32 +02:00
$ ( '#js-overlay_content_wrap #report_status_form textarea' ) . val ( "" ) ;
$ ( '#js-overlay_content_wrap #caption_status_form textarea' ) . val ( "" ) ;
2018-09-23 16:14:28 +02:00
$ ( '#js-overlay_content_wrap .overlay_addlist_body' ) . empty ( ) ;
2018-11-25 19:14:16 +01:00
$ ( '#js-overlay_content_wrap #addfilter' ) . trigger ( "reset" ) ;
2019-05-07 19:19:29 +02:00
$ ( '#js-overlay_content_wrap .status_form .additional_textarea' ) . remove ( ) ;
2018-11-25 19:14:16 +01:00
if ( window . current _file ) {
if ( current _file === "/user" ) {
2018-03-11 12:07:57 +01:00
history . pushState ( null , null , "/" + location . pathname . split ( "/" ) [ 1 ] + location . search ) ;
} else {
history . pushState ( null , null , current _file ) ;
}
2018-11-25 19:14:16 +01:00
}
2019-02-03 19:56:49 +01:00
}
2018-12-02 15:01:21 +01:00
} ) ;
2018-03-11 12:07:57 +01:00
$ ( function ( ) {
2018-05-19 19:52:19 +02:00
$ ( "#enable_follow" ) . click ( function ( ) {
localStorage . setItem ( "setting_who_to_follow" , "true" ) ;
setWhoToFollow ( true ) ;
} ) ;
2019-07-17 17:52:20 +02:00
$ ( "#hide_ffdl" ) . click ( function ( ) {
localStorage . hide _firefox _download = "true" ;
$ ( "#widget_ffdl" ) . slideUp ( ) ;
} ) ;
2018-12-02 15:01:21 +01:00
$ ( "#search_form" ) . focus ( function ( ) {
if ( $ ( "#search_form" ) . val ( ) == "" ) searchlocalfill ( ) ;
else searchremotefill ( $ ( "#search_form" ) . val ( ) ) ;
} ) . keyup ( function ( ) {
if ( $ ( "#search_form" ) . val ( ) == "" ) searchlocalfill ( ) ;
else searchremotefill ( $ ( "#search_form" ) . val ( ) ) ;
} ) ;
$ ( document ) . click ( function ( e ) {
if ( ! $ ( e . target ) . closest ( '.header_search_suggestions' ) . length && ! $ ( e . target ) . closest ( '#search_form' ) . length ) $ ( ".header_search_suggestions" ) . addClass ( "invisible" ) ;
} ) ;
$ ( ".search_form" ) . submit ( function ( e ) {
e . preventDefault ( ) ;
searchredirect ( $ ( "#search_form" ) . val ( ) ) ;
} ) ;
2019-08-21 18:25:27 +02:00
$ ( '.overlay_redirect_invidious_yes' ) . click ( function ( ) {
$ ( '.close_button' ) . click ( ) ;
window . open ( "https://" + server _setting _invidious + "/watch?v=" + $ ( ".overlay_redirect_invidious" ) . data ( "video" ) , "_blank" ) ;
if ( $ ( "#redirect_invidious_permanent" ) [ 0 ] . checked ) localStorage . setting _redirect _invidious = "true" ;
} ) ;
$ ( '.overlay_redirect_invidious_no' ) . click ( function ( ) {
$ ( '.close_button' ) . click ( ) ;
window . open ( "https://www.youtube.com/watch?v=" + $ ( ".overlay_redirect_invidious" ) . data ( "video" ) , "_blank" ) ;
if ( $ ( "#redirect_invidious_permanent" ) [ 0 ] . checked ) localStorage . setting _redirect _invidious = "false" ;
} ) ;
2019-09-21 17:13:45 +02:00
$ ( '.overlay_redirect_nitter_yes' ) . click ( function ( ) {
$ ( '.close_button' ) . click ( ) ;
window . open ( "https://" + server _setting _nitter + "/" + $ ( ".overlay_redirect_nitter" ) . data ( "path" ) , "_blank" ) ;
if ( $ ( "#redirect_nitter_permanent" ) [ 0 ] . checked ) localStorage . setting _redirect _nitter = "true" ;
} ) ;
$ ( '.overlay_redirect_nitter_no' ) . click ( function ( ) {
$ ( '.close_button' ) . click ( ) ;
window . open ( "https://twitter.com/" + $ ( ".overlay_redirect_nitter" ) . data ( "path" ) , "_blank" ) ;
if ( $ ( "#redirect_nitter_permanent" ) [ 0 ] . checked ) localStorage . setting _redirect _nitter = "false" ;
} ) ;
2020-02-09 19:26:29 +01:00
$ ( '.overlay_redirect_bibliogram_yes' ) . click ( function ( ) {
$ ( '.close_button' ) . click ( ) ;
window . open ( "https://" + server _setting _bibliogram + "/" + $ ( ".overlay_redirect_bibliogram" ) . data ( "path" ) , "_blank" ) ;
if ( $ ( "#redirect_bibliogram_permanent" ) [ 0 ] . checked ) localStorage . setting _redirect _bibliogram = "true" ;
} ) ;
$ ( '.overlay_redirect_bibliogram_no' ) . click ( function ( ) {
$ ( '.close_button' ) . click ( ) ;
window . open ( "https://www.instagram.com/" + $ ( ".overlay_redirect_bibliogram" ) . data ( "path" ) , "_blank" ) ;
if ( $ ( "#redirect_bibliogram_permanent" ) [ 0 ] . checked ) localStorage . setting _redirect _bibliogram = "false" ;
} ) ;
$ ( '.overlay_redirect_nofb_yes' ) . click ( function ( ) {
$ ( '.close_button' ) . click ( ) ;
window . open ( "https://nofb.pw/?p=" + encodeURIComponent ( "https://www.facebook.com/" + $ ( ".overlay_redirect_nofb" ) . data ( "path" ) ) , "_blank" ) ;
if ( $ ( "#redirect_nofb_permanent" ) [ 0 ] . checked ) localStorage . setting _redirect _nofb = "true" ;
} ) ;
$ ( '.overlay_redirect_nofb_no' ) . click ( function ( ) {
$ ( '.close_button' ) . click ( ) ;
window . open ( "https://www.facebook.com/" + $ ( ".overlay_redirect_nofb" ) . data ( "path" ) , "_blank" ) ;
if ( $ ( "#redirect_nofb_permanent" ) [ 0 ] . checked ) localStorage . setting _redirect _nofb = "false" ;
} ) ;
2019-10-13 18:34:02 +02:00
$ ( '.overlay_rewrite_invidious_yes' ) . click ( function ( ) {
$ ( '.close_button' ) . click ( ) ;
2020-02-09 19:26:29 +01:00
submitStatusArray ( $ ( ".overlay_rewrite_invidious" ) . data ( "params" ) , $ ( ".overlay_rewrite_invidious" ) . data ( "callback" ) , "true" , $ ( ".overlay_rewrite_invidious" ) . data ( "nitter" ) , $ ( ".overlay_rewrite_invidious" ) . data ( "bibliogram" ) , $ ( ".overlay_rewrite_invidious" ) . data ( "nofb" ) ) ;
2019-10-13 18:34:02 +02:00
if ( $ ( "#rewrite_invidious_permanent" ) [ 0 ] . checked ) localStorage . setting _rewrite _invidious = "true" ;
} ) ;
$ ( '.overlay_rewrite_invidious_no' ) . click ( function ( ) {
$ ( '.close_button' ) . click ( ) ;
2020-02-09 19:26:29 +01:00
submitStatusArray ( $ ( ".overlay_rewrite_invidious" ) . data ( "params" ) , $ ( ".overlay_rewrite_invidious" ) . data ( "callback" ) , "false" , $ ( ".overlay_rewrite_invidious" ) . data ( "nitter" ) , $ ( ".overlay_rewrite_invidious" ) . data ( "bibliogram" ) , $ ( ".overlay_rewrite_invidious" ) . data ( "nofb" ) ) ;
2019-10-13 18:34:02 +02:00
if ( $ ( "#rewrite_invidious_permanent" ) [ 0 ] . checked ) localStorage . setting _rewrite _invidious = "false" ;
} ) ;
$ ( '.overlay_rewrite_nitter_yes' ) . click ( function ( ) {
$ ( '.close_button' ) . click ( ) ;
2020-02-09 19:26:29 +01:00
submitStatusArray ( $ ( ".overlay_rewrite_nitter" ) . data ( "params" ) , $ ( ".overlay_rewrite_nitter" ) . data ( "callback" ) , $ ( ".overlay_rewrite_nitter" ) . data ( "invidious" ) , "true" , $ ( ".overlay_rewrite_nitter" ) . data ( "bibliogram" ) , $ ( ".overlay_rewrite_nitter" ) . data ( "bibliogram" ) ) ;
2019-10-13 18:34:02 +02:00
if ( $ ( "#rewrite_nitter_permanent" ) [ 0 ] . checked ) localStorage . setting _rewrite _nitter = "true" ;
} ) ;
$ ( '.overlay_rewrite_nitter_no' ) . click ( function ( ) {
$ ( '.close_button' ) . click ( ) ;
2020-02-09 19:26:29 +01:00
submitStatusArray ( $ ( ".overlay_rewrite_nitter" ) . data ( "params" ) , $ ( ".overlay_rewrite_nitter" ) . data ( "callback" ) , $ ( ".overlay_rewrite_nitter" ) . data ( "invidious" ) , "false" , $ ( ".overlay_rewrite_nitter" ) . data ( "bibliogram" ) , $ ( ".overlay_rewrite_nitter" ) . data ( "bibliogram" ) ) ;
2019-10-13 18:34:02 +02:00
if ( $ ( "#rewrite_nitter_permanent" ) [ 0 ] . checked ) localStorage . setting _rewrite _nitter = "false" ;
} ) ;
2020-02-09 19:26:29 +01:00
$ ( '.overlay_rewrite_bibliogram_yes' ) . click ( function ( ) {
$ ( '.close_button' ) . click ( ) ;
submitStatusArray ( $ ( ".overlay_rewrite_bibliogram" ) . data ( "params" ) , $ ( ".overlay_rewrite_bibliogram" ) . data ( "callback" ) , $ ( ".overlay_rewrite_bibliogram" ) . data ( "invidious" ) , $ ( ".overlay_rewrite_bibliogram" ) . data ( "nitter" ) , "true" , $ ( ".overlay_rewrite_bibliogram" ) . data ( "nofb" ) ) ;
if ( $ ( "#rewrite_bibliogram_permanent" ) [ 0 ] . checked ) localStorage . setting _rewrite _bibliogram = "true" ;
} ) ;
$ ( '.overlay_rewrite_bibliogram_no' ) . click ( function ( ) {
$ ( '.close_button' ) . click ( ) ;
submitStatusArray ( $ ( ".overlay_rewrite_bibliogram" ) . data ( "params" ) , $ ( ".overlay_rewrite_bibliogram" ) . data ( "callback" ) , $ ( ".overlay_rewrite_bibliogram" ) . data ( "invidious" ) , $ ( ".overlay_rewrite_bibliogram" ) . data ( "nitter" ) , "false" , $ ( ".overlay_rewrite_bibliogram" ) . data ( "nofb" ) ) ;
if ( $ ( "#rewrite_bibliogram_permanent" ) [ 0 ] . checked ) localStorage . setting _rewrite _bibliogram = "false" ;
} ) ;
$ ( '.overlay_rewrite_nofb_yes' ) . click ( function ( ) {
$ ( '.close_button' ) . click ( ) ;
submitStatusArray ( $ ( ".overlay_rewrite_nofb" ) . data ( "params" ) , $ ( ".overlay_rewrite_nofb" ) . data ( "callback" ) , $ ( ".overlay_rewrite_nofb" ) . data ( "invidious" ) , $ ( ".overlay_rewrite_nofb" ) . data ( "nitter" ) , $ ( ".overlay_rewrite_nofb" ) . data ( "bibliogram" ) , "true" ) ;
if ( $ ( "#rewrite_nofb_permanent" ) [ 0 ] . checked ) localStorage . setting _rewrite _nofb = "true" ;
} ) ;
$ ( '.overlay_rewrite_nofb_no' ) . click ( function ( ) {
$ ( '.close_button' ) . click ( ) ;
submitStatusArray ( $ ( ".overlay_rewrite_nofb" ) . data ( "params" ) , $ ( ".overlay_rewrite_nofb" ) . data ( "callback" ) , $ ( ".overlay_rewrite_nofb" ) . data ( "invidious" ) , $ ( ".overlay_rewrite_nofb" ) . data ( "nitter" ) , $ ( ".overlay_rewrite_nofb" ) . data ( "bibliogram" ) , "false" ) ;
if ( $ ( "#rewrite_nofb_permanent" ) [ 0 ] . checked ) localStorage . setting _rewrite _nofb = "false" ;
} ) ;
2019-02-03 19:56:49 +01:00
if ( $ ( "#js-overlay_content_wrap" ) . hasClass ( "view" ) ) $ ( document . body ) . css ( "overflow-y" , "hidden" ) ;
$ ( "#js-overlay_content_wrap" ) . attrchange ( function ( attr ) {
if ( attr == "class" && $ ( "#js-overlay_content_wrap" ) . hasClass ( "view" ) ) $ ( document . body ) . css ( "overflow-y" , "hidden" ) ;
else $ ( document . body ) . css ( "overflow-y" , "auto" ) ;
} ) ;
2019-03-01 16:17:03 +01:00
$ ( document ) . on ( "click" , ".media_detail .media_backward" , function ( ) {
$ ( ".media_detail" ) . attr ( "cid" , $ ( ".media_detail" ) . attr ( "cid" ) - 1 ) ;
if ( $ ( ".media_detail" ) . attr ( "cid" ) == 0 ) $ ( ".media_detail .media_backward" ) . fadeOut ( ) ;
$ ( ".media_detail .media_forward" ) . fadeIn ( ) ;
$ ( ".media_detail .media_box img" ) . attr ( "src" , JSON . parse ( $ ( ".media_detail" ) . attr ( "pictures" ) ) [ $ ( ".media_detail" ) . attr ( "cid" ) ] ) ;
} ) ;
$ ( document ) . on ( "click" , ".media_detail .media_forward" , function ( ) {
$ ( ".media_detail" ) . attr ( "cid" , parseInt ( $ ( ".media_detail" ) . attr ( "cid" ) ) + 1 ) ;
if ( $ ( ".media_detail" ) . attr ( "cid" ) == JSON . parse ( $ ( ".media_detail" ) . attr ( "pictures" ) ) . length - 1 ) $ ( ".media_detail .media_forward" ) . fadeOut ( ) ;
$ ( ".media_detail .media_backward" ) . fadeIn ( ) ;
$ ( ".media_detail .media_box img" ) . attr ( "src" , JSON . parse ( $ ( ".media_detail" ) . attr ( "pictures" ) ) [ $ ( ".media_detail" ) . attr ( "cid" ) ] ) ;
} ) ;
2019-04-15 16:40:57 +02:00
$ ( document ) . on ( "keyup" , ".status_poll_editor .poll_time input" , function ( ) {
if ( $ ( this ) . is ( ":invalid" ) ) $ ( this ) . parent ( ) . addClass ( "redborder" ) ;
else $ ( this ) . parent ( ) . removeClass ( "redborder" ) ;
} ) ;
$ ( document ) . on ( "click" , ".poll_vote_option,.poll_vote_label,.poll_vote" , function ( e ) {
e . stopPropagation ( ) ;
} ) ;
$ ( document ) . on ( 'click' , '.poll_vote' , function ( e ) {
var poll _id = $ ( this ) . parent ( ) . data ( 'poll' ) ;
var poll _random = $ ( this ) . parent ( ) . data ( 'random' ) ;
if ( poll _id !== null ) {
let poll _options = new Array ;
$ ( '#poll_' + poll _id + '_' + poll _random + ' input[name="poll_' + poll _id + '"]' ) . each ( function ( i ) {
if ( $ ( this ) . is ( ":checked" ) ) poll _options . push ( i ) ;
} ) ;
if ( poll _options . length != 0 ) {
api . post ( 'polls/' + poll _id + '/votes' , { choices : poll _options } , function ( data ) {
$ ( ".poll_" + poll _id ) . after ( poll _template ( data ) ) ;
$ ( ".poll_" + poll _id ) . remove ( ) ;
} ) ;
}
}
return false ;
} ) ;
2020-07-22 18:11:54 +02:00
$ ( document ) . on ( 'click' , '.poll_show_result' , function ( e ) {
var poll _id = $ ( this ) . parent ( ) . data ( 'poll' ) ;
var poll _random = $ ( this ) . parent ( ) . data ( 'random' ) ;
if ( poll _id !== null && poll _random !== null ) {
api . get ( 'polls/' + poll _id , function ( data ) {
data . seeresult = true ;
$ ( "#poll_" + poll _id + "_" + poll _random ) . after ( poll _template ( data ) ) ;
$ ( "#poll_" + poll _id + "_" + poll _random ) . remove ( ) ;
} ) ;
}
return false ;
} ) ;
$ ( document ) . on ( 'click' , '.poll_refresh' , function ( e ) {
var poll _id = $ ( this ) . parent ( ) . parent ( ) . data ( 'poll' ) ;
var poll _random = $ ( this ) . parent ( ) . parent ( ) . data ( 'random' ) ;
if ( poll _id !== null && poll _random !== null ) {
api . get ( 'polls/' + poll _id , function ( data ) {
$ ( "#poll_" + poll _id + "_" + poll _random ) . after ( poll _template ( data ) ) ;
$ ( "#poll_" + poll _id + "_" + poll _random ) . remove ( ) ;
} ) ;
}
return false ;
} ) ;
2019-06-06 19:13:53 +02:00
$ ( document ) . on ( 'click' , '.link_preview' , function ( e ) {
e . stopPropagation ( ) ;
2019-08-21 18:25:27 +02:00
const ytcom = $ ( this ) . data ( "url" ) . match ( /https?:\/\/(www\.)?youtube\.com\/watch\?v=([a-zA-Z\d_-]+)/ ) ;
const ytbe = $ ( this ) . data ( "url" ) . match ( /https?:\/\/(www\.)?youtu\.be\/([a-zA-Z\d_-]+)/ ) ;
2019-09-21 17:13:45 +02:00
const twcom = $ ( this ) . data ( "url" ) . match ( /https?:\/\/(www\.)?twitter\.com\/(.*)/ ) ;
2020-02-09 19:26:29 +01:00
const igpost = $ ( this ) . data ( "url" ) . match ( /https?:\/\/(www\.)?instagram\.com\/p\/([a-zA-Z\d_-]+)/ ) ;
const igacc = $ ( this ) . data ( "url" ) . match ( /https?:\/\/(www\.)?instagram\.com\/([a-zA-Z\d_\.]+)/ ) ;
const fbcom = $ ( this ) . data ( "url" ) . match ( /https?:\/\/(www\.)?facebook\.com\/(.*)/ ) ;
2019-08-21 18:25:27 +02:00
if ( ytcom ) openVideo ( ytcom [ 2 ] ) ;
else if ( ytbe ) openVideo ( ytbe [ 2 ] ) ;
2019-09-21 17:13:45 +02:00
else if ( twcom ) openNitter ( twcom [ 2 ] ) ;
2020-02-09 19:26:29 +01:00
else if ( igpost ) openBibliogram ( "p/" + igpost [ 2 ] ) ;
else if ( igacc ) openBibliogram ( "u/" + igacc [ 2 ] ) ;
else if ( fbcom ) openNoFB ( fbcom [ 2 ] ) ;
2019-08-21 18:25:27 +02:00
else window . open ( $ ( this ) . data ( "url" ) , "_blank" ) ;
2019-06-06 19:13:53 +02:00
} ) ;
2019-05-07 19:19:29 +02:00
$ ( document ) . on ( 'focus' , '.status_textarea textarea,.status_top .status_spoiler' , function ( e ) {
global _focus _textfield = $ ( this ) . data ( "random" ) ;
$ ( ".status_textarea textarea" ) . change ( ) ;
} ) ;
2019-06-20 16:50:42 +02:00
$ ( document ) . on ( 'mouseenter' , 'a.mention' , function ( e ) {
if ( $ ( this ) . data ( "mid" ) ) {
var hover _user = this ;
var user _to = setTimeout ( function ( ) {
api . get ( "accounts/" + $ ( hover _user ) . data ( "mid" ) , function ( data ) {
var user _popup = follows _template ( data ) ;
$ ( user _popup ) . addClass ( "user_popup" ) ;
$ ( user _popup ) . children ( ".follows_profile" ) . append ( ` <ul class="follows_profile_counts">
< li class = "follows_profile_count follows_profile_toots_count" >
< a class = "follows_toots_count_link" >
< span class = "title" > $ { _ _ ( 'TOOTS' ) } < / s p a n >
< span class = "js_follows_toots_count count" > $ { data . statuses _count } < / s p a n >
< / a >
< / l i >
< li class = "follows_profile_count follows_profile_follows_count" >
< a class = "follows_following_count_link" >
< span class = "title" > $ { _ _ ( 'FOLLOWING' ) } < / s p a n >
< span class = "js_follows_following_count count" > $ { data . following _count } < / s p a n >
< / a >
< / l i >
< li class = "follows_profile_count follows_profile_followers_count" >
< a class = "follows_followers_count_link" >
< span class = "title" > $ { _ _ ( 'FOLLOWERS' ) } < / s p a n >
< span class = "js_follows_followers_count count" > $ { data . followers _count } < / s p a n >
< / a >
< / l i >
< / u l > ` ) ;
$ ( user _popup ) . attr ( "style" , "left:" + ( $ ( hover _user ) . position ( ) . left ) + "px" ) ;
$ ( user _popup ) . click ( function ( e ) {
e . stopPropagation ( ) ;
} ) ;
$ ( hover _user ) . parent ( ) . append ( user _popup ) ;
replace _emoji ( ) ;
api . get ( 'accounts/relationships?id[]=' + data . id , function ( RelationshipsObj ) {
if ( RelationshipsObj [ 0 ] . following ) {
const button = $ ( '.follows_profile_box .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" ) ;
}
} ) ;
$ ( this ) . mouseleave ( function ( e ) {
$ ( this ) . off ( "mouseleave" ) ;
var hide _user _to = setTimeout ( function ( ) {
$ ( ".user_popup[mid=" + $ ( hover _user ) . data ( "mid" ) + "]" ) . remove ( ) ;
} , 200 ) ;
$ ( ".user_popup[mid=" + $ ( hover _user ) . data ( "mid" ) + "]" ) . mouseenter ( function ( ) {
clearTimeout ( hide _user _to ) ;
$ ( ".user_popup[mid=" + $ ( hover _user ) . data ( "mid" ) + "]" ) . mouseleave ( function ( ) {
$ ( ".user_popup[mid=" + $ ( hover _user ) . data ( "mid" ) + "]" ) . remove ( ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} , 1000 ) ;
$ ( this ) . mouseleave ( function ( ) {
$ ( this ) . off ( "mouseleave" ) ;
clearTimeout ( user _to ) ;
} ) ;
}
} ) ;
2018-03-11 12:07:57 +01:00
shortcut . add ( "n" , function ( ) {
$ ( "#creat_status" ) . click ( ) ;
} , {
2018-12-02 15:01:21 +01:00
"disable_in_input" : true ,
2018-03-11 12:07:57 +01:00
} ) ;
shortcut . add ( "/" , function ( ) {
$ ( "#search_form" ) . focus ( ) ;
} , {
"disable_in_input" : true ,
'keycode' : 191
} ) ;
2019-12-23 14:58:06 +01:00
shortcut . add ( "Meta+Enter" , function ( e ) {
2018-03-11 12:07:57 +01:00
$ ( ".active_submit_button" ) . click ( ) ;
} ) ;
2019-12-23 14:58:06 +01:00
shortcut . add ( "Ctrl+Enter" , function ( e ) {
2018-03-11 12:07:57 +01:00
$ ( ".active_submit_button" ) . click ( ) ;
} ) ;
shortcut . add ( "." , function ( ) {
$ ( "#js-stream_update" ) . click ( ) ;
} , {
"disable_in_input" : true ,
} ) ;
shortcut . add ( "Shift+h" , function ( ) {
location . href = "/home" ;
} , {
"disable_in_input" : true ,
} ) ;
shortcut . add ( "Shift+l" , function ( ) {
location . href = "/local" ;
} , {
"disable_in_input" : true ,
} ) ;
shortcut . add ( "Shift+f" , function ( ) {
location . href = "/federated" ;
} , {
"disable_in_input" : true ,
} ) ;
shortcut . add ( "Shift+n" , function ( ) {
location . href = "/notifications" ;
} , {
"disable_in_input" : true ,
} ) ;
shortcut . add ( "Shift+p" , function ( ) {
location . href = current _url ;
} , {
"disable_in_input" : true ,
} ) ;
shortcut . add ( "Shift+v" , function ( ) {
location . href = current _favourites _link ;
} , {
"disable_in_input" : true ,
} ) ;
shortcut . add ( "esc" , function ( ) {
$ ( "#js-overlay_content_wrap" ) . click ( ) ;
} ) ;
2018-08-04 15:52:34 +02:00
} ) ;
2020-03-29 20:17:40 +02:00
$ ( document ) . ready ( function ( ) {
api . get ( "announcements" , function ( data ) {
if ( data . length > 0 ) {
$ ( ".article_wrap" ) . before ( $ ( "<div>" ) . addClass ( "announcement_wrap" ) ) ;
for ( var i = 0 ; i < data . length ; i ++ ) {
$ ( ".announcement_wrap" ) . append ( announcement _template ( data [ i ] ) ) ;
}
replace _emoji ( ) ;
replaceInternalLink ( ) ;
$ ( ".announcement" ) . each ( function ( ) { enableReactionPicker ( this ) } ) ;
}
} ) ;
} ) ;