1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-18 06:15:49 +02:00

Massive JS formatting refactoring

This commit is contained in:
chylex 2018-07-08 06:09:51 +02:00
parent 937c8e22c4
commit 6d6bb79199
14 changed files with 146 additions and 146 deletions
Resources
Plugins
.debug
clear-columns
edit-design
emoji-keyboard
reply-account
templates
timeline-polls
Scripts

View File

@ -2,6 +2,7 @@ enabled(){
this.isDebugging = false; this.isDebugging = false;
this.onKeyDown = (e) => { this.onKeyDown = (e) => {
// ========================== // ==========================
// F4 key - toggle debug mode // F4 key - toggle debug mode
// ========================== // ==========================
@ -11,8 +12,6 @@ enabled(){
$(".nav-user-info").first().css("background-color", this.isDebugging ? "#5A6B75" : "#292F33"); $(".nav-user-info").first().css("background-color", this.isDebugging ? "#5A6B75" : "#292F33");
} }
// Debug mode handling
else if (this.isDebugging){ else if (this.isDebugging){
e.preventDefault(); e.preventDefault();
@ -22,15 +21,16 @@ enabled(){
// =================================== // ===================================
if (e.keyCode === 78 || e.keyCode === 83){ if (e.keyCode === 78 || e.keyCode === 83){
var col = TD.controller.columnManager.getAllOrdered()[0]; let col = TD.controller.columnManager.getAllOrdered()[0];
let model = col.model;
var prevPopup = col.model.getHasNotification(); let prevPopup = model.getHasNotification();
var prevSound = col.model.getHasSound(); let prevSound = model.getHasSound();
col.model.setHasNotification(e.keyCode === 78); model.setHasNotification(e.keyCode === 78);
col.model.setHasSound(e.keyCode === 83); model.setHasSound(e.keyCode === 83);
$.publish("/notifications/new",[{ $.publish("/notifications/new", [{
column: col, column: col,
items: [ items: [
col.updateArray[Math.floor(Math.random()*col.updateArray.length)] col.updateArray[Math.floor(Math.random()*col.updateArray.length)]
@ -38,8 +38,8 @@ enabled(){
}]); }]);
setTimeout(function(){ setTimeout(function(){
col.model.setHasNotification(prevPopup); model.setHasNotification(prevPopup);
col.model.setHasSound(prevSound); model.setHasSound(prevSound);
}, 1); }, 1);
} }

View File

@ -6,24 +6,24 @@ constructor(){
enabled(){ enabled(){
// prepare variables and functions // prepare variables and functions
var clearColumn = (columnName) => { const clearColumn = (columnName) => {
TD.controller.columnManager.get(columnName).clear(); TD.controller.columnManager.get(columnName).clear();
TD.controller.stats.columnActionClick("clear"); TD.controller.stats.columnActionClick("clear");
}; };
var resetColumn = (columnName) => { const resetColumn = (columnName) => {
let col = TD.controller.columnManager.get(columnName); let col = TD.controller.columnManager.get(columnName);
col.model.setClearedTimestamp(0); col.model.setClearedTimestamp(0);
col.reloadTweets(); col.reloadTweets();
}; };
var forEachColumn = (func) => { const forEachColumn = (func) => {
Object.keys(TD.controller.columnManager.getAll()).forEach(func); Object.keys(TD.controller.columnManager.getAll()).forEach(func);
}; };
var wasShiftPressed = false; let wasShiftPressed = false;
var updateShiftState = (pressed) => { const updateShiftState = (pressed) => {
if (pressed != wasShiftPressed){ if (pressed != wasShiftPressed){
wasShiftPressed = pressed; wasShiftPressed = pressed;
@ -40,7 +40,7 @@ enabled(){
// prepare event handlers // prepare event handlers
this.eventClickSingle = function(e){ this.eventClickSingle = function(e){
var name = $(this).closest(".js-column").attr("data-column"); let name = $(this).closest(".js-column").attr("data-column");
e.shiftKey ? resetColumn(name) : clearColumn(name); e.shiftKey ? resetColumn(name) : clearColumn(name);
}; };
@ -58,10 +58,10 @@ enabled(){
forEachColumn(e.shiftKey ? resetColumn : clearColumn); forEachColumn(e.shiftKey ? resetColumn : clearColumn);
} }
else{ else{
var focusedColumn = $(".js-column.is-focused"); let focusedColumn = $(".js-column.is-focused");
if (focusedColumn.length){ if (focusedColumn.length){
var name = focusedColumn.attr("data-column"); let name = focusedColumn.attr("data-column");
e.shiftKey ? resetColumn(name) : clearColumn(name); e.shiftKey ? resetColumn(name) : clearColumn(name);
} }
} }
@ -97,7 +97,7 @@ enabled(){
window.TDPF_injectMustache("menus/column_nav_menu.mustache", "replace", "{{_i}}Add column{{/i}}</div> </a> </div>", `{{_i}}Add column{{/i}}</div></a>${this.btnClearAllHTML}</div>`) window.TDPF_injectMustache("menus/column_nav_menu.mustache", "replace", "{{_i}}Add column{{/i}}</div> </a> </div>", `{{_i}}Add column{{/i}}</div></a>${this.btnClearAllHTML}</div>`)
// load custom style // load custom style
var css = window.TDPF_createCustomStyle(this); let css = window.TDPF_createCustomStyle(this);
css.insert(".js-app-add-column.is-hidden + .clear-columns-btn-all-parent { display: none; }"); css.insert(".js-app-add-column.is-hidden + .clear-columns-btn-all-parent { display: none; }");
css.insert(".column-header-links { min-width: 51px !important; }"); css.insert(".column-header-links { min-width: 51px !important; }");
css.insert("[data-td-icon='icon-message'] .column-header-links { min-width: 110px !important; }"); css.insert("[data-td-icon='icon-message'] .column-header-links { min-width: 110px !important; }");
@ -120,7 +120,7 @@ ready(){
$(".js-app-add-column").first().after(this.btnClearAllHTML); $(".js-app-add-column").first().after(this.btnClearAllHTML);
// setup tooltip handling // setup tooltip handling
var tooltipEvents = $._data($(".js-header-action")[0]).events; let tooltipEvents = $._data($(".js-header-action")[0], "events");
if (tooltipEvents.mouseover && tooltipEvents.mouseover.length && tooltipEvents.mouseout && tooltipEvents.mouseout.length){ if (tooltipEvents.mouseover && tooltipEvents.mouseover.length && tooltipEvents.mouseout && tooltipEvents.mouseout.length){
$(".clear-columns-btn-all-parent").on("mouseover", tooltipEvents.mouseover[0].handler).on("mouseout", tooltipEvents.mouseout[0].handler); $(".clear-columns-btn-all-parent").on("mouseover", tooltipEvents.mouseover[0].handler).on("mouseout", tooltipEvents.mouseout[0].handler);

View File

@ -21,7 +21,7 @@ enabled(){
avatarRadius: 2 avatarRadius: 2
}; };
var prepareDefaultConfig = () => { const prepareDefaultConfig = () => {
this.defaultConfig._theme = TD.settings.getTheme(); this.defaultConfig._theme = TD.settings.getTheme();
switch(TD.settings.getColumnWidth()){ switch(TD.settings.getColumnWidth()){
@ -39,7 +39,7 @@ enabled(){
this.firstTimeLoad = null; this.firstTimeLoad = null;
var me = this; const me = this;
// modal dialog loading // modal dialog loading
$TDP.readFileRoot(this.$token, "modal.html").then(contents => { $TDP.readFileRoot(this.$token, "modal.html").then(contents => {
@ -72,7 +72,7 @@ enabled(){
} }
}; };
var loadConfigObject = obj => { const loadConfigObject = obj => {
this.tmpConfig = obj || {}; this.tmpConfig = obj || {};
this.firstTimeLoad = obj === null; this.firstTimeLoad = obj === null;
@ -139,7 +139,7 @@ enabled(){
}; };
// modal dialog setup // modal dialog setup
var updateKey = function(key, value){ const updateKey = function(key, value){
me.config[key] = value; me.config[key] = value;
setTimeout(function(){ setTimeout(function(){
@ -643,7 +643,7 @@ ready(){
$(".js-app").append('<div id="td-design-plugin-modal" class="js-modal settings-modal ovl scroll-v scroll-styled-v"></div>'); $(".js-app").append('<div id="td-design-plugin-modal" class="js-modal settings-modal ovl scroll-v scroll-styled-v"></div>');
// global settings override // global settings override
var me = this; const me = this;
this.prevFuncSettingsGetInfo = TD.components.GlobalSettings.prototype.getInfo; this.prevFuncSettingsGetInfo = TD.components.GlobalSettings.prototype.getInfo;
this.prevFuncSettingsSwitchTab = TD.components.GlobalSettings.prototype.switchTab; this.prevFuncSettingsSwitchTab = TD.components.GlobalSettings.prototype.switchTab;

View File

@ -26,7 +26,7 @@ enabled(){
this.emojiData3 = []; // no skin tones, appended this.emojiData3 = []; // no skin tones, appended
this.emojiNames = []; this.emojiNames = [];
var me = this; const me = this;
// styles // styles
@ -51,12 +51,12 @@ enabled(){
// layout // layout
var buttonHTML = '<button class="needsclick btn btn-on-blue txt-left padding-v--6 padding-h--8 emoji-keyboard-popup-btn"><i class="icon icon-heart"></i></button>'; let buttonHTML = '<button class="needsclick btn btn-on-blue txt-left padding-v--6 padding-h--8 emoji-keyboard-popup-btn"><i class="icon icon-heart"></i></button>';
this.prevComposeMustache = TD.mustaches["compose/docked_compose.mustache"]; this.prevComposeMustache = TD.mustaches["compose/docked_compose.mustache"];
window.TDPF_injectMustache("compose/docked_compose.mustache", "append", '<div class="cf margin-t--12 margin-b--30">', buttonHTML); window.TDPF_injectMustache("compose/docked_compose.mustache", "append", '<div class="cf margin-t--12 margin-b--30">', buttonHTML);
var maybeDockedComposePanel = $(".js-docked-compose"); let maybeDockedComposePanel = $(".js-docked-compose");
if (maybeDockedComposePanel.length){ if (maybeDockedComposePanel.length){
maybeDockedComposePanel.find(".cf.margin-t--12.margin-b--30").first().append(buttonHTML); maybeDockedComposePanel.find(".cf.margin-t--12.margin-b--30").first().append(buttonHTML);
@ -67,10 +67,10 @@ enabled(){
this.currentKeyboard = null; this.currentKeyboard = null;
this.currentSpanner = null; this.currentSpanner = null;
var wasSearchFocused = false; let wasSearchFocused = false;
var lastEmojiKeyword, lastEmojiPosition, lastEmojiLength; let lastEmojiKeyword, lastEmojiPosition, lastEmojiLength;
var hideKeyboard = (refocus) => { const hideKeyboard = (refocus) => {
$(this.currentKeyboard).remove(); $(this.currentKeyboard).remove();
this.currentKeyboard = null; this.currentKeyboard = null;
@ -94,7 +94,7 @@ enabled(){
lastEmojiKeyword = null; lastEmojiKeyword = null;
}; };
var generateEmojiHTML = skinTone => { const generateEmojiHTML = skinTone => {
let index = 0; let index = 0;
let html = [ "<p style='font-size:13px;color:#444;margin:4px;text-align:center'>Please, note that some emoji may not show up correctly in the text box above, but they will display in the tweet.</p>" ]; let html = [ "<p style='font-size:13px;color:#444;margin:4px;text-align:center'>Please, note that some emoji may not show up correctly in the text box above, but they will display in the tweet.</p>" ];
@ -113,7 +113,7 @@ enabled(){
return html.join(""); return html.join("");
}; };
var updateFilters = () => { const updateFilters = () => {
let keywords = this.currentKeywords; let keywords = this.currentKeywords;
let container = $(this.currentKeyboard.children[1]); let container = $(this.currentKeyboard.children[1]);
@ -135,7 +135,7 @@ enabled(){
} }
}; };
var selectSkinTone = skinTone => { const selectSkinTone = skinTone => {
let selectedEle = this.currentKeyboard.children[2].querySelector("[data-tone='"+this.selectedSkinTone+"']"); let selectedEle = this.currentKeyboard.children[2].querySelector("[data-tone='"+this.selectedSkinTone+"']");
selectedEle && selectedEle.classList.remove("sel"); selectedEle && selectedEle.classList.remove("sel");
@ -146,12 +146,12 @@ enabled(){
}; };
this.generateKeyboard = (left, top) => { this.generateKeyboard = (left, top) => {
var outer = document.createElement("div"); let outer = document.createElement("div");
outer.classList.add("emoji-keyboard"); outer.classList.add("emoji-keyboard");
outer.style.left = left+"px"; outer.style.left = left+"px";
outer.style.top = top+"px"; outer.style.top = top+"px";
var keyboard = document.createElement("div"); let keyboard = document.createElement("div");
keyboard.classList.add("emoji-keyboard-list"); keyboard.classList.add("emoji-keyboard-list");
keyboard.addEventListener("click", function(e){ keyboard.addEventListener("click", function(e){
@ -164,11 +164,11 @@ enabled(){
e.stopPropagation(); e.stopPropagation();
}); });
var search = document.createElement("div"); let search = document.createElement("div");
search.innerHTML = "<input type='text' placeholder='Search...'>"; search.innerHTML = "<input type='text' placeholder='Search...'>";
search.classList.add("emoji-keyboard-search"); search.classList.add("emoji-keyboard-search");
var skintones = document.createElement("div"); let skintones = document.createElement("div");
skintones.innerHTML = me.skinToneData.map(entry => "<div data-tone='"+entry[0]+"' style='background-color:"+entry[1]+"'></div>").join(""); skintones.innerHTML = me.skinToneData.map(entry => "<div data-tone='"+entry[0]+"' style='background-color:"+entry[1]+"'></div>").join("");
skintones.classList.add("emoji-keyboard-skintones"); skintones.classList.add("emoji-keyboard-skintones");
@ -189,7 +189,7 @@ enabled(){
e.stopPropagation(); e.stopPropagation();
}); });
var searchInput = search.children[0]; let searchInput = search.children[0];
searchInput.focus(); searchInput.focus();
wasSearchFocused = false; wasSearchFocused = false;
@ -232,12 +232,12 @@ enabled(){
this.composePanelScroller.trigger("scroll"); this.composePanelScroller.trigger("scroll");
}; };
var getKeyboardTop = () => { const getKeyboardTop = () => {
let button = $(".emoji-keyboard-popup-btn"); let button = $(".emoji-keyboard-popup-btn");
return button.offset().top+button.outerHeight()+me.composePanelScroller.scrollTop()+8; return button.offset().top+button.outerHeight()+me.composePanelScroller.scrollTop()+8;
}; };
var insertEmoji = (src, alt) => { const insertEmoji = (src, alt) => {
let input = this.composeInput; let input = this.composeInput;
let val = input.val(); let val = input.val();
@ -418,7 +418,7 @@ ready(){
// HTML generation // HTML generation
var convUnicode = function(codePt){ const convUnicode = function(codePt){
if (codePt > 0xFFFF){ if (codePt > 0xFFFF){
codePt -= 0x10000; codePt -= 0x10000;
return String.fromCharCode(0xD800+(codePt>>10), 0xDC00+(codePt&0x3FF)); return String.fromCharCode(0xD800+(codePt>>10), 0xDC00+(codePt&0x3FF));

View File

@ -1,5 +1,5 @@
enabled(){ enabled(){
var configuration = { defaultAccount: "#preferred" }; let configuration = { defaultAccount: "#preferred" };
window.TDPF_loadConfigurationFile(this, "configuration.js", "configuration.default.js", obj => configuration = obj); window.TDPF_loadConfigurationFile(this, "configuration.js", "configuration.default.js", obj => configuration = obj);
@ -8,7 +8,7 @@ enabled(){
this.uiComposeTweetEvent = (e, data) => { this.uiComposeTweetEvent = (e, data) => {
return if !(data.type === "reply" || (data.type === "tweet" && "quotedTweet" in data)) || data.popFromInline || !("element" in data); return if !(data.type === "reply" || (data.type === "tweet" && "quotedTweet" in data)) || data.popFromInline || !("element" in data);
var query; let query;
if (configuration.useAdvancedSelector){ if (configuration.useAdvancedSelector){
if (configuration.customSelector){ if (configuration.customSelector){
@ -88,7 +88,7 @@ enabled(){
return; return;
} }
var identifier = null; let identifier = null;
switch(query){ switch(query){
case "#preferred": case "#preferred":
@ -106,7 +106,7 @@ enabled(){
default: default:
if (query[0] === '@'){ if (query[0] === '@'){
var obj = TD.storage.accountController.getAccountFromUsername(query.substring(1)); let obj = TD.storage.accountController.getAccountFromUsername(query.substring(1));
if (obj.length === 0){ if (obj.length === 0){
$TD.alert("warning", "Plugin reply-account has invalid configuration: requested account not found: "+query); $TD.alert("warning", "Plugin reply-account has invalid configuration: requested account not found: "+query);
@ -126,7 +126,7 @@ enabled(){
}; };
this.onSelectedAccountChanged = () => { this.onSelectedAccountChanged = () => {
var selected = $(".js-account-item.is-selected", ".js-account-list"); let selected = $(".js-account-item.is-selected", ".js-account-list");
this.lastSelectedAccount = selected.length === 1 ? selected.attr("data-account-key") : null; this.lastSelectedAccount = selected.length === 1 ? selected.attr("data-account-key") : null;
}; };
} }

View File

@ -44,12 +44,12 @@ enabled(){
// button // button
var buttonHTML = '<button class="manage-templates-btn needsclick btn btn-on-blue full-width txt-left margin-b--12 padding-v--6 padding-h--12"><i class="icon icon-bookmark"></i><span class="label padding-ls">Manage templates</span></button>'; let buttonHTML = '<button class="manage-templates-btn needsclick btn btn-on-blue full-width txt-left margin-b--12 padding-v--6 padding-h--12"><i class="icon icon-bookmark"></i><span class="label padding-ls">Manage templates</span></button>';
this.prevComposeMustache = TD.mustaches["compose/docked_compose.mustache"]; this.prevComposeMustache = TD.mustaches["compose/docked_compose.mustache"];
window.TDPF_injectMustache("compose/docked_compose.mustache", "prepend", '<div class="js-tweet-type-button">', buttonHTML); window.TDPF_injectMustache("compose/docked_compose.mustache", "prepend", '<div class="js-tweet-type-button">', buttonHTML);
var dockedComposePanel = $(".js-docked-compose"); let dockedComposePanel = $(".js-docked-compose");
if (dockedComposePanel.length){ if (dockedComposePanel.length){
dockedComposePanel.find(".js-tweet-type-button").first().before(buttonHTML); dockedComposePanel.find(".js-tweet-type-button").first().before(buttonHTML);
@ -57,7 +57,7 @@ enabled(){
// template implementation // template implementation
var readTemplateTokens = (contents, tokenData) => { const readTemplateTokens = (contents, tokenData) => {
let startIndex = -1; let startIndex = -1;
let endIndex = -1; let endIndex = -1;
@ -125,7 +125,7 @@ enabled(){
return [ contents, data ]; return [ contents, data ];
}; };
var doAjaxRequest = (index, url, evaluator) => { const doAjaxRequest = (index, url, evaluator) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!url){ if (!url){
resolve([ index, "{ajax}" ]); resolve([ index, "{ajax}" ]);
@ -145,7 +145,7 @@ enabled(){
}); });
}; };
var useTemplate = (contents, append) => { const useTemplate = (contents, append) => {
let ele = $(".js-compose-text"); let ele = $(".js-compose-text");
return if ele.length === 0; return if ele.length === 0;
@ -227,7 +227,7 @@ enabled(){
this.editingTemplate = null; this.editingTemplate = null;
var showTemplateModal = () => { const showTemplateModal = () => {
$(".js-app-content").prepend(this.htmlModal); $(".js-app-content").prepend(this.htmlModal);
/* TODO possibly implement this later /* TODO possibly implement this later
@ -328,11 +328,11 @@ enabled(){
onTemplatesUpdated(false); onTemplatesUpdated(false);
}; };
var hideTemplateModal = function(){ const hideTemplateModal = () => {
$("#templates-modal-wrap").remove(); $("#templates-modal-wrap").remove();
}; };
var toggleEditor = function(){ const toggleEditor = () => {
let editor = $("#template-editor"); let editor = $("#template-editor");
$("[name]", editor).val(""); $("[name]", editor).val("");
@ -341,7 +341,7 @@ enabled(){
} }
}; };
var onTemplatesUpdated = (save) => { const onTemplatesUpdated = (save) => {
let eles = []; let eles = [];
for(let identifier of Object.keys(this.config.templates)){ for(let identifier of Object.keys(this.config.templates)){

View File

@ -38,7 +38,7 @@ enabled(){
// hooks // hooks
var funcs = { const funcs = {
TwitterStatus: TD.services.TwitterStatus.prototype.render, TwitterStatus: TD.services.TwitterStatus.prototype.render,
TwitterActionOnTweet: TD.services.TwitterActionOnTweet.prototype.render, TwitterActionOnTweet: TD.services.TwitterActionOnTweet.prototype.render,
TweetDetailView: TD.components.TweetDetailView.prototype._renderChirp TweetDetailView: TD.components.TweetDetailView.prototype._renderChirp

View File

@ -2,17 +2,17 @@
// //
// Variable: Current highlighted column jQuery & data objects. // Variable: Current highlighted column jQuery & data objects.
// //
var highlightedColumnEle, highlightedColumnObj; let highlightedColumnEle, highlightedColumnObj;
// //
// Variable: Currently highlighted tweet jQuery & data objects. // Variable: Currently highlighted tweet jQuery & data objects.
// //
var highlightedTweetEle, highlightedTweetObj; let highlightedTweetEle, highlightedTweetObj;
// //
// Variable: Array of functions called after the website app is loaded. // Variable: Array of functions called after the website app is loaded.
// //
var onAppReady = []; let onAppReady = [];
// //
// Variable: DOM HTML element. // Variable: DOM HTML element.
@ -438,8 +438,8 @@
// Block: Expand shortened links on hover or display tooltip. // Block: Expand shortened links on hover or display tooltip.
// //
(function(){ (function(){
var prevMouseX = -1, prevMouseY = -1; let prevMouseX = -1, prevMouseY = -1;
var tooltipTimer, tooltipDisplayed; let tooltipTimer, tooltipDisplayed;
$(document.body).delegate("a[data-full-url]", { $(document.body).delegate("a[data-full-url]", {
mouseenter: function(){ mouseenter: function(){
@ -922,7 +922,7 @@
(function(){ (function(){
return if !ensurePropertyExists(TD, "vo", "Column", "prototype", "clear"); return if !ensurePropertyExists(TD, "vo", "Column", "prototype", "clear");
var holdingShift = false; let holdingShift = false;
const updateShiftState = (pressed) => { const updateShiftState = (pressed) => {
if (pressed != holdingShift){ if (pressed != holdingShift){
@ -1174,7 +1174,7 @@
return if !ensurePropertyExists(TD, "components", "BaseModal", "prototype", "setAndShowContainer"); return if !ensurePropertyExists(TD, "components", "BaseModal", "prototype", "setAndShowContainer");
return if !ensurePropertyExists(TD, "ui", "Column", "prototype", "playGifIfNotManuallyPaused"); return if !ensurePropertyExists(TD, "ui", "Column", "prototype", "playGifIfNotManuallyPaused");
var cancelModal = false; let cancelModal = false;
TD.components.MediaGallery.prototype._loadTweet = appendToFunction(TD.components.MediaGallery.prototype._loadTweet, function(){ TD.components.MediaGallery.prototype._loadTweet = appendToFunction(TD.components.MediaGallery.prototype._loadTweet, function(){
let media = this.chirp.getMedia().find(media => media.mediaId === this.clickedMediaEntityId); let media = this.chirp.getMedia().find(media => media.mediaId === this.clickedMediaEntityId);
@ -1215,12 +1215,13 @@
// Block: Add a pin icon to make tweet compose drawer stay open. // Block: Add a pin icon to make tweet compose drawer stay open.
// //
onAppReady.push(function(){ onAppReady.push(function(){
let ele = $(`<svg id="td-compose-drawer-pin" viewBox="0 0 24 24" class="icon js-show-tip" data-original-title="Stay open" data-tooltip-position="left"> let ele = $(`
<svg id="td-compose-drawer-pin" viewBox="0 0 24 24" class="icon js-show-tip" data-original-title="Stay open" data-tooltip-position="left">
<path d="M9.884,16.959l3.272,0.001l-0.82,4.568l-1.635,0l-0.817,-4.569Z"/> <path d="M9.884,16.959l3.272,0.001l-0.82,4.568l-1.635,0l-0.817,-4.569Z"/>
<rect x="8.694" y="7.208" width="5.652" height="7.445"/> <rect x="8.694" y="7.208" width="5.652" height="7.445"/>
<path d="M16.877,17.448c0,-1.908 -1.549,-3.456 -3.456,-3.456l-3.802,0c-1.907,0 -3.456,1.548 -3.456,3.456l10.714,0Z"/> <path d="M16.877,17.448c0,-1.908 -1.549,-3.456 -3.456,-3.456l-3.802,0c-1.907,0 -3.456,1.548 -3.456,3.456l10.714,0Z"/>
<path d="M6.572,5.676l2.182,2.183l5.532,0l2.182,-2.183l0,-1.455l-9.896,0l0,1.455Z"/> <path d="M6.572,5.676l2.182,2.183l5.532,0l2.182,-2.183l0,-1.455l-9.896,0l0,1.455Z"/>
</svg>`).appendTo(".js-docked-compose .js-compose-header"); </svg>`).appendTo(".js-docked-compose .js-compose-header");
ele.click(function(){ ele.click(function(){
if (TD.settings.getComposeStayOpen()){ if (TD.settings.getComposeStayOpen()){
@ -1479,8 +1480,7 @@
</div> </div>
</li> </li>
</ul> </ul>
</div> </div>`).appendTo(document.body);
`).appendTo(document.body);
ele.find("button").click(function(){ ele.find("button").click(function(){
ele.fadeOut(200); ele.fadeOut(200);
@ -1521,7 +1521,7 @@
}; };
if (window.TD_SESSION && window.TD_SESSION.gc){ if (window.TD_SESSION && window.TD_SESSION.gc){
var state; let state;
try{ try{
state = JSON.parse(window.TD_SESSION.gc); state = JSON.parse(window.TD_SESSION.gc);

View File

@ -3,14 +3,14 @@
// Block: Setup a simple JavaScript object configuration loader. // Block: Setup a simple JavaScript object configuration loader.
// //
window.TDPF_loadConfigurationFile = function(pluginObject, fileNameUser, fileNameDefault, onSuccess, onFailure){ window.TDPF_loadConfigurationFile = function(pluginObject, fileNameUser, fileNameDefault, onSuccess, onFailure){
var identifier = pluginObject.$id; let identifier = pluginObject.$id;
var token = pluginObject.$token; let token = pluginObject.$token;
$TDP.checkFileExists(token, fileNameUser).then(exists => { $TDP.checkFileExists(token, fileNameUser).then(exists => {
var fileName = exists ? fileNameUser : fileNameDefault; let fileName = exists ? fileNameUser : fileNameDefault;
(exists ? $TDP.readFile(token, fileName, true) : $TDP.readFileRoot(token, fileName)).then(contents => { (exists ? $TDP.readFile(token, fileName, true) : $TDP.readFileRoot(token, fileName)).then(contents => {
var obj; let obj;
try{ try{
obj = eval("("+contents+")"); obj = eval("("+contents+")");
@ -39,7 +39,7 @@
// Block: Setup a function to add/remove custom CSS. // Block: Setup a function to add/remove custom CSS.
// //
window.TDPF_createCustomStyle = function(pluginObject){ window.TDPF_createCustomStyle = function(pluginObject){
var element = document.createElement("style"); let element = document.createElement("style");
element.id = "plugin-"+pluginObject.$id+"-"+Math.random().toString(36).substring(2, 7); element.id = "plugin-"+pluginObject.$id+"-"+Math.random().toString(36).substring(2, 7);
document.head.appendChild(element); document.head.appendChild(element);

View File

@ -2,14 +2,14 @@
// //
// Variable: Collection of all <a> tags. // Variable: Collection of all <a> tags.
// //
var links = document.getElementsByTagName("A"); const links = document.getElementsByTagName("A");
// //
// Function: Adds an event listener to all elements in the array or collection. // Function: Adds an event listener to all elements in the array or collection.
// //
var addEventListener = function(collection, type, listener){ const addEventListener = function(collection, type, listener){
for(let index = 0; index < collection.length; index++){ for(let ele of collection){
collection[index].addEventListener(type, listener); ele.addEventListener(type, listener);
} }
}; };
@ -42,16 +42,16 @@
// Block: Expand shortened links on hover or display tooltip. // Block: Expand shortened links on hover or display tooltip.
// //
(function(){ (function(){
var prevMouseX = -1, prevMouseY = -1; let prevMouseX = -1, prevMouseY = -1;
var tooltipTimer, tooltipDisplayed; let tooltipTimer, tooltipDisplayed;
addEventListener(links, "mouseenter", function(e){ addEventListener(links, "mouseenter", function(e){
var me = e.currentTarget; let me = e.currentTarget;
var url = me.getAttribute("data-full-url"); let url = me.getAttribute("data-full-url");
return if !url; return if !url;
var text = me.textContent; let text = me.textContent;
return if text.charCodeAt(text.length-1) !== 8230 && text.charCodeAt(0) !== 8230; // horizontal ellipsis return if text.charCodeAt(text.length-1) !== 8230 && text.charCodeAt(0) !== 8230; // horizontal ellipsis
if ($TDX.expandLinksOnHover){ if ($TDX.expandLinksOnHover){
@ -72,7 +72,7 @@
return if !e.currentTarget.hasAttribute("data-full-url"); return if !e.currentTarget.hasAttribute("data-full-url");
if ($TDX.expandLinksOnHover){ if ($TDX.expandLinksOnHover){
var prevText = e.currentTarget.getAttribute("td-prev-text"); let prevText = e.currentTarget.getAttribute("td-prev-text");
if (prevText){ if (prevText){
e.currentTarget.innerHTML = prevText; e.currentTarget.innerHTML = prevText;
@ -89,7 +89,7 @@
addEventListener(links, "mousemove", function(e){ addEventListener(links, "mousemove", function(e){
if (tooltipDisplayed && (prevMouseX !== e.clientX || prevMouseY !== e.clientY)){ if (tooltipDisplayed && (prevMouseX !== e.clientX || prevMouseY !== e.clientY)){
var url = e.currentTarget.getAttribute("data-full-url"); let url = e.currentTarget.getAttribute("data-full-url");
return if !url; return if !url;
$TD.displayTooltip(url); $TD.displayTooltip(url);
@ -110,7 +110,7 @@
// Block: Setup a handler for 'Show this thread'. // Block: Setup a handler for 'Show this thread'.
// //
(function(){ (function(){
var btn = document.getElementById("tduck-show-thread"); let btn = document.getElementById("tduck-show-thread");
return if !btn; return if !btn;
btn.addEventListener("click", function(){ btn.addEventListener("click", function(){

View File

@ -1,6 +1,4 @@
(function(){ (function(){
var isReloading = false;
// //
// Class: Abstract plugin base class. // Class: Abstract plugin base class.
// //
@ -107,12 +105,16 @@
// //
// Block: Setup a function to reload the page. // Block: Setup a function to reload the page.
// //
window.TDPF_requestReload = function(){ (function(){
if (!isReloading){ let isReloading = false;
window.setTimeout(window.TDGF_reload, 1);
isReloading = true; window.TDPF_requestReload = function(){
} if (!isReloading){
}; window.setTimeout(window.TDGF_reload, 1);
isReloading = true;
}
};
})();
// //
// Block: Setup bridges to global functions. // Block: Setup bridges to global functions.

View File

@ -2,13 +2,13 @@
// //
// Function: Inject custom CSS into the page. // Function: Inject custom CSS into the page.
// //
var injectCSS = function(){ const injectCSS = function(){
if (!document.head){ if (!document.head){
setTimeout(injectCSS, 5); setTimeout(injectCSS, 5);
return; return;
} }
var style = document.createElement("style"); let style = document.createElement("style");
style.innerText = `#import "styles/twitter.base.css"`; style.innerText = `#import "styles/twitter.base.css"`;
@ -26,7 +26,7 @@
// //
if (location.pathname === "/login"){ if (location.pathname === "/login"){
document.addEventListener("DOMContentLoaded", function(){ document.addEventListener("DOMContentLoaded", function(){
let openLinkExternally = function(e){ const openLinkExternally = function(e){
let href = e.currentTarget.getAttribute("href"); let href = e.currentTarget.getAttribute("href");
$TD.openBrowser(href[0] === '/' ? location.origin+href : href); $TD.openBrowser(href[0] === '/' ? location.origin+href : href);
@ -34,10 +34,8 @@
e.stopPropagation(); e.stopPropagation();
}; };
let links = document.getElementsByTagName("A"); for(let link of document.getElementsByTagName("A")){
link.addEventListener("click", openLinkExternally);
for(let index = 0; index < links.length; index++){
links[index].addEventListener("click", openLinkExternally);
} }
let texts = document.querySelector(".page-canvas > div:last-child"); let texts = document.querySelector(".page-canvas > div:last-child");

View File

@ -2,7 +2,7 @@
// //
// Function: Creates the update notification element. Removes the old one if already exists. // Function: Creates the update notification element. Removes the old one if already exists.
// //
var displayNotification = function(version, changelog){ const displayNotification = function(version, changelog){
// styles // styles
let css = document.getElementById("tweetduck-update-css"); let css = document.getElementById("tweetduck-update-css");