| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- $(".navigator-action").on("click", function () {
- let url = $(this).attr("action");
- console.log("URL: " + url);
- window.location.href = url;
- var elems = document.querySelectorAll(".navigator-action");
- [].forEach.call(elems, function (el) {
- el.classList.remove("active");
- });
- $(this).addClass("active");
- })
- // for avatar
- //$('#user_avatar').change(function (e) {
- // e.preventDefault();
- // console.log("user_avatar");
- // var fileLoad = document.getElementById("user_avatar").files[0];
- // var fileExt = fileLoad.name.match(/(.*)\??/i).shift().replace(/\?.*/, '').split('.').pop();
- // if (fileExt != "png" && fileExt != "jpg" && fileExt != "jpeg" && fileExt != "PNG" && fileExt != "JPG" && fileExt != "JPEG") {
- // toastr.error("Only PNG or JPG type are accepted");
- // } else if (fileLoad.size >= 5 * 1024 * 1024 || fileLoad.size < 10) {
- // toastr.error("Please check your image size");
- // } else {
- // var oFReader = new FileReader();
- // oFReader.readAsDataURL(fileLoad);
- // oFReader.onload = function (oFREvent) {
- // document.getElementById("image-user").src = oFREvent.target.result;
- // };
- // var control = $("#user_avatar");
- // control.replaceWith(control = control.clone(true));
- // }
- //});
- // Get the input field
- var input = document.getElementById("search");
- if (input != null) {
- // Execute a function when the user releases a key on the keyboard
- input.addEventListener("keyup", function (event) {
- // Number 13 is the "Enter" key on the keyboard
- if (event.keyCode === 13) {
- // Cancel the default action, if needed
- event.preventDefault();
- // Trigger the button element with a click
- let keySearch = $("#search").val();
- let subDomain = $("#subDomain").val();
- window.location.href = subDomain + '/Home/Search?key=' + keySearch;
- }
- });
- }
- // When the user scrolls the page, execute myFunction
- window.onscroll = function () { myFunction() };
- // Get the header
- var header = document.getElementById("myHeader");
- var sticky;
- if (header != null) {
- sticky = header.offsetTop;
- }
- // Get the offset position of the navbar
- var topToShow = 200;
- // Add the sticky class to the header when you reach its scroll position. Remove "sticky" when you leave the scroll position
- function myFunction() {
- let checkHomeHide = $("#myHeader").hasClass("home");
- let checkGameHide = $("#myHeader").hasClass("game");
- if (header != null) {
- if (checkHomeHide) {
- if (window.pageYOffset > topToShow) {
- header.classList.add("sticky");
- header.classList.remove("hide");
- } else {
- header.classList.remove("sticky");
- header.classList.add("hide");
- }
- }
- else if (checkGameHide) {
- if (window.pageYOffset > topToShow) {
- header.classList.add("sticky");
- header.classList.remove("hide");
- } else {
- header.classList.remove("sticky");
- header.classList.add("hide");
- }
- }
- else {
- if (window.pageYOffset > sticky) {
- header.classList.add("sticky");
- } else {
- header.classList.remove("sticky");
- }
- }
- }
- }
- // for avatar
- $('#user_avatar').change(function (e) {
- e.preventDefault();
- //console.log("user_avatar");
- var fileLoad = document.getElementById("user_avatar").files[0];
- var fileExt = fileLoad.name.match(/(.*)\??/i).shift().replace(/\?.*/, '').split('.').pop();
- if (fileExt != "png" && fileExt != "jpg" && fileExt != "jpeg") {
- $.ajax({
- type: "POST",
- url: "/Partial/Response",
- data: {
- "message": "Only PNG or JPG type are accepted",
- },
- success: function (data) {
- $('#informModel').html(data);
- $('#myInform').modal({ "backdrop": "static", keyboard: true });
- $('#myInform').modal('show');
- },
- failure: function (data) {
- console.log(data);
- },
- error: function (data) {
- console.log(data);
- }
- });
- } else if (fileLoad.size >= 5 * 1024 * 1024 || fileLoad.size < 10) {
- $.ajax({
- type: "POST",
- url: "/Partial/Response",
- data: {
- "message": "Please check your image size",
- },
- success: function (data) {
- $('#informModel').html(data);
- $('#myInform').modal({ "backdrop": "static", keyboard: true });
- $('#myInform').modal('show');
- },
- failure: function (data) {
- console.log(data);
- },
- error: function (data) {
- console.log(data);
- }
- });
- } else {
- var oFReader = new FileReader();
- oFReader.readAsDataURL(fileLoad);
- oFReader.onload = function (oFREvent) {
- document.getElementById("personal-picture").src = oFREvent.target.result;
- //$("#checkAvatar").val("1");
- //$("#upload_avatar").submit();
- var formData = new FormData();
- formData.append('__RequestVerificationToken', $('input[name=__RequestVerificationToken]').val());
- formData.append('user_avatar', fileLoad);
- $.ajax({
- type: "POST",
- url: "/Account/UploadAvatar",
- headers: {
- 'RequestVerificationToken': $('input[name=__RequestVerificationToken]').val(),
- 'Accept': 'application/json'
- },
- data: formData,
- processData: false,
- contentType: false,
- success: function (data) {
- location.reload();
- },
- failure: function (data) {
- console.log(data);
- },
- error: function (data) {
- console.log(data);
- }
- });
- };
- var control = $("#user_avatar");
- control.replaceWith(control = control.clone(true));
- }
- });
- $(".open-or-close-eye").on("click", function () {
- console.log("open close eye");
- if ($(".open-eye").hasClass("hide")) {
- $(".open-eye").removeClass("hide");
- $(".close-eye").addClass("hide");
- } else {
- $(".open-eye").addClass("hide");
- $(".close-eye").removeClass("hide");
- }
- })
|