Advertisement
Guest User

Untitled

a guest
Jul 8th, 2018
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.86 KB | None | 0 0
  1.  
  2. var mailIsValid = false;
  3.  
  4. setTimeout(function () {
  5. $('#box_1').addClass('active');
  6. }, 1000);
  7.  
  8. setTimeout(function () {
  9. $('#habbo').addClass('dance');
  10. }, 1000);
  11.  
  12. setTimeout(function () {
  13. $('#box_1').removeClass('active');
  14. }, 2500);
  15.  
  16. setTimeout(function () {
  17. $('#box_2').addClass('active');
  18. }, 3500);
  19.  
  20. setTimeout(function () {
  21. $('#room_2').addClass('active');
  22. }, 4000);
  23.  
  24. setTimeout(function () {
  25. $('#room_1').removeClass('active');
  26. }, 4500);
  27.  
  28. setTimeout(function () {
  29. $('#room_3').addClass('active');
  30. }, 5000);
  31.  
  32. setTimeout(function () {
  33. $('#box_2').removeClass('active');
  34. }, 7000);
  35.  
  36. setTimeout(function () {
  37. $('#box_3').addClass('active');
  38. }, 8000);
  39.  
  40. setTimeout(function () {
  41. $('#furni').addClass('active');
  42. }, 9000);
  43.  
  44. setTimeout(function () {
  45. $('#box_3').removeClass('active');
  46. }, 14500);
  47.  
  48. setTimeout(function () {
  49. $('#box_4').addClass('active');
  50. }, 15500);
  51.  
  52. setTimeout(function () {
  53. $('#friends').addClass('active');
  54. }, 16000);
  55.  
  56. function changeAvatar(value) {
  57. if (value.length > 2) {
  58. $.ajax({
  59. type: "POST",
  60. url: "/api/login/look",
  61. data: "username=" + value,
  62. success: function (response) {
  63. var jsonObj = jQuery.parseJSON(response);
  64. if (jsonObj.valid == 'false') {
  65. $("#imager").css("background-image", "url(/web-gallery/index/images/ghost.png");
  66. }
  67. else {
  68. $("#imager").css("background-image", "url(https://data.sunnieday.nl/sunnie-imaging/avatars/" + jsonObj.response + "&action=std&direction=3&head_direction=3&img_format=png&gesture=spk&headonly=0&size=b");
  69. }
  70. }
  71. });
  72. }
  73. else {
  74. $("#imager").css("background-image", "url(/web-gallery/index/images/ghost.png");
  75. }
  76. }
  77.  
  78. function isEmail(email) {
  79. var regex = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
  80. return regex.test(email);
  81. }
  82.  
  83. function validateRegisterEmail(value) {
  84. if (isEmail(value)) {
  85. if (value.length > 2) {
  86. $.ajax({
  87. type: "POST",
  88. url: "/api/login/mail",
  89. data: "mail=" + value,
  90. success: function (response) {
  91. var jsonObj = jQuery.parseJSON(response);
  92. if (jsonObj.valid == 'false') {
  93. $('#reg-mail').addClass("error");
  94. $('#mail-error-block').removeClass("hidden_item");
  95. mailIsValid = false;
  96. }
  97. else {
  98. $('#reg-mail').removeClass("error");
  99. $('#reg-mail').addClass("check");
  100. $('#mail-error-block').addClass("hidden_item");
  101. mailIsValid = true;
  102. }
  103. }
  104. });
  105. }
  106. else {
  107. $('#reg-mail').addClass("error");
  108. }
  109. }
  110. else {
  111. $('#reg-mail').removeClass("check");
  112. mailIsValid = false;
  113. }
  114. }
  115.  
  116. function validateUsername(value) {
  117. var filter = /[^-a-zA-Z0-9_.:=#!,?@]/i;
  118. if (value.length >= 3 && value.length <= 25) {
  119. if (!filter.test(value)) {
  120.  
  121. $.ajax({
  122. type: "POST",
  123. url: "/api/login/username",
  124. data: "username=" + value,
  125. success: function (response) {
  126. var jsonObj = jQuery.parseJSON(response);
  127. if (jsonObj.valid == 'false') {
  128. $('#reg-username').addClass("error");
  129. }
  130. else {
  131. $('#reg-username').removeClass("error");
  132. $('#reg-username').addClass("check");
  133. }
  134. }
  135. });
  136. }
  137. else {
  138. $('#reg-username').addClass("error");
  139. }
  140. }
  141. else {
  142. $('#reg-username').addClass("error");
  143. }
  144. }
  145.  
  146. $('#volgende-wachtwoord').click(function () {
  147. var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
  148.  
  149. var email = $("#reg-mail").val();
  150. var dag = $("#geboortedag option:selected").val();
  151. var maand = $("#geboortemaand option:selected").val();
  152. var jaar = $("#geboortejaar option:selected").val();
  153.  
  154. if (email == "") {
  155. $('#page1_alert').addClass('alert-danger').html("Oeps! Je bent je e-mailadres vergeten!").fadeIn('slow').delay(3000).fadeOut('slow');
  156. $('#reg-mail').addClass("error");
  157. }
  158. else if (dag == "" || maand == "" || jaar == "") {
  159. $('#page1_alert').addClass('alert-danger').html("Oeps! Je bent je geboortedatum vergeten!").fadeIn('slow').delay(3000).fadeOut('slow');
  160. }
  161.  
  162. else if (!mailIsValid) {
  163. $('#page1_alert').addClass('alert-danger').html("Oeps! Gebruik alsjeblieft een geldige e-mailadres!").fadeIn('slow').delay(3000).fadeOut('slow');
  164. $('#reg-mail').addClass("error");
  165. }
  166. else {
  167. $("#stap2").show();
  168. $("#stap1").animate({opacity: 0}, {
  169. step: function (now, mx) {
  170. scale = 1 - (1 - now) * 0.2;
  171. left = (now * 50) + "%";
  172. opacity = 1 - now;
  173. $("#stap1").css({
  174. 'position': 'absolute'
  175. });
  176. $("#stap2").css({'left': left, 'opacity': opacity});
  177. },
  178. duration: 800,
  179. complete: function () {
  180. $("#stap1").hide();
  181. },
  182. easing: 'easeInOutBack'
  183. });
  184. }
  185. });
  186.  
  187. $('#volgende-look').click(function () {
  188. var password = $("#reg-password").val();
  189. var passwordRepeat = $("#reg-password-repeat").val();
  190.  
  191. if (password == "" || passwordRepeat == "") {
  192. $('#page2_alert').addClass('alert-danger').html("Vergeet niet alle velden in te vullen!").fadeIn('slow').delay(3000).fadeOut('slow');
  193. }
  194. else if (password.length < 6) {
  195. $('#page2_alert').addClass('alert-danger').html("Je wachtwoord moet meer dan 6 tekens lang zijn en letters en cijfers bevatten.").fadeIn('slow').delay(3000).fadeOut('slow');
  196. }
  197. else if (password != passwordRepeat) {
  198. $('#page2_alert').addClass('alert-danger').html("Je wachtwoorden komen niet overeen!").fadeIn('slow').delay(3000).fadeOut('slow');
  199. }
  200. else {
  201. $("#stap3").show();
  202. $("#stap2").animate({opacity: 0}, {
  203. step: function (now, mx) {
  204. scale = 1 - (1 - now) * 0.2;
  205. left = (now * 50) + "%";
  206. opacity = 1 - now;
  207. $("#stap2").css({
  208. 'position': 'absolute'
  209. });
  210. $("#stap3").css({'left': left, 'opacity': opacity});
  211. },
  212. duration: 800,
  213. complete: function () {
  214. $("#stap2").hide();
  215. },
  216. easing: 'easeInOutBack'
  217. });
  218. }
  219.  
  220. });
  221.  
  222. $('#volgende-tos').click(function () {
  223. $("#stap4").show();
  224. $("#stap3").animate({opacity: 0}, {
  225. step: function (now, mx) {
  226. scale = 1 - (1 - now) * 0.2;
  227. left = (now * 50) + "%";
  228. opacity = 1 - now;
  229. $("#stap3").css({
  230. 'position': 'absolute'
  231. });
  232. $("#stap4").css({'left': left, 'opacity': opacity});
  233. },
  234. duration: 800,
  235. complete: function () {
  236. $("#stap3").hide();
  237. },
  238. easing: 'easeInOutBack'
  239. });
  240. });
  241.  
  242. $('#vorige-stap1').click(function () {
  243. $("#stap1").show();
  244. $("#stap2").animate({opacity: 0}, {
  245. step: function (now, mx) {
  246. scale = 0.8 + (1 - now) * 0.2;
  247. left = ((1 - now) * 50) + "%";
  248. opacity = 1 - now;
  249. $("#stap2").css({'left': left});
  250. $("#stap1").css({'opacity': opacity});
  251. },
  252. duration: 800,
  253. complete: function () {
  254. $("#stap2").hide();
  255. animating = false;
  256. },
  257. easing: 'easeInOutBack'
  258. });
  259. });
  260.  
  261. $('#vorige-stap2').click(function () {
  262. $("#stap2").show();
  263. $("#stap3").animate({opacity: 0}, {
  264. step: function (now, mx) {
  265. scale = 0.8 + (1 - now) * 0.2;
  266. left = ((1 - now) * 50) + "%";
  267. opacity = 1 - now;
  268. $("#stap3").css({'left': left});
  269. $("#stap2").css({'opacity': opacity});
  270. },
  271. duration: 800,
  272. complete: function () {
  273. $("#stap3").hide();
  274. animating = false;
  275. },
  276. easing: 'easeInOutBack'
  277. });
  278. });
  279.  
  280. $('#vorige-stap3').click(function () {
  281. $("#stap3").show();
  282. $("#stap4").animate({opacity: 0}, {
  283. step: function (now, mx) {
  284. scale = 0.8 + (1 - now) * 0.2;
  285. left = ((1 - now) * 50) + "%";
  286. opacity = 1 - now;
  287. $("#stap4").css({'left': left});
  288. $("#stap3").css({'opacity': opacity});
  289. },
  290. duration: 800,
  291. complete: function () {
  292. $("#stap4").hide();
  293. animating = false;
  294. },
  295. easing: 'easeInOutBack'
  296. });
  297. });
  298.  
  299. function returnSunnie(value, field) {
  300. if (value != 4) {
  301. $("#stap" + value).show();
  302. $("#stap4").animate({opacity: 0}, {
  303. step: function (now, mx) {
  304. scale = 0.8 + (1 - now) * 0.2;
  305. left = ((1 - now) * 50) + "%";
  306. opacity = 1 - now;
  307. $("#stap4").css({'left': left});
  308. $("#stap" + value).css({'opacity': opacity});
  309. },
  310. duration: 800,
  311. complete: function () {
  312. $("#stap4").hide();
  313. animating = false;
  314. },
  315. easing: 'easeInOutBack'
  316. });
  317. }
  318. if (field != 'none') {
  319. $('#reg-' + field).addClass("error");
  320. }
  321. }
  322. // Forgot password
  323.  
  324. $('#open_forgot').click(function () {
  325. $('#forgot_password').addClass('active');
  326. });
  327.  
  328.  
  329. $('.close_forgot').click(function (event) {
  330. $('#forgot_password').removeClass('active');
  331. event.preventDefault();
  332. });
  333.  
  334.  
  335. // Register
  336.  
  337. $('.signup').click(function () {
  338. $('#register').addClass('active');
  339. $('#login').removeClass('active');
  340. });
  341.  
  342. $('.signin').click(function () {
  343. $('#register').removeClass('active');
  344. $('#login').addClass('active');
  345. });
  346.  
  347. $('#signup-cancel').click(function () {
  348. $('#register').removeClass('active');
  349. $('#login').addClass('active');
  350. });
  351.  
  352.  
  353. // Select
  354. (function () {
  355. [].slice.call(document.querySelectorAll('select.cs-select')).forEach(function (el) {
  356. new SelectFx(el);
  357. });
  358. })();
  359.  
  360.  
  361. var registerStyle = $(".roundedStyle").children("img").attr("alt");
  362. var selectedlook = 'hr-115-45.hd-180-1.ch-3111-81-1408.lg-275-1408';
  363. var selectedSlot = '1-sunnie-hoofd-m';
  364. $(".roundedStyle").click(function () {
  365. $(".roundedStyle").each(function () {
  366. $(this).removeClass("active")
  367. });
  368. $(this).addClass("active");
  369. registerStyle = $(this).children("img").attr("alt");
  370. selectedlook = $(this).children("img").data("look");
  371. selectedSlot = $(this).children("img").data("slot");
  372.  
  373. $("#sunnielook-voorbeeld").attr("src", "https://www.sunnieday.nl/images/looks/index/" + selectedSlot + "-big.png");
  374.  
  375. });
  376.  
  377. $("#log-mail, #log-password").keypress(function (event) {
  378. if (13 == event.which) {
  379. event.preventDefault();
  380. $("#doLogin").trigger("click");
  381. }
  382. });
  383. $("#forgot-mail").keypress(function (event) {
  384. if (13 == event.which) {
  385. event.preventDefault();
  386. $("#doForgot").trigger("click");
  387. }
  388. });
  389. $("#reg-username").keypress(function (event) {
  390. if (13 == event.which) {
  391. event.preventDefault();
  392. $("#doRegister").trigger("click");
  393. }
  394. });
  395.  
  396. /* Menu Mobile */
  397. $(".burger").click(function () {
  398. $(".menu_mobile_content, .burger").toggleClass("active");
  399. });
  400.  
  401. $("#doLogin").click(function (event) {
  402. var mail = $("#log-mail").val();
  403. var password = $("#log-password").val();
  404. if (0 == mail.length || 0 == password.length) {
  405. $(".alert").addClass("alert-danger").html("<b>Oeps!</b> Vergeet niet alle velden in te vullen!").fadeIn("slow").delay(1E3).fadeOut("slow");
  406. } else {
  407. $.ajax({
  408. type: "POST",
  409. url: "/login/do",
  410. data: {'log-mail': mail, 'log-password': password},
  411. success: function (response) {
  412. var jsonObj = jQuery.parseJSON(response);
  413. if (jsonObj.valid == 'false') {
  414. $('.alert').addClass('alert-danger').html(jsonObj.response).fadeIn('slow').delay(3000).fadeOut('slow');
  415. }
  416. else {
  417. if ($('.alert').hasClass('alert-danger')) {
  418. $('.alert').removeClass('alert-danger');
  419. }
  420. $('.alert').addClass('alert-success').html(jsonObj.response).fadeIn('slow').delay(1000).fadeOut('slow');
  421. window.location.href = '/me';
  422. }
  423. }
  424. });
  425. }
  426. event.preventDefault();
  427.  
  428. });
  429.  
  430. $('#doRegister').click(function () {
  431. var username = $("#reg-username").val();
  432. var mail = $("#reg-mail").val();
  433. var password = $("#reg-password").val();
  434. var bthDay = $("#geboortedag").val();
  435. var bthMonth = $("#geboortemaand").val();
  436. var bthYear = $("#geboortejaar").val();
  437. var security = grecaptcha.getResponse();
  438. var terms = $('#accept-terms').is(':checked');
  439. grecaptcha.reset();
  440.  
  441. $('#page4_alert').addClass('alert-warning').html('We controleren je registratie. Een ogenblik geduld alstublieft!').fadeIn('slow');
  442.  
  443. $.ajax({
  444. type: "POST",
  445. url: "/account/register",
  446. data: {username: username, email: mail, password: password, 'bth-day': bthDay, 'bth-month': bthMonth, 'bth-year': bthYear, 'look': selectedSlot, 'captcha': security, 'source': 'web', rules: terms },
  447. success: function (response) {
  448.  
  449. if ($('.alert').hasClass('alert-warning')) {
  450. $('.alert').removeClass('alert-warning');
  451. }
  452.  
  453. if (!response.data.valid) {
  454. $('#page' + response.data.return + '_alert').addClass('alert-danger').html(response.data.message).delay(5000).fadeOut('slow');
  455. returnSunnie(response.data.return, response.data.field);
  456. }
  457. else {
  458. if ($('.alert').hasClass('alert-danger')) {
  459. $('.alert').removeClass('alert-danger');
  460. }
  461.  
  462. if ($('.alert').hasClass('alert-warning')) {
  463. $('.alert').removeClass('alert-warning');
  464. }
  465.  
  466. $('.alert').addClass('alert-success').html(response.data.message).delay(1000).fadeOut('slow');
  467. window.location.href = '/me';
  468. }
  469. }
  470. });
  471. });
  472.  
  473.  
  474. $(document).ready(function () {
  475. $.ajax({
  476. url: "/api/online",
  477. success: function (a) {
  478. $(".online").html(a.data.online + " spelers online!")
  479. }
  480. });
  481. });
  482.  
  483. $('#doforgot').click(function () {
  484. event.preventDefault();
  485. });
  486.  
  487.  
  488. $("#doForgot").click(function (event) {
  489. var mail = $("#forgot-mail").val();
  490. $("#forget_alert").addClass("alert-danger").html("We controleren de gegevens. Een ogenblik geduld alstublieft!").fadeIn("slow");
  491. if (0 == mail.length) {
  492. $("#forget_alert").addClass("alert-danger").html("<b>Oeps!</b> Vergeet niet alle velden in te vullen!").fadeIn("slow").delay(1E3).fadeOut("slow");
  493. } else {
  494. $.ajax({
  495. type: "POST",
  496. url: "/api/login/resetpassword",
  497. data: {mail: mail},
  498. success: function (response) {
  499. $("#forget_alert").addClass("alert-danger").html("We controleren de gegevens. Een ogenblik geduld alstublieft!").fadeIn("slow");
  500.  
  501. if (!response.data.valid) {
  502. $("#forget_alert").addClass("alert-danger").html(response.data.response).fadeIn("slow").delay(2000).fadeOut("slow");
  503. }
  504. else {
  505.  
  506. if ($("#forget_alert").hasClass("alert-danger")) {
  507. $("#forget_alert").removeClass("alert-danger");
  508. }
  509.  
  510. $("#forget_alert").addClass("alert-success").html(response.data.response).fadeIn("slow");
  511. $("#doForgot").html("Je kunt over 10 seconden weer een mail sturen!").delay(10000).prop("disabled", true);
  512.  
  513. if ($("#doForgot").hasClass("customGreenButton")) {
  514. $("#doForgot").removeClass("customGreenButton");
  515. $("#doForgot").addClass("customRedButton");
  516. }
  517.  
  518. setTimeout(function () {
  519. $("#doForgot").html("Stuur opnieuw een mail!").delay(10000).prop("disabled", false);
  520. if ($("#doForgot").hasClass("customRedButton")) {
  521. $("#doForgot").removeClass("customRedButton");
  522. $("#doForgot").addClass("customGreenButton");
  523. }
  524. }, 10000);
  525.  
  526. }
  527. }
  528. });
  529. }
  530. event.preventDefault();
  531. });
  532.  
  533. function redirectToMePage() {
  534. window.location.href = 'https://sunnieday.nl/me';
  535. }
  536.  
  537. $('.close_facebook').click(function (event) {
  538. $('#oauth_login').removeClass('active');
  539. event.preventDefault();
  540. });
  541.  
  542. $('#loginFacebook').click(function (event) {
  543. $('#oauth_login').addClass('active');
  544. facebookLogin();
  545. event.preventDefault();
  546. });
  547.  
  548. var loginTimer;
  549.  
  550. function facebookLogin() {
  551. var timeleft = 15;
  552. loginTimer = setInterval(function(){
  553.  
  554. $('#facebook_login_status').css('text-align','center');
  555. $('#facebook_login_buttons').hide();
  556. $('#facebook_login_loading').show();
  557.  
  558. --timeleft;
  559.  
  560. if(timeleft > 10){
  561. $('#facebook_login_status').html("Een ogenblik geduld...");
  562. }
  563. else {
  564. $('#facebook_login_status').html("Een ogenblik geduld... Inloggen via Facebook duurt langer dan verwacht. ");
  565. }
  566.  
  567. if(timeleft <= 0){
  568. $('#facebook_login_status').html("Op dit moment is inloggen via Facebook niet beschikbaar. Je kunt nog wel via een e-mailadres een account aanmaken en spelen zonder Facebook! <br/><br/>Neem contact op met de Sunnieday helpdesk voor meer informatie!").css('text-align','left');
  569. $('#facebook_login_buttons').show();
  570. $('#facebook_login_loading').hide();
  571. clearInterval(loginTimer);
  572. }
  573. },1000);
  574.  
  575. FB.login(function (response) {
  576. if (response.authResponse) {
  577. getFacebookData();
  578. } else {
  579. $('#facebook_login_status').html("Op dit moment is inloggen via Facebook niet beschikbaar. Je kunt nog wel via een e-mailadres een account aanmaken en spelen zonder Facebook! <br/><br/>Neem contact op met de Sunnieday helpdesk voor meer informatie!").css('text-align','left');
  580. $('#facebook_login_buttons').show();
  581. $('#facebook_login_loading').hide();
  582. clearInterval(loginTimer);
  583. }
  584. }, {scope: 'email'});
  585. }
  586.  
  587. function getFacebookData(){
  588. FB.api('/me', {locale: 'nl_NL', fields: 'id,name,email'},
  589. function (response) {
  590. $.ajax({
  591. type: "POST",
  592. url: "/api/facebook/callback",
  593. data: {response: response},
  594. success: function (response) {
  595. if(response.data.valid){
  596. clearInterval(loginTimer);
  597. window.location.href = '/me';
  598. }
  599. else {
  600. clearInterval(loginTimer);
  601. $('#facebook_login_status').html(response.data.message).css('text-align','left');
  602. $('#facebook_login_buttons').show();
  603. $('#facebook_login_loading').hide();
  604. }
  605. }
  606. });
  607. });
  608. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement