1(function webpackUniversalModuleDefinition(root, factory) { 2 if (typeof exports === "object" && typeof module === "object") 3 module.exports = factory(); 4 else if (typeof define === "function" && define.amd) define([], factory); 5 else if (typeof exports === "object") exports["POWERMODE"] = factory(); 6 else root["POWERMODE"] = factory(); 7})(this, function () { 8 return /******/ (function (modules) { 9 // webpackBootstrap 10 /******/ // The module cache 11 /******/ var installedModules = {}; 12 13 /******/ // The require function 14 /******/ function __webpack_require__(moduleId) { 15 /******/ // Check if module is in cache 16 /******/ if (installedModules[moduleId]) 17 /******/ return installedModules[moduleId].exports; 18 19 /******/ // Create a new module (and put it into the cache) 20 /******/ var module = (installedModules[moduleId] = { 21 /******/ exports: {}, 22 /******/ id: moduleId, 23 /******/ loaded: false, 24 /******/ 25 }); 26 27 /******/ // Execute the module function 28 /******/ modules[moduleId].call( 29 module.exports, 30 module, 31 module.exports, 32 __webpack_require__ 33 ); 34 35 /******/ // Flag the module as loaded 36 /******/ module.loaded = true; 37 38 /******/ // Return the exports of the module 39 /******/ return module.exports; 40 /******/ 41 } 42 43 /******/ // expose the modules object (__webpack_modules__) 44 /******/ __webpack_require__.m = modules; 45 46 /******/ // expose the module cache 47 /******/ __webpack_require__.c = installedModules; 48 49 /******/ // __webpack_public_path__ 50 /******/ __webpack_require__.p = ""; 51 52 /******/ // Load entry module and return exports 53 /******/ return __webpack_require__(0); 54 /******/ 55 })( 56 /************************************************************************/ 57 /******/ [ 58 /* 0 */ 59 /***/ function (module, exports, __webpack_require__) { 60 "use strict"; 61 62 var canvas = document.createElement("canvas"); 63 canvas.width = window.innerWidth; 64 canvas.height = window.innerHeight; 65 canvas.style.cssText = 66 "position:fixed;top:0;left:0;pointer-events:none;z-index:999999"; 67 window.addEventListener("resize", function () { 68 canvas.width = window.innerWidth; 69 canvas.height = window.innerHeight; 70 }); 71 document.body.appendChild(canvas); 72 var context = canvas.getContext("2d"); 73 var particles = []; 74 var particlePointer = 0; 75 var rendering = false; 76 77 POWERMODE.shake = true; 78 79 function getRandom(min, max) { 80 return Math.random() * (max - min) + min; 81 } 82 83 function getColor(el) { 84 if (POWERMODE.colorful) { 85 var u = getRandom(0, 360); 86 return ( 87 "hsla(" + 88 getRandom(u - 10, u + 10) + 89 ", 100%, " + 90 getRandom(50, 80) + 91 "%, " + 92 1 + 93 ")" 94 ); 95 } else { 96 return window.getComputedStyle(el).color; 97 } 98 } 99 100 function getCaret() { 101 var el = document.activeElement; 102 var bcr; 103 if ( 104 el.tagName === "TEXTAREA" || 105 (el.tagName === "INPUT" && el.getAttribute("type") === "text") 106 ) { 107 var offset = __webpack_require__(1)(el, el.selectionEnd); 108 bcr = el.getBoundingClientRect(); 109 return { 110 x: offset.left + bcr.left, 111 y: offset.top + bcr.top, 112 color: getColor(el), 113 }; 114 } 115 var selection = window.getSelection(); 116 if (selection.rangeCount) { 117 var range = selection.getRangeAt(0); 118 var startNode = range.startContainer; 119 if (startNode.nodeType === document.TEXT_NODE) { 120 startNode = startNode.parentNode; 121 } 122 bcr = range.getBoundingClientRect(); 123 return { 124 x: bcr.left, 125 y: bcr.top, 126 color: getColor(startNode), 127 }; 128 } 129 return { x: 0, y: 0, color: "transparent" }; 130 } 131 132 function createParticle(x, y, color) { 133 return { 134 x: x, 135 y: y, 136 alpha: 1, 137 color: color, 138 velocity: { 139 x: -1 + Math.random() * 2, 140 y: -3.5 + Math.random() * 2, 141 }, 142 }; 143 } 144 145 function POWERMODE() { 146 { 147 // spawn particles 148 var caret = getCaret(); 149 var numParticles = 5 + Math.round(Math.random() * 10); 150 while (numParticles--) { 151 particles[particlePointer] = createParticle( 152 caret.x, 153 caret.y, 154 caret.color 155 ); 156 particlePointer = (particlePointer + 1) % 500; 157 } 158 } 159 { 160 // shake screen 161 if (POWERMODE.shake) { 162 var intensity = 1 + 2 * Math.random(); 163 var x = intensity * (Math.random() > 0.5 ? -1 : 1); 164 var y = intensity * (Math.random() > 0.5 ? -1 : 1); 165 document.body.style.marginLeft = x + "px"; 166 document.body.style.marginTop = y + "px"; 167 setTimeout(function () { 168 document.body.style.marginLeft = ""; 169 document.body.style.marginTop = ""; 170 }, 75); 171 } 172 } 173 if (!rendering) { 174 requestAnimationFrame(loop); 175 } 176 } 177 POWERMODE.colorful = false;
178 179 function loop() { 180 rendering = true; 181 context.clearRect(0, 0, canvas.width, canvas.height); 182 var rendered = false; 183 var rect = canvas.getBoundingClientRect(); 184 for (var i = 0; i < particles.length; ++i) { 185 var particle = particles[i]; 186 if (particle.alpha <= 0.1) continue; 187 particle.velocity.y += 0.075; 188 particle.x += particle.velocity.x; 189 particle.y += particle.velocity.y; 190 particle.alpha *= 0.96; 191 context.globalAlpha = particle.alpha; 192 context.fillStyle = particle.color; 193 context.fillRect( 194 Math.round(particle.x - 1.5) - rect.left, 195 Math.round(particle.y - 1.5) - rect.top, 196 3, 197 3 198 ); 199 rendered = true; 200 } 201 if (rendered) { 202 requestAnimationFrame(loop); 203 } else { 204 rendering = false; 205 } 206 } 207 208 module.exports = POWERMODE; 209 210 /***/ 211 }, 212 /* 1 */ 213 /***/ function (module, exports) { 214 /* jshint browser: true */ 215 216 (function () { 217 // The properties that we copy into a mirrored div. 218 // Note that some browsers, such as Firefox, 219 // do not concatenate properties, i.e. padding-top, bottom etc. -> padding, 220 // so we have to do every single property specifically. 221 var properties = [ 222 "direction", // RTL support 223 "boxSizing", 224 "width", // on Chrome and IE, exclude the scrollbar, so the mirror div wraps exactly as the textarea does 225 "height", 226 "overflowX", 227 "overflowY", // copy the scrollbar for IE 228 229 "borderTopWidth", 230 "borderRightWidth", 231 "borderBottomWidth", 232 "borderLeftWidth", 233 "borderStyle", 234 235 "paddingTop", 236 "paddingRight", 237 "paddingBottom", 238 "paddingLeft", 239 240 // https://developer.mozilla.org/en-US/docs/Web/CSS/font 241 "fontStyle", 242 "fontVariant", 243 "fontWeight", 244 "fontStretch", 245 "fontSize", 246 "fontSizeAdjust", 247 "lineHeight", 248 "fontFamily", 249 250 "textAlign", 251 "textTransform", 252 "textIndent", 253 "textDecoration", // might not make a difference, but better be safe 254 255 "letterSpacing", 256 "wordSpacing", 257 258 "tabSize", 259 "MozTabSize", 260 ]; 261 262 var isFirefox = window.mozInnerScreenX != null; 263 264 function getCaretCoordinates(element, position, options) { 265 var debug = (options && options.debug) || false; 266 if (debug) { 267 var el = document.querySelector( 268 "#input-textarea-caret-position-mirror-div" 269 ); 270 if (el) { 271 el.parentNode.removeChild(el); 272 } 273 } 274 275 // mirrored div 276 var div = document.createElement("div"); 277 div.id = "input-textarea-caret-position-mirror-div"; 278 document.body.appendChild(div); 279 280 var style = div.style; 281 var computed = window.getComputedStyle 282 ? getComputedStyle(element) 283 : element.currentStyle; // currentStyle for IE < 9 284 285 // default textarea styles 286 style.whiteSpace = "pre-wrap"; 287 if (element.nodeName !== "INPUT") style.wordWrap = "break-word"; // only for textarea-s 288 289 // position off-screen 290 style.position = "absolute"; // required to return coordinates properly 291 if (!debug) style.visibility = "hidden"; // not 'display: none' because we want rendering 292 293 // transfer the element's properties to the div 294 properties.forEach(function (prop) { 295 style[prop] = computed[prop]; 296 }); 297 298 if (isFirefox) { 299 // Firefox lies about the overflow property for textareas: https://bugzilla.mozilla.org/show_bug.cgi?id=984275 300 if (element.scrollHeight > parseInt(computed.height)) 301 style.overflowY = "scroll"; 302 } else { 303 style.overflow = "hidden"; // for Chrome to not render a scrollbar; IE keeps overflowY = 'scroll' 304 } 305 306 div.textContent = element.value.substring(0, position); 307 // the second special handling for input type="text" vs textarea: spaces need to be replaced with
307non-breaking spaces - http://stackoverflow.com/a/13402035/1269037 308 if (element.nodeName === "INPUT") 309 div.textContent = div.textContent.replace(/\s/g, "\u00a0"); 310 311 var span = document.createElement("span"); 312 // Wrapping must be replicated *exactly*, including when a long word gets 313 // onto the next line, with whitespace at the end of the line before (#7). 314 // The *only* reliable way to do that is to copy the *entire* rest of the 315 // textarea's content into the <span> created at the caret position. 316 // for inputs, just '.' would be enough, but why bother? 317 span.textContent = element.value.substring(position) || "."; // || because a completely empty faux span doesn't render at all 318 div.appendChild(span); 319 320 var coordinates = { 321 top: span.offsetTop + parseInt(computed["borderTopWidth"]), 322 left: span.offsetLeft + parseInt(computed["borderLeftWidth"]), 323 }; 324 325 if (debug) { 326 span.style.backgroundColor = "#aaa"; 327 } else { 328 document.body.removeChild(div); 329 } 330 331 return coordinates; 332 } 333 334 if ( 335 typeof module != "undefined" && 336 typeof module.exports != "undefined" 337 ) { 338 module.exports = getCaretCoordinates; 339 } else { 340 window.getCaretCoordinates = getCaretCoordinates; 341 } 342 })(); 343 344 /***/ 345 }, 346 /******/ 347 ] 348 ); 349});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.