content,internal: rewrite badge.js with typescript

For golang/go#43359

Change-Id: I48e21ddecb5a26e28d112f0ede5779ec599b8b4f
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/299253
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Jamal Carvalho 2021-03-05 15:28:49 -05:00
Родитель e16008d285
Коммит 60231949ce
6 изменённых файлов: 23 добавлений и 12 удалений

Просмотреть файл

@ -52,6 +52,6 @@
{{define "post_content"}}
<script>
loadScript("/static/js/badge.min.js");
loadScript("/static/js/badge.js");
</script>
{{end}}

Просмотреть файл

@ -1,15 +1,17 @@
/**
'use strict';
/*!
* @license
* Copyright 2019-2020 The Go Authors. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/
const snippetEls = document.querySelectorAll('.js-toolsCopySnippet');
snippetEls.forEach(inputEl => {
inputEl.addEventListener('click', e => {
var _a;
e.preventDefault();
e.currentTarget.select();
(_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.select();
document.execCommand('copy');
});
});
//# sourceMappingURL=badge.js.map

Просмотреть файл

@ -0,0 +1 @@
{"version":3,"file":"badge.js","sourceRoot":"","sources":["badge.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;AAEH,MAAM,UAAU,GAAG,QAAQ,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;AACrE,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;IAC3B,OAAO,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE;;QACpC,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,MAAC,CAAC,CAAC,aAAkC,0CAAE,MAAM,GAAG;QAChD,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

7
content/static/js/badge.min.js поставляемый
Просмотреть файл

@ -1,7 +0,0 @@
/*
Copyright 2019-2020 The Go Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
*/
var snippetEls=document.querySelectorAll(".js-toolsCopySnippet");snippetEls.forEach(function(b){b.addEventListener("click",function(a){a.preventDefault();a.currentTarget.select();document.execCommand("copy")})});

Просмотреть файл

@ -0,0 +1,15 @@
/*!
* @license
* Copyright 2019-2020 The Go Authors. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/
const snippetEls = document.querySelectorAll('.js-toolsCopySnippet');
snippetEls.forEach(inputEl => {
inputEl.addEventListener('click', e => {
e.preventDefault();
(e.currentTarget as HTMLInputElement)?.select();
document.execCommand('copy');
});
});

Просмотреть файл

@ -16,7 +16,7 @@ var scriptHashes = []string{
"'sha256-dwce5DnVX7uk6fdvvNxQyLTH/cJrTMDK6zzrdKwdwcg='",
"'sha256-M35cNZ8vPcaBGw5WTgh0Gn7DLsxkvPbdTFN1pELeevM='",
// From content/static/html/pages/badge.tmpl
"'sha256-T7xOt6cgLji3rhOWyKK7t5XKv8+LASQwOnHiHHy8Kwk='",
"'sha256-v9+UvX+P27rKraeTl7uAfOWdLmmQU39RskIoqUrU4wo='",
// From content/static/html/pages/fetch.tmpl
"'sha256-1J6DWwTWs/QDZ2+ORDuUQCibmFnXXaNXYOtc0Jk6VU4='",
// From content/static/html/worker/index.tmpl