Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.80 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Генератор Титулов</title>
  5.  
  6. <style>
  7. body {
  8. margin: 0px;
  9.  
  10. background: #6A7495;
  11. color: #C2C2DA;
  12. font-family: Verdana;
  13. }
  14.  
  15. #preview {
  16. height: 160px;
  17. width: 160px;
  18.  
  19. display: flex;
  20. justify-content: center; /* align horizontal */
  21. align-items: center; /* align vertical */
  22. text-align: center;
  23. }
  24.  
  25. input[type=text] { text-align: center; }
  26. label {
  27. float: left;
  28. width: 5em;
  29. margin-right: 1em;
  30. }
  31.  
  32. /* rows & cols */
  33.  
  34. .col-1 {width: 8.33%;}
  35. .col-2 {width: 16.66%;}
  36. .col-3 {width: 25%;}
  37. .col-4 {width: 33.33%;}
  38. .col-5 {width: 41.66%;}
  39. .col-6 {width: 50%;}
  40. .col-7 {width: 58.33%;}
  41. .col-8 {width: 66.66%;}
  42. .col-9 {width: 75%;}
  43. .col-10 {width: 83.33%;}
  44. .col-11 {width: 91.66%;}
  45. .col-12 {width: 100%;}
  46.  
  47. [class*="col-"] {
  48. float: left;
  49. padding: 15px;
  50. }
  51.  
  52. .row::after {
  53. content: "";
  54. clear: both;
  55. display: block;
  56. }
  57. </style>
  58. <meta charset="utf-8">
  59. </head>
  60. <body>
  61. <div class="row">
  62. <div class="col-none" id="preview">
  63. <div>
  64. &laquo;<span id="content">Little Mouse</span>&raquo;
  65. <br />
  66. <img src="/s/tg/mices/1.png?v=3" data-mice-id="1" height="110" alt="" id="mice_example" />
  67. </div>
  68. </div>
  69. <div class="col-3">
  70. <form id="generator">
  71. <h2>Генератор Титулов</h2>
  72. <input type="radio" name="grtype" value="rgb"> RGB <input type="radio" name="grtype" value="hsv" checked> HSV <input type="radio" name="grtype" value="hsvi"> HSVi
  73. <br /><br />
  74. <label for="title">&nbsp;</label>
  75. <input type="text" id="title" name="title" value="Little Mouse" size="9">
  76. <br /><br />
  77. <label for="fade_start">Цвет #1</label>
  78. <input type="color" id="fade_start" name="fade_start" value="#E50600">
  79. <br />
  80. <label for="fade_end">Цвет #2</label>
  81. <input type="color" id="fade_end" name="fade_end" value="#00BABF">
  82. <br /><br />
  83. <input type="button" onclick="window.location.hash='t=hsv&v=Little%20Mouse&from=%23e50600&to=%2300babf'; load_params(); update_preview();" value="Сброс" />
  84. <textarea id="output_code" style="margin: 0px; width: 450px; height: 100px;"></textarea>
  85. </form>
  86. </div>
  87. </div>
  88.  
  89. <script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
  90. <script type="text/javascript" src="/s/tg/tinycolor.js"></script>
  91. <script type="text/javascript" src="/s/tg/tinygradient.js"></script>
  92. <script type="text/javascript">
  93. $.unparam = function(a){if(""==a)return null;for(var b={},c=a.split("&"),d=0;d<c.length;d++){var e=c[d].split("="),f=decodeURIComponent(e[0]),g=decodeURIComponent(e[1]);"undefined"==typeof b[f]?"[]"!=f.substr(f.length-2)?b[f]=g:b[f.substr(0,f.length-2)]=[g]:"string"==typeof b[f]?b[f]=g:b[f.substr(0,f.length-2)].push(g)}return b}
  94. </script>
  95. <script type="text/javascript">
  96. var title_input = $("input[name=\"title\"]");
  97. var title_preview = $("#preview span#content");
  98.  
  99. function load_params() {
  100. var gradient_info = $.unparam(window.location.hash.substr(1));
  101. if (gradient_info != null) {
  102. $("input[name='grtype'][value='" + gradient_info.t + "']").prop("checked", true);
  103. $("input[name='title']").val(gradient_info.v);
  104. $("input[name='fade_start']").val(gradient_info.from);
  105. $("input[name='fade_end']").val(gradient_info.to);
  106. }
  107. }
  108.  
  109. function update_preview() {
  110. var title_raw = title_input.val().length > 0 ? title_input.val() : "Little Mouse";
  111. var title_html = "";
  112. var twlength = title_raw.trim(' ').length;
  113.  
  114. if (twlength < 2) {title_preview.html(title_raw); return;}
  115.  
  116. var gradient = tinygradient($("#fade_start").val(), $("#fade_end").val());
  117. var gr_type = $("input[name=\"grtype\"]:checked").val();
  118. var gr_done = gr_type == "rgb" ? gradient.rgb(twlength) : gradient.hsv(twlength, gr_type == "hsvi");
  119.  
  120. for (var i = 0, s = 0, len = title_raw.length; i < len; i++) {
  121. if (title_raw.charAt(i) != " ") {
  122. var color = gr_done[i - s].toHexString();
  123.  
  124. title_html += '<font color="' + color + '">' + title_raw.charAt(i) + '</font>';
  125. } else {
  126. s++;
  127. title_html += " ";
  128. }
  129. }
  130.  
  131. title_preview.html(title_html);
  132. $("#output_code").val(title_html);
  133. window.location.hash = $.param({t: gr_type, v: title_raw, from: $("#fade_start").val(), to: $("#fade_end").val()})
  134. }
  135.  
  136. $("form#generator > input").on('input', update_preview);
  137. $("form#generator > input[name=\"grtype\"]").on('change', update_preview);
  138. //$(window).on('hashchange', load_params);
  139.  
  140. $(document).ready(function() {
  141. $("#preview").click(function() {
  142. var image = $("img#mice_example");
  143. image.data('miceId', (image.data('miceId') % 3) + 1);
  144. image.attr("src", "/s/tg/mices/" + image.data('miceId') + ".png?v=3");
  145. });
  146. load_params();
  147. update_preview();
  148. });
  149. </script>
  150. </body>
  151. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement