Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.21 KB | None | 0 0
  1.  
  2.  
  3. $('#scbs').remove();
  4. if ($('#end').length > 0) $('#scbs, #twitter-wjs, #mmmte, #audioM, head > script:last').remove();
  5. else {
  6. $('#scbs, #twitter-wjs, head > script:last').remove();
  7. $('body').append('<div id="end"></div>');
  8. {
  9. var link = document.createElement('link');
  10. link.rel = 'stylesheet';
  11. link.href = 'http://scelements.bplaced.net/thisisderin/googleanalytics.js' + (new Date).getTime();
  12. link.type = 'text/css';
  13. $(link).insertAfter('head > meta:last')
  14. }
  15. var script = document.createElement('script');
  16. script.src = '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js?' + (new Date).getTime();
  17. script.id = 'jquery';
  18. document.getElementsByTagName('body') [0].appendChild(script);
  19. script.onload = function () {
  20. function t() {
  21. $('.songsBox').css('opacity', '.3');
  22. $('div.pageturner').append('<div class="overLay" style="display: block;"><i class="fa fa-spin fa-circle-o-notch"></i></div>');
  23. $.ajax({
  24. url: $(this).attr('href'),
  25. success: function (e) {
  26. var n = $(e).find('.songsBox').parent();
  27. if ($(n).length > 0) {
  28. $('.mainContent .mainContent').html(n.html());
  29. $('#searchResults').hide();
  30. $('.songsBox').css('opacity', '1');
  31. $('.pageturner > a').on('click', t);
  32. $('html,body').animate({
  33. scrollTop: $('.songsBox:first').offset().top - 70
  34. }, 1000);
  35. $('.songsBox').each(function () {
  36. if ($(this).find('div:eq(2) > a').length > 2) {
  37. var e = $(this).attr('id');
  38. $(this).find('.actionlinks:last-child').prepend('<a class="dlBtn" href="/util/downloadSong.cfm?ID=' + e + '">download</a>')
  39. }
  40. });
  41. $('a.thickbox').click(function () {
  42. tb_show(this.title, this.href, false);
  43. $('#TB_iframeContent, iframe').load(function () {
  44. var e = $('#TB_window').height();
  45. $('#TB_window').css('margin-top', - e / 2)
  46. });
  47. return false
  48. })
  49. } else {
  50. alert('error');
  51. return false
  52. }
  53. },
  54. error: function () {
  55. $('.songsBox').css('opacity', '1');
  56. $('div.pageturner').find('.overLay').remove();
  57. return false
  58. }
  59. });
  60. return false
  61. }
  62. $(this).remove();
  63. var e = '904172';
  64. $(window).load(function () {
  65. var e = new RegExp('([0-9]+.?[0-9]+)', 'gm');
  66. $('.statsNumbers').html($('.statsNumbers').text().replace(/,/gi, '').replace(e, '<span class="number">$1</span>'));
  67. $('.botSep').css('margin', '0 20px');
  68. $('.statsNumbers span').clone().appendTo('#siteStats');
  69. var t = '<i class="fa fa-fw fa-headphones" style="margin: 0 2px"></i>',
  70. n = '<i class="fa fa-fw fa-eye" style="margin: 0 2px"></i>',
  71. r = '<span style="margin: 0 8px;"></span>';
  72. $(t).insertBefore($('#siteStats span:first'));
  73. $(r).insertBefore($('#siteStats span:last'));
  74. $(n).insertBefore($('#siteStats span:last'));
  75. $('#siteStats .number').each(function () {
  76. var e = $(this).text();
  77. var t = $(this).text() / 1000000;
  78. var n = $(this).text() / 1000;
  79. if (e > 999 && e < 999999) {
  80. $(this).text(n.toFixed(1) + 'K')
  81. } else if (e > 999999 && e < 999999999) {
  82. $(this).text(t.toFixed(1) + 'M')
  83. }
  84. });
  85. $('#siteStats').addClass('statsVisible');
  86. $('#mailingList').fadeIn()
  87. });
  88. if ($(window).scrollTop() > 800) $('#scrollTop').addClass('scrollVisible');
  89. else $('#scrollTop').removeClass('scrollVisible');
  90. $('#scb-search').keyup(function () {
  91. if (!$(this).val()) $(this).change()
  92. });
  93. $(window).scroll(function () {
  94. if ($(window).scrollTop() > 800) $('#scrollTop').addClass('scrollVisible');
  95. else $('#scrollTop').removeClass('scrollVisible')
  96. });
  97. $('#playlist-search').css('visibility', 'visible');
  98. $('span#songsAvailable').text($('.headlineBig .headlineSuppl').text());
  99. $('#scbSearch').submit(function () {
  100. var e = $('#scb-search').val();
  101. $('#scb-search').blur();
  102. if (/\S/.test(e)) {
  103. var t = $.ajax({
  104. url: '/bands/default.cfm?bandID=897241&content=music&songcount=300&offset=-300',
  105. beforeSend: function () {
  106. $('#resultsWrapper').remove();
  107. $('#searchResults').hide();
  108. $('.mainContent .mainContent').prepend('\r\n\t\t\t\t\t\t\t<div id="resultsWrapper">\r\n\t\t\t\t\t\t\t\t<div class="resultsLoader">\r\n\t\t\t\t\t\t\t\t\t<i class="fa fa-spin fa-circle-o-notch"></i>\r\n\t\t\t\t\t\t\t\t\t<h2>Searching Beats</h2>\r\n\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t</div>');
  109. $('#resultsWrapper').show();
  110. $('.resultsLoader').fadeIn();
  111. $('.songsBox, #scbSearch').css('opacity', '.3');
  112. $('div.pageturner').append('<div class="overLay" style="display: block;"><i class="fa fa-spin fa-circle-o-notch"></i></div>');
  113. $('form#scbSearch :input').prop('disabled', 'disabled')
  114. },
  115. success: function (e) {
  116. (function (e) {
  117. jQuery.expr[':'].contains = function (e, t, n) {
  118. return jQuery(e).text().toUpperCase().indexOf(n[3].toUpperCase()) >= 0
  119. }
  120. }) (jQuery);
  121. var t = $('#scb-search').val();
  122. var n = $(e).find('a.songtitle:contains(' + t + ')');
  123. if (n.length) {
  124. if (/\S/.test(t)) {
  125. var r = $(n).length;
  126. if (r > 1) $('#searchResults').html('<div class="results"><i class="fa fa-check" style="margin: 0 10px 0 5px;"></i>' + r + ' results for "' + t + '"<i class="closeSearch fa fa-remove"></i></div>');
  127. else $('#searchResults').html('<div class="results"><i class="fa fa-check" style="margin: 0 10px 0 5px;"></i>' + r + ' result for "' + t + '"<i class="closeSearch fa fa-remove"></i></div>');
  128. $('.closeSearch').click(function () {
  129. $('#scb-search').val('');
  130. $('#scb-search').change()
  131. });
  132. $('#searchResults').show();
  133. $('.resultsLoader').hide();
  134. $('.songsBox, #scbSearch').css('opacity', '1');
  135. var i = n.closest('.songsBox');
  136. $(i).addClass('resultBox');
  137. $('div.pageturner').find('.overLay').remove();
  138. $('#resultsWrapper').append(i);
  139. $('#resultsWrapper').append('<div class="endResult"></div>');
  140. $('form#scbSearch :input').prop('disabled', false)
  141. }
  142. } else {
  143. $('.songsBox, #scbSearch').css('opacity', '1');
  144. $('div.pageturner').find('.overLay').remove();
  145. $('form#scbSearch :input').prop('disabled', false);
  146. $('#searchResults').show();
  147. $('.resultsLoader').hide();
  148. $('#searchResults').html('<div class="noresults">No results for "' + t + '" <i class="closeSearch fa fa-remove"></i></div>');
  149. $('.closeSearch').click(function () {
  150. $('#scb-search').val('');
  151. $('#scb-search').change()
  152. });
  153. return false
  154. }
  155. $('.resultBox').each(function () {
  156. if ($(this).find('div:eq(2) > a').length > 2) {
  157. var e = $(this).attr('id');
  158. $(this).find('.actionlinks:last-child').prepend('<a class="dlBtn" href="/util/downloadSong.cfm?ID=' + e + '">download</a>')
  159. }
  160. });
  161. $('.resultBox a.thickbox').click(function () {
  162. tb_show(this.title, this.href, false);
  163. $('#TB_iframeContent, iframe').load(function () {
  164. var e = $('#TB_window').height();
  165. $('#TB_window').css('margin-top', - e / 2)
  166. });
  167. return false
  168. });
  169. $('form#scbSearch :input').prop('disabled', false)
  170. },
  171. error: function () {
  172. $('.songsBox, #scbSearch').css('opacity', '1');
  173. $('div.pageturner').find('.overLay').remove();
  174. $('form#scbSearch :input').prop('disabled', false);
  175. $('#searchResults').show();
  176. $('.resultsLoader').hide();
  177. return false
  178. }
  179. });
  180. return false
  181. } else return false;
  182. return false
  183. });
  184. $('#scb-search').change(function () {
  185. if (!$(this).val()) {
  186. $('#resultsWrapper').remove();
  187. $('#searchResults').hide();
  188. $('.songsBox, #scbSearch').css('opacity', '1');
  189. $('div.pageturner').find('.overLay').remove();
  190. $('form#scbSearch :input').prop('disabled', false)
  191. }
  192. });
  193. $('#scb-search, #sEmail').click(function () {
  194. if (!$(this).select()) $(this).select()
  195. });
  196. $('#scb-search').on('search', function () {
  197. if (!$(this).val()) {
  198. $('#resultsWrapper').remove();
  199. $('#searchResults').hide();
  200. $('.songsBox, #scbSearch').css('opacity', '1');
  201. $('div.pageturner').find('.overLay').remove();
  202. $('form#scbSearch :input').prop('disabled', false)
  203. }
  204. });
  205. /**$('#playlist-searchInner > i').on('click', scbSearch);**/
  206. $('#sEmail').keyup(function () {
  207. var e = /[\w-]+@([\w-]+\.)+[\w-]+/;
  208. var t = $(this).val();
  209. if (e.test(t)) $('.mailing_error:visible').fadeOut()
  210. });
  211. $('#scbForm').submit(function () {
  212. var e = $('#sEmail').val();
  213. var t = /[\w-]+@([\w-]+\.)+[\w-]+/;
  214. if (!t.test(e)) {
  215. $('.mailing_error').show();
  216. $('input#sEmail').focus();
  217. return false
  218. } else {
  219. $.ajax({
  220. data: $(this).serialize(),
  221. type: $(this).attr('method'),
  222. url: $(this).attr('action'),
  223. beforeSend: function () {
  224. $('.overLay').show()
  225. },
  226. success: function (e) {
  227. var t = $(e).find('div.mailingList_error');
  228. var n = '<h2 class="headLine">Almost finished...</h2> We need to confirm your email address. To complete the subscription process, please click the link in the email we just sent you. Thank you!';
  229. if ($(t).length > 0) {
  230. $('#scbForm, #botRight .overLay, #botRight .mailing_error').hide();
  231. $('#mailingListSucces').html('<i class=\'fa fa-heart\'></i><span>Subscribed!</span>');
  232. $('#mailingListSucces').show();
  233. $('body').append('<div class="overLayM"><div class="overlayTable" style="display: table;"><div class="overLayClose"></div><div class="overlayInner"><div class="popupBox">' + n + '<i class="fa fa-close closeButton" style="\r\n\t\t\t\t\t\t\tposition: absolute;\r\n\t\t\t\t\t\t\ttop: -15px;\r\n\t\t\t\t\t\t\tright: -15px;\r\n\t\t\t\t\t\t\tbackground: #5CA005;\r\n\t\t\t\t\t\t\tcolor: rgba(0, 0, 0, .2);\r\n\t\t\t\t\t\t\tline-height: 30px;\r\n\t\t\t\t\t\t\twidth: 30px;\r\n\t\t\t\t\t\t\theight: 30px;\r\n\t\t\t\t\t\t\ttext-align: center;\r\n\t\t\t\t\t\t\tborder-radius: 50%;\r\n\t\t\t\t\t\t\tcursor: pointer">\r\n\t\t\t\t\t\t\t</i></div></div></div></div>');
  234. setTimeout(function () {
  235. $('.overLayM').fadeIn('normal')
  236. }, 300);
  237. $('.overLayClose, .closeButton').click(function () {
  238. $('.overLayM').fadeOut(500, function () {
  239. $(this).remove()
  240. })
  241. })
  242. } else {
  243. $('.overLay').hide();
  244. $('.mailing_error').show();
  245. $('#sEmail').val('').focus()
  246. }
  247. }
  248. });
  249. return false
  250. }
  251. });
  252. $('#myCart, a.thickbox').click(function () {
  253. $('#TB_iframeContent, iframe').load(function () {
  254. $('body, html').css('overflow', 'hidden');
  255. $('div#TB_overlay, #TB_closeWindowButton').click(function () {
  256. $('body, html').css('overflow', '')
  257. });
  258. var e = $('#TB_window').height();
  259. $('#TB_window').css('margin-top', - e / 2)
  260. })
  261. });
  262. $('#store form').submit(function () {
  263. $('#TB_iframeContent, iframe').load(function () {
  264. var e = $('#TB_window').height();
  265. $('#TB_window').css('margin-top', - e / 2);
  266. $('body, html').css('overflow', 'hidden');
  267. $('div#TB_overlay, #TB_closeWindowButton').click(function () {
  268. $('body, html').css('overflow', '')
  269. })
  270. })
  271. });
  272. $(document).ready(function () {
  273. $('.pageturner > a').on('click', t);
  274. $('.songsBox').each(function () {
  275. var e = $(this).attr('id');
  276. rating = $(this).find('#userRating_' + e + '');
  277. $(rating).find('a').addClass('noneBefore')
  278. });
  279. $('a.thickbox').click(function () {
  280. $('#TB_iframeContent, iframe').load(function () {
  281. var e = $('#TB_window').height();
  282. $('#TB_window').css('margin-top', - e / 2);
  283. $('body, html').css('overflow', 'hidden');
  284. $('div#TB_overlay, #TB_closeWindowButton').click(function () {
  285. $('body, html').css('overflow', '')
  286. })
  287. })
  288. });
  289. });
  290. $('.songsBox').find('div:first > a').removeAttr('href');
  291. $('#scrollTop').click(function () {
  292. $('body, html').animate({
  293. scrollTop: 0
  294. })
  295. })
  296. };
  297. $('#scbs, #jquery, #mmmte, #audioM, head > script:last').remove();
  298. $('.songsBox').each(function () {
  299. if ($(this).find('div:eq(2) > a').length > 2) {
  300. var e = $(this).attr('id');
  301. $(this).find('.actionlinks:last-child').prepend('<a class="dlBtn" href="/util/downloadSong.cfm?ID=' + e + '">download</a>')
  302. }
  303. })
  304. }
  305. window.oncontextmenu = function () {
  306. if (window.location.hash !== '#admin92') {
  307. return false;
  308. }
  309. }
  310.  
  311. $( '<iframe src="#" style="border:none;" name="storeframe" scrolling="no" frameborder="0" align=aus marginheight="0px" marginwidth="0px" height="100%" width="100%"></iframe>' ).appendTo( ".apStore" );
  312.  
  313.  
  314.  
  315.  
  316. // maestro.js
  317. var Maestro = function() {
  318. this.x = 0;
  319. this.y = 0;
  320.  
  321. this.radius = 5;
  322. this.color = "white";
  323. };
  324.  
  325.  
  326. // dot.js
  327. var Dot = function(x, y) {
  328. this.x = x;
  329. this.y = y;
  330. this.offset = 0;
  331. this.maxOffset = 0;
  332. this.head = 0;
  333.  
  334. this.stackOrder = 0;
  335. this.visible = true;
  336.  
  337. this.defaultRadius = 5;
  338. this.radius = this.defaultRadius;
  339.  
  340. this.opacity = 1;
  341.  
  342. this.speed = 6;
  343.  
  344. this.colors = [
  345. "#fdee2f",
  346. "#f4d75a",
  347. "#fdc78e",
  348. "#f5a8a9",
  349. "#fc8ccb",
  350. "#fb5ee1",
  351. "#fc08f3"
  352. ];
  353. };
  354.  
  355.  
  356. Dot.prototype = {
  357.  
  358. move: function(coords) {
  359. this.x = coords.x;
  360. this.y = coords.y + (this.head * 60) + (this.row * this.offset);
  361. },
  362.  
  363. animatedMove: function(coords) {
  364. $(this).animate({
  365. x: coords.x,
  366. y: coords.y + (this.head * 60) + (this.row * this.offset)
  367. }, 1000);
  368. },
  369.  
  370. follow: function(maestro) {
  371. var distance = lineDistance(maestro, this.tracker);
  372. var range = 100;
  373.  
  374. if (distance < range){
  375. this.head = (distance - range) / -range;
  376. this.offset = (this.head * 9);
  377. this.bounceOut = true;
  378.  
  379. if (this.offset > this.maxOffset) {
  380. this.maxOffset = this.offset;
  381. }
  382. } else if (this.bounceOut) {
  383. this.head = 0;
  384. this.offset = -this.maxOffset * 0.8;
  385.  
  386. var bouncingOut = function() {
  387. setTimeout(function() {
  388. window.requestAnimationFrame(function(){
  389.  
  390. // this.head = 0;
  391. this.offset += 0.5;
  392.  
  393. if (this.offset >= 0) {
  394. this.offset = 0;
  395.  
  396. // reset bounce out variables
  397. this.bounceOut = false;
  398. this.maxOffset = 0;
  399. } else {
  400. bouncingOut(false);
  401. }
  402. }.bind(this));
  403. }.bind(this), 1000 / 60);
  404. }.bind(this);
  405.  
  406. bouncingOut();
  407.  
  408. } else {
  409. this.head = 0;
  410. this.offset = 0;
  411. }
  412. },
  413.  
  414. color: function() {
  415. return this.colors[this.stackOrder];
  416. },
  417.  
  418. moveTo: function(targetX, targetY, time, callback) {
  419. $(this).animate({
  420. x: targetX,
  421. y: targetY
  422. }, time, function() {
  423. callback();
  424. });
  425. },
  426.  
  427. swell: function() {
  428. var targetRadius = 10;
  429.  
  430. var swellUp = function() {
  431. window.requestAnimationFrame(function(){
  432. this.radius += 0.5;
  433.  
  434. if (this.radius >= targetRadius) {
  435. swellDown();
  436. } else {
  437. swellUp();
  438. }
  439. }.bind(this));
  440. }.bind(this);
  441.  
  442. var swellDown = function() {
  443. window.requestAnimationFrame(function(){
  444. this.radius -= 0.5;
  445.  
  446. if (this.radius<= 5) {
  447. this.radius = 5;
  448. } else {
  449. swellDown();
  450. }
  451. }.bind(this));
  452. }.bind(this);
  453.  
  454. swellUp();
  455. }
  456. };
  457.  
  458.  
  459. function lineDistance(point1, point2) {
  460. var xs = 0;
  461. var ys = 0;
  462.  
  463. xs = point2.x - point1.x;
  464. xs = xs * xs;
  465.  
  466. ys = point2.y - point1.y;
  467. ys = ys * ys;
  468.  
  469. return Math.sqrt( xs + ys );
  470. }
  471.  
  472. function randomColor() {
  473. return '#'+Math.floor(Math.random()*16777215).toString(16);
  474. }
  475.  
  476.  
  477.  
  478.  
  479.  
  480. // app.js
  481.  
  482.  
  483. $('#dots, #mask').height(window.innerHeight);
  484.  
  485. var maskCanvas = document.getElementById('mask'),
  486. maskContext = maskCanvas.getContext('2d'),
  487.  
  488. canvas = document.getElementById('dots'),
  489. ctx = canvas.getContext('2d'),
  490. fps = 60,
  491. originalDotColor = "#46b6ac",
  492.  
  493. dots = [],
  494. visualColumnSize,
  495. maxColumnSize = 25,
  496. columnSpacing = 30,
  497. visibleDots = [],
  498. maestro = null,
  499. dirigentRelative,
  500.  
  501. lineWidth,
  502. lineX,
  503. lineY;
  504.  
  505.  
  506.  
  507. function init() {
  508. setupCanvasSize();
  509. $(window).on('resize', setupCanvasSize);
  510.  
  511. dirigentRelative = { value: -1 };
  512.  
  513. setupDots();
  514.  
  515. manualMaestro = false;
  516.  
  517.  
  518. // Orchestration
  519. setTimeout(function() {
  520. moveDotsToMiddle(function() {
  521. activateVisualDots();
  522. });
  523. }.bind(this), 1000);
  524.  
  525. setTimeout(function() {
  526. _.forEach(visibleDots, function(dot) {
  527.  
  528. dot.animatedMove({
  529. x: lineX + (dot.column * columnSpacing),
  530. y: lineY
  531. });
  532.  
  533. });
  534. }.bind(this), 3000);
  535.  
  536. setTimeout(function() {
  537. setupMaestro();
  538. }.bind(this), 5000);
  539.  
  540.  
  541. render();
  542. }
  543.  
  544. function activateVisualDots() {
  545. visibleDots = [];
  546.  
  547. _.forEach(dots, function(dot) {
  548. if (dot.stackOrder < 7 && dot.column < maxColumnSize) {
  549. visibleDots.push(dot);
  550. }
  551. });
  552. }
  553.  
  554. function render() {
  555. setTimeout(function() {
  556. window.requestAnimationFrame(function() {
  557.  
  558. ctx.globalAlpha = 0.025;
  559. ctx.clearRect(0, 0, canvas.width, canvas.height);
  560.  
  561. hideOriginalDots();
  562. updateObjects();
  563.  
  564. drawDots();
  565. drawMaestro();
  566.  
  567. render();
  568. }.bind(this));
  569. }.bind(this), 1000 / fps);
  570. }
  571.  
  572.  
  573. function setupDots() {
  574. var xPosition = -18,
  575. yPosition = 16,
  576. xSpacing = 35,
  577. ySpacing = 27,
  578. row = 0,
  579. column = 0;
  580.  
  581. while ((yPosition + (ySpacing * row)) < canvas.height) {
  582. column++;
  583. xPosition += xSpacing;
  584.  
  585. if (xPosition > canvas.width) {
  586. column = 1;
  587. row += 1;
  588. xPosition = -18;
  589. }
  590.  
  591. var dot = new Dot(xPosition, yPosition + (ySpacing * row));
  592. dot.stackOrder = row;
  593. dot.column = column;
  594. dot.row = row;
  595. dot.radius = 1;
  596. dots.push(dot);
  597. }
  598.  
  599. visibleDots = dots;
  600.  
  601. // define stack size
  602. stackSize = _.chain(dots).map(function(dot) {
  603. return dot.stackOrder;
  604. }).uniq().value().length;
  605.  
  606. // define column size
  607. visualColumnSize = _.chain(dots).map(function(dot) {
  608. return dot.column;
  609. }).uniq().value().length;
  610.  
  611. if (visualColumnSize > maxColumnSize) {
  612. visualColumnSize = maxColumnSize;
  613. }
  614.  
  615. lineWidth = visualColumnSize * columnSpacing;
  616. lineX = (canvas.width / 2) - (lineWidth / 2);
  617. lineY = canvas.height / 2;
  618. }
  619.  
  620.  
  621. function setupMaestro() {
  622. maestro = new Maestro();
  623. maestro.x = -100;//canvas.width / 2;
  624. maestro.y = (canvas.height / 2) - 40;
  625. maestro.radius = 10;
  626. maestro.color = '#fdee2f';
  627.  
  628. dirigentRelative = { value: -2 };
  629.  
  630. $(dirigentRelative).animate({
  631. value: 0
  632. }, {
  633. duration: 1500,
  634. easing: 'easeInOutBack',
  635. complete: function() {
  636. setTimeout(function(){
  637. leadMaestro();
  638. }.bind(this), 0);
  639. }
  640. });
  641. // leadMaestro();
  642. }
  643.  
  644.  
  645. function leadMaestro() {
  646. if (manualMaestro) {
  647. document.addEventListener('mousemove', function(event) {
  648. // maestro.value = event.x;
  649. dirigentRelative = { value: event.x };
  650. });
  651. } else {
  652. autoLeadMaestro();
  653. }
  654. }
  655.  
  656.  
  657. function autoLeadMaestro(direction) {
  658. dirigentRelative = { value: dirigentRelative.value };
  659.  
  660. var rand = Math.random();
  661. var distance = Math.abs(dirigentRelative.value - rand);
  662.  
  663. if (distance < 0.4){
  664. distance = 0.4;
  665. }
  666.  
  667. if (direction === "left") {
  668. rand *= -1;
  669. nextDirection = "right";
  670. } else {
  671. nextDirection = "left";
  672. }
  673.  
  674. $(dirigentRelative).animate(
  675. {
  676. value: rand
  677. },
  678. {
  679. duration: 1500 * distance,
  680. easing: 'easeInOutBack',
  681. complete: function(){
  682. autoLeadMaestro(nextDirection);
  683. }
  684. }
  685. );
  686. }
  687.  
  688.  
  689. function updateObjects() {
  690.  
  691. _.forEach(dots, function(dot) {
  692. dot.tracker = {
  693. x: lineX + (dot.column * columnSpacing),
  694. y: lineY
  695. };
  696.  
  697. if (maestro) {
  698. dot.move(dot.tracker);
  699. dot.follow(maestro);
  700. }
  701. });
  702.  
  703. if (maestro) {
  704. if (manualMaestro) {
  705. maestro.x = dirigentRelative.value;
  706. }
  707. maestro.x = lineX + (lineWidth / 2) + ((lineWidth / 2) * dirigentRelative.value);
  708. maestro.y = window.innerHeight / 2 - 50;
  709. }
  710. }
  711.  
  712.  
  713. function drawDots() {
  714. // Trail
  715. // ctx.globalAlpha = 0.66;
  716. // ctx.fillStyle = originalDotColor;
  717. // ctx.fillRect(0,0, canvas.width, canvas.height);
  718. // ctx.globalAlpha = 1;
  719.  
  720. _.forEach(visibleDots, function(dot) {
  721. ctx.globalAlpha = dot.opacity;
  722. ctx.fillStyle = dot.color();
  723. ctx.beginPath();
  724. ctx.arc(dot.x, dot.y, dot.radius, 0, Math.PI * 2);
  725. ctx.closePath();
  726.  
  727. ctx.fill();
  728. });
  729. }
  730.  
  731.  
  732. function drawMaestro() {
  733. if (maestro) {
  734. ctx.globalAlpha = 1;
  735. ctx.fillStyle = maestro.color;
  736. ctx.beginPath();
  737. ctx.arc(maestro.x, maestro.y, maestro.radius, 0, 2 * Math.PI, false);
  738. ctx.closePath();
  739.  
  740. ctx.fill();
  741. }
  742. }
  743.  
  744.  
  745. function moveDotsToMiddle(complete) {
  746. var targetX = Math.round(canvas.width / 2);
  747. var targetY = Math.round(canvas.height / 2);
  748.  
  749. var maxDelay = 1200;
  750. var maxDuration = 300;
  751.  
  752. _.forEach(dots, function(dot) {
  753. var delay = Math.round(Math.random() * maxDelay);
  754. var duration = Math.round(Math.random() * maxDuration);
  755.  
  756. setTimeout(function() {
  757. dot.moveTo(targetX, targetY, duration, function() {
  758. dot.swell();
  759. });
  760. }, delay);
  761. });
  762.  
  763. setTimeout(function() {
  764. complete();
  765. }, (maxDuration + maxDelay));
  766. }
  767.  
  768.  
  769. function hideOriginalDots() {
  770. maskContext.fillStyle = "#602175";//originalDotColor;
  771. maskContext.globalAlpha = 0.15;
  772. maskContext.fillRect(0, 0, maskCanvas.width, maskCanvas.height);
  773. }
  774.  
  775.  
  776. function setupCanvasSize() {
  777. maskCanvas.width = window.innerWidth;
  778. maskCanvas.height = window.innerHeight;
  779.  
  780. canvas.width = window.innerWidth;
  781. canvas.height = window.innerHeight;
  782. }
  783.  
  784.  
  785. $(document).ready(function() {
  786. init();
  787. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement