From bae73521e9648bf70f8a5aa30af522866bcb74ae Mon Sep 17 00:00:00 2001 From: cutls Date: Sun, 24 Nov 2019 23:53:35 +0900 Subject: [PATCH] WIP: use-strict --- app/js/login/manager.js | 10 +++++----- app/js/platform/end.js | 2 +- app/js/platform/preload.js | 2 +- app/js/tl/card.js | 2 +- app/js/tl/filter.js | 1 + app/js/tl/list.js | 1 + app/js/tl/misskeyparse.js | 1 + app/js/tl/mix.js | 1 + app/js/tl/notification.js | 1 + app/js/tl/old-mix.js | 1 + app/js/tl/parse.js | 5 +++-- app/js/tl/poll.js | 1 + app/js/tl/speech.js | 23 ++++++++++++----------- app/js/tl/src.js | 1 + app/js/tl/tag.js | 1 + app/js/tl/tl.js | 3 ++- app/js/ui/img.js | 5 +++-- app/js/ui/layout.js | 3 ++- app/js/ui/menu.js | 1 + app/js/ui/pip.js | 1 + app/js/ui/post-box.js | 1 + app/js/ui/radio.js | 1 + app/js/ui/scroll.js | 1 + app/js/ui/settings.js | 1 + app/js/ui/sort.js | 1 + app/js/ui/spotify.js | 1 + app/js/ui/theme.js | 1 + app/js/ui/tips.js | 3 ++- app/js/userdata/his-data.js | 1 + app/js/userdata/prof-edit.js | 1 + app/js/userdata/showOnTL.js | 1 + 31 files changed, 53 insertions(+), 26 deletions(-) diff --git a/app/js/login/manager.js b/app/js/login/manager.js index 19d8902d..77b1ab53 100644 --- a/app/js/login/manager.js +++ b/app/js/login/manager.js @@ -62,7 +62,7 @@ function load() { refresh${lang.lang_manager_refresh} - delete${lang.lang_manager_delete}" + delete${lang.lang_manager_delete}
${lang.lang_manager_color}
@@ -317,7 +317,7 @@ function support() { Object.keys(idata).forEach(function(key) { var instance = idata[key] if (instance == 'instance') { - templete = + var templete = '' + @@ -951,7 +951,7 @@ function multisel() { var list = key * 1 + 1 if (key == last) { sel = 'selected' - mainb = '(' + lang.lang_manager_def + ')' + var mainb = '(' + lang.lang_manager_def + ')' var domain = localStorage.getItem('domain_' + key) var profimg = localStorage.getItem('prof_' + key) var domain = localStorage.getItem('domain_' + key) @@ -962,7 +962,7 @@ function multisel() { sel = '' mainb = '' } - template = ` + var template = ` @@ -978,7 +978,7 @@ function mainacct() { M.toast({ html: lang.lang_manager_mainAcct, displayLength: 3000 }) } function colorpicker(key) { - temp = `
${lang.lang_manager_none}
+ var temp = `
${lang.lang_manager_none}
diff --git a/app/js/platform/end.js b/app/js/platform/end.js index 62968ca8..239574e6 100644 --- a/app/js/platform/end.js +++ b/app/js/platform/end.js @@ -11,7 +11,7 @@ $(document).on('click', 'a', e => { if (url) { urls = url.match(/https?:\/\/(.+)/) //トゥートのURLぽかったら - toot = url.match(/https:\/\/([^+_]+)\/@([a-zA-Z0-9_]+)\/([0-9]+)/) + var toot = url.match(/https:\/\/([^+_]+)\/@([a-zA-Z0-9_]+)\/([0-9]+)/) if (!toot) { //Pleroma対策 toot = url.match(/https:\/\/([^+_]+)\/users\/([a-zA-Z0-9_]+)\/statuses\/([0-9]+)/) diff --git a/app/js/platform/preload.js b/app/js/platform/preload.js index 32bcd622..59219ce0 100644 --- a/app/js/platform/preload.js +++ b/app/js/platform/preload.js @@ -4,7 +4,7 @@ const shell = electron.shell var ipc = electron.ipcRenderer onmessage = function(e) { if (e.data[0] == 'openUrl') { - urls = e.data[1].match(/https?:\/\/(.+)/) + var urls = e.data[1].match(/https?:\/\/(.+)/) if (urls) { shell.openExternal(e.data[1]) } diff --git a/app/js/tl/card.js b/app/js/tl/card.js index cb60d609..eac0e6fd 100644 --- a/app/js/tl/card.js +++ b/app/js/tl/card.js @@ -173,7 +173,7 @@ function additionalIndv(tlid, acct_id, id) { console.error(error) }) .then(function(json) { - cards = json.card + var cards = json.card var analyze = cardHtml(cards, acct_id, id) $('[toot-id=' + id + '] .additional').html(analyze) if (json.title) { diff --git a/app/js/tl/filter.js b/app/js/tl/filter.js index 61878950..535aecaf 100644 --- a/app/js/tl/filter.js +++ b/app/js/tl/filter.js @@ -1,3 +1,4 @@ +'use strict' /*メディアフィルター機能*/ //各TL上方のMedia[On/Off] function mediaToggle(tlid) { diff --git a/app/js/tl/list.js b/app/js/tl/list.js index 579bbfcb..2c376060 100644 --- a/app/js/tl/list.js +++ b/app/js/tl/list.js @@ -1,3 +1,4 @@ +'use strict' function listMenu() { $('#left-menu div').removeClass('active') $('#listMenu').addClass('active') diff --git a/app/js/tl/misskeyparse.js b/app/js/tl/misskeyparse.js index 5d49ecd7..52385b75 100644 --- a/app/js/tl/misskeyparse.js +++ b/app/js/tl/misskeyparse.js @@ -1,3 +1,4 @@ +'use strict' function escapeHTMLtemp(str) { if (!str) { return ""; diff --git a/app/js/tl/mix.js b/app/js/tl/mix.js index 224697e9..28d996cf 100644 --- a/app/js/tl/mix.js +++ b/app/js/tl/mix.js @@ -1,3 +1,4 @@ +'use strict' //Integrated TL async function mixtl(acct_id, tlid, type, delc, voice) { localStorage.setItem('now', type) diff --git a/app/js/tl/notification.js b/app/js/tl/notification.js index d23d5a37..be7c3f87 100644 --- a/app/js/tl/notification.js +++ b/app/js/tl/notification.js @@ -1,3 +1,4 @@ +'use strict' //通知 //取得+Streaming接続 function notf(acct_id, tlid, sys) { diff --git a/app/js/tl/old-mix.js b/app/js/tl/old-mix.js index 1e8da013..0605a7d6 100644 --- a/app/js/tl/old-mix.js +++ b/app/js/tl/old-mix.js @@ -1,3 +1,4 @@ +'use strict' //Integrated TL function mixtl(acct_id, tlid, type, delc, voice) { localStorage.removeItem('morelock') diff --git a/app/js/tl/parse.js b/app/js/tl/parse.js index 765a278e..e128268e 100644 --- a/app/js/tl/parse.js +++ b/app/js/tl/parse.js @@ -1,3 +1,4 @@ +'use strict' //オブジェクトパーサー(トゥート) function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) { var splitter = new GraphemeSplitter() @@ -539,11 +540,11 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) { .match( /https?:\/\/([^+_]+)\/?(?!.*((media|tags)|mentions)).*([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)?/ ) - urlsck = content.match(/(https?):\/\/([^<>]*?)\/([^"]*)/g) + var urlsck = content.match(/(https?):\/\/([^<>]*?)\/([^"]*)/g) if (urlsck) { for (var urlct = 0; urlct < urlsck.length; urlct++) { var urlindv = urlsck[urlct] - urlCont = urlindv.match(/(https?):\/\/([^a-zA-Z0-9.-]*?)\.(.+?)\/([^"]*)/) + var urlCont = urlindv.match(/(https?):\/\/([^a-zA-Z0-9.-]*?)\.(.+?)\/([^"]*)/) if (urlCont) { urlindv = urlindv.replace(/[.*+?^=!:${}()|[\]\/\\]/g, '\\$&') var encoded = encodeURI(urlCont[4]) diff --git a/app/js/tl/poll.js b/app/js/tl/poll.js index 1947eda1..4b936fd5 100644 --- a/app/js/tl/poll.js +++ b/app/js/tl/poll.js @@ -1,3 +1,4 @@ +'use strict' //アンケートのトグル function pollToggle() { if ($('#poll').hasClass('hide')) { diff --git a/app/js/tl/speech.js b/app/js/tl/speech.js index dccb8a41..408cf799 100644 --- a/app/js/tl/speech.js +++ b/app/js/tl/speech.js @@ -1,8 +1,9 @@ -$voise = null -isBouyomi = localStorage.getItem('voice_bouyomi') -$voiseName = lang.lang_speech -$voices = speechSynthesis.getVoices() -$synthes = new SpeechSynthesisUtterance() +'use strict' +var $voise = null +var isBouyomi = localStorage.getItem('voice_bouyomi') +var $voiseName = lang.lang_speech +var $voices = speechSynthesis.getVoices() +var $synthes = new SpeechSynthesisUtterance() $voise = $.grep($voices, function(n, i) { return n.name == $voiseName })[0] @@ -12,14 +13,14 @@ speechSynthesis.cancel() if (!localStorage.getItem('voice_vol')) { localStorage.setItem('voice_vol', 1) } -voiceRate = localStorage.getItem('voice_speed') +var voiceRate = localStorage.getItem('voice_speed') $synthes.rate = voiceRate -voicePitch = localStorage.getItem('voice_pitch') +var voicePitch = localStorage.getItem('voice_pitch') $synthes.pitch = voicePitch -voiceVol = localStorage.getItem('voice_vol') +var voiceVol = localStorage.getItem('voice_vol') $synthes.volume = voiceVol function say(msgr) { - msg = voiceParse(msgr) + var msg = voiceParse(msgr) var voice = localStorage.getItem('voicebank') var obj = JSON.parse(voice) if (!obj) { @@ -31,7 +32,7 @@ function say(msgr) { localStorage.setItem('voicebank', json) } } -$repeat = setInterval(function() { +var $repeat = setInterval(function() { if (!speechSynthesis.speaking) { var voice = localStorage.getItem('voicebank') if (voice) { @@ -72,7 +73,7 @@ $repeat = setInterval(function() { } }, 300) function voiceParse(msg) { - msg = $.strip_tags(msg) + var msg = $.strip_tags(msg) msg = msg.replace(/#/g, '') msg = msg.replace(/'/g, '') msg = msg.replace(/"/g, '') diff --git a/app/js/tl/src.js b/app/js/tl/src.js index 4a4dc78e..0f991552 100644 --- a/app/js/tl/src.js +++ b/app/js/tl/src.js @@ -1,3 +1,4 @@ +'use strict' //検索 //検索ボックストグル function searchMenu() { diff --git a/app/js/tl/tag.js b/app/js/tl/tag.js index 57aa8a02..2b426ea2 100644 --- a/app/js/tl/tag.js +++ b/app/js/tl/tag.js @@ -1,3 +1,4 @@ +'use strict' //タグ表示 if (location.search) { var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/) diff --git a/app/js/tl/tl.js b/app/js/tl/tl.js index 563ef182..6b19aaa0 100644 --- a/app/js/tl/tl.js +++ b/app/js/tl/tl.js @@ -1,5 +1,6 @@ +'use strict' //TL取得 -moreloading = false +var moreloading = false var errorct = 0 function tl(type, data, acct_id, tlid, delc, voice, mode) { scrollevent() diff --git a/app/js/ui/img.js b/app/js/ui/img.js index 1d919cb4..7facf0db 100644 --- a/app/js/ui/img.js +++ b/app/js/ui/img.js @@ -1,3 +1,4 @@ +'use strict' /*イメージビューワー*/ //postのimg.jsとは異なります。 function imgv(id, key, acct_id) { @@ -76,7 +77,7 @@ function imgCont(type) { } function imageXhr(id, key, murl) { var startTime = new Date() - xhr = new XMLHttpRequest() + var xhr = new XMLHttpRequest() xhr.open('GET', murl, true) xhr.responseType = 'arraybuffer' xhr.addEventListener( @@ -104,7 +105,7 @@ function imageXhr(id, key, murl) { ) xhr.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { - r = new FileReader() + var r = new FileReader() r.readAsDataURL(this.response) r.onload = function() { var b64 = r.result diff --git a/app/js/ui/layout.js b/app/js/ui/layout.js index 72eb741f..c8d70013 100644 --- a/app/js/ui/layout.js +++ b/app/js/ui/layout.js @@ -1,3 +1,4 @@ +'use strict' //レイアウトの設定 var websocketOld = [] @@ -706,7 +707,7 @@ function setToggleTag(tlid) { } } function colorpicker(key) { - temp = `
Default
+ var temp = `
Default
Red
Pink
Purple
diff --git a/app/js/ui/menu.js b/app/js/ui/menu.js index e907d5b0..f5f8304b 100644 --- a/app/js/ui/menu.js +++ b/app/js/ui/menu.js @@ -1,3 +1,4 @@ +'use strict' function menu() { localStorage.setItem("menu-done", true); $("#fukidashi").addClass("hide") diff --git a/app/js/ui/pip.js b/app/js/ui/pip.js index 44bc43c1..f4708efe 100644 --- a/app/js/ui/pip.js +++ b/app/js/ui/pip.js @@ -1,3 +1,4 @@ +'use strict' function pip(id) { $("#pip-content").html($("[toot-id=" + id + "] .additional").html()); $("#pip").removeClass("hide"); diff --git a/app/js/ui/post-box.js b/app/js/ui/post-box.js index 4a7a34a1..397b3e59 100644 --- a/app/js/ui/post-box.js +++ b/app/js/ui/post-box.js @@ -1,3 +1,4 @@ +'use strict' /*ささやきボックス(Cr民並感)*/ //✕隠す function hide() { diff --git a/app/js/ui/radio.js b/app/js/ui/radio.js index cff54bba..e9478578 100644 --- a/app/js/ui/radio.js +++ b/app/js/ui/radio.js @@ -1,3 +1,4 @@ +'use strict' var r = document.getElementById("radio"); function Rtoggle() { if ($("#radio").hasClass("play")) { diff --git a/app/js/ui/scroll.js b/app/js/ui/scroll.js index 9a309e86..d1833f77 100644 --- a/app/js/ui/scroll.js +++ b/app/js/ui/scroll.js @@ -1,3 +1,4 @@ +'use strict' //スクロールで続きを読む function scrollevent() { $('.tl-box').scroll(function() { diff --git a/app/js/ui/settings.js b/app/js/ui/settings.js index 2c9d0539..ff006da5 100644 --- a/app/js/ui/settings.js +++ b/app/js/ui/settings.js @@ -1,3 +1,4 @@ +'use strict' //設定(setting.html)で読む var envView = new Vue({ el: "#envView", diff --git a/app/js/ui/sort.js b/app/js/ui/sort.js index 06c4b1f2..a6d2ac28 100644 --- a/app/js/ui/sort.js +++ b/app/js/ui/sort.js @@ -1,3 +1,4 @@ +'use strict' //ソートデータ読み込み function sortLoad () { $("#sort").html(""); diff --git a/app/js/ui/spotify.js b/app/js/ui/spotify.js index f514def9..76d90011 100644 --- a/app/js/ui/spotify.js +++ b/app/js/ui/spotify.js @@ -1,3 +1,4 @@ +'use strict' function spotifyConnect() { var auth = "https://accounts.spotify.com/authorize?client_id=0f18e54abe0b4aedb4591e353d3aff69&redirect_uri=https://thedesk.top/spotify-connect&response_type=code&scope=user-read-currently-playing"; var platform = localStorage.getItem("platform"); diff --git a/app/js/ui/theme.js b/app/js/ui/theme.js index bafebc4c..40d8dd84 100644 --- a/app/js/ui/theme.js +++ b/app/js/ui/theme.js @@ -1,3 +1,4 @@ +'use strict' //テーマ適用 function themes(theme) { if (!theme) { diff --git a/app/js/ui/tips.js b/app/js/ui/tips.js index a2d97955..938d4c74 100644 --- a/app/js/ui/tips.js +++ b/app/js/ui/tips.js @@ -1,3 +1,4 @@ +'use strict' //左下のメッセージ var todcTrigger = null function todo(mes) { @@ -128,7 +129,7 @@ function trendTagonTip() { }) } //Spotify -spotint = null +var spotint = null function spotifytips() { if (spotint) clearInterval(spotint) var start = diff --git a/app/js/userdata/his-data.js b/app/js/userdata/his-data.js index 47cc1fba..bda9e76d 100644 --- a/app/js/userdata/his-data.js +++ b/app/js/userdata/his-data.js @@ -1,3 +1,4 @@ +'use strict' //ユーザーデータ表示 //タイムライン function utl(user, more, acct_id) { diff --git a/app/js/userdata/prof-edit.js b/app/js/userdata/prof-edit.js index 939b2ad0..365fbde6 100644 --- a/app/js/userdata/prof-edit.js +++ b/app/js/userdata/prof-edit.js @@ -1,3 +1,4 @@ +'use strict' //プロフ編集 //文字系 function profedit() { diff --git a/app/js/userdata/showOnTL.js b/app/js/userdata/showOnTL.js index 03b353d0..090e716a 100644 --- a/app/js/userdata/showOnTL.js +++ b/app/js/userdata/showOnTL.js @@ -1,3 +1,4 @@ +'use strict' //ユーザーデータ表示 localStorage.removeItem("history"); //コード受信