mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-07 09:15:50 +02:00
Massive JS formatting refactoring
This commit is contained in:
parent
937c8e22c4
commit
6d6bb79199
Resources
Plugins
.debug
clear-columns
edit-design
emoji-keyboard
reply-account
templates
timeline-polls
Scripts
@ -2,6 +2,7 @@ enabled(){
|
||||
this.isDebugging = false;
|
||||
|
||||
this.onKeyDown = (e) => {
|
||||
|
||||
// ==========================
|
||||
// F4 key - toggle debug mode
|
||||
// ==========================
|
||||
@ -11,8 +12,6 @@ enabled(){
|
||||
$(".nav-user-info").first().css("background-color", this.isDebugging ? "#5A6B75" : "#292F33");
|
||||
}
|
||||
|
||||
// Debug mode handling
|
||||
|
||||
else if (this.isDebugging){
|
||||
e.preventDefault();
|
||||
|
||||
@ -22,15 +21,16 @@ enabled(){
|
||||
// ===================================
|
||||
|
||||
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();
|
||||
var prevSound = col.model.getHasSound();
|
||||
let prevPopup = model.getHasNotification();
|
||||
let prevSound = model.getHasSound();
|
||||
|
||||
col.model.setHasNotification(e.keyCode === 78);
|
||||
col.model.setHasSound(e.keyCode === 83);
|
||||
model.setHasNotification(e.keyCode === 78);
|
||||
model.setHasSound(e.keyCode === 83);
|
||||
|
||||
$.publish("/notifications/new",[{
|
||||
$.publish("/notifications/new", [{
|
||||
column: col,
|
||||
items: [
|
||||
col.updateArray[Math.floor(Math.random()*col.updateArray.length)]
|
||||
@ -38,8 +38,8 @@ enabled(){
|
||||
}]);
|
||||
|
||||
setTimeout(function(){
|
||||
col.model.setHasNotification(prevPopup);
|
||||
col.model.setHasSound(prevSound);
|
||||
model.setHasNotification(prevPopup);
|
||||
model.setHasSound(prevSound);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
|
@ -6,24 +6,24 @@ constructor(){
|
||||
|
||||
enabled(){
|
||||
// prepare variables and functions
|
||||
var clearColumn = (columnName) => {
|
||||
const clearColumn = (columnName) => {
|
||||
TD.controller.columnManager.get(columnName).clear();
|
||||
TD.controller.stats.columnActionClick("clear");
|
||||
};
|
||||
|
||||
var resetColumn = (columnName) => {
|
||||
const resetColumn = (columnName) => {
|
||||
let col = TD.controller.columnManager.get(columnName);
|
||||
col.model.setClearedTimestamp(0);
|
||||
col.reloadTweets();
|
||||
};
|
||||
|
||||
var forEachColumn = (func) => {
|
||||
const forEachColumn = (func) => {
|
||||
Object.keys(TD.controller.columnManager.getAll()).forEach(func);
|
||||
};
|
||||
|
||||
var wasShiftPressed = false;
|
||||
let wasShiftPressed = false;
|
||||
|
||||
var updateShiftState = (pressed) => {
|
||||
const updateShiftState = (pressed) => {
|
||||
if (pressed != wasShiftPressed){
|
||||
wasShiftPressed = pressed;
|
||||
|
||||
@ -40,7 +40,7 @@ enabled(){
|
||||
|
||||
// prepare event handlers
|
||||
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);
|
||||
};
|
||||
|
||||
@ -58,10 +58,10 @@ enabled(){
|
||||
forEachColumn(e.shiftKey ? resetColumn : clearColumn);
|
||||
}
|
||||
else{
|
||||
var focusedColumn = $(".js-column.is-focused");
|
||||
let focusedColumn = $(".js-column.is-focused");
|
||||
|
||||
if (focusedColumn.length){
|
||||
var name = focusedColumn.attr("data-column");
|
||||
let name = focusedColumn.attr("data-column");
|
||||
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>`)
|
||||
|
||||
// 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(".column-header-links { min-width: 51px !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);
|
||||
|
||||
// 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){
|
||||
$(".clear-columns-btn-all-parent").on("mouseover", tooltipEvents.mouseover[0].handler).on("mouseout", tooltipEvents.mouseout[0].handler);
|
||||
|
@ -21,7 +21,7 @@ enabled(){
|
||||
avatarRadius: 2
|
||||
};
|
||||
|
||||
var prepareDefaultConfig = () => {
|
||||
const prepareDefaultConfig = () => {
|
||||
this.defaultConfig._theme = TD.settings.getTheme();
|
||||
|
||||
switch(TD.settings.getColumnWidth()){
|
||||
@ -39,7 +39,7 @@ enabled(){
|
||||
|
||||
this.firstTimeLoad = null;
|
||||
|
||||
var me = this;
|
||||
const me = this;
|
||||
|
||||
// modal dialog loading
|
||||
$TDP.readFileRoot(this.$token, "modal.html").then(contents => {
|
||||
@ -72,7 +72,7 @@ enabled(){
|
||||
}
|
||||
};
|
||||
|
||||
var loadConfigObject = obj => {
|
||||
const loadConfigObject = obj => {
|
||||
this.tmpConfig = obj || {};
|
||||
this.firstTimeLoad = obj === null;
|
||||
|
||||
@ -139,7 +139,7 @@ enabled(){
|
||||
};
|
||||
|
||||
// modal dialog setup
|
||||
var updateKey = function(key, value){
|
||||
const updateKey = function(key, value){
|
||||
me.config[key] = value;
|
||||
|
||||
setTimeout(function(){
|
||||
@ -228,7 +228,7 @@ enabled(){
|
||||
if (value == me.config[key]){
|
||||
item.addClass("selected");
|
||||
}
|
||||
|
||||
|
||||
item.click(function(){
|
||||
modal.find("[data-td-key='"+key+"']").removeClass("selected");
|
||||
item.addClass("selected");
|
||||
@ -407,7 +407,7 @@ enabled(){
|
||||
case "dark":
|
||||
this.css.insert(".scroll-styled-v:not(.scroll-alt)::-webkit-scrollbar-track, .scroll-styled-h:not(.scroll-alt)::-webkit-scrollbar-track { border-left-color: #14171A !important }");
|
||||
break;
|
||||
|
||||
|
||||
case "light":
|
||||
this.css.insert(".scroll-styled-v:not(.scroll-alt)::-webkit-scrollbar-thumb:not(:hover), .scroll-styled-h:not(.scroll-alt)::-webkit-scrollbar-thumb:not(:hover) { background-color: #d2d6da !important }");
|
||||
this.css.insert(".app-columns-container.scroll-styled-h::-webkit-scrollbar-thumb:not(:hover) { background-color: #a5aeb5 !important }");
|
||||
@ -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>');
|
||||
|
||||
// global settings override
|
||||
var me = this;
|
||||
const me = this;
|
||||
|
||||
this.prevFuncSettingsGetInfo = TD.components.GlobalSettings.prototype.getInfo;
|
||||
this.prevFuncSettingsSwitchTab = TD.components.GlobalSettings.prototype.switchTab;
|
||||
|
@ -26,7 +26,7 @@ enabled(){
|
||||
this.emojiData3 = []; // no skin tones, appended
|
||||
this.emojiNames = [];
|
||||
|
||||
var me = this;
|
||||
const me = this;
|
||||
|
||||
// styles
|
||||
|
||||
@ -51,12 +51,12 @@ enabled(){
|
||||
|
||||
// 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"];
|
||||
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){
|
||||
maybeDockedComposePanel.find(".cf.margin-t--12.margin-b--30").first().append(buttonHTML);
|
||||
@ -67,10 +67,10 @@ enabled(){
|
||||
this.currentKeyboard = null;
|
||||
this.currentSpanner = null;
|
||||
|
||||
var wasSearchFocused = false;
|
||||
var lastEmojiKeyword, lastEmojiPosition, lastEmojiLength;
|
||||
let wasSearchFocused = false;
|
||||
let lastEmojiKeyword, lastEmojiPosition, lastEmojiLength;
|
||||
|
||||
var hideKeyboard = (refocus) => {
|
||||
const hideKeyboard = (refocus) => {
|
||||
$(this.currentKeyboard).remove();
|
||||
this.currentKeyboard = null;
|
||||
|
||||
@ -94,7 +94,7 @@ enabled(){
|
||||
lastEmojiKeyword = null;
|
||||
};
|
||||
|
||||
var generateEmojiHTML = skinTone => {
|
||||
const generateEmojiHTML = skinTone => {
|
||||
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>" ];
|
||||
|
||||
@ -113,7 +113,7 @@ enabled(){
|
||||
return html.join("");
|
||||
};
|
||||
|
||||
var updateFilters = () => {
|
||||
const updateFilters = () => {
|
||||
let keywords = this.currentKeywords;
|
||||
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+"']");
|
||||
selectedEle && selectedEle.classList.remove("sel");
|
||||
|
||||
@ -146,12 +146,12 @@ enabled(){
|
||||
};
|
||||
|
||||
this.generateKeyboard = (left, top) => {
|
||||
var outer = document.createElement("div");
|
||||
let outer = document.createElement("div");
|
||||
outer.classList.add("emoji-keyboard");
|
||||
outer.style.left = left+"px";
|
||||
outer.style.top = top+"px";
|
||||
|
||||
var keyboard = document.createElement("div");
|
||||
let keyboard = document.createElement("div");
|
||||
keyboard.classList.add("emoji-keyboard-list");
|
||||
|
||||
keyboard.addEventListener("click", function(e){
|
||||
@ -164,11 +164,11 @@ enabled(){
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
var search = document.createElement("div");
|
||||
let search = document.createElement("div");
|
||||
search.innerHTML = "<input type='text' placeholder='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.classList.add("emoji-keyboard-skintones");
|
||||
|
||||
@ -189,7 +189,7 @@ enabled(){
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
var searchInput = search.children[0];
|
||||
let searchInput = search.children[0];
|
||||
searchInput.focus();
|
||||
|
||||
wasSearchFocused = false;
|
||||
@ -232,21 +232,21 @@ enabled(){
|
||||
this.composePanelScroller.trigger("scroll");
|
||||
};
|
||||
|
||||
var getKeyboardTop = () => {
|
||||
const getKeyboardTop = () => {
|
||||
let button = $(".emoji-keyboard-popup-btn");
|
||||
return button.offset().top+button.outerHeight()+me.composePanelScroller.scrollTop()+8;
|
||||
};
|
||||
|
||||
var insertEmoji = (src, alt) => {
|
||||
const insertEmoji = (src, alt) => {
|
||||
let input = this.composeInput;
|
||||
|
||||
|
||||
let val = input.val();
|
||||
let posStart = input[0].selectionStart;
|
||||
let posEnd = input[0].selectionEnd;
|
||||
|
||||
|
||||
input.val(val.slice(0, posStart)+alt+val.slice(posEnd));
|
||||
input.trigger("change");
|
||||
|
||||
|
||||
input[0].selectionStart = posStart+alt.length;
|
||||
input[0].selectionEnd = posStart+alt.length;
|
||||
|
||||
@ -288,7 +288,7 @@ enabled(){
|
||||
if (ele.selectionStart === lastEmojiPosition){
|
||||
ele.selectionStart -= lastEmojiLength; // selects the emoji
|
||||
document.execCommand("insertText", false, lastEmojiKeyword);
|
||||
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
@ -418,7 +418,7 @@ ready(){
|
||||
|
||||
// HTML generation
|
||||
|
||||
var convUnicode = function(codePt){
|
||||
const convUnicode = function(codePt){
|
||||
if (codePt > 0xFFFF){
|
||||
codePt -= 0x10000;
|
||||
return String.fromCharCode(0xD800+(codePt>>10), 0xDC00+(codePt&0x3FF));
|
||||
@ -489,7 +489,7 @@ ready(){
|
||||
|
||||
if (skinToneState === 1){
|
||||
let skinIndex = decl.indexOf('$');
|
||||
|
||||
|
||||
if (skinIndex !== -1){
|
||||
let declPre = decl.slice(0, skinIndex);
|
||||
let declPost = decl.slice(skinIndex+1);
|
||||
|
@ -1,5 +1,5 @@
|
||||
enabled(){
|
||||
var configuration = { defaultAccount: "#preferred" };
|
||||
let configuration = { defaultAccount: "#preferred" };
|
||||
|
||||
window.TDPF_loadConfigurationFile(this, "configuration.js", "configuration.default.js", obj => configuration = obj);
|
||||
|
||||
@ -8,7 +8,7 @@ enabled(){
|
||||
this.uiComposeTweetEvent = (e, 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.customSelector){
|
||||
@ -88,7 +88,7 @@ enabled(){
|
||||
return;
|
||||
}
|
||||
|
||||
var identifier = null;
|
||||
let identifier = null;
|
||||
|
||||
switch(query){
|
||||
case "#preferred":
|
||||
@ -106,7 +106,7 @@ enabled(){
|
||||
|
||||
default:
|
||||
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){
|
||||
$TD.alert("warning", "Plugin reply-account has invalid configuration: requested account not found: "+query);
|
||||
@ -126,7 +126,7 @@ enabled(){
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
@ -44,12 +44,12 @@ enabled(){
|
||||
|
||||
// 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"];
|
||||
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){
|
||||
dockedComposePanel.find(".js-tweet-type-button").first().before(buttonHTML);
|
||||
@ -57,7 +57,7 @@ enabled(){
|
||||
|
||||
// template implementation
|
||||
|
||||
var readTemplateTokens = (contents, tokenData) => {
|
||||
const readTemplateTokens = (contents, tokenData) => {
|
||||
let startIndex = -1;
|
||||
let endIndex = -1;
|
||||
|
||||
@ -125,7 +125,7 @@ enabled(){
|
||||
return [ contents, data ];
|
||||
};
|
||||
|
||||
var doAjaxRequest = (index, url, evaluator) => {
|
||||
const doAjaxRequest = (index, url, evaluator) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!url){
|
||||
resolve([ index, "{ajax}" ]);
|
||||
@ -145,7 +145,7 @@ enabled(){
|
||||
});
|
||||
};
|
||||
|
||||
var useTemplate = (contents, append) => {
|
||||
const useTemplate = (contents, append) => {
|
||||
let ele = $(".js-compose-text");
|
||||
return if ele.length === 0;
|
||||
|
||||
@ -183,7 +183,7 @@ enabled(){
|
||||
url = evaluator;
|
||||
evaluator = null;
|
||||
}
|
||||
|
||||
|
||||
promises.push(doAjaxRequest(index2, url, evaluator));
|
||||
break;
|
||||
}
|
||||
@ -227,7 +227,7 @@ enabled(){
|
||||
|
||||
this.editingTemplate = null;
|
||||
|
||||
var showTemplateModal = () => {
|
||||
const showTemplateModal = () => {
|
||||
$(".js-app-content").prepend(this.htmlModal);
|
||||
|
||||
/* TODO possibly implement this later
|
||||
@ -328,11 +328,11 @@ enabled(){
|
||||
onTemplatesUpdated(false);
|
||||
};
|
||||
|
||||
var hideTemplateModal = function(){
|
||||
const hideTemplateModal = () => {
|
||||
$("#templates-modal-wrap").remove();
|
||||
};
|
||||
|
||||
var toggleEditor = function(){
|
||||
const toggleEditor = () => {
|
||||
let editor = $("#template-editor");
|
||||
$("[name]", editor).val("");
|
||||
|
||||
@ -341,7 +341,7 @@ enabled(){
|
||||
}
|
||||
};
|
||||
|
||||
var onTemplatesUpdated = (save) => {
|
||||
const onTemplatesUpdated = (save) => {
|
||||
let eles = [];
|
||||
|
||||
for(let identifier of Object.keys(this.config.templates)){
|
||||
|
@ -8,7 +8,7 @@
|
||||
<button data-action="new-template" class="Button--primary"><i class="icon icon-plus icon-small padding-rs"></i><span class="label">New Template</span></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="template-editor" class="invisible">
|
||||
<div class="template-editor-form">
|
||||
<div class="compose-text-title">Template Name</div>
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
<div class="compose-text-title">Contents</div>
|
||||
<textarea name="template-contents" class="compose-text scroll-v scroll-styled-v scroll-styled-h scroll-alt"></textarea>
|
||||
|
||||
|
||||
<div class="compose-text-title template-editor-tips-button">Advanced <i class="icon icon-arrow-d"></i></div>
|
||||
<div class="template-editor-tips">
|
||||
<p>You can use the following tokens. All tokens except for <span style="font-family: monospace">{ajax}</span> can only be used once.</p>
|
||||
@ -69,7 +69,7 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
|
||||
.templates-modal-bottom {
|
||||
flex: 0 0 auto;
|
||||
padding: 16px;
|
||||
@ -92,7 +92,7 @@
|
||||
}
|
||||
|
||||
/* Template list */
|
||||
|
||||
|
||||
#template-list {
|
||||
height: 100%;
|
||||
flex: 1 1 auto;
|
||||
|
@ -38,7 +38,7 @@ enabled(){
|
||||
|
||||
// hooks
|
||||
|
||||
var funcs = {
|
||||
const funcs = {
|
||||
TwitterStatus: TD.services.TwitterStatus.prototype.render,
|
||||
TwitterActionOnTweet: TD.services.TwitterActionOnTweet.prototype.render,
|
||||
TweetDetailView: TD.components.TweetDetailView.prototype._renderChirp
|
||||
|
@ -2,17 +2,17 @@
|
||||
//
|
||||
// Variable: Current highlighted column jQuery & data objects.
|
||||
//
|
||||
var highlightedColumnEle, highlightedColumnObj;
|
||||
let highlightedColumnEle, highlightedColumnObj;
|
||||
|
||||
//
|
||||
// Variable: Currently highlighted tweet jQuery & data objects.
|
||||
//
|
||||
var highlightedTweetEle, highlightedTweetObj;
|
||||
let highlightedTweetEle, highlightedTweetObj;
|
||||
|
||||
//
|
||||
// Variable: Array of functions called after the website app is loaded.
|
||||
//
|
||||
var onAppReady = [];
|
||||
let onAppReady = [];
|
||||
|
||||
//
|
||||
// Variable: DOM HTML element.
|
||||
@ -116,10 +116,10 @@
|
||||
$(document).on("uiColumnRendered", function(e, data){
|
||||
let icon = data.$column.find(".column-type-icon").first();
|
||||
return if icon.length !== 1;
|
||||
|
||||
|
||||
let name = Array.prototype.find.call(icon[0].classList, cls => cls.startsWith("icon-"));
|
||||
return if !name;
|
||||
|
||||
|
||||
data.$column.attr("data-td-icon", name);
|
||||
data.column._tduck_icon = name;
|
||||
});
|
||||
@ -278,10 +278,10 @@
|
||||
let chirpId = source ? source.id : "";
|
||||
let tweetUrl = source ? source.getChirpURL() : "";
|
||||
let quoteUrl = source && source.quotedTweet ? source.quotedTweet.getChirpURL() : "";
|
||||
|
||||
|
||||
$TD.onTweetPopup(column.model.privateState.apiid, chirpId, window.TDGF_getColumnName(column), html.html(), duration, tweetUrl, quoteUrl);
|
||||
}
|
||||
|
||||
|
||||
if (column.model.getHasSound()){
|
||||
$TD.onTweetSound();
|
||||
}
|
||||
@ -300,7 +300,7 @@
|
||||
const showTweetDetailInternal = function(column, chirp){
|
||||
TD.ui.updates.showDetailView(column, chirp, column.findChirp(chirp) || chirp);
|
||||
TD.controller.columnManager.showColumn(column.model.privateState.key);
|
||||
|
||||
|
||||
$(document).trigger("uiGridClearSelection");
|
||||
};
|
||||
|
||||
@ -368,11 +368,11 @@
|
||||
TD.settings.setFontSize = appendToFunction(TD.settings.setFontSize, function(name){
|
||||
setTimeout(refreshSettings, 0);
|
||||
});
|
||||
|
||||
|
||||
TD.settings.setTheme = appendToFunction(TD.settings.setTheme, function(name){
|
||||
setTimeout(refreshSettings, 0);
|
||||
});
|
||||
|
||||
|
||||
onAppReady.push(refreshSettings);
|
||||
})();
|
||||
|
||||
@ -397,7 +397,7 @@
|
||||
TD.controller.notifications.hasNotifications = function(){
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
TD.controller.notifications.isPermissionGranted = function(){
|
||||
return true;
|
||||
};
|
||||
@ -420,11 +420,11 @@
|
||||
|
||||
let button = $('<li class="is-selectable" data-tweetduck><a href="#" data-action>TweetDuck</a></li>');
|
||||
button.insertBefore(menu.children(".drp-h-divider").last());
|
||||
|
||||
|
||||
button.on("click", "a", function(){
|
||||
$TD.openContextMenu();
|
||||
});
|
||||
|
||||
|
||||
button.hover(function(){
|
||||
$(this).addClass("is-selected");
|
||||
}, function(){
|
||||
@ -438,8 +438,8 @@
|
||||
// Block: Expand shortened links on hover or display tooltip.
|
||||
//
|
||||
(function(){
|
||||
var prevMouseX = -1, prevMouseY = -1;
|
||||
var tooltipTimer, tooltipDisplayed;
|
||||
let prevMouseX = -1, prevMouseY = -1;
|
||||
let tooltipTimer, tooltipDisplayed;
|
||||
|
||||
$(document.body).delegate("a[data-full-url]", {
|
||||
mouseenter: function(){
|
||||
@ -906,7 +906,7 @@
|
||||
$(document).on("dataTweetSent", function(e, data){
|
||||
if (data.response.state && data.response.state === "scheduled"){
|
||||
let column = Object.values(TD.controller.columnManager.getAll()).find(column => column.model.state.type === "scheduled");
|
||||
|
||||
|
||||
if (column){
|
||||
setTimeout(function(){
|
||||
column.reloadTweets();
|
||||
@ -922,7 +922,7 @@
|
||||
(function(){
|
||||
return if !ensurePropertyExists(TD, "vo", "Column", "prototype", "clear");
|
||||
|
||||
var holdingShift = false;
|
||||
let holdingShift = false;
|
||||
|
||||
const updateShiftState = (pressed) => {
|
||||
if (pressed != holdingShift){
|
||||
@ -1174,7 +1174,7 @@
|
||||
return if !ensurePropertyExists(TD, "components", "BaseModal", "prototype", "setAndShowContainer");
|
||||
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(){
|
||||
let media = this.chirp.getMedia().find(media => media.mediaId === this.clickedMediaEntityId);
|
||||
@ -1184,7 +1184,7 @@
|
||||
cancelModal = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
TD.components.BaseModal.prototype.setAndShowContainer = prependToFunction(TD.components.BaseModal.prototype.setAndShowContainer, function(){
|
||||
if (cancelModal){
|
||||
cancelModal = false;
|
||||
@ -1215,12 +1215,13 @@
|
||||
// Block: Add a pin icon to make tweet compose drawer stay open.
|
||||
//
|
||||
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"/>
|
||||
<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="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(){
|
||||
if (TD.settings.getComposeStayOpen()){
|
||||
@ -1249,16 +1250,16 @@
|
||||
if (data.query && data.searchScope !== "users" && !data.columnKey){
|
||||
if ($TDX.openSearchInFirstColumn){
|
||||
let order = TD.controller.columnManager._columnOrder;
|
||||
|
||||
|
||||
if (order.length > 1){
|
||||
let columnKey = order[order.length-1];
|
||||
|
||||
|
||||
order.splice(order.length-1, 1);
|
||||
order.splice(1, 0, columnKey);
|
||||
TD.controller.columnManager.move(columnKey, "left");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!("tweetduck" in data)){
|
||||
$(".js-app-search-input").val("");
|
||||
$(".js-perform-search").blur();
|
||||
@ -1378,7 +1379,7 @@
|
||||
$(".js-btn-fav", ".js-modal-inner").each(function(){
|
||||
let event = $._data(this, "events").click[0];
|
||||
let handler = event.handler;
|
||||
|
||||
|
||||
event.handler = function(){
|
||||
overrideState();
|
||||
handler.apply(this, arguments);
|
||||
@ -1392,7 +1393,7 @@
|
||||
let event = $._data(this, "events").click[0];
|
||||
let handler = event.handler;
|
||||
let context = handler.context;
|
||||
|
||||
|
||||
event.handler = function(){
|
||||
overrideState();
|
||||
handler.apply(this, arguments);
|
||||
@ -1434,11 +1435,11 @@
|
||||
|
||||
TD.services.TwitterConversation.prototype.renderThread = function(){
|
||||
let prevMessages = this.messages;
|
||||
|
||||
|
||||
this.messages = prevMessages.slice(0, 100);
|
||||
let result = prevFunc.apply(this, arguments);
|
||||
this.messages = prevMessages;
|
||||
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
@ -1479,9 +1480,8 @@
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
`).appendTo(document.body);
|
||||
|
||||
</div>`).appendTo(document.body);
|
||||
|
||||
ele.find("button").click(function(){
|
||||
ele.fadeOut(200);
|
||||
});
|
||||
@ -1521,7 +1521,7 @@
|
||||
};
|
||||
|
||||
if (window.TD_SESSION && window.TD_SESSION.gc){
|
||||
var state;
|
||||
let state;
|
||||
|
||||
try{
|
||||
state = JSON.parse(window.TD_SESSION.gc);
|
||||
@ -1562,7 +1562,7 @@
|
||||
$(document).one("dataColumnsLoaded", function(){
|
||||
let columns = Object.values(TD.controller.columnManager.getAll());
|
||||
let remaining = columns.length;
|
||||
|
||||
|
||||
for(let column of columns){
|
||||
column.ui.getChirpContainer().one("dataColumnFeedUpdated", () => {
|
||||
if (--remaining === 0){
|
||||
|
@ -3,14 +3,14 @@
|
||||
// Block: Setup a simple JavaScript object configuration loader.
|
||||
//
|
||||
window.TDPF_loadConfigurationFile = function(pluginObject, fileNameUser, fileNameDefault, onSuccess, onFailure){
|
||||
var identifier = pluginObject.$id;
|
||||
var token = pluginObject.$token;
|
||||
let identifier = pluginObject.$id;
|
||||
let token = pluginObject.$token;
|
||||
|
||||
$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 => {
|
||||
var obj;
|
||||
let obj;
|
||||
|
||||
try{
|
||||
obj = eval("("+contents+")");
|
||||
@ -39,7 +39,7 @@
|
||||
// Block: Setup a function to add/remove custom CSS.
|
||||
//
|
||||
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);
|
||||
document.head.appendChild(element);
|
||||
|
||||
|
@ -2,14 +2,14 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
var addEventListener = function(collection, type, listener){
|
||||
for(let index = 0; index < collection.length; index++){
|
||||
collection[index].addEventListener(type, listener);
|
||||
const addEventListener = function(collection, type, listener){
|
||||
for(let ele of collection){
|
||||
ele.addEventListener(type, listener);
|
||||
}
|
||||
};
|
||||
|
||||
@ -20,13 +20,13 @@
|
||||
const onLinkClick = function(e){
|
||||
if (e.button === 0 || e.button === 1){
|
||||
let ele = e.currentTarget;
|
||||
|
||||
|
||||
$TD.openBrowser(ele.href);
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
if ($TDX.skipOnLinkClick){
|
||||
let parentClasses = ele.parentNode.classList;
|
||||
|
||||
|
||||
if (parentClasses.contains("js-tweet-text") || parentClasses.contains("js-quoted-tweet-text") || parentClasses.contains("js-timestamp")){
|
||||
$TD.loadNextNotification();
|
||||
}
|
||||
@ -42,18 +42,18 @@
|
||||
// Block: Expand shortened links on hover or display tooltip.
|
||||
//
|
||||
(function(){
|
||||
var prevMouseX = -1, prevMouseY = -1;
|
||||
var tooltipTimer, tooltipDisplayed;
|
||||
let prevMouseX = -1, prevMouseY = -1;
|
||||
let tooltipTimer, tooltipDisplayed;
|
||||
|
||||
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;
|
||||
|
||||
var text = me.textContent;
|
||||
let text = me.textContent;
|
||||
return if text.charCodeAt(text.length-1) !== 8230 && text.charCodeAt(0) !== 8230; // horizontal ellipsis
|
||||
|
||||
|
||||
if ($TDX.expandLinksOnHover){
|
||||
tooltipTimer = window.setTimeout(function(){
|
||||
me.setAttribute("td-prev-text", text);
|
||||
@ -72,8 +72,8 @@
|
||||
return if !e.currentTarget.hasAttribute("data-full-url");
|
||||
|
||||
if ($TDX.expandLinksOnHover){
|
||||
var prevText = e.currentTarget.getAttribute("td-prev-text");
|
||||
|
||||
let prevText = e.currentTarget.getAttribute("td-prev-text");
|
||||
|
||||
if (prevText){
|
||||
e.currentTarget.innerHTML = prevText;
|
||||
}
|
||||
@ -89,7 +89,7 @@
|
||||
|
||||
addEventListener(links, "mousemove", function(e){
|
||||
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;
|
||||
|
||||
$TD.displayTooltip(url);
|
||||
@ -110,7 +110,7 @@
|
||||
// Block: Setup a handler for 'Show this thread'.
|
||||
//
|
||||
(function(){
|
||||
var btn = document.getElementById("tduck-show-thread");
|
||||
let btn = document.getElementById("tduck-show-thread");
|
||||
return if !btn;
|
||||
|
||||
btn.addEventListener("click", function(){
|
||||
@ -138,7 +138,7 @@
|
||||
document.body.addEventListener("mouseenter", function(){
|
||||
document.body.classList.add("td-hover");
|
||||
});
|
||||
|
||||
|
||||
document.body.addEventListener("mouseleave", function(){
|
||||
document.body.classList.remove("td-hover");
|
||||
});
|
||||
|
@ -1,6 +1,4 @@
|
||||
(function(){
|
||||
var isReloading = false;
|
||||
|
||||
//
|
||||
// Class: Abstract plugin base class.
|
||||
//
|
||||
@ -107,12 +105,16 @@
|
||||
//
|
||||
// Block: Setup a function to reload the page.
|
||||
//
|
||||
window.TDPF_requestReload = function(){
|
||||
if (!isReloading){
|
||||
window.setTimeout(window.TDGF_reload, 1);
|
||||
isReloading = true;
|
||||
}
|
||||
};
|
||||
(function(){
|
||||
let isReloading = false;
|
||||
|
||||
window.TDPF_requestReload = function(){
|
||||
if (!isReloading){
|
||||
window.setTimeout(window.TDGF_reload, 1);
|
||||
isReloading = true;
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
//
|
||||
// Block: Setup bridges to global functions.
|
||||
|
@ -2,13 +2,13 @@
|
||||
//
|
||||
// Function: Inject custom CSS into the page.
|
||||
//
|
||||
var injectCSS = function(){
|
||||
const injectCSS = function(){
|
||||
if (!document.head){
|
||||
setTimeout(injectCSS, 5);
|
||||
return;
|
||||
}
|
||||
|
||||
var style = document.createElement("style");
|
||||
let style = document.createElement("style");
|
||||
|
||||
style.innerText = `#import "styles/twitter.base.css"`;
|
||||
|
||||
@ -26,22 +26,20 @@
|
||||
//
|
||||
if (location.pathname === "/login"){
|
||||
document.addEventListener("DOMContentLoaded", function(){
|
||||
let openLinkExternally = function(e){
|
||||
const openLinkExternally = function(e){
|
||||
let href = e.currentTarget.getAttribute("href");
|
||||
$TD.openBrowser(href[0] === '/' ? location.origin+href : href);
|
||||
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
let links = document.getElementsByTagName("A");
|
||||
|
||||
for(let index = 0; index < links.length; index++){
|
||||
links[index].addEventListener("click", openLinkExternally);
|
||||
|
||||
for(let link of document.getElementsByTagName("A")){
|
||||
link.addEventListener("click", openLinkExternally);
|
||||
}
|
||||
|
||||
|
||||
let texts = document.querySelector(".page-canvas > div:last-child");
|
||||
|
||||
|
||||
if (texts){
|
||||
texts.insertAdjacentHTML("beforeend", `<p class="tweetduck-helper">Used the TweetDuck app before? <a href="#">Import your profile »</a></p>`);
|
||||
|
||||
@ -57,7 +55,7 @@
|
||||
else if (location.pathname === "/logout"){
|
||||
document.addEventListener("DOMContentLoaded", function(){
|
||||
let cancel = document.querySelector(".buttons .cancel");
|
||||
|
||||
|
||||
if (cancel && cancel.tagName === "A"){
|
||||
cancel.href = "https://tweetdeck.twitter.com/";
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Function: Creates the update notification element. Removes the old one if already exists.
|
||||
//
|
||||
var displayNotification = function(version, changelog){
|
||||
const displayNotification = function(version, changelog){
|
||||
|
||||
// styles
|
||||
let css = document.getElementById("tweetduck-update-css");
|
||||
|
Loading…
Reference in New Issue
Block a user