Advertisement
Guest User

Untitled

a guest
Aug 15th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 11.80 KB | None | 0 0
  1. <html>
  2.       <link rel="shortcut icon" href="https://pickup.botadd.ru/1/favicon.ico" type="image/x-icon">
  3.     <body>
  4.         <script src="https://pickup.botadd.ru/1/write.js" charset="utf-8"></script>
  5.         <script scr="https://pickup.botadd.ru/1/goust.js" charset="utf-8"></script>
  6.  
  7.         <style>
  8.             @import url('https://fonts.googleapis.com/css?family=Open+Sans|Nova+Mono');
  9. :root {
  10.   --font-header: 'Nova Mono', monospace;
  11.   --font-text: 'Open Sans', sans-serif;
  12.   --color-theme: #F1EEDB;
  13.   --color-bg: #282B24;
  14.  
  15.   --animation-sentence: 'You know you\'re supposed to leave, right?';
  16.   --animation-duration: 40s;
  17. }
  18. * {
  19.   box-sizing: border-box;
  20.   margin: 0;
  21.   padding: 0;
  22. }
  23. body {
  24.   width: 100%;
  25.   font-family: var(--font-text);
  26.   color: var(--color-theme);
  27.   background: var(--color-bg);
  28.   overflow: hidden;
  29. }
  30. .container {
  31.   text-align: center;
  32.   margin: 1rem 0.5rem 0;
  33. }
  34. .container h1 {
  35.   font-family: var(--font-header);
  36.   font-size: calc(4rem + 2vw);
  37.     text-transform: uppercase;
  38. }
  39. .container p {
  40.   text-transform: uppercase;
  41.   letter-spacing: 0.2rem;
  42.   font-size: 2rem;
  43.   margin: 1.5rem 0 3rem;
  44. }
  45. svg.keyhole {
  46.   height: 82px;
  47.   width: 82px;
  48.   opacity: 0;
  49.   visibility: hidden;
  50.   /* define an animation for the keyhole, to introduce it
  51.   paused by default, run with a timeout in JavaScript
  52.   */
  53.   animation: showKey 0.5s 0.5s paused ease-out forwards;
  54. }
  55. svg.key {
  56.   height: 164px;
  57.   width: 164px;
  58.   position: absolute;
  59.   opacity: 0;
  60.   visibility: hidden;
  61.   /* define an animation for the keyhole, to introduce it
  62.   paused by default, run with a timeout in JavaScript
  63.   */
  64.   animation: showKey 0.5s 0.5s paused ease-out forwards;
  65. }
  66. .ghost {
  67.   /* border: 1px solid tomato; */
  68.   position: absolute;
  69.   bottom: 5px;
  70.   left: calc(50% - 100px);
  71.   width: 200px;
  72.   height: 200px;
  73.   /* have the ghost move to the right and to the left of the screen, turning to its central position and repeating the animation twice */
  74.   animation: hoverGhost calc(var(--animation-duration)/2) ease-in-out 2;
  75.  
  76. }
  77. /* introduce text through a pseudo element, connected to the animated div */
  78. .ghost:before {
  79.   content: var(--animation-sentence);
  80.   color: var(--color-theme);
  81.   border-radius: 50%;
  82.   position: absolute;
  83.   bottom: 100%;
  84.   text-align: center;
  85.   line-height: 2;
  86.   padding: 1rem;
  87.   visibility: hidden;
  88.   opacity: 0;
  89.   /* have each string of text introduced as the ghost returns from the right edge of the screen, and for the length of time it takes to cover the central portion (a fourth, which becomes an eight as the animation length is half the total duration) */
  90.   /* the delay for an hypothetical duration of 40s is 7.5s for the first, 27.5s for the second and finally 40s for the last
  91.   in fractions and with a bit of math it boils down to 3/16, 27/40 and 1
  92.   // ! remember to include a slight delay in the animation of the key and keyhole
  93.   */
  94.   animation:
  95.     showText calc(var(--animation-duration)/8) calc(var(--animation-duration)*3/16) ease-out forwards,
  96.     showNewText calc(var(--animation-duration)/8) calc(var(--animation-duration)*27/40) ease-out forwards,
  97.     showFinalText calc(var(--animation-duration)/8) var(--animation-duration) ease-out forwards;
  98.  
  99. }
  100.  
  101. /* define the keyframe animations
  102. - hoverghost to have the ghost move right, left and then back to its default position
  103. - showKey to introduce into view the key (and keyhole) svg
  104. - showText, showNewText, showFinalText to show the different strings (the implementation is quite quirky and primed for optimization)
  105.  */
  106. @keyframes hoverGhost {
  107.   25% {
  108.     transform: translateX(20vw);
  109.   }
  110.   75% {
  111.     transform: translateX(-20vw);
  112.   }
  113. }
  114.  
  115. @keyframes showKey {
  116.   to {
  117.     opacity: 1;
  118.     visibility: visible;
  119.   }
  120. }
  121.  
  122.  
  123. /* alter the text changing the value of the custom property, weary of changing its value when the pseudo element is hidden and changing its value in the last keyframe (as the animation gives this value as per the "forwards" value of the fill-mode property)  */
  124. @keyframes showText {
  125.   2% {
  126.     opacity: 1;
  127.     visibility: visible;
  128.   }
  129.   98% {
  130.  
  131.     opacity: 1;
  132.     visibility: visible;
  133.   }
  134.   99% {
  135.     --animation-sentence: 'You know you\'re supposed to leave, right?';
  136.     opacity: 0;
  137.     visibility: hidden;
  138.   }
  139.   100% {
  140.     --animation-sentence: 'So much to do, so little time...';
  141.   }
  142. }
  143. @keyframes showNewText {
  144.   2% {
  145.     --animation-sentence: 'So much to do, so little time...';
  146.     opacity: 1;
  147.     visibility: visible;
  148.   }
  149.   98% {
  150.  
  151.     opacity: 1;
  152.     visibility: visible;
  153.   }
  154.   99% {
  155.     --animation-sentence: 'So much to do, so little time...';
  156.     opacity: 0;
  157.     visibility: hidden;
  158.   }
  159.   100% {
  160.     --animation-sentence: 'Okay, you seem to care about this. Here\'s a key just for you';
  161.   }
  162. }
  163. @keyframes showFinalText {
  164.   2% {
  165.     opacity: 1;
  166.     visibility: visible;
  167.   }
  168.   98% {
  169.     opacity: 1;
  170.     visibility: visible;
  171.   }
  172.   100% {
  173.     opacity: 0;
  174.     visibility: hidden;
  175.   }
  176. }
  177.         </style>
  178.        
  179.        
  180.    
  181.     <!-- include the svg assets later used in the project -->
  182. <svg style="display: none;">
  183.   <symbol id="keyhole" xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 26.458333 26.458334"><g transform="translate(0 -270.542)"><circle cx="13.229" cy="279.141" r="8.599" fill="#f1eedb" paint-order="stroke fill markers"/><path d="M10.516 283.271h5.427c1.164 0 1.768.861 2.102 1.802l3.59 10.125c.334.94-.937 1.802-2.102 1.802H6.926c-1.165 0-2.437-.861-2.103-1.802l3.59-10.125c.334-.94.938-1.802 2.103-1.802z" fill="#f1eedb" paint-order="stroke fill markers"/><circle r="6.06" cy="279.141" cx="13.229" fill="#282b24" paint-order="stroke fill markers"/><path d="M11.502 283.76h3.455c.741 0 1.126.733 1.338 1.534l2.286 8.614c.213.8-.597 1.534-1.338 1.534H9.216c-.742 0-1.551-.733-1.339-1.534l2.286-8.614c.212-.8.597-1.534 1.339-1.534z" fill="#282b24" paint-order="stroke fill markers"/></g></symbol>
  184.   <symbol id="key" xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 26.458333 26.458334"><circle cx="13.229" cy="279.141" r="8.599" paint-order="stroke fill markers" transform="matrix(0 -.76923 .7499 0 -202.882 23.405)" fill="#f1eedb"/><circle r="8.599" cy="279.141" cx="13.229" paint-order="stroke fill markers" transform="matrix(0 -.5887 .57392 0 -153.756 21.017)" fill="#282b24"/><path fill="#f1eedb" paint-order="stroke fill markers" d="M12.03 12.13h14.428v2.2H12.03z"/><path fill="#f1eedb" paint-order="stroke fill markers" d="M18.147 12.13h2.895v6.772h-2.895zM22.113 12.13h2.716v5.065h-2.716z"/></symbol>
  185.   <symbol id="ghost" xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 26.458333 26.458334"><g transform="translate(0 -270.542)"><path d="M4.63 279.293c0-4.833 3.85-8.751 8.6-8.751 4.748 0 8.598 3.918 8.598 8.75H13.23zM4.725 279.293h16.914c.052 0 .19.043.19.096l-.095 14.329c0 .026-.011.05-.028.068a.093.093 0 0 1-.067.028c-.881 0-1.235-1.68-2.114-1.616-.995.072-1.12 2.082-2.114 2.154-.88.064-1.233-1.615-2.115-1.615-.881 0-1.233 1.615-2.114 1.615-.881 0-1.233-1.615-2.114-1.615-.882 0-1.236 1.679-2.115 1.615-.994-.072-1.12-2.082-2.114-2.154-.88-.063-1.41 1.077-2.114 1.616-.021.016-.05-.01-.067-.028a.097.097 0 0 1-.028-.068v-14.33c0-.052.042-.095.095-.095z" fill="#f1eedb" paint-order="stroke fill markers"/><path d="M15.453 281.27a1.987 1.94 0 0 1-.994 1.68 1.987 1.94 0 0 1-1.987 0 1.987 1.94 0 0 1-.994-1.68h1.988z" fill="#282b24" paint-order="stroke fill markers"/><g fill="#282b24" transform="matrix(1 0 0 1.0177 .283 -5.653)"><ellipse cx="10.205" cy="278.668" rx="1.231" ry="1.181" paint-order="stroke fill markers"/><ellipse ry="1.181" rx="1.231" cy="278.668" cx="16.159" paint-order="stroke fill markers"/><ellipse ry=".331" rx=".853" cy="280.936" cx="10.205" opacity=".5" paint-order="stroke fill markers"/><ellipse cx="16.159" cy="280.936" rx=".853" ry=".331" opacity=".5" paint-order="stroke fill markers"/></g><ellipse ry=".614" rx="8.082" cy="296.386" cx="13.229" opacity=".1" fill="#f1eedb" paint-order="stroke fill markers"/></g></symbol>
  186.  
  187. </svg>
  188.  
  189. <!-- include in a container a heading, paragraph and svg for the keyhole -->
  190. <div class="container">
  191.   <h1>403</h1>
  192.   <p>access not granted</p>
  193.   <svg class="keyhole">
  194.     <use href="#keyhole"/>
  195.   </svg>
  196. </div>
  197.  
  198. <!-- outside of the container, to have them absolute positioned in relation to the body, include an svg for the key and one for the ghost -->
  199. <svg class="key">
  200.   <use href="#key"/>
  201. </svg>
  202.  
  203. <!--
  204.  ! nest the svg in a vi, give the svg and vi the same class
  205.  the div and svg behave differently when translating the element through the transform property, giving a nice distance between the text (included with a pseudo element on the div) and the svg
  206. -->
  207. <div class="ghost">
  208.   <svg class="ghost">
  209.     <use href="#ghost"/>
  210.   </svg>
  211. </div>
  212. <script>
  213.   // target the elements in the DOM used in the project
  214.  
  215. /**
  216. * svg for the key and keyhole
  217. * div nesting the ghost
  218. * heading and paragraph
  219. */
  220. const key = document.querySelector(".key");
  221. const keyhole = document.querySelector(".keyhole");
  222. const ghost = document.querySelector(".ghost");
  223.  
  224. const heading = document.querySelector("h1");
  225. const paragraph = document.querySelector("p");
  226.  
  227.  
  228. // for the length of the timout, consider the --animation-duration custom property and add a small delay
  229. // retrieve properties on the root element
  230. const root = document.querySelector(":root");
  231. const rootStyles = getComputedStyle(root);
  232. // retrieve the animation-duration custom property
  233. // ! this is specified as "40s", in seconds, so parse the number and includ it in milliseconds
  234. const animationDuration = parseInt(rootStyles.getPropertyValue("--animation-duration"))*1000;
  235. let keyTimer = animationDuration*9/8;
  236.  
  237.  
  238. // retrieve the dimensions of the key (to have the key exactly where the cursor would lie)
  239. const keyBox = key.getBoundingClientRect();
  240. // console.log(keyBox);
  241.  
  242.  
  243. // KEY & KEYHOLE ANIMATION
  244. // include a timeout with the specified time frame
  245. const timeoutID = setTimeout(() => {
  246. // after the specified time, change the cursor as to seemingly grab the key
  247. key.parentElement.parentElement.style.cursor = "grab";
  248.  
  249. // introduce the key and keyhole svg elements by triggering the paused-by-default animation
  250. key.style.animationPlayState = "running";
  251. keyhole.style.animationPlayState = "running";
  252.  
  253. // ! pointer-events set to none on the key to allow for a mouseover event on the keyhole
  254. // the key is indeed used in stead of the normal cursor and would overlap on top of everything
  255. key.style.pointerEvents = "none";
  256.  
  257. // when the cursor hovers anywhere in the window, call a function to update the position of the key and have it match the cursor
  258. window.addEventListener("mousemove", updateKeyPosition);
  259.  
  260. // when the cursor hovers on the keyhole, call a function to grant access and remove present listeners
  261. keyhole.addEventListener("mouseover", grantAccess);
  262.  
  263. clearTimeout(timeoutID);
  264. }, keyTimer);
  265.  
  266.  
  267. // define the function which updates the position of the absolute-positioned key according to the mouse coordinates (and the keys own dimensions)
  268. const updateKeyPosition = (e) => {
  269. let x = e.clientX;
  270. let y = e.clientY;
  271. key.style.left = x - keyBox.width/1.5;
  272. key.style.top = y - keyBox.height/2;
  273. };
  274.  
  275. // define the function which notifies the user of the grant access
  276. const grantAccess = () => {
  277. // restore the cursor
  278. key.parentElement.parentElement.style.cursor = "default";
  279.  
  280. // change the text of the heading and paragraph elements
  281. heading.textContent = '?YZ‰ yay ?YZ‰';
  282. paragraph.textContent = 'access granted';
  283.  
  284. // remove the svg elements for the key and keywhole from the flow of the document
  285. keyhole.style.display = "none";
  286. key.style.display = "none";
  287.  
  288. // remove the event listeners, most notably the one on the window
  289. window.removeEventListener("mousemove", updateKeyPosition);
  290. keyhole.removeEventListener("mouseover", grantAccess);
  291. };
  292.  
  293. </script>
  294. </body>
  295. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement