A Twitch.tv viewer reward and games system.
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.

209 lines
5.1 KiB

  1. !function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.jade=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. 'use strict';
  3. /**
  4. * Merge two attribute objects giving precedence
  5. * to values in object `b`. Classes are special-cased
  6. * allowing for arrays and merging/joining appropriately
  7. * resulting in a string.
  8. *
  9. * @param {Object} a
  10. * @param {Object} b
  11. * @return {Object} a
  12. * @api private
  13. */
  14. exports.merge = function merge(a, b) {
  15. if (arguments.length === 1) {
  16. var attrs = a[0];
  17. for (var i = 1; i < a.length; i++) {
  18. attrs = merge(attrs, a[i]);
  19. }
  20. return attrs;
  21. }
  22. var ac = a['class'];
  23. var bc = b['class'];
  24. if (ac || bc) {
  25. ac = ac || [];
  26. bc = bc || [];
  27. if (!Array.isArray(ac)) ac = [ac];
  28. if (!Array.isArray(bc)) bc = [bc];
  29. a['class'] = ac.concat(bc).filter(nulls);
  30. }
  31. for (var key in b) {
  32. if (key != 'class') {
  33. a[key] = b[key];
  34. }
  35. }
  36. return a;
  37. };
  38. /**
  39. * Filter null `val`s.
  40. *
  41. * @param {*} val
  42. * @return {Boolean}
  43. * @api private
  44. */
  45. function nulls(val) {
  46. return val != null && val !== '';
  47. }
  48. /**
  49. * join array as classes.
  50. *
  51. * @param {*} val
  52. * @return {String}
  53. */
  54. exports.joinClasses = joinClasses;
  55. function joinClasses(val) {
  56. return Array.isArray(val) ? val.map(joinClasses).filter(nulls).join(' ') : val;
  57. }
  58. /**
  59. * Render the given classes.
  60. *
  61. * @param {Array} classes
  62. * @param {Array.<Boolean>} escaped
  63. * @return {String}
  64. */
  65. exports.cls = function cls(classes, escaped) {
  66. var buf = [];
  67. for (var i = 0; i < classes.length; i++) {
  68. if (escaped && escaped[i]) {
  69. buf.push(exports.escape(joinClasses([classes[i]])));
  70. } else {
  71. buf.push(joinClasses(classes[i]));
  72. }
  73. }
  74. var text = joinClasses(buf);
  75. if (text.length) {
  76. return ' class="' + text + '"';
  77. } else {
  78. return '';
  79. }
  80. };
  81. /**
  82. * Render the given attribute.
  83. *
  84. * @param {String} key
  85. * @param {String} val
  86. * @param {Boolean} escaped
  87. * @param {Boolean} terse
  88. * @return {String}
  89. */
  90. exports.attr = function attr(key, val, escaped, terse) {
  91. if ('boolean' == typeof val || null == val) {
  92. if (val) {
  93. return ' ' + (terse ? key : key + '="' + key + '"');
  94. } else {
  95. return '';
  96. }
  97. } else if (0 == key.indexOf('data') && 'string' != typeof val) {
  98. return ' ' + key + "='" + JSON.stringify(val).replace(/'/g, '&apos;') + "'";
  99. } else if (escaped) {
  100. return ' ' + key + '="' + exports.escape(val) + '"';
  101. } else {
  102. return ' ' + key + '="' + val + '"';
  103. }
  104. };
  105. /**
  106. * Render the given attributes object.
  107. *
  108. * @param {Object} obj
  109. * @param {Object} escaped
  110. * @return {String}
  111. */
  112. exports.attrs = function attrs(obj, terse){
  113. var buf = [];
  114. var keys = Object.keys(obj);
  115. if (keys.length) {
  116. for (var i = 0; i < keys.length; ++i) {
  117. var key = keys[i]
  118. , val = obj[key];
  119. if ('class' == key) {
  120. if (val = joinClasses(val)) {
  121. buf.push(' ' + key + '="' + val + '"');
  122. }
  123. } else {
  124. buf.push(exports.attr(key, val, false, terse));
  125. }
  126. }
  127. }
  128. return buf.join('');
  129. };
  130. /**
  131. * Escape the given string of `html`.
  132. *
  133. * @param {String} html
  134. * @return {String}
  135. * @api private
  136. */
  137. exports.escape = function escape(html){
  138. var result = String(html)
  139. .replace(/&/g, '&amp;')
  140. .replace(/</g, '&lt;')
  141. .replace(/>/g, '&gt;')
  142. .replace(/"/g, '&quot;');
  143. if (result === '' + html) return html;
  144. else return result;
  145. };
  146. /**
  147. * Re-throw the given `err` in context to the
  148. * the jade in `filename` at the given `lineno`.
  149. *
  150. * @param {Error} err
  151. * @param {String} filename
  152. * @param {String} lineno
  153. * @api private
  154. */
  155. exports.rethrow = function rethrow(err, filename, lineno, str){
  156. if (!(err instanceof Error)) throw err;
  157. if ((typeof window != 'undefined' || !filename) && !str) {
  158. err.message += ' on line ' + lineno;
  159. throw err;
  160. }
  161. try {
  162. str = str || require('fs').readFileSync(filename, 'utf8')
  163. } catch (ex) {
  164. rethrow(err, null, lineno)
  165. }
  166. var context = 3
  167. , lines = str.split('\n')
  168. , start = Math.max(lineno - context, 0)
  169. , end = Math.min(lines.length, lineno + context);
  170. // Error context
  171. var context = lines.slice(start, end).map(function(line, i){
  172. var curr = i + start + 1;
  173. return (curr == lineno ? ' > ' : ' ')
  174. + curr
  175. + '| '
  176. + line;
  177. }).join('\n');
  178. // Alter exception message
  179. err.path = filename;
  180. err.message = (filename || 'Jade') + ':' + lineno
  181. + '\n' + context + '\n\n' + err.message;
  182. throw err;
  183. };
  184. },{"fs":2}],2:[function(require,module,exports){
  185. },{}]},{},[1])
  186. (1)
  187. });