2017-03-18 09:21:18 +00:00
|
|
|
"use strict";
|
|
|
|
|
2016-12-18 15:53:28 +00:00
|
|
|
// vendor libraries
|
2017-03-18 09:21:18 +00:00
|
|
|
const $ = require("jquery");
|
2016-12-18 15:53:28 +00:00
|
|
|
|
|
|
|
// our libraries
|
2017-04-18 07:31:46 +00:00
|
|
|
const socket = require("./socket");
|
2016-10-09 19:14:02 +00:00
|
|
|
|
2018-07-06 18:15:15 +00:00
|
|
|
const {vueApp, findChannel} = require("./vue");
|
|
|
|
|
2018-07-08 14:57:02 +00:00
|
|
|
window.vueMounted = () => {
|
|
|
|
require("./socket-events");
|
|
|
|
const contextMenuFactory = require("./contextMenuFactory");
|
|
|
|
const utils = require("./utils");
|
|
|
|
require("./webpush");
|
|
|
|
require("./keybinds");
|
|
|
|
|
2018-01-11 11:33:36 +00:00
|
|
|
const sidebar = $("#sidebar, #footer");
|
|
|
|
const viewport = $("#viewport");
|
2014-08-16 16:15:17 +00:00
|
|
|
|
2017-11-01 09:16:19 +00:00
|
|
|
viewport.on("contextmenu", ".network .chan", function(e) {
|
2018-03-26 08:08:43 +00:00
|
|
|
return contextMenuFactory.createContextMenu($(this), e).show();
|
2017-11-01 09:16:19 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
viewport.on("click contextmenu", ".user", function(e) {
|
2018-01-09 16:16:20 +00:00
|
|
|
// If user is selecting text, do not open context menu
|
|
|
|
// This primarily only targets mobile devices where selection is performed with touch
|
|
|
|
if (!window.getSelection().isCollapsed) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-03-26 08:08:43 +00:00
|
|
|
return contextMenuFactory.createContextMenu($(this), e).show();
|
2016-03-19 18:20:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
viewport.on("click", "#chat .menu", function(e) {
|
2019-07-17 09:33:59 +00:00
|
|
|
e.currentTarget = $(
|
|
|
|
`#sidebar .chan[data-id="${$(this)
|
|
|
|
.closest(".chan")
|
|
|
|
.attr("data-id")}"]`
|
|
|
|
)[0];
|
2018-03-26 08:08:43 +00:00
|
|
|
return contextMenuFactory.createContextMenu($(this), e).show();
|
2016-02-12 11:34:10 +00:00
|
|
|
});
|
|
|
|
|
2017-09-19 09:18:54 +00:00
|
|
|
if (navigator.platform.match(/(Mac|iPhone|iPod|iPad)/i)) {
|
|
|
|
$(document.body).addClass("is-apple");
|
|
|
|
}
|
|
|
|
|
2018-07-09 17:31:48 +00:00
|
|
|
viewport.on("click", ".inline-channel", function() {
|
2018-04-28 08:19:49 +00:00
|
|
|
const name = $(this).attr("data-chan");
|
2018-01-11 11:33:36 +00:00
|
|
|
const chan = utils.findCurrentNetworkChan(name);
|
2016-05-30 19:38:53 +00:00
|
|
|
|
2018-07-09 17:31:48 +00:00
|
|
|
if (chan) {
|
|
|
|
$(`#sidebar .chan[data-id="${chan.id}"]`).trigger("click");
|
2016-02-29 16:48:57 +00:00
|
|
|
}
|
2018-05-29 09:56:41 +00:00
|
|
|
|
|
|
|
socket.emit("input", {
|
2018-07-09 17:31:48 +00:00
|
|
|
target: vueApp.activeChannel.channel.id,
|
2018-05-29 09:56:41 +00:00
|
|
|
text: "/join " + name,
|
|
|
|
});
|
2016-02-29 16:48:57 +00:00
|
|
|
});
|
|
|
|
|
2019-07-15 19:26:32 +00:00
|
|
|
const openWindow = function openWindow(e, {pushState, replaceHistory} = {}) {
|
2018-01-11 11:33:36 +00:00
|
|
|
const self = $(this);
|
2018-04-28 08:19:49 +00:00
|
|
|
const target = self.attr("data-target");
|
2018-02-20 07:28:04 +00:00
|
|
|
|
2014-08-16 16:15:17 +00:00
|
|
|
if (!target) {
|
2018-05-02 13:57:19 +00:00
|
|
|
return;
|
2014-08-16 16:15:17 +00:00
|
|
|
}
|
|
|
|
|
Improve UI of the About section and changelog viewer
- Keep consistent width between the Help page and Changelog (which is already different from other windows 😠)
- Add icons to the About links
- Make sure `li` elements (i.e. all the lists in changelogs) are consistent in size with rest of the client
- Display version and release notes link on the "About The Lounge" header line, smaller, pushed to the right
- Check new releases when opening the Help window in order to display it without having to open the release notes. Release notes are being fed to the Changelog page at that moment to avoid fetching twice.
- Re-check version/fetch release notes after 24h. Since The Lounge can now run 24/7, reconnect when losing the network, we have to assume an "always-on" usage.
- Change icon, animate background color when getting response from GitHub to avoid flashing.
- Combine click handlers with our wonderful window management. These were the same handler, even with similar checks (`target` exists, etc.), just in 2 different places. This is necessary for the next item.
- Combine "Open release notes" and "Go back to Help" button behaviors with window management handlers. The window management code is gross as ever, and is in desperate need of a refactor, but at least there is no duplicated code for the same behavior + history management. This fixes the "Next" history behavior (however reloading the app while viewing the notes does not load on the notes, but this is a bug for a different PR!).
- Added a rule in the history management thingy: if a link we want to add history handling to has an `id`, store that in the state
- Added a button to go back to the Help window
- Fixed links to releases
- Send user to the GitHub issues *list* instead of *new issue form* because if they do not have a GitHub account, they will be redirected to the login page, which is a rather unpleasant experience when you are already confused...
- Fixed a bug that would return data about a new release in `latest` even though it is already the `current`. It was showing the current version as "The Lounge v... is now available".
- Added https://user-images.githubusercontent.com to the CSP rule when prefetch storage is enabled, because that is where we have stored screenshots in the changelog so far. Meh (we can improve that later if we decide to have a dedicated place for screenshots).
- Fetch changelog info even in public mode because users in public mode can access the release notes. They do not see the result of the version checker however.
2017-12-23 03:40:41 +00:00
|
|
|
// This is a rather gross hack to account for sources that are in the
|
|
|
|
// sidebar specifically. Needs to be done better when window management gets
|
|
|
|
// refactored.
|
2017-12-24 07:51:58 +00:00
|
|
|
const inSidebar = self.parents("#sidebar, #footer").length > 0;
|
2019-02-12 12:59:06 +00:00
|
|
|
const channel = inSidebar ? findChannel(Number(self.attr("data-id"))) : null;
|
Improve UI of the About section and changelog viewer
- Keep consistent width between the Help page and Changelog (which is already different from other windows 😠)
- Add icons to the About links
- Make sure `li` elements (i.e. all the lists in changelogs) are consistent in size with rest of the client
- Display version and release notes link on the "About The Lounge" header line, smaller, pushed to the right
- Check new releases when opening the Help window in order to display it without having to open the release notes. Release notes are being fed to the Changelog page at that moment to avoid fetching twice.
- Re-check version/fetch release notes after 24h. Since The Lounge can now run 24/7, reconnect when losing the network, we have to assume an "always-on" usage.
- Change icon, animate background color when getting response from GitHub to avoid flashing.
- Combine click handlers with our wonderful window management. These were the same handler, even with similar checks (`target` exists, etc.), just in 2 different places. This is necessary for the next item.
- Combine "Open release notes" and "Go back to Help" button behaviors with window management handlers. The window management code is gross as ever, and is in desperate need of a refactor, but at least there is no duplicated code for the same behavior + history management. This fixes the "Next" history behavior (however reloading the app while viewing the notes does not load on the notes, but this is a bug for a different PR!).
- Added a rule in the history management thingy: if a link we want to add history handling to has an `id`, store that in the state
- Added a button to go back to the Help window
- Fixed links to releases
- Send user to the GitHub issues *list* instead of *new issue form* because if they do not have a GitHub account, they will be redirected to the login page, which is a rather unpleasant experience when you are already confused...
- Fixed a bug that would return data about a new release in `latest` even though it is already the `current`. It was showing the current version as "The Lounge v... is now available".
- Added https://user-images.githubusercontent.com to the CSP rule when prefetch storage is enabled, because that is where we have stored screenshots in the changelog so far. Meh (we can improve that later if we decide to have a dedicated place for screenshots).
- Fetch changelog info even in public mode because users in public mode can access the release notes. They do not see the result of the version checker however.
2017-12-23 03:40:41 +00:00
|
|
|
|
2018-07-10 08:06:08 +00:00
|
|
|
if (vueApp.activeChannel) {
|
2018-07-10 09:20:52 +00:00
|
|
|
const {channel: lastChannel} = vueApp.activeChannel;
|
|
|
|
|
2019-02-12 12:59:06 +00:00
|
|
|
// If user clicks on the currently active channel, do nothing
|
|
|
|
if (channel && lastChannel === channel.channel) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-10 09:20:52 +00:00
|
|
|
if (lastChannel.messages.length > 0) {
|
|
|
|
lastChannel.firstUnread = lastChannel.messages[lastChannel.messages.length - 1].id;
|
2018-07-12 20:39:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (lastChannel.messages.length > 100) {
|
2018-07-11 07:38:18 +00:00
|
|
|
lastChannel.messages.splice(0, lastChannel.messages.length - 100);
|
2018-07-12 20:39:23 +00:00
|
|
|
lastChannel.moreHistoryAvailable = true;
|
2018-07-10 09:20:52 +00:00
|
|
|
}
|
2018-07-10 08:06:08 +00:00
|
|
|
}
|
|
|
|
|
2019-02-18 09:18:32 +00:00
|
|
|
if (channel) {
|
2019-02-27 18:15:58 +00:00
|
|
|
vueApp.$store.commit("activeWindow", null);
|
2018-07-06 18:15:15 +00:00
|
|
|
vueApp.activeChannel = channel;
|
|
|
|
|
|
|
|
if (channel) {
|
|
|
|
channel.channel.highlight = 0;
|
|
|
|
channel.channel.unread = 0;
|
|
|
|
}
|
Improve UI of the About section and changelog viewer
- Keep consistent width between the Help page and Changelog (which is already different from other windows 😠)
- Add icons to the About links
- Make sure `li` elements (i.e. all the lists in changelogs) are consistent in size with rest of the client
- Display version and release notes link on the "About The Lounge" header line, smaller, pushed to the right
- Check new releases when opening the Help window in order to display it without having to open the release notes. Release notes are being fed to the Changelog page at that moment to avoid fetching twice.
- Re-check version/fetch release notes after 24h. Since The Lounge can now run 24/7, reconnect when losing the network, we have to assume an "always-on" usage.
- Change icon, animate background color when getting response from GitHub to avoid flashing.
- Combine click handlers with our wonderful window management. These were the same handler, even with similar checks (`target` exists, etc.), just in 2 different places. This is necessary for the next item.
- Combine "Open release notes" and "Go back to Help" button behaviors with window management handlers. The window management code is gross as ever, and is in desperate need of a refactor, but at least there is no duplicated code for the same behavior + history management. This fixes the "Next" history behavior (however reloading the app while viewing the notes does not load on the notes, but this is a bug for a different PR!).
- Added a rule in the history management thingy: if a link we want to add history handling to has an `id`, store that in the state
- Added a button to go back to the Help window
- Fixed links to releases
- Send user to the GitHub issues *list* instead of *new issue form* because if they do not have a GitHub account, they will be redirected to the login page, which is a rather unpleasant experience when you are already confused...
- Fixed a bug that would return data about a new release in `latest` even though it is already the `current`. It was showing the current version as "The Lounge v... is now available".
- Added https://user-images.githubusercontent.com to the CSP rule when prefetch storage is enabled, because that is where we have stored screenshots in the changelog so far. Meh (we can improve that later if we decide to have a dedicated place for screenshots).
- Fetch changelog info even in public mode because users in public mode can access the release notes. They do not see the result of the version checker however.
2017-12-23 03:40:41 +00:00
|
|
|
|
2018-07-09 17:31:48 +00:00
|
|
|
socket.emit("open", channel ? channel.channel.id : null);
|
|
|
|
|
2019-08-03 18:48:06 +00:00
|
|
|
if ($(window).outerWidth() <= utils.mobileViewportPixels) {
|
2019-04-13 20:44:04 +00:00
|
|
|
vueApp.setSidebar(false);
|
2018-03-15 13:11:15 +00:00
|
|
|
}
|
2019-02-20 09:10:18 +00:00
|
|
|
} else {
|
|
|
|
vueApp.activeChannel = null;
|
2019-08-02 13:29:30 +00:00
|
|
|
const component = self.attr("data-component");
|
|
|
|
vueApp.$store.commit("activeWindow", component);
|
2019-08-02 13:12:01 +00:00
|
|
|
|
2019-08-03 18:48:06 +00:00
|
|
|
if ($(window).outerWidth() <= utils.mobileViewportPixels) {
|
2019-08-02 13:12:01 +00:00
|
|
|
vueApp.setSidebar(false);
|
|
|
|
}
|
Improve UI of the About section and changelog viewer
- Keep consistent width between the Help page and Changelog (which is already different from other windows 😠)
- Add icons to the About links
- Make sure `li` elements (i.e. all the lists in changelogs) are consistent in size with rest of the client
- Display version and release notes link on the "About The Lounge" header line, smaller, pushed to the right
- Check new releases when opening the Help window in order to display it without having to open the release notes. Release notes are being fed to the Changelog page at that moment to avoid fetching twice.
- Re-check version/fetch release notes after 24h. Since The Lounge can now run 24/7, reconnect when losing the network, we have to assume an "always-on" usage.
- Change icon, animate background color when getting response from GitHub to avoid flashing.
- Combine click handlers with our wonderful window management. These were the same handler, even with similar checks (`target` exists, etc.), just in 2 different places. This is necessary for the next item.
- Combine "Open release notes" and "Go back to Help" button behaviors with window management handlers. The window management code is gross as ever, and is in desperate need of a refactor, but at least there is no duplicated code for the same behavior + history management. This fixes the "Next" history behavior (however reloading the app while viewing the notes does not load on the notes, but this is a bug for a different PR!).
- Added a rule in the history management thingy: if a link we want to add history handling to has an `id`, store that in the state
- Added a button to go back to the Help window
- Fixed links to releases
- Send user to the GitHub issues *list* instead of *new issue form* because if they do not have a GitHub account, they will be redirected to the login page, which is a rather unpleasant experience when you are already confused...
- Fixed a bug that would return data about a new release in `latest` even though it is already the `current`. It was showing the current version as "The Lounge v... is now available".
- Added https://user-images.githubusercontent.com to the CSP rule when prefetch storage is enabled, because that is where we have stored screenshots in the changelog so far. Meh (we can improve that later if we decide to have a dedicated place for screenshots).
- Fetch changelog info even in public mode because users in public mode can access the release notes. They do not see the result of the version checker however.
2017-12-23 03:40:41 +00:00
|
|
|
}
|
2016-06-12 02:16:17 +00:00
|
|
|
|
2018-09-05 19:44:19 +00:00
|
|
|
utils.synchronizeNotifiedState();
|
2014-12-11 22:42:22 +00:00
|
|
|
|
2014-09-25 23:51:53 +00:00
|
|
|
if (self.hasClass("chan")) {
|
2018-07-08 13:42:54 +00:00
|
|
|
vueApp.$nextTick(() => $("#chat-container").addClass("active"));
|
2014-09-25 23:51:53 +00:00
|
|
|
}
|
|
|
|
|
2019-02-20 09:10:18 +00:00
|
|
|
/* TODO: move to ChatInput.vue
|
2018-01-11 11:33:36 +00:00
|
|
|
const chanChat = chan.find(".chat");
|
2018-02-20 07:28:04 +00:00
|
|
|
|
2018-07-19 10:46:30 +00:00
|
|
|
if (chanChat.length > 0 && channel.type !== "special") {
|
2018-03-20 15:24:44 +00:00
|
|
|
// On touch devices unfocus (blur) the input to correctly close the virtual keyboard
|
|
|
|
// An explicit blur is required, as the keyboard may open back up if the focus remains
|
|
|
|
// See https://github.com/thelounge/thelounge/issues/2257
|
2018-07-13 10:24:05 +00:00
|
|
|
$("#input").trigger("ontouchstart" in window ? "blur" : "focus");
|
2016-07-10 11:01:31 +00:00
|
|
|
}
|
2019-03-03 19:43:57 +00:00
|
|
|
*/
|
2016-07-10 11:01:31 +00:00
|
|
|
|
2018-07-08 12:18:17 +00:00
|
|
|
if (channel && channel.channel.usersOutdated) {
|
|
|
|
channel.channel.usersOutdated = false;
|
|
|
|
|
|
|
|
socket.emit("names", {
|
|
|
|
target: channel.channel.id,
|
|
|
|
});
|
2016-02-17 02:29:44 +00:00
|
|
|
}
|
|
|
|
|
Improve UI of the About section and changelog viewer
- Keep consistent width between the Help page and Changelog (which is already different from other windows 😠)
- Add icons to the About links
- Make sure `li` elements (i.e. all the lists in changelogs) are consistent in size with rest of the client
- Display version and release notes link on the "About The Lounge" header line, smaller, pushed to the right
- Check new releases when opening the Help window in order to display it without having to open the release notes. Release notes are being fed to the Changelog page at that moment to avoid fetching twice.
- Re-check version/fetch release notes after 24h. Since The Lounge can now run 24/7, reconnect when losing the network, we have to assume an "always-on" usage.
- Change icon, animate background color when getting response from GitHub to avoid flashing.
- Combine click handlers with our wonderful window management. These were the same handler, even with similar checks (`target` exists, etc.), just in 2 different places. This is necessary for the next item.
- Combine "Open release notes" and "Go back to Help" button behaviors with window management handlers. The window management code is gross as ever, and is in desperate need of a refactor, but at least there is no duplicated code for the same behavior + history management. This fixes the "Next" history behavior (however reloading the app while viewing the notes does not load on the notes, but this is a bug for a different PR!).
- Added a rule in the history management thingy: if a link we want to add history handling to has an `id`, store that in the state
- Added a button to go back to the Help window
- Fixed links to releases
- Send user to the GitHub issues *list* instead of *new issue form* because if they do not have a GitHub account, they will be redirected to the login page, which is a rather unpleasant experience when you are already confused...
- Fixed a bug that would return data about a new release in `latest` even though it is already the `current`. It was showing the current version as "The Lounge v... is now available".
- Added https://user-images.githubusercontent.com to the CSP rule when prefetch storage is enabled, because that is where we have stored screenshots in the changelog so far. Meh (we can improve that later if we decide to have a dedicated place for screenshots).
- Fetch changelog info even in public mode because users in public mode can access the release notes. They do not see the result of the version checker however.
2017-12-23 03:40:41 +00:00
|
|
|
// Pushes states to history web API when clicking elements with a data-target attribute.
|
|
|
|
// States are very trivial and only contain a single `clickTarget` property which
|
|
|
|
// contains a CSS selector that targets elements which takes the user to a different view
|
|
|
|
// when clicked. The `popstate` event listener will trigger synthetic click events using that
|
|
|
|
// selector and thus take the user to a different view/state.
|
2018-03-26 08:46:01 +00:00
|
|
|
if (pushState === false) {
|
2018-03-20 15:24:44 +00:00
|
|
|
return false;
|
Improve UI of the About section and changelog viewer
- Keep consistent width between the Help page and Changelog (which is already different from other windows 😠)
- Add icons to the About links
- Make sure `li` elements (i.e. all the lists in changelogs) are consistent in size with rest of the client
- Display version and release notes link on the "About The Lounge" header line, smaller, pushed to the right
- Check new releases when opening the Help window in order to display it without having to open the release notes. Release notes are being fed to the Changelog page at that moment to avoid fetching twice.
- Re-check version/fetch release notes after 24h. Since The Lounge can now run 24/7, reconnect when losing the network, we have to assume an "always-on" usage.
- Change icon, animate background color when getting response from GitHub to avoid flashing.
- Combine click handlers with our wonderful window management. These were the same handler, even with similar checks (`target` exists, etc.), just in 2 different places. This is necessary for the next item.
- Combine "Open release notes" and "Go back to Help" button behaviors with window management handlers. The window management code is gross as ever, and is in desperate need of a refactor, but at least there is no duplicated code for the same behavior + history management. This fixes the "Next" history behavior (however reloading the app while viewing the notes does not load on the notes, but this is a bug for a different PR!).
- Added a rule in the history management thingy: if a link we want to add history handling to has an `id`, store that in the state
- Added a button to go back to the Help window
- Fixed links to releases
- Send user to the GitHub issues *list* instead of *new issue form* because if they do not have a GitHub account, they will be redirected to the login page, which is a rather unpleasant experience when you are already confused...
- Fixed a bug that would return data about a new release in `latest` even though it is already the `current`. It was showing the current version as "The Lounge v... is now available".
- Added https://user-images.githubusercontent.com to the CSP rule when prefetch storage is enabled, because that is where we have stored screenshots in the changelog so far. Meh (we can improve that later if we decide to have a dedicated place for screenshots).
- Fetch changelog info even in public mode because users in public mode can access the release notes. They do not see the result of the version checker however.
2017-12-23 03:40:41 +00:00
|
|
|
}
|
2018-02-20 07:28:04 +00:00
|
|
|
|
Improve UI of the About section and changelog viewer
- Keep consistent width between the Help page and Changelog (which is already different from other windows 😠)
- Add icons to the About links
- Make sure `li` elements (i.e. all the lists in changelogs) are consistent in size with rest of the client
- Display version and release notes link on the "About The Lounge" header line, smaller, pushed to the right
- Check new releases when opening the Help window in order to display it without having to open the release notes. Release notes are being fed to the Changelog page at that moment to avoid fetching twice.
- Re-check version/fetch release notes after 24h. Since The Lounge can now run 24/7, reconnect when losing the network, we have to assume an "always-on" usage.
- Change icon, animate background color when getting response from GitHub to avoid flashing.
- Combine click handlers with our wonderful window management. These were the same handler, even with similar checks (`target` exists, etc.), just in 2 different places. This is necessary for the next item.
- Combine "Open release notes" and "Go back to Help" button behaviors with window management handlers. The window management code is gross as ever, and is in desperate need of a refactor, but at least there is no duplicated code for the same behavior + history management. This fixes the "Next" history behavior (however reloading the app while viewing the notes does not load on the notes, but this is a bug for a different PR!).
- Added a rule in the history management thingy: if a link we want to add history handling to has an `id`, store that in the state
- Added a button to go back to the Help window
- Fixed links to releases
- Send user to the GitHub issues *list* instead of *new issue form* because if they do not have a GitHub account, they will be redirected to the login page, which is a rather unpleasant experience when you are already confused...
- Fixed a bug that would return data about a new release in `latest` even though it is already the `current`. It was showing the current version as "The Lounge v... is now available".
- Added https://user-images.githubusercontent.com to the CSP rule when prefetch storage is enabled, because that is where we have stored screenshots in the changelog so far. Meh (we can improve that later if we decide to have a dedicated place for screenshots).
- Fetch changelog info even in public mode because users in public mode can access the release notes. They do not see the result of the version checker however.
2017-12-23 03:40:41 +00:00
|
|
|
const state = {};
|
|
|
|
|
2018-01-30 09:38:33 +00:00
|
|
|
if (self.prop("id")) {
|
|
|
|
state.clickTarget = `#${self.prop("id")}`;
|
Improve UI of the About section and changelog viewer
- Keep consistent width between the Help page and Changelog (which is already different from other windows 😠)
- Add icons to the About links
- Make sure `li` elements (i.e. all the lists in changelogs) are consistent in size with rest of the client
- Display version and release notes link on the "About The Lounge" header line, smaller, pushed to the right
- Check new releases when opening the Help window in order to display it without having to open the release notes. Release notes are being fed to the Changelog page at that moment to avoid fetching twice.
- Re-check version/fetch release notes after 24h. Since The Lounge can now run 24/7, reconnect when losing the network, we have to assume an "always-on" usage.
- Change icon, animate background color when getting response from GitHub to avoid flashing.
- Combine click handlers with our wonderful window management. These were the same handler, even with similar checks (`target` exists, etc.), just in 2 different places. This is necessary for the next item.
- Combine "Open release notes" and "Go back to Help" button behaviors with window management handlers. The window management code is gross as ever, and is in desperate need of a refactor, but at least there is no duplicated code for the same behavior + history management. This fixes the "Next" history behavior (however reloading the app while viewing the notes does not load on the notes, but this is a bug for a different PR!).
- Added a rule in the history management thingy: if a link we want to add history handling to has an `id`, store that in the state
- Added a button to go back to the Help window
- Fixed links to releases
- Send user to the GitHub issues *list* instead of *new issue form* because if they do not have a GitHub account, they will be redirected to the login page, which is a rather unpleasant experience when you are already confused...
- Fixed a bug that would return data about a new release in `latest` even though it is already the `current`. It was showing the current version as "The Lounge v... is now available".
- Added https://user-images.githubusercontent.com to the CSP rule when prefetch storage is enabled, because that is where we have stored screenshots in the changelog so far. Meh (we can improve that later if we decide to have a dedicated place for screenshots).
- Fetch changelog info even in public mode because users in public mode can access the release notes. They do not see the result of the version checker however.
2017-12-23 03:40:41 +00:00
|
|
|
} else if (self.hasClass("chan")) {
|
2018-07-19 10:46:30 +00:00
|
|
|
state.clickTarget = `#sidebar .chan[data-id="${self.attr("data-id")}"]`;
|
Improve UI of the About section and changelog viewer
- Keep consistent width between the Help page and Changelog (which is already different from other windows 😠)
- Add icons to the About links
- Make sure `li` elements (i.e. all the lists in changelogs) are consistent in size with rest of the client
- Display version and release notes link on the "About The Lounge" header line, smaller, pushed to the right
- Check new releases when opening the Help window in order to display it without having to open the release notes. Release notes are being fed to the Changelog page at that moment to avoid fetching twice.
- Re-check version/fetch release notes after 24h. Since The Lounge can now run 24/7, reconnect when losing the network, we have to assume an "always-on" usage.
- Change icon, animate background color when getting response from GitHub to avoid flashing.
- Combine click handlers with our wonderful window management. These were the same handler, even with similar checks (`target` exists, etc.), just in 2 different places. This is necessary for the next item.
- Combine "Open release notes" and "Go back to Help" button behaviors with window management handlers. The window management code is gross as ever, and is in desperate need of a refactor, but at least there is no duplicated code for the same behavior + history management. This fixes the "Next" history behavior (however reloading the app while viewing the notes does not load on the notes, but this is a bug for a different PR!).
- Added a rule in the history management thingy: if a link we want to add history handling to has an `id`, store that in the state
- Added a button to go back to the Help window
- Fixed links to releases
- Send user to the GitHub issues *list* instead of *new issue form* because if they do not have a GitHub account, they will be redirected to the login page, which is a rather unpleasant experience when you are already confused...
- Fixed a bug that would return data about a new release in `latest` even though it is already the `current`. It was showing the current version as "The Lounge v... is now available".
- Added https://user-images.githubusercontent.com to the CSP rule when prefetch storage is enabled, because that is where we have stored screenshots in the changelog so far. Meh (we can improve that later if we decide to have a dedicated place for screenshots).
- Fetch changelog info even in public mode because users in public mode can access the release notes. They do not see the result of the version checker however.
2017-12-23 03:40:41 +00:00
|
|
|
} else {
|
|
|
|
state.clickTarget = `#footer button[data-target="${target}"]`;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (history && history.pushState) {
|
2018-03-26 08:46:01 +00:00
|
|
|
if (replaceHistory && history.replaceState) {
|
Improve UI of the About section and changelog viewer
- Keep consistent width between the Help page and Changelog (which is already different from other windows 😠)
- Add icons to the About links
- Make sure `li` elements (i.e. all the lists in changelogs) are consistent in size with rest of the client
- Display version and release notes link on the "About The Lounge" header line, smaller, pushed to the right
- Check new releases when opening the Help window in order to display it without having to open the release notes. Release notes are being fed to the Changelog page at that moment to avoid fetching twice.
- Re-check version/fetch release notes after 24h. Since The Lounge can now run 24/7, reconnect when losing the network, we have to assume an "always-on" usage.
- Change icon, animate background color when getting response from GitHub to avoid flashing.
- Combine click handlers with our wonderful window management. These were the same handler, even with similar checks (`target` exists, etc.), just in 2 different places. This is necessary for the next item.
- Combine "Open release notes" and "Go back to Help" button behaviors with window management handlers. The window management code is gross as ever, and is in desperate need of a refactor, but at least there is no duplicated code for the same behavior + history management. This fixes the "Next" history behavior (however reloading the app while viewing the notes does not load on the notes, but this is a bug for a different PR!).
- Added a rule in the history management thingy: if a link we want to add history handling to has an `id`, store that in the state
- Added a button to go back to the Help window
- Fixed links to releases
- Send user to the GitHub issues *list* instead of *new issue form* because if they do not have a GitHub account, they will be redirected to the login page, which is a rather unpleasant experience when you are already confused...
- Fixed a bug that would return data about a new release in `latest` even though it is already the `current`. It was showing the current version as "The Lounge v... is now available".
- Added https://user-images.githubusercontent.com to the CSP rule when prefetch storage is enabled, because that is where we have stored screenshots in the changelog so far. Meh (we can improve that later if we decide to have a dedicated place for screenshots).
- Fetch changelog info even in public mode because users in public mode can access the release notes. They do not see the result of the version checker however.
2017-12-23 03:40:41 +00:00
|
|
|
history.replaceState(state, null, target);
|
|
|
|
} else {
|
|
|
|
history.pushState(state, null, target);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
sidebar.on("click", ".chan, button", openWindow);
|
2019-08-05 15:37:59 +00:00
|
|
|
$("#windows").on("click", "#view-changelog, #back-to-help", openWindow);
|
2014-08-16 16:15:17 +00:00
|
|
|
|
2017-06-09 11:10:55 +00:00
|
|
|
$(document).on("visibilitychange focus click", () => {
|
2018-09-05 19:44:19 +00:00
|
|
|
utils.synchronizeNotifiedState();
|
2017-04-15 15:40:19 +00:00
|
|
|
});
|
2016-12-10 09:33:36 +00:00
|
|
|
|
2017-04-08 12:34:31 +00:00
|
|
|
window.addEventListener("popstate", (e) => {
|
|
|
|
const {state} = e;
|
2018-02-20 07:28:04 +00:00
|
|
|
|
2017-04-08 12:34:31 +00:00
|
|
|
if (!state) {
|
|
|
|
return;
|
2017-01-28 17:48:34 +00:00
|
|
|
}
|
2017-04-08 12:34:31 +00:00
|
|
|
|
2017-09-09 20:36:06 +00:00
|
|
|
let {clickTarget} = state;
|
|
|
|
|
2017-04-08 12:34:31 +00:00
|
|
|
if (clickTarget) {
|
2017-09-09 20:36:06 +00:00
|
|
|
// This will be true when click target corresponds to opening a thumbnail,
|
|
|
|
// browsing to the previous/next thumbnail, or closing the image viewer.
|
2017-09-10 19:00:27 +00:00
|
|
|
const imageViewerRelated = clickTarget.includes(".toggle-thumbnail");
|
2017-09-09 20:36:06 +00:00
|
|
|
|
|
|
|
// If the click target is not related to the image viewer but the viewer
|
|
|
|
// is currently opened, we need to close it.
|
|
|
|
if (!imageViewerRelated && $("#image-viewer").hasClass("opened")) {
|
|
|
|
clickTarget += ", #image-viewer";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Emit the click to the target, while making sure it is not going to be
|
|
|
|
// added to the state again.
|
2017-04-08 12:34:31 +00:00
|
|
|
$(clickTarget).trigger("click", {
|
2017-11-15 06:35:15 +00:00
|
|
|
pushState: false,
|
2017-04-08 12:34:31 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2017-08-28 09:18:31 +00:00
|
|
|
|
|
|
|
// Only start opening socket.io connection after all events have been registered
|
|
|
|
socket.open();
|
2018-07-08 14:57:02 +00:00
|
|
|
};
|