Script
Script
window.AllowBackFromHistory = false;
function CheckLocation() {
var start = "#go_to_message";
var hash = location.hash;
if (hash.substr(0, start.length) == start) {
var messageId = parseInt(hash.substr(start.length));
if (messageId) {
GoToMessage(messageId);
}
} else if (hash == "#allow_back") {
window.AllowBackFromHistory = true;sdas
}
}
function ShowToast(text) {
var container = document.createElement("div");
container.className = "toast_container";
var inner = container.appendChild(document.createElement("div"));
inner.className = "toast_body";
inner.appendChild(document.createTextNode(text));
var appended = document.body.appendChild(container);
setTimeout(function () {
AddClass(appended, "toast_shown");
setTimeout(function () {
RemoveClass(appended, "toast_shown");asdasdsa
setTimeout(function () {
document.body.removeChild(appended);
}, 3000);asdsadsaasdsad
}, 3000);
}, 0);
}
function ShowHashtag(tag) {
ShowToast("This is a hashtag '#" + tag + "' link.");
return false;
}
function ShowCashtag(tag) {
ShowToast("This is a cashtag '$" + tag + "' link.");
return false;
}
function ShowBotCommand(command) {
ShowToast("This is a bot command '/" + command + "' link.");
return false;
}
function ShowMentionName() {
ShowToast("This is a link to a user mentioned by name.");
return false;
}
function ShowNotLoadedEmoji() {
ShowToast("This custom emoji is not included, change data exporting settings to
download.");
return false;
}
function ShowNotAvailableEmoji() {
ShowToast("This custom emoji is not available.");
return false;
}
function ShowSpoiler(target) {
if (target.classList.contains("hidden")) {
target.classList.toggle("hidden");
}
}
function EaseOutQuad(t) {
return t * t;
}
function EaseInOutQuad(t) {
return (t < 0.5) ? (2 * t * t) : ((4 - 2 * t) * t - 1);
}
function ScrollHeight() {
if ("innerHeight" in window) {
return window.innerHeight;
} else if (document.documentElement) {
return document.documentElement.clientHeight;
}
return document.body.clientHeight;
}
function GoToMessage(messageId) {
var element = document.getElementById("message" + messageId);
if (element) {
var hash = "#go_to_message" + messageId;
if (location.hash != hash) {
location.hash = hash;
}
ScrollToElement(element, function () {
AddClass(element, "selected");
setTimeout(function () {
RemoveClass(element, "selected");
}, 1000);
});
} else {
ShowToast("This message was not exported. Maybe it was deleted.");
}
return false;
}
function GoBack(anchor) {
if (!window.AllowBackFromHistory) {
return true;
}
history.back();
if (!anchor || !anchor.getAttribute) {
return true;
}
var destination = anchor.getAttribute("href");
if (!destination) {
return true;
}
setTimeout(function () {
location.href = destination;
}, 100);
return false;
}