$(window).on('load', function () { var datakey = $(".chonngay").attr('data-key'); if (datakey != null) { //datakey.split("-") var year = datakey.split("-")[0]; var month = datakey.split("-")[1]; var day = datakey.split("-")[2]; //console.log(year, month, day); $('.ngayduonglich').val(day); $('.thangduonglich').val(month); $('.solarYear').val(year); } }); if (typeof ($.fn.stick_in_parent) == "function") { var width = window.innerWidth; var $leftThre = $('.container_right_calender'); if (width >= 768) { $leftThre.css("height", $leftThre.parent().height() - 67); $leftThre.find(".sticky").stick_in_parent(); } } var now = new Date(); //set ngày dương var selectSolarDay = document.getElementById("ngayduonglich"); var i; for (i = 1; i <= 31; i++) { selectSolarDay.options[selectSolarDay.options.length] = new Option(i, i); } // set tháng dương var selectSolarMonth = document.getElementById("thangduonglich"); var i; for (i = 1; i <= 12; i++) { selectSolarMonth.options[selectSolarMonth.options.length] = new Option(i, i); } // var selectSolarDaymo = document.getElementById("ngayduonglich-mo"); var i; for (i = 1; i <= 31; i++) { selectSolarDaymo.options[selectSolarDaymo.options.length] = new Option(i, i); } // set tháng dương var selectSolarMonthmo = document.getElementById("thangduonglich-mo"); var i; for (i = 1; i <= 12; i++) { selectSolarMonthmo.options[selectSolarMonthmo.options.length] = new Option(i, i); } var solarDay = now.getDate() var solarMonth = now.getMonth() + 1 var solarYear = now.getFullYear(); $("#ngayduonglich").val(solarDay); $("#thangduonglich").val(solarMonth); $("#solarYear").val(solarYear); $("#ngayduonglich-mo").val(solarDay); $("#thangduonglich-mo").val(solarMonth); $("#solarYear-mo").val(solarYear); $('.viewdate').click(function () { if ($(this).hasClass("mobile")) { if ($("body").hasClass("embed")) { var solarDate = $("#solarYear-mo").val() + "-" + selectSolarMonthmo.options[selectSolarMonthmo.selectedIndex].value + "-" + selectSolarDaymo.options[selectSolarDaymo.selectedIndex].value + "?theme=embed"; } else { var solarDate = $("#solarYear-mo").val() + "-" + selectSolarMonthmo.options[selectSolarMonthmo.selectedIndex].value + "-" + selectSolarDaymo.options[selectSolarDaymo.selectedIndex].value; } } else { if ($("body").hasClass("embed")) { var solarDate = $("#solarYear").val() + "-" + selectSolarMonth.options[selectSolarMonth.selectedIndex].value + "-" + selectSolarDay.options[selectSolarDay.selectedIndex].value + "?theme=embed"; } else { var solarDate = $("#solarYear").val() + "-" + selectSolarMonth.options[selectSolarMonth.selectedIndex].value + "-" + selectSolarDay.options[selectSolarDay.selectedIndex].value; } } //var solarDate = solarYear + "-" + solarMonth + "-" + solarDay; //var val = $("#datepicker").val(); console.log("sdsd", val); // location.href = window.location.href.split("?")[0] + "?date=" + solarDate; location.href = location.protocol + "//" + location.hostname + "/lich-am/" + solarDate //location.href = "./Calendar/Date?date=" + solarDate; }); function getRandomInt(max) { return Math.floor(Math.random() * Math.floor(max)); } var index = getRandomInt(10) if (typeof (index) !== "undefined") { $('.page').css({ "background": "url(/themes/default/images/calendar/bg" + index + ".jpg)", "background-position": "center", "background-repeat": "no-repeat", "background-size": "cover", "background-attachment": "fixed"}); }