home.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. $(document).ready(function () {
  2. new WOW().init();
  3. jQuery('#slider').slippry({
  4. control: false,
  5. pager: false,
  6. transition: 'horizontal'
  7. });
  8. });
  9. // Video
  10. // 2. This code loads the IFrame Player API code asynchronously.
  11. var tag = document.createElement('script');
  12. tag.src = "https://www.youtube.com/iframe_api";
  13. var firstScriptTag = document.getElementsByTagName('script')[0];
  14. firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  15. // 3. This function creates an <iframe> (and YouTube player)
  16. // after the API code downloads.
  17. var player;
  18. var playerWidth = 470;
  19. function onYouTubeIframeAPIReady() {
  20. player = new YT.Player('player-video', {
  21. height: '100%',
  22. width: '100%',
  23. videoId: "Ixkd3pLIlY4",
  24. playerVars: {
  25. autoplay: 0,
  26. controls: 0,
  27. showinfo: 0,
  28. playsinline: 1,
  29. rel: 0
  30. },
  31. events: {
  32. // 'onReady': onPlayerReady,
  33. // 'onStateChange': onPlayerStateChange
  34. }
  35. });
  36. }
  37. $(document).on('click', '#home-video .layout-video', function () {
  38. if (isFunction(player.getPlayerState)) {
  39. if (player.getPlayerState() == 1) {
  40. player.pauseVideo();
  41. $("#home-video .layout-video").removeClass('hide-layout');
  42. } else {
  43. player.playVideo();
  44. $("#home-video .layout-video").addClass('hide-layout');
  45. }
  46. }
  47. });
  48. function isFunction(functionToCheck) {
  49. return functionToCheck && {}.toString.call(functionToCheck) === '[object Function]';
  50. }
  51. function checkToRedirect(url, typeCourse) {
  52. $.ajax({
  53. url: "/Home/CheckAccount",
  54. type: "POST",
  55. data: {
  56. typeCourse: typeCourse
  57. },
  58. success: function (data) {
  59. if (data.code == "0") {
  60. // login already
  61. window.location.href = url;
  62. } else {
  63. //show
  64. window.location.href = "/Home/Index";
  65. // $('#login-dialog').modal('show');
  66. }
  67. },
  68. error: function (result) {
  69. }
  70. });
  71. }
  72. function login() {
  73. $('#login-dialog').modal('show');
  74. $('#signup-dialog').modal('hide');
  75. $('#choose-language-dialog').modal('hide');
  76. $('#free-account-dialog').modal('hide');
  77. }
  78. function registerCourse() {
  79. $('#login-dialog').modal('hide');
  80. $('#signup-dialog').modal('hide');
  81. $('#choose-language-dialog').modal('show');
  82. $('#free-account-dialog').modal('hide');
  83. }
  84. function createFree() {
  85. $('#login-dialog').modal('hide');
  86. $('#signup-dialog').modal('hide');
  87. $('#choose-language-dialog').modal('hide');
  88. $('#free-account-dialog').modal('show');
  89. }
  90. function chooseCourse(courseId) {
  91. $('#free-account-dialog').modal('hide');
  92. $('#choose-language-dialog').modal('hide');
  93. $('#login-dialog').modal('hide');
  94. $('#signup-dialog').modal('hide');
  95. $("#packageId").val(courseId);
  96. $.ajax({
  97. url: urlConfig("/Home/CourseSet"),
  98. type: "POST",
  99. data: {
  100. __RequestVerificationToken: $('input[name=__RequestVerificationToken]').val(),
  101. courseId: courseId,
  102. }
  103. }).success(function (data) {
  104. if (courseId == 3) {
  105. // Tieng anh => show register dialog
  106. $('#signup-dialog').modal('show');
  107. } else {
  108. //$('#free-account-dialog').modal('show');
  109. $('#signup-dialog').modal('show');
  110. }
  111. });
  112. }
  113. function registerAction(course) {
  114. // call register api
  115. $.ajax({
  116. url: urlConfig("/Home/RegisterSubWithoutCaptcha"),
  117. type: "POST",
  118. data: {
  119. __RequestVerificationToken: $('input[name=__RequestVerificationToken]').val(),
  120. packageId: course,
  121. }
  122. }).success(function (data) {
  123. if (data.error_code == "100") {
  124. // success
  125. $('#sub-register-dialog').modal('show');
  126. } else {
  127. console.log(data.error_content);
  128. $('#message-dialog').modal('show');
  129. $('#message-content').html(data.error_content);
  130. }
  131. });
  132. }
  133. function ResentOtp() {
  134. $.ajax({
  135. url: urlConfig("/Home/ResentOtp"),
  136. type: "POST",
  137. data: {
  138. __RequestVerificationToken: $('input[name=__RequestVerificationToken]').val(),
  139. }
  140. }).success(function (data) {
  141. if (data.error_code == "100") {
  142. $("#otp-result").html(data.error_content);
  143. } else {
  144. Reload();
  145. }
  146. });
  147. }
  148. function myFunction() {
  149. document.getElementById("myDropdown").classList.toggle("show");
  150. }
  151. // Close the dropdown menu if the user clicks outside of it
  152. window.onclick = function (event) {
  153. if (!event.target.matches('.dropbtn')) {
  154. var dropdowns = document.getElementsByClassName("dropdown-content");
  155. var i;
  156. for (i = 0; i < dropdowns.length; i++) {
  157. var openDropdown = dropdowns[i];
  158. if (openDropdown.classList.contains('show')) {
  159. openDropdown.classList.remove('show');
  160. }
  161. }
  162. }
  163. }