├── README.md
├── LICENSE
├── index.css
├── index.html
├── index.js
└── jquery-3.4.0.min.js
/README.md:
--------------------------------------------------------------------------------
1 | # music festival lineup generator
2 |
3 | A site that generates festival lineups automatically based on your SoundCloud
4 | likes
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 yan
4 |
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 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/index.css:
--------------------------------------------------------------------------------
1 | .loader,
2 | .loader:before,
3 | .loader:after {
4 | background: #666;
5 | -webkit-animation: load1 1s infinite ease-in-out;
6 | animation: load1 1s infinite ease-in-out;
7 | width: 1em;
8 | height: 4em;
9 | }
10 | .loader {
11 | color: #666;
12 | display: none;
13 | text-indent: -9999em;
14 | margin: 88px auto;
15 | position: relative;
16 | font-size: 11px;
17 | -webkit-transform: translateZ(0);
18 | -ms-transform: translateZ(0);
19 | transform: translateZ(0);
20 | -webkit-animation-delay: -0.16s;
21 | animation-delay: -0.16s;
22 | }
23 | .loader:before,
24 | .loader:after {
25 | position: absolute;
26 | top: 0;
27 | content: '';
28 | }
29 | .loader:before {
30 | left: -1.5em;
31 | -webkit-animation-delay: -0.32s;
32 | animation-delay: -0.32s;
33 | }
34 | .loader:after {
35 | left: 1.5em;
36 | }
37 | @-webkit-keyframes load1 {
38 | 0%,
39 | 80%,
40 | 100% {
41 | box-shadow: 0 0;
42 | height: 4em;
43 | }
44 | 40% {
45 | box-shadow: 0 -2em;
46 | height: 5em;
47 | }
48 | }
49 | @keyframes load1 {
50 | 0%,
51 | 80%,
52 | 100% {
53 | box-shadow: 0 0;
54 | height: 4em;
55 | }
56 | 40% {
57 | box-shadow: 0 -2em;
58 | height: 5em;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | music festival lineup generator
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
Welcome to my music festival lineup generator!
15 |
16 |
17 |
42 |
43 |
44 |
45 | Download as image
46 |
47 | loading...
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | const CLIENT_ID = 'YUKXoArFcqrlQn9tfNHvvyfnDISj04zk'
2 | const PAGE_SIZE = 200
3 | // Number of artists in each tier.
4 | const SLOTS = {
5 | h0: 0,
6 | h1: 3,
7 | h2: 6,
8 | h3: 12,
9 | h4: 24,
10 | h5: 36,
11 | h6: 0
12 | }
13 | const SEPARATOR = ' \u2022 '
14 |
15 | // Cached info
16 | let results = []
17 | let previousUserName
18 | let previousUrl
19 | let downloadUrl
20 |
21 | SC.initialize({
22 | client_id: CLIENT_ID
23 | })
24 |
25 | /**
26 | * Gets a SoundCloud URL from a username if needed
27 | * @param {string} input
28 | */
29 | const getSoundcloudUrl = (input) => {
30 | input = input.toLowerCase().trim()
31 | if (input.startsWith('http://') || input.startsWith('https://')) {
32 | return input
33 | }
34 | return `https://soundcloud.com/${input}`
35 | }
36 |
37 | /**
38 | * Show status or error to the user.
39 | * @param {string} msg
40 | * @param {boolean} showLoader
41 | */
42 | const showStatus = (msg, showLoader) => {
43 | $('#status').text(msg)
44 | if (showLoader) {
45 | $('#loader').show()
46 | } else {
47 | $('#loader').hide()
48 | }
49 | }
50 |
51 | /**
52 | * Clear the results section. Called every time a parameter is changed.
53 | */
54 | const clearResults = () => {
55 | document.getElementById('results').style.background = ''
56 | $('#h0').hide()
57 | Object.keys(SLOTS).forEach((element) => {
58 | $(`#${element}`).text('')
59 | })
60 | }
61 |
62 | /**
63 | * Given a soundcloud URL, this finds the corresponding user ID.
64 | * @param {string} scUrl
65 | * @param {Function} onSuccess
66 | * @param {Function} onError
67 | */
68 | const getUserId = (scUrl, onSuccess, onFail) => {
69 | const resolveUrl =
70 | `https://api.soundcloud.com/resolve.json?url=${scUrl}&client_id=${CLIENT_ID}`
71 | $.getJSON(resolveUrl, (response) => {
72 | if (response.id) {
73 | onSuccess(response.id, response.username)
74 | } else {
75 | onFail(onFail)
76 | }
77 | }).fail(onFail)
78 | }
79 |
80 | /**
81 | * Calculate and render the results.
82 | */
83 | const processAndDisplay = () => {
84 | // Map of {: {yourLikes:..., totalLikes:...}>
85 | const artists = {}
86 | results.forEach((entry) => {
87 | const artistName = entry.user.username
88 | if (!artists[artistName]) {
89 | artists[artistName] = { yourLikes: 0, totalLikes: 0 }
90 | }
91 | artists[artistName].totalLikes += entry.likes_count
92 | artists[artistName].yourLikes += 1
93 | })
94 | let sortable = []
95 | for (let artist in artists) {
96 | const counts = artists[artist]
97 | sortable.push({ artist, counts })
98 | }
99 | console.log('number of results:', sortable.length)
100 | const defaultThreshold = sortable.length > 150 ? 2 : 1
101 | const weight = document.getElementById('weight').valueAsNumber
102 | const threshold = Number($('input[name=threshold]:checked').val()) || defaultThreshold
103 | console.log('threshold and weight', threshold, weight)
104 | sortable = sortable.filter((item) => {
105 | return item.counts.yourLikes >= threshold
106 | }).sort((a, b) => {
107 | return (a.counts.totalLikes * a.counts.yourLikes ** (weight - 1)) - (b.counts.totalLikes * b.counts.yourLikes ** (weight - 1))
108 | })
109 | showStatus('')
110 | $('#h0').show()
111 | for (let tier in SLOTS) {
112 | const num = SLOTS[tier]
113 | for (let i = 0; i < num; i++) {
114 | const next = sortable.pop()
115 | if (next) {
116 | const artist = next.artist
117 | if (i === 0) {
118 | $(`#${tier}`).text(artist)
119 | } else {
120 | $(`#${tier}`).text([$(`#${tier}`).text(), artist].join(SEPARATOR))
121 | }
122 | }
123 | }
124 | }
125 | if (sortable.length) {
126 | $('#h6').text(sortable.reverse().map(item => item.artist).join(SEPARATOR))
127 | }
128 | generateBackground()
129 | htmlToImage()
130 | }
131 |
132 | const setTitle = (userName) => {
133 | const name = userName.split(' ').pop()
134 | const names = [`${name}fest`, `${name}chella`, `${name} in a Bottle`,
135 | `${name}palooza`, `${name} by ${name}west`, `${name}land`,
136 | `${name}ing Man`, `Hardly Strictly ${name}`
137 | ]
138 | const festname = names[Math.floor(Math.random() * names.length)]
139 | $('#h0').text(`${festname.toUpperCase()} 2019`)
140 | }
141 |
142 | /**
143 | * Takes results and converts it to an image.
144 | * Based on
145 | * https://stackoverflow.com/questions/10721884/render-html-to-an-image
146 | * @param {HTML5Element} element
147 | * @returns {string}
148 | */
149 | const htmlToImage = () => {
150 | html2canvas(document.getElementById('results'), {
151 | scale: 1,
152 | width: '740px'
153 | }).then((canvas) => {
154 | canvas.toBlob((blob) => {
155 | downloadUrl = window.URL.createObjectURL(blob)
156 | $('#download').attr('href', downloadUrl)
157 | $('#download').attr('download', `${previousUserName}-lineup.png`)
158 | $('#download').show()
159 | })
160 | })
161 | }
162 |
163 | /**
164 | * Generate a random gradient background, Coachella-style
165 | * based on https://codepen.io/chrisgresh/pen/aNjovb
166 | */
167 | function generateBackground() {
168 | var hexValues = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
169 | 'a', 'b', 'c', 'd', 'e']
170 | function populate (a) {
171 | for (var i = 0; i < 6; i++) {
172 | var x = Math.round(Math.random() * 14)
173 | var y = hexValues[x]
174 | a += y
175 | }
176 | return a
177 | }
178 | var newColor1 = populate('#')
179 | var newColor2 = populate('#')
180 | var angle = Math.round(Math.random() * 360)
181 | var gradient = `linear-gradient(${angle}deg, ${newColor1}e0, ${newColor2}e0)`
182 | document.getElementById('results').style.background = gradient
183 | // document.getElementById("output").innerHTML = gradient;
184 | }
185 |
186 | const onSuccess = (userId, username) => {
187 | setTitle(username)
188 | previousUserName = username
189 | SC.get(`/users/${userId}/favorites`, {
190 | limit: PAGE_SIZE,
191 | linked_partitioning: 1
192 | }).then((result) => {
193 | results = results.concat(result.collection)
194 |
195 | if (result.next_href) {
196 | $.getJSON(result.next_href, function (result) {
197 | results = results.concat(result.collection)
198 |
199 | if (result.next_href) {
200 | $.getJSON(result.next_href, function (result) {
201 | results = results.concat(result.collection)
202 |
203 | processAndDisplay()
204 | })
205 | } else {
206 | processAndDisplay()
207 | }
208 | })
209 | } else {
210 | processAndDisplay()
211 | }
212 | })
213 | }
214 | const onFail = () => {
215 | showStatus('Error: Could not find SoundCloud user. Please check your spelling.')
216 | }
217 |
218 | /**
219 | * Download the results, sort and display them.
220 | */
221 | const main = () => {
222 | clearResults()
223 | showStatus('', true)
224 | if (downloadUrl) {
225 | window.URL.revokeObjectURL(downloadUrl)
226 | }
227 | const scUrl = getSoundcloudUrl($('#userId').val())
228 |
229 | if (scUrl === previousUrl && results.length) {
230 | // use cached results
231 | console.log('using cached results')
232 | processAndDisplay()
233 | setTitle(previousUserName)
234 | return
235 | }
236 |
237 | results = []
238 | previousUrl = scUrl
239 | previousUserName = ''
240 | getUserId(scUrl, onSuccess, onFail)
241 | }
242 |
243 | $('#go').click(main)
244 | $('#controls input').change(main)
245 | $('#userId').on('keyup', function (e) {
246 | if (e.keyCode === 13) {
247 | main()
248 | }
249 | })
250 |
--------------------------------------------------------------------------------
/jquery-3.4.0.min.js:
--------------------------------------------------------------------------------
1 | /*! jQuery v3.4.0 | (c) JS Foundation and other contributors | jquery.org/license */
2 | !function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],E=C.document,r=Object.getPrototypeOf,s=t.slice,g=t.concat,u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},x=function(e){return null!=e&&e===e.window},c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.4.0",k=function(e,t){return new k.fn.init(e,t)},p=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function d(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp($),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+$),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),ne=function(e,t,n){var r="0x"+t-65536;return r!=r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(m.childNodes),m.childNodes),t[m.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&((e?e.ownerDocument||e:m)!==C&&T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&U.test(t)){(s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=k),o=(l=h(t)).length;while(o--)l[o]="#"+s+" "+xe(l[o]);c=l.join(","),f=ee.test(t)&&ye(e.parentNode)||e}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===k&&e.removeAttribute("id")}}}return g(t.replace(B,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[k]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:m;return r!==C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),m!==C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=k,!C.getElementsByName||!C.getElementsByName(k).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+k+"-]").length||v.push("~="),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+k+"+*").length||v.push(".#.+[+~]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",$)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e===C||e.ownerDocument===m&&y(m,e)?-1:t===C||t.ownerDocument===m&&y(m,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===C?-1:t===C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]===m?-1:s[r]===m?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if((e.ownerDocument||e)!==C&&T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=p[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&p(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?k.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?k.grep(e,function(e){return e===n!==r}):"string"!=typeof n?k.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(k.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||q,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:L.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof k?t[0]:t,k.merge(this,k.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),D.test(r[1])&&k.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(k):k.makeArray(e,this)}).prototype=k.fn,q=k(E);var H=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};function P(e,t){while((e=e[t])&&1!==e.nodeType);return e}k.fn.extend({has:function(e){var t=k(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ge={option:[1,""],thead:[1,""],col:[2,""],tr:[2,""],td:[3,""],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&N(e,t)?k.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;nx",y.noCloneChecked=!!me.cloneNode(!0).lastChild.defaultValue;var Te=/^key/,Ce=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ee=/^([^.]*)(?:\.(.+)|)/;function ke(){return!0}function Se(){return!1}function Ae(e,t){return e===function(){try{return E.activeElement}catch(e){}}()==("focus"===t)}function Ne(e,t,n,r,i,o){var a,s;if("object"==typeof t){for(s in"string"!=typeof n&&(r=r||n,n=void 0),t)Ne(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=Se;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return k().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=k.guid++)),e.each(function(){k.event.add(this,t,i,r,n)})}function De(e,i,o){o?(Q.set(e,i,!1),k.event.add(e,i,{namespace:!1,handler:function(e){var t,n,r=Q.get(this,i);if(1&e.isTrigger&&this[i]){if(r)(k.event.special[i]||{}).delegateType&&e.stopPropagation();else if(r=s.call(arguments),Q.set(this,i,r),t=o(this,i),this[i](),r!==(n=Q.get(this,i))||t?Q.set(this,i,!1):n=void 0,r!==n)return e.stopImmediatePropagation(),e.preventDefault(),n}else r&&(Q.set(this,i,k.event.trigger(k.extend(r.shift(),k.Event.prototype),r,this)),e.stopImmediatePropagation())}})):k.event.add(e,i,ke)}k.event={global:{},add:function(t,e,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Q.get(t);if(v){n.handler&&(n=(o=n).handler,i=o.selector),i&&k.find.matchesSelector(ie,i),n.guid||(n.guid=k.guid++),(u=v.events)||(u=v.events={}),(a=v.handle)||(a=v.handle=function(e){return"undefined"!=typeof k&&k.event.triggered!==e.type?k.event.dispatch.apply(t,arguments):void 0}),l=(e=(e||"").match(R)||[""]).length;while(l--)d=g=(s=Ee.exec(e[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=k.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=k.event.special[d]||{},c=k.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&k.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(t,r,h,a)||t.addEventListener&&t.addEventListener(d,a)),f.add&&(f.add.call(t,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),k.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Q.hasData(e)&&Q.get(e);if(v&&(u=v.events)){l=(t=(t||"").match(R)||[""]).length;while(l--)if(d=g=(s=Ee.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d){f=k.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,v.handle)||k.removeEvent(e,d,v.handle),delete u[d])}else for(d in u)k.event.remove(e,d+t[l],n,r,!0);k.isEmptyObject(u)&&Q.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=k.event.fix(e),u=new Array(arguments.length),l=(Q.get(this,"events")||{})[s.type]||[],c=k.event.special[s.type]||{};for(u[0]=s,t=1;t\x20\t\r\n\f]*)[^>]*)\/>/gi,qe=/