My public website https://www.chameth.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

smart-underlines.js 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. /*
  2. From https://github.com/CloudflareApps/SmartUnderline
  3. MIT License
  4. Copyright (c) 2017 Cloudflare Inc.
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in all
  12. copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  19. SOFTWARE.
  20. */
  21. (function() {
  22. var PHI, backgroundPositionYCache, calculateBaselineYRatio, calculateTextHighestY, calculateTypeMetrics, clearCanvas, containerIdAttrName, containsAnyNonInlineElements, containsInvalidElements, countParentContainers, destroy, fontAvailable, getBackgroundColor, getBackgroundColorNode, getFirstAvailableFont, getLinkColor, getUnderlineBackgroundPositionY, hasValidLinkContent, init, initLink, initLinkOnHover, isTransparent, isUnderlined, linkAlwysAttrName, linkBgPosAttrName, linkColorAttrName, linkContainers, linkHoverAttrName, linkLargeAttrName, linkSmallAttrName, performanceTimes, renderStyles, selectionColor, sortContainersForCSSPrecendence, styleNode, time, uniqueLinkContainerID;
  23. window.SmartUnderline = {
  24. init: function() {},
  25. destroy: function() {}
  26. };
  27. if (!(window['getComputedStyle'] && document.documentElement.getAttribute)) {
  28. return;
  29. }
  30. PHI = 1.618034;
  31. selectionColor = '#b4d5fe';
  32. linkColorAttrName = 'data-smart-underline-link-color';
  33. linkSmallAttrName = 'data-smart-underline-link-small';
  34. linkLargeAttrName = 'data-smart-underline-link-large';
  35. linkAlwysAttrName = 'data-smart-underline-link-always';
  36. linkBgPosAttrName = 'data-smart-underline-link-background-position';
  37. linkHoverAttrName = 'data-smart-underline-link-hover';
  38. containerIdAttrName = 'data-smart-underline-container-id';
  39. performanceTimes = [];
  40. time = function() {
  41. return +(new Date);
  42. };
  43. linkContainers = {};
  44. uniqueLinkContainerID = (function() {
  45. var id;
  46. id = 0;
  47. return function() {
  48. return id += 1;
  49. };
  50. })();
  51. clearCanvas = function(canvas, context) {
  52. return context.clearRect(0, 0, canvas.width, canvas.height);
  53. };
  54. calculateTextHighestY = function(text, canvas, context) {
  55. var alpha, highestY, i, j, pixelData, r, ref, ref1, textWidth, x, y;
  56. clearCanvas(canvas, context);
  57. context.fillStyle = 'red';
  58. textWidth = context.measureText(text).width;
  59. context.fillText(text, 0, 0);
  60. highestY = void 0;
  61. for (x = i = 0, ref = textWidth; 0 <= ref ? i <= ref : i >= ref; x = 0 <= ref ? ++i : --i) {
  62. for (y = j = 0, ref1 = canvas.height; 0 <= ref1 ? j <= ref1 : j >= ref1; y = 0 <= ref1 ? ++j : --j) {
  63. pixelData = context.getImageData(x, y, x + 1, y + 1);
  64. r = pixelData.data[0];
  65. alpha = pixelData.data[3];
  66. if (r === 255 && alpha > 50) {
  67. if (!highestY) {
  68. highestY = y;
  69. }
  70. if (y > highestY) {
  71. highestY = y;
  72. }
  73. }
  74. }
  75. }
  76. clearCanvas(canvas, context);
  77. return highestY;
  78. };
  79. calculateTypeMetrics = function(computedStyle) {
  80. var baselineY, canvas, context, descenderHeight, gLowestPixel;
  81. canvas = document.createElement('canvas');
  82. context = canvas.getContext('2d');
  83. canvas.height = canvas.width = 2 * parseInt(computedStyle.fontSize, 10);
  84. context.textBaseline = 'top';
  85. context.textAlign = 'start';
  86. context.fontStretch = 1;
  87. context.angle = 0;
  88. context.font = computedStyle.fontVariant + " " + computedStyle.fontStyle + " " + computedStyle.fontWeight + " " + computedStyle.fontSize + "/" + computedStyle.lineHeight + " " + computedStyle.fontFamily;
  89. baselineY = calculateTextHighestY('I', canvas, context);
  90. gLowestPixel = calculateTextHighestY('g', canvas, context);
  91. descenderHeight = gLowestPixel - baselineY;
  92. return {
  93. baselineY: baselineY,
  94. descenderHeight: descenderHeight
  95. };
  96. };
  97. calculateBaselineYRatio = function(node) {
  98. var baselinePositionY, baselineYRatio, height, large, largeRect, small, smallRect, test;
  99. test = document.createElement('div');
  100. test.style.display = 'block';
  101. test.style.position = 'absolute';
  102. test.style.bottom = 0;
  103. test.style.right = 0;
  104. test.style.width = 0;
  105. test.style.height = 0;
  106. test.style.margin = 0;
  107. test.style.padding = 0;
  108. test.style.visibility = 'hidden';
  109. test.style.overflow = 'hidden';
  110. test.style.wordWrap = 'normal';
  111. test.style.whiteSpace = 'nowrap';
  112. small = document.createElement('span');
  113. large = document.createElement('span');
  114. small.style.display = 'inline';
  115. large.style.display = 'inline';
  116. small.style.fontSize = '0px';
  117. large.style.fontSize = '2000px';
  118. small.innerHTML = 'X';
  119. large.innerHTML = 'X';
  120. test.appendChild(small);
  121. test.appendChild(large);
  122. node.appendChild(test);
  123. smallRect = small.getBoundingClientRect();
  124. largeRect = large.getBoundingClientRect();
  125. node.removeChild(test);
  126. baselinePositionY = smallRect.top - largeRect.top;
  127. height = largeRect.height;
  128. return baselineYRatio = Math.abs(baselinePositionY / height);
  129. };
  130. backgroundPositionYCache = {};
  131. getFirstAvailableFont = function(fontFamily) {
  132. var font, fonts, i, len;
  133. fonts = fontFamily.split(',');
  134. for (i = 0, len = fonts.length; i < len; i++) {
  135. font = fonts[i];
  136. if (fontAvailable(font)) {
  137. return font;
  138. }
  139. }
  140. return false;
  141. };
  142. fontAvailable = function(font) {
  143. var baselineSize, canvas, context, newSize, text;
  144. canvas = document.createElement('canvas');
  145. context = canvas.getContext('2d');
  146. text = 'abcdefghijklmnopqrstuvwxyz0123456789';
  147. context.font = '72px monospace';
  148. baselineSize = context.measureText(text).width;
  149. context.font = "72px " + font + ", monospace";
  150. newSize = context.measureText(text).width;
  151. if (newSize === baselineSize) {
  152. return false;
  153. }
  154. return true;
  155. };
  156. getUnderlineBackgroundPositionY = function(node) {
  157. var adjustment, backgroundPositionY, backgroundPositionYPercent, baselineY, baselineYRatio, cache, cacheKey, clientRects, computedStyle, descenderHeight, descenderY, firstAvailableFont, fontSizeInt, minimumCloseness, ref, textHeight;
  158. computedStyle = getComputedStyle(node);
  159. firstAvailableFont = getFirstAvailableFont(computedStyle.fontFamily);
  160. if (!firstAvailableFont) {
  161. cacheKey = "" + (Math.random());
  162. } else {
  163. cacheKey = "font:" + firstAvailableFont + "size:" + computedStyle.fontSize + "weight:" + computedStyle.fontWeight;
  164. }
  165. cache = backgroundPositionYCache[cacheKey];
  166. if (cache) {
  167. return cache;
  168. }
  169. ref = calculateTypeMetrics(computedStyle), baselineY = ref.baselineY, descenderHeight = ref.descenderHeight;
  170. clientRects = node.getClientRects();
  171. if (!(clientRects != null ? clientRects.length : void 0)) {
  172. return;
  173. }
  174. adjustment = 1;
  175. textHeight = clientRects[0].height - adjustment;
  176. if (-1 < navigator.userAgent.toLowerCase().indexOf('firefox')) {
  177. adjustment = .98;
  178. baselineYRatio = calculateBaselineYRatio(node);
  179. baselineY = baselineYRatio * textHeight * adjustment;
  180. }
  181. descenderY = baselineY + descenderHeight;
  182. fontSizeInt = parseInt(computedStyle.fontSize, 10);
  183. minimumCloseness = 3;
  184. backgroundPositionY = baselineY + Math.max(minimumCloseness, descenderHeight / PHI);
  185. if (descenderHeight === 4) {
  186. backgroundPositionY = descenderY - 1;
  187. }
  188. if (descenderHeight === 3) {
  189. backgroundPositionY = descenderY;
  190. }
  191. backgroundPositionYPercent = Math.round(100 * backgroundPositionY / textHeight);
  192. if (descenderHeight > 2 && fontSizeInt > 10 && backgroundPositionYPercent <= 100) {
  193. backgroundPositionYCache[cacheKey] = backgroundPositionYPercent;
  194. return backgroundPositionYPercent;
  195. }
  196. };
  197. isTransparent = function(color) {
  198. var alpha, rgbaAlphaMatch;
  199. if (color === 'transparent' || color === 'rgba(0, 0, 0, 0)') {
  200. return true;
  201. }
  202. rgbaAlphaMatch = color.match(/^rgba\(.*,(.+)\)/i);
  203. if ((rgbaAlphaMatch != null ? rgbaAlphaMatch.length : void 0) === 2) {
  204. alpha = parseFloat(rgbaAlphaMatch[1]);
  205. if (alpha < .0001) {
  206. return true;
  207. }
  208. }
  209. return false;
  210. };
  211. getBackgroundColorNode = function(node) {
  212. var backgroundColor, computedStyle, parentNode, reachedRootNode;
  213. computedStyle = getComputedStyle(node);
  214. backgroundColor = computedStyle.backgroundColor;
  215. parentNode = node.parentNode;
  216. reachedRootNode = !parentNode || parentNode === document.documentElement || parentNode === node;
  217. if (computedStyle.backgroundImage !== 'none') {
  218. return null;
  219. }
  220. if (isTransparent(backgroundColor)) {
  221. if (reachedRootNode) {
  222. return node.parentNode || node;
  223. } else {
  224. return getBackgroundColorNode(parentNode);
  225. }
  226. } else {
  227. return node;
  228. }
  229. };
  230. hasValidLinkContent = function(node) {
  231. return containsInvalidElements(node) || containsAnyNonInlineElements(node);
  232. };
  233. containsInvalidElements = function(node) {
  234. var child, i, len, ref, ref1, ref2;
  235. ref = node.children;
  236. for (i = 0, len = ref.length; i < len; i++) {
  237. child = ref[i];
  238. if ((ref1 = (ref2 = child.tagName) != null ? ref2.toLowerCase() : void 0) === 'img' || ref1 === 'video' || ref1 === 'canvas' || ref1 === 'embed' || ref1 === 'object' || ref1 === 'iframe') {
  239. return true;
  240. }
  241. return containsInvalidElements(child);
  242. }
  243. return false;
  244. };
  245. containsAnyNonInlineElements = function(node) {
  246. var child, i, len, ref, style;
  247. ref = node.children;
  248. for (i = 0, len = ref.length; i < len; i++) {
  249. child = ref[i];
  250. style = getComputedStyle(child);
  251. if (style.display !== 'inline') {
  252. return true;
  253. }
  254. return containsAnyNonInlineElements(child);
  255. }
  256. return false;
  257. };
  258. getBackgroundColor = function(node) {
  259. var backgroundColor;
  260. backgroundColor = getComputedStyle(node).backgroundColor;
  261. if (node === document.documentElement && isTransparent(backgroundColor)) {
  262. return 'rgb(255, 255, 255)';
  263. } else {
  264. return backgroundColor;
  265. }
  266. };
  267. getLinkColor = function(node) {
  268. return getComputedStyle(node).color;
  269. };
  270. styleNode = document.createElement('style');
  271. countParentContainers = function(node, count) {
  272. var parentNode, reachedRootNode;
  273. if (count == null) {
  274. count = 0;
  275. }
  276. parentNode = node.parentNode;
  277. reachedRootNode = !parentNode || parentNode === document || parentNode === node;
  278. if (reachedRootNode) {
  279. return count;
  280. } else {
  281. if (parentNode.hasAttribute(containerIdAttrName)) {
  282. count += 1;
  283. }
  284. return count + countParentContainers(parentNode);
  285. }
  286. };
  287. sortContainersForCSSPrecendence = function(containers) {
  288. var container, id, sorted;
  289. sorted = [];
  290. for (id in containers) {
  291. container = containers[id];
  292. container.depth = countParentContainers(container.container);
  293. sorted.push(container);
  294. }
  295. sorted.sort(function(a, b) {
  296. if (a.depth < b.depth) {
  297. return -1;
  298. }
  299. if (a.depth > b.depth) {
  300. return 1;
  301. }
  302. return 0;
  303. });
  304. return sorted;
  305. };
  306. isUnderlined = function(style) {
  307. var i, len, property, ref, ref1;
  308. ref = ['textDecorationLine', 'textDecoration'];
  309. for (i = 0, len = ref.length; i < len; i++) {
  310. property = ref[i];
  311. if ((ref1 = style[property]) != null ? ref1.match(/\bunderline\b/) : void 0) {
  312. return true;
  313. }
  314. }
  315. return false;
  316. };
  317. initLink = function(link) {
  318. var backgroundPositionY, container, fontSize, id, style;
  319. style = getComputedStyle(link);
  320. fontSize = parseFloat(style.fontSize);
  321. if (isUnderlined(style) && style.display === 'inline' && fontSize >= 10 && !hasValidLinkContent(link)) {
  322. container = getBackgroundColorNode(link);
  323. if (container) {
  324. backgroundPositionY = getUnderlineBackgroundPositionY(link);
  325. if (backgroundPositionY) {
  326. link.setAttribute(linkColorAttrName, getLinkColor(link));
  327. link.setAttribute(linkBgPosAttrName, backgroundPositionY);
  328. id = container.getAttribute(containerIdAttrName);
  329. if (id) {
  330. linkContainers[id].links.push(link);
  331. } else {
  332. id = uniqueLinkContainerID();
  333. container.setAttribute(containerIdAttrName, id);
  334. linkContainers[id] = {
  335. id: id,
  336. container: container,
  337. links: [link]
  338. };
  339. }
  340. return true;
  341. }
  342. }
  343. }
  344. return false;
  345. };
  346. renderStyles = function() {
  347. var backgroundColor, backgroundPositionY, color, container, containersWithPrecedence, i, j, len, len1, link, linkBackgroundPositionYs, linkColors, linkSelector, ref, styles;
  348. styles = '';
  349. containersWithPrecedence = sortContainersForCSSPrecendence(linkContainers);
  350. linkBackgroundPositionYs = {};
  351. for (i = 0, len = containersWithPrecedence.length; i < len; i++) {
  352. container = containersWithPrecedence[i];
  353. linkColors = {};
  354. ref = container.links;
  355. for (j = 0, len1 = ref.length; j < len1; j++) {
  356. link = ref[j];
  357. linkColors[getLinkColor(link)] = true;
  358. linkBackgroundPositionYs[getUnderlineBackgroundPositionY(link)] = true;
  359. }
  360. backgroundColor = getBackgroundColor(container.container);
  361. for (color in linkColors) {
  362. linkSelector = function(modifier) {
  363. if (modifier == null) {
  364. modifier = '';
  365. }
  366. return "[" + containerIdAttrName + "=\"" + container.id + "\"] a[" + linkColorAttrName + "=\"" + color + "\"][" + linkAlwysAttrName + "]" + modifier + ",\n[" + containerIdAttrName + "=\"" + container.id + "\"] a[" + linkColorAttrName + "=\"" + color + "\"][" + linkHoverAttrName + "]" + modifier + ":hover";
  367. };
  368. styles += (linkSelector()) + ", " + (linkSelector(':visited')) + " {\n color: " + color + ";\n text-decoration: none !important;\n text-shadow: 0.03em 0 " + backgroundColor + ", -0.03em 0 " + backgroundColor + ", 0 0.03em " + backgroundColor + ", 0 -0.03em " + backgroundColor + ", 0.06em 0 " + backgroundColor + ", -0.06em 0 " + backgroundColor + ", 0.09em 0 " + backgroundColor + ", -0.09em 0 " + backgroundColor + ", 0.12em 0 " + backgroundColor + ", -0.12em 0 " + backgroundColor + ", 0.15em 0 " + backgroundColor + ", -0.15em 0 " + backgroundColor + ";\n background-color: transparent;\n background-image: -webkit-linear-gradient(" + backgroundColor + ", " + backgroundColor + "), -webkit-linear-gradient(" + backgroundColor + ", " + backgroundColor + "), -webkit-linear-gradient(" + color + ", " + color + ");\n background-image: -moz-linear-gradient(" + backgroundColor + ", " + backgroundColor + "), -moz-linear-gradient(" + backgroundColor + ", " + backgroundColor + "), -moz-linear-gradient(" + color + ", " + color + ");\n background-image: -o-linear-gradient(" + backgroundColor + ", " + backgroundColor + "), -o-linear-gradient(" + backgroundColor + ", " + backgroundColor + "), -o-linear-gradient(" + color + ", " + color + ");\n background-image: -ms-linear-gradient(" + backgroundColor + ", " + backgroundColor + "), -ms-linear-gradient(" + backgroundColor + ", " + backgroundColor + "), -ms-linear-gradient(" + color + ", " + color + ");\n background-image: linear-gradient(" + backgroundColor + ", " + backgroundColor + "), linear-gradient(" + backgroundColor + ", " + backgroundColor + "), linear-gradient(" + color + ", " + color + ");\n -webkit-background-size: 0.05em 1px, 0.05em 1px, 1px 1px;\n -moz-background-size: 0.05em 1px, 0.05em 1px, 1px 1px;\n background-size: 0.05em 1px, 0.05em 1px, 1px 1px;\n background-repeat: no-repeat, no-repeat, repeat-x;\n}\n\n" + (linkSelector('::selection')) + " {\n text-shadow: 0.03em 0 " + selectionColor + ", -0.03em 0 " + selectionColor + ", 0 0.03em " + selectionColor + ", 0 -0.03em " + selectionColor + ", 0.06em 0 " + selectionColor + ", -0.06em 0 " + selectionColor + ", 0.09em 0 " + selectionColor + ", -0.09em 0 " + selectionColor + ", 0.12em 0 " + selectionColor + ", -0.12em 0 " + selectionColor + ", 0.15em 0 " + selectionColor + ", -0.15em 0 " + selectionColor + ";\n background: " + selectionColor + ";\n}\n\n" + (linkSelector('::-moz-selection')) + " {\n text-shadow: 0.03em 0 " + selectionColor + ", -0.03em 0 " + selectionColor + ", 0 0.03em " + selectionColor + ", 0 -0.03em " + selectionColor + ", 0.06em 0 " + selectionColor + ", -0.06em 0 " + selectionColor + ", 0.09em 0 " + selectionColor + ", -0.09em 0 " + selectionColor + ", 0.12em 0 " + selectionColor + ", -0.12em 0 " + selectionColor + ", 0.15em 0 " + selectionColor + ", -0.15em 0 " + selectionColor + ";\n background: " + selectionColor + ";\n}";
  369. }
  370. }
  371. for (backgroundPositionY in linkBackgroundPositionYs) {
  372. styles += "a[" + linkBgPosAttrName + "=\"" + backgroundPositionY + "\"] {\n background-position: 0% " + backgroundPositionY + "%, 100% " + backgroundPositionY + "%, 0% " + backgroundPositionY + "%;\n}";
  373. }
  374. return styleNode.innerHTML = styles;
  375. };
  376. initLinkOnHover = function() {
  377. var alreadyMadeSmart, link, madeSmart;
  378. link = this;
  379. alreadyMadeSmart = link.hasAttribute(linkHoverAttrName);
  380. if (!alreadyMadeSmart) {
  381. madeSmart = initLink(link);
  382. if (madeSmart) {
  383. link.setAttribute(linkHoverAttrName, '');
  384. return renderStyles();
  385. }
  386. }
  387. };
  388. init = function(options) {
  389. var i, len, link, links, madeSmart, startTime;
  390. startTime = time();
  391. links = document.querySelectorAll((options.location ? options.location + ' ' : '') + "a");
  392. if (!links.length) {
  393. return;
  394. }
  395. linkContainers = {};
  396. for (i = 0, len = links.length; i < len; i++) {
  397. link = links[i];
  398. madeSmart = initLink(link);
  399. if (madeSmart) {
  400. link.setAttribute(linkAlwysAttrName, '');
  401. } else {
  402. link.removeEventListener('mouseover', initLinkOnHover);
  403. link.addEventListener('mouseover', initLinkOnHover);
  404. }
  405. }
  406. renderStyles();
  407. document.body.appendChild(styleNode);
  408. return performanceTimes.push(time() - startTime);
  409. };
  410. destroy = function() {
  411. var attribute, i, len, ref, ref1, results;
  412. if ((ref = styleNode.parentNode) != null) {
  413. ref.removeChild(styleNode);
  414. }
  415. Array.prototype.forEach.call(document.querySelectorAll("[" + linkHoverAttrName + "]"), function(node) {
  416. return node.removeEventListener(initLinkOnHover);
  417. });
  418. ref1 = [linkColorAttrName, linkSmallAttrName, linkLargeAttrName, linkAlwysAttrName, linkHoverAttrName, containerIdAttrName];
  419. results = [];
  420. for (i = 0, len = ref1.length; i < len; i++) {
  421. attribute = ref1[i];
  422. results.push(Array.prototype.forEach.call(document.querySelectorAll("[" + attribute + "]"), function(node) {
  423. return node.removeAttribute(attribute);
  424. }));
  425. }
  426. return results;
  427. };
  428. window.SmartUnderline = {
  429. init: function(options) {
  430. if (options == null) {
  431. options = {};
  432. }
  433. if (document.readyState === 'loading') {
  434. window.addEventListener('DOMContentLoaded', function() {
  435. return init(options);
  436. });
  437. return window.addEventListener('load', function() {
  438. destroy();
  439. return init(options);
  440. });
  441. } else {
  442. destroy();
  443. return init(options);
  444. }
  445. },
  446. destroy: function() {
  447. return destroy();
  448. },
  449. performanceTimes: function() {
  450. return performanceTimes;
  451. }
  452. };
  453. }).call(this);
  454. window.addEventListener('load', function() {
  455. SmartUnderline.init({
  456. location: ''
  457. });
  458. });