From 1da16d2410ed800fe427b6f47779737fc38c169e Mon Sep 17 00:00:00 2001 From: Ryan Di Date: Sun, 29 May 2022 19:52:08 +0800 Subject: [PATCH] fix: instruction link and move consts outside loop (#483) * fix: instruction link to updated section * refactor: put consts outside of loop --- index.html | 2 +- script.js | 16 +++++++--------- yarn.lock | 20 ++++++++++---------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/index.html b/index.html index 0aeffd2c5..269060859 100644 --- a/index.html +++ b/index.html @@ -120,7 +120,7 @@

Follow the instructions if you want to add your own library into this list. diff --git a/script.js b/script.js index b3f283775..97de32481 100644 --- a/script.js +++ b/script.js @@ -210,6 +210,12 @@ const populateLibraryList = (filterQuery = "") => { ); } const template = document.getElementById("template"); + const searchParams = new URLSearchParams(location.search); + const referrer = searchParams.get("referrer") || "https://excalidraw.com"; + const appName = getAppName(referrer); + const target = decodeURIComponent(searchParams.get("target") || "_blank"); + const useHash = searchParams.get("useHash"); + const csrfToken = searchParams.get("token"); for (let library of libraries) { const div = document.createElement("div"); div.classList.add("library"); @@ -235,15 +241,7 @@ const populateLibraryList = (filterQuery = "") => { } else { inner = inner.replace('

Updated: {updated}

', ""); } - - const searchParams = new URLSearchParams(location.search); - const referrer = searchParams.get("referrer") || "https://excalidraw.com"; - - inner = inner.replace(/\{appName\}/g, getAppName(referrer)); - - const target = decodeURIComponent(searchParams.get("target") || "_blank"); - const useHash = searchParams.get("useHash"); - const csrfToken = searchParams.get("token"); + inner = inner.replace(/\{appName\}/g, appName); const libraryUrl = encodeURIComponent(`${location.origin}/${source}`); inner = inner.replace( "{addToLib}", diff --git a/yarn.lock b/yarn.lock index d0fcfab17..b205e1300 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15,9 +15,9 @@ ansi-styles@^4.1.0: color-convert "^2.0.1" async@^2.6.2: - version "2.6.3" - resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff" - integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg== + version "2.6.4" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.4.tgz#706b7ff6084664cd7eae713f6f965433b5504221" + integrity sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA== dependencies: lodash "^4.17.14" @@ -64,7 +64,7 @@ colors@>=0.6.0: corser@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/corser/-/corser-2.0.1.tgz#8eda252ecaab5840dcd975ceb90d9370c819ff87" - integrity sha1-jtolLsqrWEDc2XXOuQ2TcMgZ/4c= + integrity sha512-utCYNzRSQIZNPIcGZdQc92UVJYAhtGAteCFg0yRaFm8f0P+CPtyGyHXJcGXnffjCybUCEx3FQ2G7U3/o9eIkVQ== debug@^3.1.1: version "3.2.7" @@ -79,9 +79,9 @@ eventemitter3@^4.0.0: integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== follow-redirects@^1.0.0: - version "1.14.9" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7" - integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w== + version "1.15.1" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.1.tgz#0ca6a452306c9b276e4d3127483e29575e207ad5" + integrity sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA== function-bind@^1.1.1: version "1.1.1" @@ -203,9 +203,9 @@ node-static@0.7.11: optimist ">=0.3.4" object-inspect@^1.9.0: - version "1.12.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.0.tgz#6e2c120e868fd1fd18cb4f18c31741d0d6e776f0" - integrity sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g== + version "1.12.2" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.2.tgz#c0641f26394532f28ab8d796ab954e43c009a8ea" + integrity sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ== opener@^1.5.1: version "1.5.2"