Skip to content

Commit 04f215b

Browse files
committed
i q
1 parent b2d634d commit 04f215b

File tree

2 files changed

+77
-13
lines changed

2 files changed

+77
-13
lines changed

i.html

Lines changed: 74 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,26 @@
1515
overflow: hidden;
1616

1717
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiPjxkZWZzPjxwYXR0ZXJuIGlkPSJwYXR0ZXJuX1o2Nmk1ZyIgcGF0dGVyblVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgd2lkdGg9IjEyIiBoZWlnaHQ9IjEyIiBwYXR0ZXJuVHJhbnNmb3JtPSJyb3RhdGUoNDUpIj48bGluZSB4MT0iMCIgeT0iMCIgeDI9IjAiIHkyPSIxMiIgc3Ryb2tlPSIjRjNGM0YzIiBzdHJva2Utd2lkdGg9IjEyIiAvPjwvcGF0dGVybj48L2RlZnM+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNwYXR0ZXJuX1o2Nmk1ZykiICAvPjwvc3ZnPg==);
18+
display: flex;
19+
justify-content: center;
20+
align-items: center;
21+
height: 100vh;
22+
}
1823

19-
img {
20-
width: 100vw;
21-
height: 100vh;
22-
object-fit: contain;
23-
display: block;
24-
}
24+
body.img img {
25+
max-width: 100%;
26+
max-height: 100vh;
27+
width: auto;
28+
height: auto;
29+
display: block;
2530
}
2631
#doc {
2732
display: none;
2833
}
2934
input {
3035
width: 90%;
36+
padding: 5px;
37+
font-size: 17px;
3138
}
3239
</style>
3340
</head>
@@ -42,28 +49,61 @@
4249
Probably because it detects request header accept: text/html
4350
</pre>
4451

45-
<label>
46-
type img url:
47-
<input type="text" id="url" value="" />
48-
</label>
52+
<div>
53+
<label>
54+
type img url:
55+
<input type="text" id="url" value="" />
56+
</label>
57+
</div>
4958

5059
<br />
5160

52-
<a href=""></a>
61+
<div>
62+
<a href=""></a>
63+
</div>
64+
5365
<br />
66+
67+
<div>
68+
<label>
69+
generated link
70+
<input type="text" id="link" value="" />
71+
</label>
72+
</div>
73+
74+
<br />
75+
5476
<div>
5577
<a href="i.html">reset</a>
5678
</div>
79+
5780
<br />
5881

5982
<div>
6083
direct link to original
6184
<a href="https://i.imgur.com/q3CHEJs.png" target="_blank">https://i.imgur.com/q3CHEJs.png</a> - will redirect to
6285
https://imgur.com/q3CHEJs
6386
</div>
87+
88+
<br />
89+
90+
<div>
91+
the same image (https://i.imgur.com/q3CHEJs.png) but handled with this document -
92+
<a href="?i=https://i.imgur.com/q3CHEJs.png">link</a>
93+
</div>
94+
95+
<br />
96+
97+
<div>
98+
<a href="?i=https://i.imgur.com/CjDxZsm.png">big image example</a>
99+
</div>
100+
101+
<br />
102+
103+
<div>
104+
<a href="?i=https://i.imgur.com/6N0MVlA.png">small image example</a>
105+
</div>
64106
</div>
65-
<br />
66-
<div>the same image (https://i.imgur.com/q3CHEJs.png) but handled with this document - <a href="?i=https://i.imgur.com/q3CHEJs.png">link</a></div>
67107
</body>
68108
<script>
69109
const i = new URLSearchParams(window.location.search).get("i");
@@ -76,11 +116,32 @@
76116

77117
const input = document.querySelector("#url");
78118
const a = document.querySelector("a");
119+
const link = document.querySelector("#link");
79120

80121
input.addEventListener("input", (e) => {
81122
const url = `${location.origin}${location.pathname}?i=${encodeURIComponent(e.target.value)}`;
82123
a.href = url;
83124
a.innerText = url;
125+
link.value = url;
126+
});
127+
128+
link.addEventListener("focus", (e) => {
129+
e.target.select();
130+
// copy on focus
131+
// and change input background to green for 1 sec
132+
e.target.style.backgroundColor = "green";
133+
setTimeout(() => {
134+
e.target.style.backgroundColor = "";
135+
}, 1000);
136+
// copy to clipboard
137+
navigator.clipboard.writeText(e.target.value).then(
138+
() => {
139+
console.log("Copying to clipboard was successful!");
140+
},
141+
(err) => {
142+
console.error("Could not copy text: ", err);
143+
}
144+
);
84145
});
85146
}
86147
</script>

index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ <h2>Services</h2>
114114
<ul data-do-sort>
115115
<li><a href="/start.html">start</a></li>
116116
<li><a href="/learn.html">learn</a></li>
117+
<li>
118+
<a href="/i.html">imgur handler</a>
119+
</li>
117120
<li><a href="pages/portsregistry/portsregistry.html">Ports Registry</a></li>
118121
<li><a href="pages/pastetool/pastetool.html">Paste tool</a></li>
119122
<li><a href="pages/todo/todo.html">Todo</a></li>

0 commit comments

Comments
 (0)