Added notificatins,automatic reconnect with bad connection,added ... at end of shortened links

This commit is contained in:
nipos 2018-05-01 18:51:00 +02:00
parent 4924089e9e
commit ab0bd55cbc
8 changed files with 134 additions and 24 deletions

View File

@ -10,16 +10,17 @@ Follow or Mastodon account and never miss an important update: [@halcyon@social.
## Instances
These instances are publicly accessible and usable by everyone, no matter which Mastodon instance you use.
- https://halcyon.toromino.de - 1.1.3
- https://halcyon.toromino.de - 1.1.4
- https://halcyon.bka.li - 1.1.4
- https://halcyon.tilde.team - 1.1.3
- https://itter.photog.social - 1.1.3
- https://social.dev-wiki.de - 1.1.1
- https://halcyon.bka.li - 1.1.3
- https://halcyon.tilde.team - 1.1.2
- https://itter.photog.social - 1.1.1
- https://halcyon.cybre.space - Outdated
You have your own Halcyon instance and want it to be listed here? Create an issue with the link and we will add it to the list.
## Blog
- Release of Version 1.1.4 - Automatically reconnect on bad connection,now supports desktop notifications,added ... at the end of shortened links
- Release of Version 1.1.3 - New function link previews introduced and bug when replying an toot which already has replies below it fixed (reply to undefined)
- Release of Version 1.1.2 - Privacy modes are now correctly displayed and used for replies,use username if display name doesn't exist,bugs on search page fixed
- Release of Version 1.1.1 - Fixed error 404 when viewing profile of own instance,numbers below profile on the left do now change during session,added nginx config

View File

@ -35,6 +35,9 @@ color: red!important;
.invisible {
display: none!important;
}
.ellipsis:after {
content:"...";
}
.no-events {
pointer-events: none;
}

View File

@ -248,6 +248,24 @@ $(".js_current_followers_count").text(current_followers_count);
$(".current_toots_count_link").attr("href", current_statuses_count_link);
$(".current_following_count_link").attr("href", current_following_count_link);
$(".current_followers_count_link").attr("href", current_followers_count_link);
if(localStorage.setting_link_previews == "true") {
$("#setting_link_previews")[0].checked = true;
}
if(localStorage.setting_desktop_notifications == "true") {
$("#setting_desktop_notifications")[0].checked = true;
if (Notification.permission === 'default') {
Notification.requestPermission(function(p) {
if (p === 'denied') {
localStorage.setItem("setting_desktop_notifications","false");
$("#setting_desktop_notifications")[0].checked = false;
}
});
}
else if(Notification.permission == "denied") {
localStorage.setItem("setting_desktop_notifications","false");
$("#setting_desktop_notifications")[0].checked = false;
}
}
replace_emoji();
}
function putMessage(Message) {
@ -257,3 +275,13 @@ setTimeout(function(){
$("#overlay_message").removeClass("view");
},3000);
};
function pushNotification(title,message) {
if (window.Notification && localStorage.setting_desktop_notifications == "true") {
if (Notification.permission === 'granted') {
notify = new Notification(title, {
body: message,
icon: '/assets/images/halcyon_logo.png'
});
}
}
}

View File

@ -1724,18 +1724,25 @@ $('#header .header_nav_list .notification_badge').removeClass('invisible');
$('#header .header_nav_list .notification_badge').text( current_count );
}
api.stream("user", function(userstream) {
if(userstream.event == "notification" && userstream.payload.type == "follow") {
$(".js_current_followers_count").html(++localStorage.current_followers_count);
}
if (userstream.event === "update" & location.pathname !== "/" ) {
$('#header .header_nav_list .home_badge').removeClass('invisible');
} else if (userstream.event === "notification" & location.pathname !== "/notifications") {
}
else if (userstream.event === "notification" & location.pathname !== "/notifications") {
current_count += 1;
localStorage.setItem("notification_count", current_count );
$('#header .header_nav_list .notification_badge').text( current_count );
if ( $('#header .header_nav_list .notification_badge').hasClass('invisible') ) {
$('#header .header_nav_list .notification_badge').removeClass('invisible')
}
if(userstream.payload.account.display_name.length == 0) {
userstream.payload.account.display_name = userstream.payload.account.username;
}
switch(userstream.payload.type) {
case "favourite":pushNotification("New favourite",userstream.payload.account.display_name+" favourited your toot");break;
case "reblog":pushNotification("New boost",userstream.payload.account.display_name+" boosted your toot");break;
case "follow":pushNotification("New follower",userstream.payload.account.display_name+" followed you");$(".js_current_followers_count").html(++localStorage.current_followers_count);break;
case "mention":pushNotification("New mention",userstream.payload.account.display_name+" mentioned you");break;
}
}
});
}
@ -2455,9 +2462,6 @@ $('.post_steraming_wrap').html(html_post_steraming)
$('.post_privacy_wrap').html(html_post_privacy);
$('.local_instance_wrap').html(html_local_instance);
$('.search_filter_wrap').html(html_search_filter);
if(localStorage.setting_link_previews == "true") {
$("#setting_link_previews")[0].checked = true;
}
return false;
});
$(document).on('change',".post_steraming_wrap select[name='post_steraming']", function(e) {
@ -2486,11 +2490,40 @@ putMessage("Changed setting to "+$(this).val() );
$("#setting_link_previews").change(function() {
if(this.checked) {
localStorage.setItem("setting_link_previews","true");
putMessage("Link preview enabled");
putMessage("Link previews enabled");
}
else {
localStorage.setItem("setting_link_previews","false");
putMessage("Link preview disabled");
putMessage("Link previews disabled");
}
});
$("#setting_desktop_notifications").change(function() {
if(this.checked) {
localStorage.setItem("setting_desktop_notifications","true");
if (Notification.permission === 'default') {
Notification.requestPermission(function(p) {
if (p === 'denied') {
localStorage.setItem("setting_desktop_notifications","false");
$("#setting_desktop_notifications")[0].checked = false;
putMessage("You didn't allow notifications");
}
else {
putMessage("Desktop notifications enabled");
}
});
}
else if(Notification.permission == "denied") {
localStorage.setItem("setting_desktop_notifications","false");
$("#setting_desktop_notifications")[0].checked = false;
putMessage("You didn't allow notifications");
}
else {
putMessage("Desktop notifications enabled");
}
}
else {
localStorage.setItem("setting_desktop_notifications","false");
putMessage("Desktop notifications disabled");
}
});
})

View File

@ -13,8 +13,7 @@ getConfig: function(key) {
return config[key];
},
get: function (endpoint) {
var queryData, callback,
queryStringAppend = "?";
var queryData,callback,queryStringAppend = "?";
if (typeof arguments[1] === "function") {
queryData = {};
callback = arguments[1];
@ -22,6 +21,10 @@ callback = arguments[1];
queryData = arguments[1];
callback = arguments[2];
}
if(typeof queryData == "string") {
queryStringAppend = queryData;
}
else {
for (var i in queryData) {
if (queryData.hasOwnProperty(i)) {
if (typeof queryData[i] === "string") {
@ -31,6 +34,8 @@ queryStringAppend += queryData[i].name + "="+ queryData[i].data + "&";
}
}
}
}
var xquerydata = queryData;
$.ajax({
url: apiBase + endpoint + queryStringAppend,
type: "GET",
@ -41,9 +46,14 @@ responce_headers = xhr.getAllResponseHeaders();
callback(data,textStatus);
},
error: function(xhr, textStatus, errorThrown) {
if(xhr.readyState == 0) {
api.get(endpoint,queryStringAppend,callback);
}
else {
putMessage(`[${xhr.status}] ${xhr.responseJSON['error']}`);
if ( xhr.status === 401 ) {
location.href = "/logout"
location.href = "/logout";
}
}
}
});
@ -79,9 +89,14 @@ responce_headers = xhr.getAllResponseHeaders();
callback(data,textStatus);
},
error: function(xhr, textStatus, errorThrown) {
if(xhr.readyState == 0) {
api.getArray(endpoint,queryData,callback);
}
else {
putMessage(`[${xhr.status}] ${xhr.responseJSON['error']}`);
if ( xhr.status === 401 ) {
location.href = "/logout"
location.href = "/logout";
}
}
}
});
@ -114,9 +129,14 @@ responce_headers = xhr.getAllResponseHeaders();
callback(data,textStatus);
},
error: function(xhr, textStatus, errorThrown) {
if(xhr.readyState == 0) {
api.getOther(endpoint,queryData,callback);
}
else {
putMessage(`[${xhr.status}] ${xhr.responseJSON['error']}`);
if ( xhr.status === 401 ) {
location.href = "/logout"
location.href = "/logout";
}
}
}
});
@ -149,9 +169,14 @@ console.log("Successful POST API request to " +apiBase+endpoint);
callback(data,textStatus)
},
error: function(xhr, textStatus, errorThrown) {
if(xhr.readyState == 0) {
api.post(endpoint,postData,callback);
}
else {
putMessage(`[${xhr.status}] ${xhr.responseJSON['error']}`);
if ( xhr.status === 401 ) {
location.href = "/logout"
location.href = "/logout";
}
}
}
});
@ -177,9 +202,14 @@ console.log("Successful POST API request to " +apiBase+endpoint);
callback(data,textStatus)
},
error: function(xhr, textStatus, errorThrown) {
if(xhr.readyState == 0) {
api.postMedia(endpoint,postData,callback);
}
else {
putMessage(`[${xhr.status}] ${xhr.responseJSON['error']}`);
if ( xhr.status === 401 ) {
location.href = "/logout"
location.href = "/logout";
}
}
}
});
@ -197,16 +227,20 @@ console.log("Successful DELETE API request to " +apiBase+endpoint);
callback(data,textStatus)
},
error: function(xhr, textStatus, errorThrown) {
if(xhr.readyState == 0) {
api.delete(endpoint,callback);
}
else {
putMessage(`[${xhr.status}] ${xhr.responseJSON['error']}`);
if ( xhr.status === 401 ) {
location.href = "/logout"
location.href = "/logout";
}
}
}
});
},
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) {
console.log("Got Data from Stream " + streamType);
event = JSON.parse(event.data);
@ -214,6 +248,9 @@ event.payload = JSON.parse(event.payload);
onData(event);
};
es.onmessage = listener;
es.onclose = function() {
api.stream(streamType,onData);
};
}
};
};

View File

@ -33,6 +33,7 @@ localStorage.setItem('setting_post_privacy', 'public');
localStorage.setItem('setting_local_instance', 'default');
localStorage.setItem('setting_search_filter', 'all');
localStorage.setItem('setting_link_previews', 'true');
localStorage.setItem('setting_desktop_notifications', 'true');
localStorage.setItem('what_to_follow_0', JSON.stringify({id:'',username:'Halcyon',display_name:'Halcyon for Mastodon',url:'https://social.csswg.org/@halcyon',avatar:'https://social.csswg.org/system/accounts/avatars/000/005/666/original/e9a158381ce1249a.png'}));
localStorage.setItem('what_to_follow_1', JSON.stringify({id:'',username:'Gargron',display_name:'Eugen',url:'https://mastodon.social/@Gargron',avatar:'https://files.mastodon.social/accounts/avatars/000/000/001/original/4df197532c6b768c.png'}));
localStorage.setItem('what_to_follow_2', JSON.stringify({id:'',username:'Mastodon',display_name:'Mastodon',url:'https://mastodon.social/@Mastodon',avatar:'https://files.mastodon.social/accounts/avatars/000/013/179/original/27bc451c7713091b.jpg'}));

View File

@ -1 +1 @@
1.1.3
1.1.4

View File

@ -23,5 +23,12 @@
<span></span>
</div>
</div>
<h3>Desktop notifications</h3>
<div class="switch">
<input type="checkbox" id="setting_desktop_notifications">
<div class="switch-btn">
<span></span>
</div>
</div>
</form>
</div>