share.erb (3326B)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | <!DOCTYPE html>
<html>
<head>
<title>Share Poll — Veto Vote</title>
<%= head_tags %>
<style media="screen">
body, html {
width: 100%;
height: 100%;
}
body, html, body > div {
overflow: hidden !important;
overflow-x: hidden;
overflow-y: hidden;
}
body {
position: fixed;
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
body > div {
padding: 0 40px 20px 40px;
}
h3 {
margin: 10px 0;
}
p {
margin: 10px 0;
}
a, i {
padding: 5px 10px;
filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.1));
border: 1px solid #eee;
border-radius: 4px;
background: #fff;
color: #777;
transition: all .1s ease;
}
a:hover {
color: #444;
}
i {
cursor: grab;
color: #aaa;
padding: 0.43em 10px;
margin-left: 6px;
position: relative;
display: inline-block;
}
i:hover {
color: #666;
}
i span {
visibility: hidden;
width: 120px;
background: rgba(0,0,0,0.8);
color: #fff;
text-align: center;
padding: 5px 0;
border-radius: 6px;
position: absolute;
z-index: 1;
width: 120px;
bottom: 100%;
left: 50%;
margin-left: -60px;
font-family: Rubik;
font-size: 0.7em;
}
i:hover span {
visibility: visible;
}
i span::after {
content: " ";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: rgba(0,0,0,0.8) transparent transparent transparent;
}
i:active {
cursor: copy;
}
input[type=text] {
position: absolute;
right: -300vw;
}
</style>
</head>
<body>
<div>
<h3>Share</h3>
<p>Share the link with others, press the copy-paste button.</p>
<a id="share" href=""><%= params[:code] %></a>
<i class="far fa-copy"><span>Copy to Clipboard.</span></i>
<input type="text" value="" />
</div>
<script src="/main.js"></script>
<script>
$('i').click(() => {
const text = $('#share').text();
$('input').val(text);
const elem = $('input')[0];
const range = document.createRange();
elem.contentEditable = true;
elem.readOnly = false;
range.selectNodeContents(elem);
const s = window.getSelection();
s.removeAllRanges();
s.addRange(range);
elem.setSelectionRange(0, 999999);
if (!navigator.userAgent.match(/ipad|ipod|iphone/i)) {
elem.select();
}
document.execCommand("copy");
$('i span').text('Copied!');
setTimeout(() => $('i span').text('Copy to Clipboard.'), 700);
});
const code = $('#share').text();
$("#share")
.attr('href', `/poll/${encodeURIComponent(code)}`)
.text(`${window.location.protocol}//${window.location.host}/poll/${encodeURIComponent(code)}`)
</script>
</body>
</html>
|