Spaces:
Running
Running
Update marker.html
Browse files- marker.html +31 -44
marker.html
CHANGED
|
@@ -92,70 +92,57 @@
|
|
| 92 |
|
| 93 |
<script>
|
| 94 |
let number = 60; // 画像の数
|
| 95 |
-
|
| 96 |
let imagesLoaded = 0; // 読み込まれた画像の数
|
| 97 |
|
| 98 |
for (let i = 1; i <= number; i++) {
|
| 99 |
-
// 新しいdiv要素を作成
|
| 100 |
let imageBox = document.createElement('div');
|
| 101 |
imageBox.className = 'image-box';
|
| 102 |
|
| 103 |
-
// 画像要素を作成
|
| 104 |
let img = document.createElement('img');
|
| 105 |
-
img.src = location.origin + "/marker/" + i + ".png";
|
| 106 |
img.alt = "画像";
|
| 107 |
|
| 108 |
-
// 画像の読み込み完了イベントを設定
|
| 109 |
img.onload = function() {
|
| 110 |
imagesLoaded++;
|
| 111 |
if (imagesLoaded === number) {
|
| 112 |
-
// 全ての画像が読み込まれたらローディング画面をフェードアウトさせる
|
| 113 |
setTimeout(function() {
|
| 114 |
document.getElementById('loading').classList.add('hidden');
|
| 115 |
-
}, 500);
|
| 116 |
}
|
| 117 |
};
|
| 118 |
|
| 119 |
-
//
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
downloadLink.className = 'download-button';
|
| 131 |
-
downloadLink.textContent = 'ダウンロード';
|
| 132 |
-
|
| 133 |
-
// コピーリンクボタンを作成
|
| 134 |
-
let copyButton = document.createElement('button');
|
| 135 |
-
copyButton.className = 'copy-button';
|
| 136 |
-
copyButton.textContent = 'URLをコピー';
|
| 137 |
-
|
| 138 |
-
// コピーボタンのクリックイベント
|
| 139 |
-
copyButton.onclick = function() {
|
| 140 |
-
const imageUrl = location.origin + "/marker/" + i + ".png";
|
| 141 |
-
navigator.clipboard.writeText(imageUrl).then(function() {
|
| 142 |
-
alert('URLがコピーされました: \n' + imageUrl);
|
| 143 |
-
}, function(err) {
|
| 144 |
-
alert('コピーに失敗しました: ', err);
|
| 145 |
-
});
|
| 146 |
-
};
|
| 147 |
-
|
| 148 |
-
// divに画像、ダウンロードボタン、コピーリンクを追加
|
| 149 |
-
imageBox.appendChild(img);
|
| 150 |
-
imageBox.appendChild(document.createElement('br'));
|
| 151 |
-
imageBox.appendChild(downloadLink);
|
| 152 |
-
imageBox.appendChild(document.createElement('br'));
|
| 153 |
-
imageBox.appendChild(copyButton);
|
| 154 |
-
|
| 155 |
-
// bodyにdivを追加
|
| 156 |
-
document.body.appendChild(imageBox);
|
| 157 |
|
|
|
|
|
|
|
|
|
|
| 158 |
</script>
|
| 159 |
|
|
|
|
| 160 |
</body>
|
| 161 |
</html>
|
|
|
|
| 92 |
|
| 93 |
<script>
|
| 94 |
let number = 60; // 画像の数
|
|
|
|
| 95 |
let imagesLoaded = 0; // 読み込まれた画像の数
|
| 96 |
|
| 97 |
for (let i = 1; i <= number; i++) {
|
|
|
|
| 98 |
let imageBox = document.createElement('div');
|
| 99 |
imageBox.className = 'image-box';
|
| 100 |
|
|
|
|
| 101 |
let img = document.createElement('img');
|
| 102 |
+
img.src = location.origin + "/marker/" + i + ".png";
|
| 103 |
img.alt = "画像";
|
| 104 |
|
|
|
|
| 105 |
img.onload = function() {
|
| 106 |
imagesLoaded++;
|
| 107 |
if (imagesLoaded === number) {
|
|
|
|
| 108 |
setTimeout(function() {
|
| 109 |
document.getElementById('loading').classList.add('hidden');
|
| 110 |
+
}, 500);
|
| 111 |
}
|
| 112 |
};
|
| 113 |
|
| 114 |
+
// ダウンロードリンクを作成(ループ内に配置)
|
| 115 |
+
let downloadLink = document.createElement('a');
|
| 116 |
+
downloadLink.href = img.src; // 画像のURLを直接指定
|
| 117 |
+
downloadLink.download = 'marker_' + i + '.png';
|
| 118 |
+
downloadLink.className = 'download-button';
|
| 119 |
+
downloadLink.textContent = 'ダウンロード';
|
| 120 |
+
|
| 121 |
+
// コピーリンクボタンを作成(ループ内に配置)
|
| 122 |
+
let copyButton = document.createElement('button');
|
| 123 |
+
copyButton.className = 'copy-button';
|
| 124 |
+
copyButton.textContent = 'URLをコピー';
|
| 125 |
+
|
| 126 |
+
copyButton.onclick = function() {
|
| 127 |
+
navigator.clipboard.writeText(img.src).then(function() {
|
| 128 |
+
alert('URLがコピーされました: \n' + img.src);
|
| 129 |
+
}).catch(function(err) {
|
| 130 |
+
alert('コピーに失敗しました: ' + err);
|
| 131 |
+
});
|
| 132 |
+
};
|
| 133 |
|
| 134 |
+
// 各要素を `imageBox` に追加
|
| 135 |
+
imageBox.appendChild(img);
|
| 136 |
+
imageBox.appendChild(document.createElement('br'));
|
| 137 |
+
imageBox.appendChild(downloadLink);
|
| 138 |
+
imageBox.appendChild(document.createElement('br'));
|
| 139 |
+
imageBox.appendChild(copyButton);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
+
// `body` に `imageBox` を追加
|
| 142 |
+
document.body.appendChild(imageBox);
|
| 143 |
+
}
|
| 144 |
</script>
|
| 145 |
|
| 146 |
+
|
| 147 |
</body>
|
| 148 |
</html>
|