Replace some removed Mastodon APIs,fix Toot button not locking on CTRL+Enter,make navbar a bit more responsive

This commit is contained in:
nipos 2019-12-23 14:58:06 +01:00
parent 875c3e0b17
commit 6ffa5dab2f
16 changed files with 239 additions and 114 deletions

View File

@ -28,6 +28,7 @@ We moved our instances list to our webpage: https://www.halcyon.social/instances
or read our new documentation pages to install it manually: https://www.halcyon.social/documentation.php?page=install or read our new documentation pages to install it manually: https://www.halcyon.social/documentation.php?page=install
## Blog ## Blog
- Release of Version 2.4.6 - Replace some removed Mastodon APIs,fix Toot button not locking on CTRL+Enter,make navbar a bit more responsive
- Release of Version 2.4.5 - Support for emoji categories,added links to admin panel,rewrite links to Invidious and Nitter at compose,bugfixes - Release of Version 2.4.5 - Support for emoji categories,added links to admin panel,rewrite links to Invidious and Nitter at compose,bugfixes
- Release of Version 2.4.4 - Option to rewrite all Twitter links to Nitter,click on animated GIF works like image now,full height for images option now works for animated GIF - Release of Version 2.4.4 - Option to rewrite all Twitter links to Nitter,click on animated GIF works like image now,full height for images option now works for animated GIF
- Release of Version 2.4.3 - Fixed login,fixed YouPlay/Invidious embeds,fixed empty image placeholder when audio available,improved status template code - Release of Version 2.4.3 - Fixed login,fixed YouPlay/Invidious embeds,fixed empty image placeholder when audio available,improved status template code

View File

@ -2993,3 +2993,16 @@ color:#FFFFFF;
.media_attachments_delete_button i{ .media_attachments_delete_button i{
margin:5px; margin:5px;
} }
@media(max-width:899px) {
#header .header_nav_wrap .header_left_box ul.header_nav_list li.header_nav_item a > span,
#header .header_nav_wrap .header_right_box ul.header_nav_list li.search_form_wrap,
#header .header_nav_wrap .header_right_box ul.header_nav_list li.toot_button_wrap .toot_button_label > span {
display:none;
}
#header .header_nav_wrap .header_right_box ul.header_nav_list li.toot_button_wrap .toot_button {
width:40px;
}
#header .header_nav_wrap .header_left_box ul.header_nav_list li.header_nav_item a {
padding-right:4px;
}
}

View File

@ -21,14 +21,14 @@ replace_emoji();
function searchremotefill(text) { function searchremotefill(text) {
if(text == "@") searchlocalfill(); if(text == "@") searchlocalfill();
else { else {
api.get("search?q="+encodeURIComponent(text)+"&resolve=false&limit=5",function(data) { api.search("q="+encodeURIComponent(text)+"&resolve=false&limit=5",function(data) {
if(data.hashtags.length == 0 && data.accounts.length == 0) $(".header_search_suggestions").addClass("invisible"); if(data.hashtags.length == 0 && data.accounts.length == 0) $(".header_search_suggestions").addClass("invisible");
else { else {
var dropdown = $("<ul>").addClass("account_list"); var dropdown = $("<ul>").addClass("account_list");
for(var i=0;i<data.hashtags.length;i++) { for(var i=0;i<data.hashtags.length;i++) {
if(i == 5) break; if(i == 5) break;
dropdown.append($("<li>").data("value",data.hashtags[i]).addClass("account_box").append($("<div>").addClass("icon_box").append($("<span>").addClass("emoji_poss").html("#️⃣").css("float","left").css("font-size","32px"))) dropdown.append($("<li>").data("value",data.hashtags[i].name).addClass("account_box").append($("<div>").addClass("icon_box").append($("<span>").addClass("emoji_poss").html("#️⃣").css("float","left").css("font-size","32px")))
.append($("<div>").addClass("label_box").append($("<span>").addClass("dn").append($("<h3>").html("#"+data.hashtags[i])))).click(function() { .append($("<div>").addClass("label_box").append($("<span>").addClass("dn").append($("<h3>").html("#"+data.hashtags[i].name)))).click(function() {
window.location.href = "/search?q="+encodeURIComponent($(this).data("value")); window.location.href = "/search?q="+encodeURIComponent($(this).data("value"));
})); }));
} }

View File

@ -61,7 +61,6 @@ blurredEle && addToken(blurredEle,prepend,callback);
blurredEle = null; blurredEle = null;
getDropDown().removeClass('showDropDown').addClass('hideDropDown'); getDropDown().removeClass('showDropDown').addClass('hideDropDown');
}); });
if(resultname) {
if(resultname == "acct") { if(resultname == "acct") {
if(ele.display_name == "") ele.display_name = ele.username; if(ele.display_name == "") ele.display_name = ele.username;
ele.display_name = htmlEscape(ele.display_name); ele.display_name = htmlEscape(ele.display_name);
@ -72,6 +71,11 @@ $(liNode).data("value",prepend+ele[resultname]+" ");
$(liNode).addClass("account_box").append($("<div>").addClass("icon_box").append($("<img>").attr("src",ele.avatar).css("float","left"))) $(liNode).addClass("account_box").append($("<div>").addClass("icon_box").append($("<img>").attr("src",ele.avatar).css("float","left")))
.append($("<div>").addClass("label_box").append($("<span>").addClass("dn").append($("<h3>").html(ele.display_name).addClass("emoji_poss"))).append($("<span>").addClass("un").html(prepend+ele.acct))); .append($("<div>").addClass("label_box").append($("<span>").addClass("dn").append($("<h3>").html(ele.display_name).addClass("emoji_poss"))).append($("<span>").addClass("un").html(prepend+ele.acct)));
} }
else if(resultname == "name") {
$(liNode).data("value",prepend+ele[resultname]+" ");
$(liNode).addClass("account_box").append($("<div>").addClass("icon_box").append($("<span>").addClass("emoji_poss").html("#️⃣").css("float","left").css("font-size","32px")))
.append($("<div>").addClass("label_box").append($("<span>").addClass("dn").append($("<h3>").html(prepend+ele[resultname]))));
}
else { else {
$(liNode).data("value",prepend+ele[resultname]+": "); $(liNode).data("value",prepend+ele[resultname]+": ");
if(ele.value) { if(ele.value) {
@ -83,12 +87,6 @@ $(liNode).addClass("account_box").append($("<div>").addClass("icon_box").append(
.append($("<div>").addClass("label_box").append($("<span>").addClass("dn").append($("<h3>").html(ele.name)))); .append($("<div>").addClass("label_box").append($("<span>").addClass("dn").append($("<h3>").html(ele.name))));
} }
} }
}
else {
$(liNode).data("value",prepend+ele+" ");
$(liNode).addClass("account_box").append($("<div>").addClass("icon_box").append($("<span>").addClass("emoji_poss").html("#️⃣").css("float","left").css("font-size","32px")))
.append($("<div>").addClass("label_box").append($("<span>").addClass("dn").append($("<h3>").html(prepend+ele))));
}
node.append(liNode); node.append(liNode);
} }
}); });
@ -184,7 +182,7 @@ return;
} }
if(extractNewInputs(node,startKey).length > 1 && extractNewInputs(node,startKey).indexOf(endKey) == -1) { if(extractNewInputs(node,startKey).length > 1 && extractNewInputs(node,startKey).indexOf(endKey) == -1) {
if(config.arrayname) { if(config.arrayname) {
api.get("search?q="+encodeURIComponent(extractNewInputs(node,startKey))+"&resolve=false&limit=5",function(matchedData) { api.search("q="+encodeURIComponent(extractNewInputs(node,startKey))+"&resolve=false&limit=5",function(matchedData) {
matchedData = matchedData[config.arrayname]; matchedData = matchedData[config.arrayname];
if(matchedData.length) { if(matchedData.length) {
if(hasDropDown()){ if(hasDropDown()){

View File

@ -401,7 +401,7 @@ setWhoToFollow();
} }
} }
function addFollowProfile(id,account) { function addFollowProfile(id,account) {
api.get('search',[{name:'q',data:"@"+account},{name:'resolve',data:'true'}], function(search) { api.search('q='+encodeURIComponent("@"+account)+"&limit=1&resolve=true",function(search) {
search.accounts[0].display_name = htmlEscape(search.accounts[0].display_name); search.accounts[0].display_name = htmlEscape(search.accounts[0].display_name);
for(i=0;i<search.accounts[0].emojis.length;i++) { for(i=0;i<search.accounts[0].emojis.length;i++) {
search.accounts[0].display_name = search.accounts[0].display_name.replace(new RegExp(":"+search.accounts[0].emojis[i].shortcode+":","g"),"<img src='"+search.accounts[0].emojis[i].url+"' class='emoji'>"); search.accounts[0].display_name = search.accounts[0].display_name.replace(new RegExp(":"+search.accounts[0].emojis[i].shortcode+":","g"),"<img src='"+search.accounts[0].emojis[i].url+"' class='emoji'>");
@ -454,7 +454,7 @@ ctx.fillText("😗",-2,4);
return ctx.getImageData(0,0,1,1).data[3] > 0; return ctx.getImageData(0,0,1,1).data[3] > 0;
} }
function openStatus(link) { function openStatus(link) {
api.get("search?q="+link,function(response) { api.search("q="+encodeURIComponent(link),function(response) {
if(response.statuses.length > 0) { if(response.statuses.length > 0) {
var data = response.statuses[0]; var data = response.statuses[0];
if(data.account.acct.indexOf("@") == -1) { if(data.account.acct.indexOf("@") == -1) {
@ -541,7 +541,7 @@ else return "";
function enableAutoComplete(textarea) { function enableAutoComplete(textarea) {
if(localStorage.setting_compose_autocomplete == "true") { if(localStorage.setting_compose_autocomplete == "true") {
textarea.autoCompleteToken({instance:1,startkey:"@",endkey:" ",arrayname:"accounts",resultname:"acct"}); textarea.autoCompleteToken({instance:1,startkey:"@",endkey:" ",arrayname:"accounts",resultname:"acct"});
textarea.autoCompleteToken({instance:2,startkey:"#",endkey:" ",arrayname:"hashtags"}); textarea.autoCompleteToken({instance:2,startkey:"#",endkey:" ",arrayname:"hashtags",resultname:"name"});
textarea.autoCompleteToken({instance:3,startkey:":",endkey:";",source:actEmojiData,resultname:"name",callback:function() { textarea.autoCompleteToken({instance:3,startkey:":",endkey:";",source:actEmojiData,resultname:"name",callback:function() {
textarea.trigger({"type":"keyup","key":":"}); textarea.trigger({"type":"keyup","key":":"});
}}); }});
@ -722,3 +722,48 @@ if(status.account.display_name.length == 0) status.account.display_name = status
} }
return status; return status;
} }
function renderTimeline(statuses,show_replies,level) {
for(let i in statuses) {
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 && !level.match(/accounts\/\d+\/statuses/)) && !(statuses[i].visibility == "direct" && level == "timelines/home")) {
timeline_template(statuses[i]).appendTo("#js-timeline");
if(statuses[i].in_reply_to_id && level === "timelines/home" | level === "timelines/public") {
if(localStorage.setting_thread_view == "true") {
(function(this_id) {
api.get('statuses/'+statuses[i].id+"/context", function(context) {
for(var b=0;b<context.ancestors.length;b++) {
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(context.ancestors[b].content.match(new RegExp(current_filters[a].phrase))) filterreplystatus = true;
}
else {
if(context.ancestors[b].content.match(new RegExp("[^a-zA-Z1-9]"+current_filters[a].phrase+"[^a-zA-Z1-9]"))) filterreplystatus = true;
}
}
}
if(filterreplystatus == false) {
$("#js-timeline .toot_entry[sid='"+context.ancestors[b].id+"']").remove();
$("#js-timeline .toot_entry[sid='"+this_id+"']").before(context_template(context.ancestors[b], 'ancestors_status default_padding'));
timeline_hide_status.push(context.ancestors[b].id);
replace_emoji();
}
}
});
})(statuses[i].id);
}
}
}
}
}

View File

@ -285,49 +285,7 @@ var load_options = [];
} }
api.get(level, load_options, function(statuses) { api.get(level, load_options, function(statuses) {
timeline_hide_status = new Array; timeline_hide_status = new Array;
for(let i in statuses) { renderTimeline(statuses,show_replies,level);
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 && !level.match(/accounts\/\d+\/statuses/)) && !(statuses[i].visibility == "direct" && level == "timelines/home")) {
timeline_template(statuses[i]).appendTo("#js-timeline");
if(statuses[i].in_reply_to_id && level === "timelines/home" | level === "timelines/public") {
if(localStorage.setting_thread_view == "true") {
(function(this_id) {
api.get('statuses/'+statuses[i].id+"/context", function(context) {
for(var b=0;b<context.ancestors.length;b++) {
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(context.ancestors[b].content.match(new RegExp(current_filters[a].phrase))) filterreplystatus = true;
}
else {
if(context.ancestors[b].content.match(new RegExp("[^a-zA-Z1-9]"+current_filters[a].phrase+"[^a-zA-Z1-9]"))) filterreplystatus = true;
}
}
}
if(filterreplystatus == false) {
$("#js-timeline .toot_entry[sid='"+context.ancestors[b].id+"']").remove();
$("#js-timeline .toot_entry[sid='"+this_id+"']").before(context_template(context.ancestors[b], 'ancestors_status default_padding'));
timeline_hide_status.push(context.ancestors[b].id);
replace_emoji();
}
}
});
})(statuses[i].id);
}
}
}
}
links = getLinkFromXHRHeader(responce_headers); links = getLinkFromXHRHeader(responce_headers);
replaceInternalLink(); replaceInternalLink();
replace_emoji(); replace_emoji();
@ -344,50 +302,7 @@ if(links && links['next']) {
load_options.unshift({name:"max_id",data:links['next'].match(/max_id=(.+)&?/)[1]}); load_options.unshift({name:"max_id",data:links['next'].match(/max_id=(.+)&?/)[1]});
api.get(level, load_options, function(statuses) { api.get(level, load_options, function(statuses) {
if (statuses.length) { if (statuses.length) {
for(let i in statuses) { renderTimeline(statuses,show_replies,level);
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 && timeline_hide_status.indexOf(statuses[i].id) == -1 && !(show_replies == "false" && statuses[i].in_reply_to_id) && !(localStorage.setting_show_bots == "false" && statuses[i].account.bot == true && !level.match(/accounts\/\d+\/statuses/)) && !(statuses[i].visibility == "direct" && level == "timelines/home")) {
timeline_template(statuses[i]).appendTo("#js-timeline");
if(statuses[i].in_reply_to_id && level === "timelines/home" | level === "timelines/public") {
if(localStorage.setting_thread_view == "true") {
(function(this_id) {
api.get('statuses/'+statuses[i].id+"/context", function(context) {
console.log(this_id);
for(var b=0;b<context.ancestors.length;b++) {
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(context.ancestors[b].content.match(new RegExp(current_filters[a].phrase))) filterreplystatus = true;
}
else {
if(context.ancestors[b].content.match(new RegExp("[^a-zA-Z1-9]"+current_filters[a].phrase+"[^a-zA-Z1-9]"))) filterreplystatus = true;
}
}
}
if(filterreplystatus == false) {
$("#js-timeline .toot_entry[sid='"+context.ancestors[b].id+"']").remove();
$("#js-timeline .toot_entry[sid='"+this_id+"']").before(context_template(context.ancestors[b], 'ancestors_status default_padding'));
timeline_hide_status.push(context.ancestors[b].id);
replace_emoji();
}
}
});
})(statuses[i].id);
}
}
}
}
links = getLinkFromXHRHeader(responce_headers); links = getLinkFromXHRHeader(responce_headers);
replaceInternalLink(); replaceInternalLink();
replace_emoji(); replace_emoji();
@ -408,6 +323,103 @@ isSyncing = true;
}; };
}; };
}); });
startStreaming(level,load_options,show_replies);
}
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();
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;
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) {
links = getLinkFromXHRHeader(responce_headers);
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");
replaceInternalLink();
replace_emoji();
if (!statuses.length) {
$('#js-timeline_footer > i').css({"display":"none"});
}
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();
}
else {
$('.timeline_footer > i').css({"display":"none"});
$('.timeline_footer').append('<img style="width: 30%;opacity: .3;" src="/assets/images/halcyon.png">');
isSyncing = true;
}
};
};
});
startStreaming("timelines/direct",load_options,show_replies);
}
function startStreaming(level,load_options,show_replies) {
$(function() { $(function() {
if(level === "timelines/home") { if(level === "timelines/home") {
var streamscope = "user", var streamscope = "user",
@ -442,6 +454,7 @@ if(userstream.event === "update") {
if(streaming_option === "manual") { if(streaming_option === "manual") {
if(!$('.toot_entry[sid="'+userstream.payload.id+'"]').length) { if(!$('.toot_entry[sid="'+userstream.payload.id+'"]').length) {
var filterstatus = false; var filterstatus = false;
if(scope == "direct" && userstream.payload.account.id == current_id) filterstatus = true;
for(var a=0;a<current_filters.length;a++) { 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(((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(current_filters[a].whole_word == false) {
@ -465,6 +478,7 @@ else if (streaming_option === "auto") {
var scrollTop = window.pageYOffset || document.documentElement.scrollTop; var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
if(!$('.toot_entry[sid="'+userstream.payload.id+'"]').length) { if(!$('.toot_entry[sid="'+userstream.payload.id+'"]').length) {
var filterstatus = false; var filterstatus = false;
if(scope == "direct" && userstream.payload.account.id == current_id) filterstatus = true;
for(var a=0;a<current_filters.length;a++) { 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(((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(current_filters[a].whole_word == false) {
@ -516,6 +530,7 @@ var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
if(scrollTop == 0) { if(scrollTop == 0) {
if(!$('.toot_entry[sid="'+userstream.payload.id+'"]').length) { if(!$('.toot_entry[sid="'+userstream.payload.id+'"]').length) {
var filterstatus = false; var filterstatus = false;
if(scope == "direct" && userstream.payload.account.id == current_id) filterstatus = true;
for(var a=0;a<current_filters.length;a++) { 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(((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(current_filters[a].whole_word == false) {
@ -929,7 +944,7 @@ load_options.shift();
}); });
}; };
function setUserSearch(query) { function setUserSearch(query) {
api.get('search', [{name:'q',data:query},{name:'resolve',data:'true'}], function(search) { api.search('q='+encodeURIComponent(query)+"&resolve=true",function(search) {
for(let i in search.accounts) { for(let i in search.accounts) {
follows_template(search.accounts[i]).appendTo("#js-follows_profile");; follows_template(search.accounts[i]).appendTo("#js-follows_profile");;
} }
@ -1524,9 +1539,11 @@ $('#'+place+'_status_form .media_attachments_preview').removeClass("over");
$('#'+place+'_status_form .media_attachments_preview').removeClass("moving"); $('#'+place+'_status_form .media_attachments_preview').removeClass("moving");
}); });
$(document).on('click','#'+place+'_status_form .submit_status_label', function(e) { $(document).on('click','#'+place+'_status_form .submit_status_label', function(e) {
setTimeout(function() {
$('#'+place+'_status_form').addClass('ready'); $('#'+place+'_status_form').addClass('ready');
$('#'+place+'_status_form .status_textarea').addClass('disallow_select'); $('#'+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>'); $('#'+place+'_status_form .character_count').html('<i class="fa fa-circle-o-notch fa-spin" aria-hidden="true"></i>');
},0);
const form = document.forms[place+"_status_form"]; const form = document.forms[place+"_status_form"];
if(!Object.keys(image_uploads[place]).length || !$('#'+place+'_status_form .status_poll_editor').hasClass("invisible")) { if(!Object.keys(image_uploads[place]).length || !$('#'+place+'_status_form .status_poll_editor').hasClass("invisible")) {
const params = { const params = {
@ -2215,10 +2232,10 @@ $("#search_form").focus();
"disable_in_input":true, "disable_in_input":true,
'keycode':191 'keycode':191
}); });
shortcut.add("Meta+Enter",function() { shortcut.add("Meta+Enter",function(e) {
$(".active_submit_button").click(); $(".active_submit_button").click();
}); });
shortcut.add("Ctrl+Enter",function() { shortcut.add("Ctrl+Enter",function(e) {
$(".active_submit_button").click(); $(".active_submit_button").click();
}); });
shortcut.add(".",function() { shortcut.add(".",function() {

View File

@ -329,8 +329,59 @@ location.href = "/logout";
} }
}); });
}, },
search: function (queryString) {
var queryData,callback,failback,queryStringAppend = "?";
if (typeof arguments[1] === "function") {
queryData = {};
callback = arguments[1];
if(arguments[2]) failback = arguments[2];
} else {
queryData = arguments[1];
callback = arguments[2];
if(arguments[3]) failback = arguments[3];
}
if(typeof queryData == "string") {
queryStringAppend = queryData;
}
else {
for (var i in queryData) {
if (queryData.hasOwnProperty(i)) {
if (typeof queryData[i] === "string") {
queryStringAppend += queryData[i] + "&";
} else if (typeof queryData[i] === "object") {
queryStringAppend += queryData[i].name + "="+ queryData[i].data + "&";
}
}
}
}
var xquerydata = queryData;
$.ajax({
url: config.instance + "/api/v2/search?" + queryString + queryStringAppend,
type: "GET",
headers: {"Authorization": "Bearer " + config.api_user_token},
success: function(data, textStatus, xhr) {
console.log("Successful GET API request to " +config.instance + "/api/v2/search");
responce_headers = xhr.getAllResponseHeaders();
callback(data,textStatus);
},
error: function(xhr, textStatus, errorThrown) {
if(xhr.readyState == 0) {
api.search(queryString,queryStringAppend,callback);
}
else if(typeof failback == "function") failback();
else {
if(xhr.responseText.length > 0) {
putMessage(`[${xhr.status}] ${xhr.responseJSON['error']}`);
if ( xhr.status === 401 ) {
location.href = "/logout";
}
}
}
}
});
},
stream: function (streamType, onData) { stream: function (streamType, onData) {
var es = new WebSocket("wss://" + apiBase.substr(8) + "streaming?access_token=" + config.api_user_token + "&stream=" + streamType); var es = new WebSocket("wss://" + apiBase.substr(8) + "streaming/?access_token=" + config.api_user_token + "&stream=" + streamType);
var listener = function(event) { var listener = function(event) {
console.log("Got Data from Stream " + streamType); console.log("Got Data from Stream " + streamType);
if(event.data.length != 0) { if(event.data.length != 0) {

View File

@ -37,7 +37,7 @@ View <span></span> new Toots
</main> </main>
<script> <script>
current_file = location.pathname; current_file = location.pathname;
setTimeline("timelines/direct",[],"true"); setDirectTimeline();
$('title').text('Halcyon / Direct'); $('title').text('Halcyon / Direct');
</script> </script>
<?php include ('footer.php'); ?> <?php include ('footer.php'); ?>

View File

@ -91,7 +91,7 @@ $domain = preg_split("/@/",$_GET['user'])[2];
$url= "https://$domain/@$name"; $url= "https://$domain/@$name";
?> ?>
const query = '<?= htmlspecialchars((string)filter_input(INPUT_GET, 'user'), ENT_QUOTES) ?>'; const query = '<?= htmlspecialchars((string)filter_input(INPUT_GET, 'user'), ENT_QUOTES) ?>';
api.get('search',[{name:'q',data:query},{name:'resolve',data:'true'}],function(search) { api.search('q='+encodeURIComponent(query)+"&resolve=true&limit=1",function(search) {
if(!search.accounts.length) { if(!search.accounts.length) {
location.href = "/404.php"; location.href = "/404.php";
} }

View File

@ -83,7 +83,7 @@ $domain = preg_split("/@/", $_GET['user'])[2];
$url= "https://$domain/@$name"; $url= "https://$domain/@$name";
?> ?>
const query = '<?= htmlspecialchars((string)filter_input(INPUT_GET, 'user'), ENT_QUOTES) ?>'; const query = '<?= htmlspecialchars((string)filter_input(INPUT_GET, 'user'), ENT_QUOTES) ?>';
api.get('search', [{name:'q',data:query},{name:'resolve',data:'true'}], function(search) { api.search('q='+encodeURIComponent(query)+"&resolve=true&limit=1",function(search) {
if ( !search.accounts.length ) { if ( !search.accounts.length ) {
location.href="/404.php"; location.href="/404.php";
} else if ("@"+search.accounts[0].acct === query || "@"+search.accounts[0].acct+"@"+localStorage.current_instance === query) { } else if ("@"+search.accounts[0].acct === query || "@"+search.accounts[0].acct+"@"+localStorage.current_instance === query) {

View File

@ -68,7 +68,7 @@ $domain = preg_split("/@/", $_GET['user'])[2];
$url= "https://$domain/@$name"; $url= "https://$domain/@$name";
?> ?>
const query = '<?= htmlspecialchars((string)filter_input(INPUT_GET, 'user'), ENT_QUOTES) ?>'; const query = '<?= htmlspecialchars((string)filter_input(INPUT_GET, 'user'), ENT_QUOTES) ?>';
api.get('search', [{name:'q',data:query},{name:'resolve',data:'true'}], function(search) { api.search('q='+encodeURIComponent(query)+"&resolve=true&limit=1",function(search) {
if ( !search.accounts.length ) { if ( !search.accounts.length ) {
location.href="/404.php"; location.href="/404.php";
} else if ("@"+search.accounts[0].acct === query || "@"+search.accounts[0].acct+"@"+localStorage.current_instance === query) { } else if ("@"+search.accounts[0].acct === query || "@"+search.accounts[0].acct+"@"+localStorage.current_instance === query) {

View File

@ -68,7 +68,7 @@ $domain = preg_split("/@/", $_GET['user'])[2];
$url= "https://$domain/@$name"; $url= "https://$domain/@$name";
?> ?>
const query = '<?= htmlspecialchars((string)filter_input(INPUT_GET, 'user'), ENT_QUOTES) ?>'; const query = '<?= htmlspecialchars((string)filter_input(INPUT_GET, 'user'), ENT_QUOTES) ?>';
api.get('search', [{name:'q',data:query},{name:'resolve',data:'true'}], function(search) { api.search('q='+encodeURIComponent(query)+"&resolve=true&limit=1",function(search) {
if ( !search.accounts.length ) { if ( !search.accounts.length ) {
location.href="/404.php"; location.href="/404.php";
} else if ("@"+search.accounts[0].acct === query || "@"+search.accounts[0].acct+"@"+localStorage.current_instance === query) { } else if ("@"+search.accounts[0].acct === query || "@"+search.accounts[0].acct+"@"+localStorage.current_instance === query) {

View File

@ -100,7 +100,7 @@ $domain = preg_split("/@/", $_GET['user'])[2];
$url= "https://$domain/@$name"; $url= "https://$domain/@$name";
?> ?>
const query = '<?= htmlspecialchars((string)filter_input(INPUT_GET, 'user'), ENT_QUOTES) ?>'; const query = '<?= htmlspecialchars((string)filter_input(INPUT_GET, 'user'), ENT_QUOTES) ?>';
api.get('search', [{name:'q',data:query},{name:'resolve',data:'true'}], function(search) { api.search('q='+encodeURIComponent(query)+"&resolve=true&limit=1",function(search) {
if ( !search.accounts.length ) { if ( !search.accounts.length ) {
location.href = "/404.php"; location.href = "/404.php";
} else if ("@"+search.accounts[0].acct === query || "@"+search.accounts[0].acct+"@"+localStorage.current_instance === query) { } else if ("@"+search.accounts[0].acct === query || "@"+search.accounts[0].acct+"@"+localStorage.current_instance === query) {

View File

@ -100,7 +100,7 @@ $domain = preg_split("/@/", $_GET['user'])[2];
$url= "https://$domain/@$name"; $url= "https://$domain/@$name";
?> ?>
const query = '<?= htmlspecialchars((string)filter_input(INPUT_GET, 'user'), ENT_QUOTES) ?>'; const query = '<?= htmlspecialchars((string)filter_input(INPUT_GET, 'user'), ENT_QUOTES) ?>';
api.get('search', [{name:'q',data:query},{name:'resolve',data:'true'}], function(search) { api.search('q='+encodeURIComponent(query)+"&resolve=true&limit=1",function(search) {
if ( !search.accounts.length ) { if ( !search.accounts.length ) {
location.href="/404.php"; location.href="/404.php";
} else if ("@"+search.accounts[0].acct === query || "@"+search.accounts[0].acct+"@"+localStorage.current_instance === query) { } else if ("@"+search.accounts[0].acct === query || "@"+search.accounts[0].acct+"@"+localStorage.current_instance === query) {

View File

@ -1 +1 @@
2.4.5 2.4.6

View File

@ -28,7 +28,7 @@ fcount = 30;
} }
for(i=0;i<fcount;i++) { for(i=0;i<fcount;i++) {
if(current_following_accts.indexOf(wtfprofiles[displayed+i]) == -1) { if(current_following_accts.indexOf(wtfprofiles[displayed+i]) == -1) {
api.get('search',[{name:'q',data:"@"+wtfprofiles[displayed+i]},{name:'resolve',data:'true'}], function(search) { api.search('q='+encodeURIComponent(wtfprofiles[displayed+i])+"&resolve=true&limit=1",function(search) {
follows_template(search.accounts[0]).appendTo("#js-follows_profile"); follows_template(search.accounts[0]).appendTo("#js-follows_profile");
replace_emoji(); replace_emoji();
if(i = 29) { if(i = 29) {