পিএইচপি অ্যাজাক্স (PHP Ajax) - পিএইচপি প্রোগ্রামিং (PHP Programming) - Computer Programming

510

AJAX ব্যবহার করে আপনি ইউজারদের জন্য অধিক বন্ধুসুলভ এবং ইন্টারেক্টিভ অনুসন্ধান ওয়েব এপ্লিকেশন তৈরি করতে পারেন।


AJAX ব্যবহার করে সরাসরি অনুসন্ধান

টিউটরিয়ালের এই পর্যায়ে আমরা আপনাকে দেখাবো কিভাবে আপনি আমাদের ওয়েব-সাইটের টিউটোরিয়ালসমূহ সরাসরি সার্চ করে খুঁজে পাবেন।

এক্ষেত্রেও আমরা পূর্বের ন্যায় কোডসমূহকে তিন ভাগে বিভক্ত করবোঃ এইচটিএমএল কোড, জাভাস্ক্রিপ্ট(AJAX) কোড এবং পিএইচপি কোড এবং তথ্য স্টোর বা বিনিময় এর জন্য একটি XML ফাইল ব্যবহার করবো। সুতরাং দেরি না করে চলুন কোডিং করা শুরু করি।

kt_satt_skill_example_id=533

উপরের উদাহরণে ইউজার যখন ইনপুট বক্সে কোন অক্ষর টাইপ করবে, তখন showlink() ফাংশনটি সম্পাদিত হবে এবং ইনপুটকৃত অক্ষর দিয়ে শুরু সকল লিংক টাইটেল এর সাজেশন ড্রপ ডাউন আকারে দেখাবে। onkeyup ইভেন্ট এর মাধ্যমে এই ফাংশনটি সম্পাদিত হয়।

kt_satt_skill_example_id=534

কোডের ব্যাখ্যাঃ

প্রথমেই আমরা ইনপুট ফিল্ডটি ফাঁকা কিনা string.length == 0 এর মাধ্যমে চেক করে নিব। যদি এটি ফাঁকা হয় তাহলে টেক্সট প্লেসহোল্ডার এর কন্টেন্ট মুছে যায় এবং প্রোগ্রামের নিয়ন্ত্রণ showSuggestion() ফাংশন থেকে বের হয়ে যায়।

অপরদিকে ইনপুট ফিল্ডটি যদি ফাঁকা না হয় সেক্ষেত্রে নিম্নের ঘটনা গুলো ঘটবেঃ

  • একটি XMLHttpRequest অবজেক্ট তৈরি করবে।
  • কার্যসম্পাদনের জন্য সার্ভার প্রস্তুত হলে এটি একটি ফাংশন তৈরি করবে।
  • সার্ভারে অবস্থিত "searchResult.php" ফাইলে তথ্যের জন্য একটি অনুরোধ পাঠাবে।
  • লক্ষ্য করুন আমরা "searchResult.php" ফাইলের সাথে একটি প্যারামিটার p যুক্ত করেছি যা সার্ভারে একটি string ভ্যারিয়েবল পাঠায়।
  • string ভ্যারিয়েবলটি ইনপুট বক্সের কন্টেন্ট ধারন করে।

পিএইচপি ফাইল

উপরের জাভাস্ক্রিপ্ট কোড এর মাধ্যমে এই পিএইচপি ফাইল(searchResult.php) এর সাথে যোগাযোগ সৃষ্টি করা হয়।

"searchResult.php" ফাইলের সোর্স কোড ইনপুট বক্সের স্ট্রিং এর সাপেক্ষে XML ফাইলে লিংক টাই্টেল এর জন্য একটি কুয়েরি পাঠায় এবং অনুসন্ধানকৃত স্ট্রিং এর সাথে মিল সম্পন্ন সকল টাইটেল ব্রাউজারে ফেরত পাঠায়ঃ

kt_satt_skill_example_id=535

কোডের ব্যাখ্যা

জাভাস্ক্রিপ্ট(AJAX) থেকে কুয়েরিটি যখন পিএইচপি ফাইলে পাঠানো হয় তখন নিম্নের ঘটনাসমুহ ঘটেঃ

  • AJAX কর্তৃক পাঠানো প্যারামিটার গ্রহন করে।
  • একটি XML ডোম(DOM) অবজেক্ট তৈরি করে
  • সকল এলিমেন্ট এর মধ্য থেকে AJAX কর্তৃক পাঠানো টেক্সট এর তথ্য খুজে বের করে।</li><li>প্রাপ্ত ফলাফল ব্রাউজারে ফেরত পাঠায়।</li><li>$suggestion ভ্যারিয়েবলে সঠিক " url" এবং "title" সেট করা হয়। যদি একের অধিক টাইটেল এর সাথে মিল খুঁজে পাওয়া যায় তাহলে সকল টাইটেলকেই(url সহ) ভ্যারিয়বলে যোগ করা হয়।</li><li>যদি কোনো মিল না পাওয়া যায়, সে ক্ষেত্রে "দুঃখিত কোনো সাজেশন নেই!" ম্যাসেজটি দেখাবে।</li></ul><hr><p style="margin-left:0px;">উপরের কোড গুলোর সমন্বয়ে নিম্নে আমরা একটি সরাসরি অনুসন্ধান এপ্লিকেশন তৈরি করেছি যেখানে ব্যবহারকারী ইনপুট বক্সে টাইপ করা শুরু করলেই তাকে সম্ভাব্য সাজেশন দেখাবে।</p><p style="margin-left:0px;">সাধারন অনুসন্ধানের তুলনায় সরাসরি অনুসন্ধান অনেক সুবিধাজনক।</p><ul><li>আপনার টাইপ এর ভিত্তিতে আপনি ফলাফল দেখতে পাবেন।</li><li>আপনি যত বেশী টাইপ করবেন ফলাফল এর পরিমানও তত সংকির্ণ হতে থাকবে।</li><li>ফলাফল এর পরিমান যদি সংকীর্ণ হয়ে যায়, সেক্ষেত্রে অধিক ফলাফল এর জন্য কিছু ক্যারেক্টার মুছে ফেলুন।</li></ul> </div> <!--end::content--> <!--begin::Content Video--> <!--end::Content Video--> <div id="chapter-13934" class="chapter-section"> </div> <!--begin::User Info--> <div class="d-flex flex-column flex-md-row align-items-start align-items-md-center justify-content-md-between justify-content-start mb-9"> <div> <span class="text-gray-800 text-uppercase mb-1 fs-7"> Content added || updated By </span> <!--begin::Item--> <div class="d-flex align-items-center pe-2"> <!--begin::Avatar--> <a href="https://sattacademy.com/user/u&id=70114/profile" class=""> <div class="symbol symbol-30px symbol-circle me-3 user-statistics" data-id="70114" data-flug="-1"> <img src="https://sattacademy.com/assets/media/avatars/blank.png" class="toolbar-img" alt=""> </div> </a> <!--end::Avatar--> <!--begin::Text--> <div class="fs-7 fw-bold"> <a href="https://sattacademy.com/user/u&id=70114/profile" class="text-gray-700 text-hover-primary"> Abdur Rakib </a> </div> <!--end::Text--> </div> <!--end::Item--> </div> </div> <!--end::User Info--> <!--begin::Question--> <div class=""> <!--end::question--> </div> <!--end::Question--> </div> </div> </div> <!--begin::Related Topics--> <div class="mb-9 mx-5"> <p class="fs-4">Read more</p> <div class="d-flex flex-wrap align-items-center"> <a href="https://sattacademy.com/guide/%E0%A6%85%E0%A7%8D%E0%A6%AF%E0%A6%BE%E0%A6%9C%E0%A6%BE%E0%A6%95%E0%A7%8D%E0%A6%B8-%E0%A6%AA%E0%A6%B0%E0%A6%BF%E0%A6%9A%E0%A6%BF%E0%A6%A4%E0%A6%BF-ajax-introduction" class="btn btn-light btn-active-primary btn-sm rounded-1 me-5 mb-5"> অ্যাজাক্স পরিচিতি (AJAX Introduction) </a> <a href="https://sattacademy.com/guide/%E0%A6%85%E0%A7%8D%E0%A6%AF%E0%A6%BE%E0%A6%9C%E0%A6%BE%E0%A6%95%E0%A7%8D%E0%A6%B8-%E0%A6%AA%E0%A6%BF%E0%A6%8F%E0%A6%87%E0%A6%9A%E0%A6%AA%E0%A6%BF-ajax-php" class="btn btn-light btn-active-primary btn-sm rounded-1 me-5 mb-5"> অ্যাজাক্স পিএইচপি (AJAX PHP) </a> <a href="https://sattacademy.com/guide/%E0%A6%85%E0%A7%8D%E0%A6%AF%E0%A6%BE%E0%A6%9C%E0%A6%BE%E0%A6%95%E0%A7%8D%E0%A6%B8-%E0%A6%A1%E0%A7%87%E0%A6%9F%E0%A6%BE%E0%A6%AC%E0%A7%87%E0%A6%9C-ajax-database" class="btn btn-light btn-active-primary btn-sm rounded-1 me-5 mb-5"> অ্যাজাক্স ডেটাবেজ (AJAX database) </a> <a href="https://sattacademy.com/guide/%E0%A6%85%E0%A7%8D%E0%A6%AF%E0%A6%BE%E0%A6%9C%E0%A6%BE%E0%A6%95%E0%A7%8D%E0%A6%B8-%E0%A6%8F%E0%A6%95%E0%A7%8D%E0%A6%B8%E0%A6%8F%E0%A6%AE%E0%A6%8F%E0%A6%B2-ajax-xml" class="btn btn-light btn-active-primary btn-sm rounded-1 me-5 mb-5"> অ্যাজাক্স এক্সএমএল (AJAX XML) </a> <a href="https://sattacademy.com/guide/%E0%A6%85%E0%A7%8D%E0%A6%AF%E0%A6%BE%E0%A6%9C%E0%A6%BE%E0%A6%95%E0%A7%8D%E0%A6%B8-rss-%E0%A6%B0%E0%A6%BF%E0%A6%B0%E0%A7%8D%E0%A6%A1%E0%A6%BE%E0%A6%B0-ajax-rss-reader" class="btn btn-light btn-active-primary btn-sm rounded-1 mb-5"> অ্যাজাক্স RSS রির্ডার (AJAX RSS reader) </a> </div> </div> <!--end::Related Topics--> <div class="row justify-content-between align-items-center my-5 px-5"> <div class="col-6"> <div class="d-flex align-items-center"> <button class="btn btn-sm btn-primary btn-active-color-primary me-2 prev-menu rounded-0" style="padding: 7px 16px;"> <i class="fas fa-angle-left text-dark"></i> Previous </button> </div> </div> <div class="col-6"> <div class="d-flex align-items-center justify-content-md-end justify-content-end"> <button class="btn btn-sm btn-primary btn-active-color-primary next-menu rounded-0" style="padding: 7px 16px;"> Next <i class="fas fa-angle-right text-dark"></i> </button> </div> </div> </div> </div> </div> <!--end::Col--> </div> <!--end::Row--> </div> <!--end::subject topic--> </div> <!--end::Container--> </div> <!--end:Post --> <div class="modal fade z-index-1500" id="kk_modal_self_test" tabindex="-1" aria-hidden="true"> <!--begin::Modal dialog--> <div class="modal-dialog modal-dialog-centered mw-650px"> <!--begin::Modal content--> <div class="modal-content rounded"> <!--begin::Modal header--> <div class="modal-header pb-0 border-0 justify-content-end"> <!--begin::Close--> <div class="btn btn-sm btn-icon btn-active-color-primary" data-bs-dismiss="modal"> <!--begin::Svg Icon | path: icons/duotune/arrows/arr061.svg--> <span class="svg-icon svg-icon-1"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"> <rect opacity="0.5" x="6" y="17.3137" width="16" height="2" rx="1" transform="rotate(-45 6 17.3137)" fill="black" /> <rect x="7.41422" y="6" width="16" height="2" rx="1" transform="rotate(45 7.41422 6)" fill="black" /> </svg> </span> <!--end::Svg Icon--> </div> <!--end::Close--> </div> <!--begin::Modal header--> <!--begin::Modal body--> <div class="modal-body scroll-y px-10 px-lg-15 pt-0 pb-15"> <!--begin:Form--> <form id="kk_modal_self_test_form" class="form" enctype="multipart/form-data"> <input type="hidden" name="_token" value="B0PHBRUcLPgnarRswzyGUVj9lpzF9AjrcABds5tb" autocomplete="off"> <input type="hidden" name="subject_id" value=""> <!--begin::Heading--> <div class="mb-9 text-center"> <!--begin::Title--> <h2 class="mb-3">Self Test</h2> <!--begin::Col--> <div class="d-flex justify-content-center align-items-center" id="total_question"> </div> <!-- end: col--> <!--end::Title--> </div> <!--end::Heading--> <!---Error Message --> <div class="messages col-md-12 mx-auto fw-bolder text-center mb-3"></div> <!---Error Message --> <div class="text-center mb-9"> <span class="fs-4 fw-bold">To attend a self test please, login first. <a href="https://sattacademy.com/login" class="text-decoration-underline">click here to login</a></span> </div> <!--begin::Actions--> <div class="text-center"> <button type="reset" id="kk_modal_self_test_cancel" class="btn btn-light me-3">Cancel</button> <a href="https://sattacademy.com/login" class="btn btn-primary"> Login </a> </div> <!--end::Actions--> </form> <!--end:Form--> </div> <!--end::Modal body--> </div> <!--end::Modal content--> </div> <!--end::Modal dialog--> </div> <!--begin::Modal - Bookmark modal--> <div class="modal fade" id="kk_modal_new_bookmark" tabindex="-1" aria-hidden="true"> <!--begin::Modal dialog--> <div class="modal-dialog modal-dialog-centered mw-600px"> <!--begin::Modal content--> <div class="modal-content rounded"> <!--begin::Modal header--> <div class="modal-header pb-0 border-0 justify-content-end"> <!--begin::Close--> <div class="btn btn-sm btn-icon btn-active-color-primary" data-bs-dismiss="modal"> <!--begin::Svg Icon | path: icons/duotune/arrows/arr061.svg--> <span class="svg-icon svg-icon-1"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"> <rect opacity="0.5" x="6" y="17.3137" width="16" height="2" rx="1" transform="rotate(-45 6 17.3137)" fill="black" /> <rect x="7.41422" y="6" width="16" height="2" rx="1" transform="rotate(45 7.41422 6)" fill="black" /> </svg> </span> <!--end::Svg Icon--> </div> <!--end::Close--> </div> <!--begin::Modal header--> <!--begin::Modal body--> <div class="modal-body scroll-y px-10 px-lg-15 pt-0 pb-15"> <!--begin:Form--> <form id="kk_modal_new_bookmark_form" class="form" method="POST" enctype="multipart/form-data"> <!-- csrf token --> <input type="hidden" name="_token" value="B0PHBRUcLPgnarRswzyGUVj9lpzF9AjrcABds5tb" autocomplete="off"> <input type="hidden" name="question_id"> <input type="hidden" name="catid"> <input type="hidden" name="type"> <!--begin::Heading--> <div class="mb-13 text-center"> <!--begin::Title--> <h4 class="mb-3">Add New Bookmark</h4> <!--end::Title--> <!--begin::Description--> <div class="text-muted fw-bold fs-7">Fill up the form and submit </div> <!--end::Description--> </div> <!--end::Heading--> <div class="messages text-center fw-bold"></div> <div class="text-center mb-9"> <span class="fs-4 fw-bold">To add a bookmark, please login first. <a href="https://sattacademy.com/login" class="text-decoration-underline">click here to login</a></span> </div> <!--begin::Actions--> <div class="text-center"> <button type="reset" id="kk_modal_bookmark_cancel" class="btn btn-light me-3 ">Cancel</button> <a href="https://sattacademy.com/login" class="btn btn-primary"> Login </a> </div> <!--end::Actions--> </form> <!--end:Form--> </div> <!--end::Modal body--> </div> <!--end::Modal content--> </div> <!--end::Modal dialog--> </div> <!--end::Modal - Bookmark modal--> <!--begin::Modal - Error Report--> <div class="modal fade" id="kk_modal_error_report" tabindex="-1" aria-hidden="true"> <!--begin::Modal dialog--> <div class="modal-dialog modal-dialog-centered mw-650px"> <!--begin::Modal content--> <div class="modal-content rounded"> <!--begin::Modal header--> <div class="modal-header pb-0 border-0 justify-content-end"> <!--begin::Close--> <div class="btn btn-sm btn-icon btn-active-color-primary" data-bs-dismiss="modal"> <!--begin::Svg Icon | path: icons/duotune/arrows/arr061.svg--> <span class="svg-icon svg-icon-1"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"> <rect opacity="0.5" x="6" y="17.3137" width="16" height="2" rx="1" transform="rotate(-45 6 17.3137)" fill="black" /> <rect x="7.41422" y="6" width="16" height="2" rx="1" transform="rotate(45 7.41422 6)" fill="black" /> </svg> </span> <!--end::Svg Icon--> </div> <!--end::Close--> </div> <!--begin::Modal header--> <!--begin::Modal body--> <div class="modal-body scroll-y px-10 px-lg-15 pt-0 pb-15"> <!--begin:Form--> <form id="kk_modal_error_report_form" class="form" enctype="multipart/form-data"> <div class="messages"></div> <!-- csrf token --> <input type="hidden" name="_token" value="B0PHBRUcLPgnarRswzyGUVj9lpzF9AjrcABds5tb" autocomplete="off"> <!--begin::Heading--> <div class="mb-13 text-center"> <!--begin::Title--> <h4 class="mb-3">Error Report</h4> <!--end::Title--> <!--begin::Description--> <div class="text-muted fw-bold fs-7">Fill up the form and submit </div> <!--end::Description--> </div> <!--end::Heading--> <!--begin::Hidden Input --> <input type="hidden" name="id" value=""> <input type="hidden" name="type" value=""> <!--begin::Hidden Input--> <div class="text-center mb-9"> <span class="fs-4 fw-bold">To report an error please, login first. <a href="https://sattacademy.com/login" class="text-decoration-underline">click here to login</a></span> </div> <!--begin::Actions--> <div class="text-center"> <button type="reset" id="kk_modal_error_report_cancel" class="btn btn-light me-3">Close</button> <a href="https://sattacademy.com/login" class="btn btn-primary"> Login </a> </div> <!--end::Actions--> </form> <!--end:Form--> </div> <!--end::Modal body--> </div> <!--end::Modal content--> </div> <!--end::Modal dialog--> </div> <!--end::Modal - Error Report--> <!--begin::Modal - Video--> <div class="modal fade" id="kk_modal_add_video" tabindex="-1" aria-hidden="true"> <!--begin::Modal dialog--> <div class="modal-dialog modal-dialog-centered mw-650px"> <!--begin::Modal content--> <div class="modal-content rounded"> <!--begin::Modal header--> <div class="modal-header pb-0 border-0 justify-content-end"> <!--begin::Close--> <div class="btn btn-sm btn-icon btn-active-color-primary" data-bs-dismiss="modal"> <!--begin::Svg Icon | path: icons/duotune/arrows/arr061.svg--> <span class="svg-icon svg-icon-1"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"> <rect opacity="0.5" x="6" y="17.3137" width="16" height="2" rx="1" transform="rotate(-45 6 17.3137)" fill="black" /> <rect x="7.41422" y="6" width="16" height="2" rx="1" transform="rotate(45 7.41422 6)" fill="black" /> </svg> </span> <!--end::Svg Icon--> </div> <!--end::Close--> </div> <!--begin::Modal header--> <!--begin::Modal body--> <div class="modal-body scroll-y px-10 px-lg-15 pt-0 pb-15"> <!--begin:Form--> <form id="kk_modal_new_video_form" class="form" enctype="multipart/form-data"> <!-- csrf token --> <input type="hidden" name="_token" value="B0PHBRUcLPgnarRswzyGUVj9lpzF9AjrcABds5tb" autocomplete="off"> <!--begin::Hidden Input--> <input type="hidden" name="data_id"> <input type="hidden" name="type"> <!--end::Hidden Input--> <!--begin::Heading--> <div class="mb-13 text-center"> <!--begin::Title--> <h3 class="mb-3">Add Video</h3> <!--end::Title--> <!--begin::Description--> <div class="text-muted fw-bold fs-7">Fill up the form and submit </div> <!--end::Description--> </div> <!--end::Heading--> <!--begin::Error Message--> <div class="messages text-center fw-bold"></div> <!--end::Error Message--> <div class="text-center mb-9"> <span class="fs-4 fw-bold">To add a video, please login first. <a href="https://sattacademy.com/login" class="text-decoration-underline">click here to login</a></span> </div> <!--begin::Actions--> <div class="text-center"> <button type="reset" id="kk_modal_add_video_cancel" class="btn btn-light me-3 ">Cancel</button> <a href="https://sattacademy.com/login" class="btn btn-primary"> Login </a> </div> <!--end::Actions--> </form> <!--end:Form--> </div> <!--end::Modal body--> </div> <!--end::Modal content--> </div> <!--end::Modal dialog--> </div> <!--end::Modal - Video--> <div class="modal fade" id="kk_modal_show_video" tabindex="-1" aria-hidden="true"> <div id="video_data"></div> </div> <!--end::Post--> <div class="container"> </div> <div class="container"> <!--begin::Dynamic promotion content--> <div id="footer-promotion-content"></div> <!--end::Dynamic promotion content--> </div> </div> <!--end::Content--> <!--begin::Footer--> <div class="footer pt-10 pb-0" id="kt_footer"> <!--Begin::Copywrite--> <div class="footer-bg"> <!--begin::Container--> <div class="container"> <!--begin::--> <div class="d-flex align-items-md-center justify-content-center py-3"> <!--begin::copyright--> <a class="text-light fw-bold fs-7" href="https://sattacademy.com">©2026 Satt Academy. All rights reserved.</a> </div> <!--end::--> </div> <!--end::Container--> </div> <!--end::Copywrite--> </div> <!--end::Footer--> <div id="overlay"></div> <div class="card" id="rightLoginCard"> <div class="sidebar-login-form"> <div class="position-relative"> <button type="button" class="btn_login_modal position-absolute model-close-btn" id="closeLoginModal"> X </button> <div class="d-flex justify-content-center align-items-center"> <section id="custom_modal" class="d-md-block"> <div class="custom_modal md_device" style="bottom: 25px;"> <div class="overflow-auto"> <div class="container"> <!-- Authentication card with logo --> <div class="black-logo"> <a class="d-flex justify-content-center mb-4 margin-auto" href="/" > <img alt="SATT ACADEMY" class="text-center justify-content-center w-50 ff" src="https://sattacademy.com/uploads/company/login_card_logo.png"> </a> </div> <div class="white-logo"> <a class="d-flex justify-content-center mb-4 margin-auto" href="/" > <img alt="SATT ACADEMY" class="text-center justify-content-center w-50 ff" src="https://sattacademy.com/uploads/company/1685883735.png"> </a> </div> <div class="card"> <div class="social-login-wrap mt-4 position-relative"> <div class="mt-3 mb-4"> <a href="https://sattacademy.com/auth/google" class="login-btn"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" class="LgbsSe-Bz112c"> <g> <path fill="#EA4335" d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"> </path> <path fill="#4285F4" d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"> </path> <path fill="#FBBC05" d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"> </path> <path fill="#34A853" d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"> </path> <path fill="none" d="M0 0h48v48H0z"></path> </g> </svg> <span>Continue with Google</span> </a> </div> <div class="mt-3 mb-4"> <a href="https://sattacademy.com/auth/facebook" class="login-btn"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 1024 1024"> <defs /> <defs> <path id="a" d="M.06.04H1024v1017.74H.06z" /> </defs> <g fill="none" fill-rule="evenodd"> <mask id="b" fill="#fff"> <use xlink:href="#a" /> </mask> <path fill="#1877F2" d="M1024 512C1024 229.23 794.77 0 512 0S0 229.23 0 512c0 255.554 187.231 467.37 432 505.78V660H302V512h130V399.2C432 270.88 508.438 200 625.39 200 681.407 200 740 210 740 210v126h-64.562C611.835 336 592 375.467 592 415.957V512h142l-22.7 148H592v357.78c244.769-38.41 432-250.226 432-505.78" mask="url(#b)" /> <path fill="#FFF" d="M711.3 660L734 512H592v-96.043c0-40.49 19.835-79.957 83.438-79.957H740V210s-58.593-10-114.61-10C508.438 200 432 270.88 432 399.2V512H302v148h130v357.78c26.067 4.09 52.784 6.22 80 6.22s53.933-2.13 80-6.22V660h119.3" /> </g> </svg> <span>Continue with Facebook</span> </a> </div> </div> <div class="or_divider_wrpa mt-3 mb-4"> <p>or</p> </div> <div class="card-bodyss pb-2"> <!-- Validation errors --> <!-- Status message --> <form method="POST" action="https://sattacademy.com/login"> <input type="hidden" name="_token" value="B0PHBRUcLPgnarRswzyGUVj9lpzF9AjrcABds5tb" autocomplete="off"> <div class="mb-3 text-start"> <label for="email" class="form-label"><b>Email, Mobile or Username:</b></label> <input type="text" class="form-control" class="" id="email" name="email" value="" required> <!-- Error messages for email --> </div> <div class="mb-3 text-start"> <label for="password" class="form-label"><b>Password:</b></label> <div class="position-relative"> <input type="password" class="form-control password" id="password" name="password" class="" required autocomplete="current-password"> <span onclick="showpass()" class="show-hide-password"> <i class="fa-solid fa-eye position-absolute show-pass"></i> <i class="fa-solid fa-eye-slash position-absolute hide-pass d-none"></i> </span> </div> <!-- Error messages for password --> </div> <div> <input type="hidden" name="route_path" value="guide/%E0%A6%85%E0%A7%8D%E0%A6%AF%E0%A6%BE%E0%A6%9C%E0%A6%BE%E0%A6%95%E0%A7%8D%E0%A6%B8-%E0%A6%B2%E0%A6%BE%E0%A6%87%E0%A6%AD-%E0%A6%85%E0%A6%A8%E0%A7%81%E0%A6%B8%E0%A6%A8%E0%A7%8D%E0%A6%A7%E0%A6%BE%E0%A6%A8-ajax-live-search"> </div> <div class="remember-forget d-flex justify-content-between gap-3 align-items-center"> <div class="form-check d-flex"> <input class="form-check-input" type="checkbox" value="" name="remember" id="remember_me"> <label class="form-check-label text-dark fw-bold" style="font-size: 15px;" class="" for="remember_me">   Remember Me </label> </div> <div> <a class="text-dark fw-bold me-3" href="https://sattacademy.com/forgot-password"> Forgot password? </a> </div> </div> <div class="my-2 text-start"> <div class="d-grid"> <button type="submit" class="btn btn-primary mt-5 mb-4">Login</button> <hr style="width: 90%; margin-inline:auto; color: #948686;margin:10px auto;"> <div class="text-center pb-3"> <p>Don't have an account? <a href="https://sattacademy.com/register">Register</a></p> </div> </div> </div> </form> </div> </div> </div> </div> </div> </section> </div> </div> </div> </div> <style> .show-hide-password i { top: 15px; right: 16px; z-index: 100; cursor: pointer; font-size: 15px; } a.login-btn { display: flex; border: 1px solid #afafaf38; width: 100%; padding: 10px; border-radius: 4px; color: #000; font-weight: 600; } a.login-btn svg { height: 18px; margin-right: 8px; min-width: 18px; width: 18px; margin-left: 10px; } a.login-btn span { flex-grow: 1; text-align: center; } .or_divider_wrpa { align-items: center; display: flex; width: 100%; text-align: center; justify-content: center; position: relative; line-height: 1; } .or_divider_wrpa::before { content: ''; height: 1px; background: #e4e6ef; width: 50%; } .or_divider_wrpa::after { content: ''; height: 1px; background: #e4e6ef; width: 50%; } .or_divider_wrpa p { padding-left: 17px; padding-right: 17px; /* line-height: 1; */ margin-bottom: 0; font-weight: 600; font-size: 14px; text-transform: uppercase; } #rightLoginCard { background: #fff; max-height: 100vh; overflow-y: auto; } </style> <!--begin::Dynamic Modal--> <div class="modal fade" tabindex="-1" id="satt_dynamic_modal"> <!--class="mw-600px"--> <div class="modal-dialog modal-dialog-centered mw-600px"> <div class="modal-content" style="background-color: transparent"> <!--begin::Close--> <button type="button" class="promotion-close-btn promotion-modal-close-btn" data-bs-dismiss="modal" aria-label="Close"> <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none"> <rect opacity="0.5" x="6" y="17.3137" width="16" height="2" rx="1" transform="rotate(-45 6 17.3137)" fill="currentColor"></rect> <rect x="7.41422" y="6" width="16" height="2" rx="1" transform="rotate(45 7.41422 6)" fill="currentColor"></rect> </svg> </button> <!--end::Close--> <div class="dynamic-modal-body promotion-body"> </div> </div> </div> </div> <!--end::Dynamic Modal--> <div class="modal fade" id="notification_item_modal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable"> <div class="modal-content"> <div class="modal-header"> <h3 class="modal-title fs-5" id="exampleModalLabel">Notification</h3> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <div href="#" class="dropdown-item notification-message-item border-0"> <!-- loader --> <div class="my-4 text-center" id="notification-details-loader"> <span class="spinner-border text-primary" role="status"></span> </div> <div class="notification-media d-none"> <div class="symbol d-flex gap-3 border-bottom"> <img src="https://sattacademy.com/custom/blank.png" alt="Avatar" class="rounded-circle" id="notification-avatar"> <div class="w-100"> <h6 class="dropdown-item-title mb-1" id="notification-title"></h6> <p class="text-sm small text-muted mb-2"><i class="far fa-clock mr-2"></i> <span id="notification-time"></span> </p> </div> </div> <div class="media-body"> <p class="text-sm my-2" id="notification-body"> </p> <a href="#" class="notification-action btn btn-primary btn-sm rounded-1 d-none">Action</a> </div> </div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> </div> </div> </div> </div> <div class="modal fade" id="notification_item_list_modal"> <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable"> <div class="modal-content"> <div class="modal-header"> <h3 class="modal-title fs-5" id="exampleModalLabel">All Notifications</h3> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> </div> </div> </div> </div> <!-- begin: Dynamic offcanvas --> <div class="offcanvas" tabindex="-1" id="satt_dynamic_offcanvas" aria-labelledby="offcanvasLabel"> <div class="offcanvas-header"> <h5 class="offcanvas-title" id="offcanvasLabel">Promotion</h5> <button type="button" class="btn-close promotion-close-btn" data-bs-dismiss="offcanvas" aria-label="Close"></button> </div> <div class="offcanvas-body promotion-body" id="dynamic_offcanvas_body"> </div> </div> <!-- end: Dynamic offcanvas --> <!--begin::Javascript--> <script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script> <script > console.warn('Livewire: The published Livewire assets are out of date\n See: https://livewire.laravel.com/docs/installation#publishing-livewires-frontend-assets') </script> <script src="https://sattacademy.com/vendor/livewire/livewire.min.js?id=918b9ea9" data-csrf="B0PHBRUcLPgnarRswzyGUVj9lpzF9AjrcABds5tb" data-update-uri="/livewire/update" data-navigate-once="true"></script> <!--Bootstrap Js --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"> </script> <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js"></script> <script src="https://sattacademy.com/custom/js/jquery.meanmenu.min.js"></script> <style> .swal2-container.swal2-center>.swal2-popup { padding: 20px !important; } div:where(.swal2-container) div:where(.swal2-actions) { gap: 12px; } span.alert_satt_title { position: absolute; top: 16px; left: 0; right: 0; font-size: 1.5rem; font-weight: 600; text-transform: uppercase; } /* .swal2-popup .swal2-title { margin-bottom: -20px; } */ .swal2-close { margin-top: -18px !important; } </style> <script> function restrict(data) { var globalPackagePlans = [{"id":17,"package_id":5,"name":"S-BASIC","package_type":"student","monthly_price":150,"yearly_price":1000,"monthly_discount":21,"yearly_discount":601,"discount_type":"fixed","description":null,"status":"active","created_by":1,"updated_by":112262,"created_at":"2024-11-12T03:03:26.000000Z","updated_at":"2025-11-23T05:59:29.000000Z","deleted_at":null},{"id":18,"package_id":5,"name":"S-PLUS","package_type":"student","monthly_price":250,"yearly_price":2500,"monthly_discount":71,"yearly_discount":2001,"discount_type":"fixed","description":null,"status":"active","created_by":1,"updated_by":112262,"created_at":"2024-11-12T03:04:38.000000Z","updated_at":"2025-11-23T06:00:04.000000Z","deleted_at":null},{"id":19,"package_id":5,"name":"S-PRO","package_type":"student","monthly_price":400,"yearly_price":4000,"monthly_discount":171,"yearly_discount":3301,"discount_type":"fixed","description":null,"status":"active","created_by":1,"updated_by":112262,"created_at":"2024-11-12T03:06:34.000000Z","updated_at":"2025-11-23T06:00:48.000000Z","deleted_at":null}]; // show alert if subscriptions need if (data.need_subscribe == true) { hideSpinner(); Swal.fire({ title: '<p class="mb-0"><b class="text-warning">Free limit exceeded!</b></p><p class="mb-0 fs-6">Subscribe for unlimited access!</p>', icon: "warning", showDenyButton: true, showCancelButton: true, confirmButtonText: "View Details", denyButtonText: `Not Now!`, html: ` <div x-data="{ activeTab: 'yearly' }" class="restrictCard"> <span class="alert_satt_title">SATT Academy</span> <!-- Nav tabs --> <ul class="nav nav-tabs justify-content-center" role="tablist"> <li class="nav-item"> <a class="nav-link" :class="{ 'active': activeTab === 'monthly' }" @click.prevent="activeTab = 'monthly'" href="#">Monthly</a> </li> <li class="nav-item"> <a class="nav-link" :class="{ 'active': activeTab === 'yearly' }" @click.prevent="activeTab = 'yearly'" href="#">Yearly</a> </li> </ul> <!-- Tab panes --> <div class="tab-content"> <div id="monthly" x-show="activeTab === 'monthly'" class="container tab-pane active"><br> <div class="table-responsive"> <table class="table" style="border: 1px solid black;"> <thead class="restrict-thead text-dark rounded"> <tr class="text-center" style="border: 1px solid black;"> <th class="ps-2">Package</th> <th>Price</th> <th>Action</th> </tr> </thead> <tbody> ${globalPackagePlans.map(plan => ` <tr style="border: 1px solid black;"> <td>${plan.name}</td> <td> <span class="text-muted text-decoration-line-through fs-7">${plan.monthly_price}</span> <span class="fw-bolder text-success fs-5">${ (plan.discount_type === 'fixed' ? plan.monthly_price - plan.monthly_discount : (plan.monthly_price - (plan.monthly_price/100)*plan.monthly_discount ) )}৳</span> </td> <td> <div class="mt-n6 d-flex gap-3"> <form action="https://sattacademy.com/subscribe" method="post"> <input type="hidden" name="_token" value="B0PHBRUcLPgnarRswzyGUVj9lpzF9AjrcABds5tb" autocomplete="off"> <input type="hidden" name="id" value="${plan.id}"/> <input type="hidden" name="type" value="plan"/> <input type="hidden" name="month_year" value="month"/> <button type="submit" class="btn btn-green text-white btn-sm ">Subscribe</button> </form> <a href="https://sattacademy.com/packages" class="btn btn-details text-white btn-sm d-none d-md-block">View Details</a> </div> </td> </tr> `).join('')} </tbody> </table> </div> </div> <div id="yearly" x-show="activeTab === 'yearly'" class="container tab-pane active"><br> <div class="table-responsive"> <table class="table" style="border: 1px solid black;"> <thead class="restrict-thead bg-secondary text-dark rounded"> <tr class="text-center" style="border: 1px solid black;"> <th class="ps-2">Package</th> <th>Price</th> <th>Action</th> </tr> </thead> <tbody> ${globalPackagePlans.map(plan => ` <tr style="border: 1px solid black;"> <td>${plan.name}</td> <td> <span class="text-muted text-decoration-line-through fs-7">${plan.yearly_price}</span> <span class="fw-bolder text-success fs-5">${ (plan.discount_type === 'fixed' ? plan.yearly_price - plan.yearly_discount : (plan.yearly_price - (plan.yearly_price/100)*plan.yearly_discount ) )}৳</span> </td> <td> <div class="mt-n6 d-flex gap-3"> <form action="https://sattacademy.com/subscribe" method="post"> <input type="hidden" name="_token" value="B0PHBRUcLPgnarRswzyGUVj9lpzF9AjrcABds5tb" autocomplete="off"> <input type="hidden" name="id" value="${plan.id}"/> <input type="hidden" name="type" value="plan"/> <input type="hidden" name="month_year" value="year"/> <button type="submit" class="btn btn-green text-white btn-sm ">Subscribe</button> </form> <a href="https://sattacademy.com/packages" class="btn btn-details text-white btn-sm d-none d-md-block">View Details</a> </div> </td> </tr> `).join('')} </tbody> </table> </div> </div> </div> </div> `, width: '570px', heightAuto: true, customClass: { popup: 'swal-height', confirmButton: 'btn-green', }, showCloseButton: true }).then((result) => { if (result.isConfirmed) { Swal.fire("Redirecting to package plan page...", "", "success"); window.location.href = "/packages"; } else if (result.isDenied) { Swal.fire("Thanks, But if you want this service you need to subscribe", "", "info"); } }); } else if (data.need_login == true) { hideSpinner(); Swal.fire({ title: data.message?.title ?? "Login to continue...", text: data.message?.body ?? "If you need more content, you need to login", icon: "warning", showDenyButton: true, showCancelButton: true, confirmButtonText: "Login Now", denyButtonText: `Not Now!` }).then((result) => { /* Read more about isConfirmed, isDenied below */ if (result.isConfirmed) { Swal.fire("Redirecting to login page...", "", "success"); // if user want to subscribe then redirect to package plan page window.location.href = "/login"; } else if (result.isDenied) { Swal.fire("Thanks, But if you need more content, you need to login", "", "info"); } }); hideSpinner(); } else { hideSpinner(); window.scrollTo({ top: 0, behavior: 'smooth' }); MathJax.Hub.Typeset(); } } // subscribe alert function hideSpinner() { $("#spinner-gif").hide(); $("#spinner-gif_1").hide(); $("#spinner-gif_2").hide(); $("#spinner-gif_3").hide(); $("#spinner-gif_4").hide(); $("#spinner-gif_5").hide(); $('.indicator-label').show(); $('.indicator-progress').hide(); $('#kk_modal_new_service_submit').removeAttr('disabled'); } function activeTab() { // active, inactive tab $(document).on('click', '.subject-list-nav li button', function(e) { e.preventDefault(); $('.subject-list-nav li button').removeClass('active'); $(this).addClass('active'); }); } </script> <script> /**** Livewire Alert Scripts ****/ (()=>{var __webpack_modules__={757:(e,t,r)=>{e.exports=r(666)},666:e=>{var t=function(e){"use strict";var t,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var o=t&&t.prototype instanceof y?t:y,i=Object.create(o.prototype),a=new x(n||[]);return i._invoke=function(e,t,r){var n=f;return function(o,i){if(n===_)throw new Error("Generator is already running");if(n===d){if("throw"===o)throw i;return S()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=L(a,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===f)throw n=d,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=_;var s=u(e,t,r);if("normal"===s.type){if(n=r.done?d:p,s.arg===h)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=d,r.method="throw",r.arg=s.arg)}}}(e,r,a),i}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var f="suspendedStart",p="suspendedYield",_="executing",d="completed",h={};function y(){}function v(){}function b(){}var m={};s(m,i,(function(){return this}));var w=Object.getPrototypeOf,g=w&&w(w(D([])));g&&g!==r&&n.call(g,i)&&(m=g);var O=b.prototype=y.prototype=Object.create(m);function E(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function r(o,i,a,c){var s=u(e[o],e,i);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,c)}),(function(e){r("throw",e,a,c)})):t.resolve(f).then((function(e){l.value=e,a(l)}),(function(e){return r("throw",e,a,c)}))}c(s.arg)}var o;this._invoke=function(e,n){function i(){return new t((function(t,o){r(e,n,t,o)}))}return o=o?o.then(i,i):i()}}function L(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,L(e,r),"throw"===r.method))return h;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var o=u(n,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,h;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,h):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,h)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function D(e){if(e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}return{next:S}}function S(){return{value:t,done:!0}}return v.prototype=b,s(O,"constructor",b),s(b,"constructor",v),v.displayName=s(b,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,s(e,c,"GeneratorFunction")),e.prototype=Object.create(O),e},e.awrap=function(e){return{__await:e}},E(k.prototype),s(k.prototype,a,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},E(O),s(O,c,"Generator"),s(O,i,(function(){return this})),s(O,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=D,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(P),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(s&&l){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),P(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:D(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),h}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](r,r.exports,__webpack_require__),r.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var __webpack_exports__={};(()=>{"use strict";var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(757),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__);function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function asyncGeneratorStep(e,t,r,n,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void r(e)}c.done?t(s):Promise.resolve(s).then(n,o)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function a(e){asyncGeneratorStep(i,n,o,a,c,"next",e)}function c(e){asyncGeneratorStep(i,n,o,a,c,"throw",e)}a(void 0)}))}}function evalCallbacksOptions(options){for(var callbacksKeysAllowed=["allowOutsideClick","allowEscapeKey","allowEnterKey","loaderHtml","inputOptions","inputValidator","preConfirm","preDeny","didClose","didDestroy","didOpen","didRender","willClose","willOpen"],_i=0,_callbacksKeysAllowed=callbacksKeysAllowed;_i<_callbacksKeysAllowed.length;_i++){var callbackKey=_callbacksKeysAllowed[_i];options.hasOwnProperty(callbackKey)&&("string"==typeof options[callbackKey]||options[callbackKey]instanceof String)&&options[callbackKey]&&""!=options[callbackKey].trim()&&(options[callbackKey]=eval(options[callbackKey]))}}function afterAlertInteraction(e){if(e.confirmed)return"self"===e.onConfirmed.component?void Livewire.find(e.onConfirmed.id).dispatchSelf(e.onConfirmed.listener,e.result):void Livewire.dispatchTo(e.onConfirmed.component,e.onConfirmed.listener,e.result);if(e.isDenied)return"self"===e.onDenied.component?void Livewire.find(e.onDenied.id).dispatchSelf(e.onDenied.listener,e.result):void Livewire.dispatchTo(e.onDenied.component,e.onDenied.listener,e.result);if(e.onProgressFinished&&e.dismiss===Swal.DismissReason.timer)return"self"===e.onProgressFinished.component?void Livewire.find(e.onProgressFinished.id).dispatchSelf(e.onProgressFinished.listener,e.result):void Livewire.dispatchTo(e.onProgressFinished.component,e.onProgressFinished.listener,e.result);if(e.onDismissed){if("self"===e.onDismissed.component)return void Livewire.find(e.onDismissed.id).dispatch(e.onDismissed.listener,e.result);Livewire.dispatchTo(e.onDismissed.component,e.onDismissed.listener,e.result)}}window.addEventListener("alert",function(){var e=_asyncToGenerator(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default().mark((function e(t){var r,n,o,i,a,c,s,l;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=t.detail.message,i=null!==(r=t.detail.type)&&void 0!==r?r:null,a=t.detail.data,c=t.detail.events,evalCallbacksOptions(s=t.detail.options),e.next=8,Swal.fire(_objectSpread({title:o,icon:i},s));case 8:afterAlertInteraction(_objectSpread(_objectSpread(_objectSpread({confirmed:(l=e.sent).isConfirmed,denied:l.isDenied,dismiss:l.dismiss,result:_objectSpread(_objectSpread({},l),{},{data:_objectSpread(_objectSpread({},a),{},{inputAttributes:null!==(n=s.inputAttributes)&&void 0!==n?n:null})})},c),l),s));case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),window.flashAlert=function(){var e=_asyncToGenerator(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default().mark((function e(t){var r,n,o,i,a,c,s;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=t.events,a=t.events.data,evalCallbacksOptions(c=t.options),e.next=6,Swal.fire(_objectSpread({title:null!==(r=t.message)&&void 0!==r?r:"",icon:null!==(n=t.type)&&void 0!==n?n:null},c));case 6:afterAlertInteraction(_objectSpread(_objectSpread({confirmed:(s=e.sent).isConfirmed,denied:s.isDenied,dismiss:s.dismiss,result:_objectSpread(_objectSpread({},s),{},{data:_objectSpread(_objectSpread({},a),{},{inputAttributes:null!==(o=c.inputAttributes)&&void 0!==o?o:null})})},i),t.options));case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()})()})(); </script> <script> </script> <script> </script> <!---Global page js----> <script src="https://sattacademy.com/custom/js/globalPage.js"></script> <!---Dependable category ----> <script src="https://sattacademy.com/js/custom.js"></script> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js"></script> <!--Toastr Notification --> <script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script> <script> </script> <!--import Global search script--> <script type="text/javascript"> //Margin remove function function revomeMargin(){ $('.search-question').find('p').css({ 'margin' : '0px' }); } //Global search $(document).ready(function() { var timeout = null; $(document).on('keyup', '.global-search-input', function() { var this_input = $(this); //console.log(id) clearTimeout(timeout); timeout = setTimeout(() => { var val = $(this).val(); if (val == "") { $('.global-search-spinner').addClass('d-none'); $('#global-search-result').html(''); } //If val is not empty. else { //show spinner $('.global-search-spinner').removeClass('d-none'); //AJAX is called. $.ajax({ type: "POST", url: "https://sattacademy.com/global-search", headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}, data: { //Assigning value of "val" into "search_txt" variable. search_txt: val, }, //If result found, this funtion will be called. success: function(data) { //console.log(data) $('.global-search-spinner').addClass('d-none'); $('#global-search-result').html(data.html); }, complete:function(){ revomeMargin(); } }); } }, 1000); }); $(document).on('click', '#go-to-search', function(){ //console.log('here'); var val = $('.global-search-input').val(); var url = "/search?search="+val; window.location.href = url ; }) }) </script> <script> document.addEventListener('livewire:navigated', () => { $('.sa-avatar').click(function(e) { $('#profile-menu').addClass('d-flex'); }); // Search $('.fa-search').click(function(e) { $('#global-menu').addClass('d-flex'); }); $(document).click(function(e) { if (e.target.id != 'profile-menu' && !e.target.classList.contains('sa-avatar')) { $('#profile-menu').removeClass('d-flex'); } // Search if (e.target.closest('#global-menu') == null && !e.target.classList.contains('fa-search')) { $('#global-menu').removeClass('d-flex'); } }); }); // PWA Loader document.addEventListener('DOMContentLoaded', function() { // Page is loaded, it is safe to hide loading animation document.getElementById('pwa-loader').style.display = 'none'; window.addEventListener('beforeunload', function() { if (window.matchMedia('(display-mode: standalone)').matches) { // User has triggered a navigation, show the loading animation document.getElementById('pwa-loader').style.display = 'block'; } }); }); </script> <script> $(document).ready(function() { const activeLink = document.querySelector('.leftmenu a.active'); if (activeLink) { activeLink.scrollIntoView({ top: 100, behavior: 'smooth', // Smooth scrolling effect block: 'start', // Align to the top of the container inline: 'nearest' // Align horizontally if necessary }); } const screenWidth = window.innerWidth; if (screenWidth < 992) { $('#offcanvasContentSidebar').addClass('offcanvas offcanvas-start'); } }); </script> <script> document.querySelectorAll('.pill').forEach(p => { setTimeout(() => p.classList.add('show'), 50); }); function showToast(msg) { const t = document.getElementById('toast'); if (!t) return; // Guard clause t.textContent = msg; t.classList.add('show'); clearTimeout(window._tt); window._tt = setTimeout(() => t.classList.remove('show'), 2200); } function addRipple(btn) { const r = document.createElement('span'); r.className = 'ripple'; btn.appendChild(r); setTimeout(() => r.remove(), 500); } // Safely attach listeners using Optional Chaining or If checks const mcqBtn = document.getElementById('mcqBtn'); if (mcqBtn) { mcqBtn.addEventListener('click', function () { addRipple(this); showToast('0 টি MCQ লোড হচ্ছে...'); }); } const cqBtn = document.getElementById('cqBtn'); if (cqBtn) { cqBtn.addEventListener('click', function () { addRipple(this); showToast('0টি CQ লোড হচ্ছে...'); }); } const pracBtn = document.getElementById('pracBtn'); if (pracBtn) { pracBtn.addEventListener('click', function () { showToast('Practice শুরু হচ্ছে!'); }); } </script> <script> $(document).ready(function() { /// chapter select base parent with children select // var chapter = $('#chapter-self-test'); chapter.select2({ placeholder: "Select chapter" }); // chapter select base parent with children select chapter.on('change', function(e) { var selectedValues = $(this).val(); // Get the selected values as an array setSelected(selectedValues); }); function setSelected(selectedValues = []) { // Enable all options first $('#chapter-self-test option').prop('disabled', false); // Iterate over each selected value selectedValues.forEach(function(value) { var userArrOptions = $("select[name='chapter_id[]'] option[data-parent-id=" + value + "]"); if (userArrOptions.length === 0) return; userArrOptions.each(function() { var optionValue = $(this).val(); // Disable the option with the matching data-parent-id $('#chapter-self-test option[value="' + optionValue + '"]').prop('selected', false); $('#chapter-self-test option[value="' + optionValue + '"]').prop('disabled', true); // Recursively disable children options disableChildren(optionValue); }); }); // Refresh Select2 to reflect changes chapter.trigger('change.select2'); } function disableChildren(parentValue) { var childrenOptions = $("select[name='chapter_id[]'] option[data-parent-id=" + parentValue + "]"); if (childrenOptions.length === 0) return; childrenOptions.each(function() { var childValue = $(this).val(); // Disable the child option $('#chapter-self-test option[value="' + childValue + '"]').prop('selected', false); $('#chapter-self-test option[value="' + childValue + '"]').prop('disabled', true); // Recursively disable children options disableChildren(childValue); }); } }); </script> <script type="text/javascript"> $(document).ready(function() { $('#bookmark_type').select2({ tags: true, dropdownParent: $("#kk_modal_new_bookmark"), maximumSelectionLength: 1 }); }); </script> <script> $("p:contains('kt_satt_page_type')").each(function () { // Extract text content const text = $(this).text(); const thisElement = $(this); // Extract page_type and id using regex const match = text.match(/kt_satt_page_type=(\w+)\s+(\d+)/); if (match) { const pageType = match[1]; const id = match[2]; // console.log(`Page Type: ${pageType}, ID: ${id}`); // Perform AJAX call $.ajax({ url: '/subject=' + id + '/page_type=' + pageType, type: 'GET', success: function (response) { // console.log(response); if (response.success) { thisElement.html(response.html); } else { // console.log(response); } }, error: function (xhr, status, error) { // console.error('Error fetching data for ID:', id, error); // alert('An error occurred while fetching the data.'); } }); } }); $(document).on('click', '.incomplete', function() { // Extract data-id and the current element const id = $(this).data('id'); const thisElement = $(this); const pageType = $(this).data('type'); $('.all_pending_example').remove(); $('.all_incomplete_chapter').remove(); $('.all_unfinished_quiz').remove(); // Find SVG icons within the clicked element const plusIcon = thisElement.find('.plus_btn'); const minusIcon = thisElement.find('.minus_btn'); if (plusIcon.is(':visible')) { plusIcon.addClass('d-none'); minusIcon.removeClass('d-none'); // Perform AJAX call $.ajax({ url: '/subject=' + id + '/page_type=' + pageType, type: 'GET', success: function (response) { if (response.success) { // Append the received HTML after the clicked element's <tr> thisElement.closest('tr').after(response.html); } else { // Handle error if response.success is false console.log('Error: ' + response.message); } }, error: function (xhr, status, error) { console.error('Error fetching data for ID:', id, error); alert('An error occurred while fetching the data.'); } }); }else { plusIcon.removeClass('d-none'); minusIcon.addClass('d-none'); } }); $(document).on('change', '.child-checkbox', function () { const group = $(this).data('group'); // Get the group identifier from the child checkbox const parentCheckbox = $(`.parent-checkbox[data-group="${group}"]`); // Select the parent checkbox for the group const allChildren = $(`.child-checkbox[data-group^="${group}"]`); // Select all child checkboxes in the group const allChecked = allChildren.length === allChildren.filter(':checked').length; // Check if all children are checked // Update the parent checkbox state parentCheckbox.prop('checked', allChecked); // Collect selected IDs and send them via AJAX sendSelectedIds(); }); $(document).on('change', '.parent-checkbox', function () { const group = $(this).data('group'); // Get the group identifier from the parent checkbox const isChecked = $(this).prop('checked'); // Check if the parent checkbox is checked const childCheckboxes = $(`.child-checkbox[data-group^="${group}"]`); // Select all child checkboxes in the group // Update all child checkboxes state based on the parent checkbox childCheckboxes.prop('checked', isChecked); // Collect selected IDs and send them via AJAX sendSelectedIds(); }); // const dataType = ''; // Function to collect selected IDs and send them via AJAX function sendSelectedIds() { const selectedIds = []; // Array to store selected IDs let dataType = ''; // Collect IDs of all checked child checkboxes $('.child-checkbox:checked').each(function () { selectedIds.push($(this).attr('id')); if(dataType == ''){ dataType = $(this).attr('data-type'); } }); // Send the selected IDs via AJAX if (selectedIds.length > 0) { markAsComplete(selectedIds, dataType, 'click', 'Mark as Complete'); } function markAsComplete(completeableId, completeableType, completionType, name) { // console.log('markAsComplete:', completeableId, completeableType, completionType); // Prepare the data to be sent to the server const data = { completeable_id: completeableId, completeable_type: completeableType, type: completionType }; // Send the request $.ajax({ type: "GET", url: "https://sattacademy.com/iscomplete-progress", data: data, dataType: 'json', success: function(data) { if (data.success) { location.reload(); }else{ location.reload(); } } }) } } </script> <script type="text/javascript"> //check mobile device function isMobileDevice() { var check = false; (function(a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i .test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i .test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera); return check; }; //Toolbar btn **Menu Show Hide**// $(document).ready(function() { $(document).on('click', '.toolbar-btn', function() { $(this).toggleClass('show'); $(this).toggleClass('menu-dropdown'); $(this).closest('div').find('.menu').toggleClass('show'); if (isMobileDevice() == 'false' || isMobileDevice() == false) { $(this).closest('div').find('.menu').css({ 'z-index': '105', 'position': 'absolute', 'margin': '0px', 'inset': '70px 0px auto auto', // 'transform' : 'traslate3d(-30px, 65px, 0px)' }); } else { $(this).closest('div').find('.menu').css({ 'z-index': '105', 'position': 'absolute', 'margin': '0px', 'inset': '170px 15px auto auto', // 'transform' : 'traslate3d(-15px, 55px, 0px)' }); } }); $('#kt_post').on('click', (evt) => { //console.log(evt.target.classList); const hasClass = evt.target.classList.contains('toolbar-btn'); if (!hasClass) { let isVisible = $('.toolbar-btn').siblings('div.menu-sub').is(":visible"); if (isVisible == true) { $('.toolbar-btn').removeClass('show').removeClass('menu-dropdown'); $('.toolbar-btn').closest('div').find('.menu').removeClass('show'); } } }); }); /**###### begin::vote||love ##########**/ $(document).on('click', '.vote', function() { var id = $(this).data('id'); var val = $(this).find('span.vote_value').text(); var type = $(this).data('type'); var click_element = $(this); $.ajax({ type: "GET", url: "https://sattacademy.com/question/vote" + '/' + id + '/' + type, dataType: 'json', success: function(data) { if (data.success) { //console.log(data); click_element.find('span.vote_value').text(parseInt(val) + 1); click_element.find('i.fa-heart').addClass('text-danger'); click_element.removeClass('vote custom-text-gray'); click_element.addClass('undo-vote text-danger'); click_element.data('vote_id', data.vote); //toastr.success(data.message); //toolbar btn chnage on toolbar btn click click_element.parent('div.favorite_btn').find('a').text('Remove Favorite'); click_element.parent('div.favorite_btn').find('a').addClass('undo-vote'); click_element.parent('div.favorite_btn').find('a').removeClass('vote'); } else { toastr.error(data.message); } } }) }); /**####### end::vote ##########**/ /**###### begin::undo vote #######**/ $(document).on('click', '.undo-vote', function() { var id = $(this).data('vote_id'); var question_id = $(this).data('id'); var val = $(this).find('span.vote_value').text(); var type = $(this).data('type'); //console.log(id); var thisbtn = $(this); $.ajax({ type: "GET", url: "https://sattacademy.com/question/undo-vote", data: { 'vote_id': id, 'question_id': question_id, 'type': type }, dataType: 'json', success: function(data) { thisbtn.find('span.vote_value').text(parseInt(val) - 1); thisbtn.find('i.fa-heart').removeClass('text-danger'); thisbtn.removeClass('undo-vote text-danger'); thisbtn.addClass('vote custom-text-gray'); //toolbar btn chnage on toolbar btn click thisbtn.parent('div.favorite_btn').find('a').text('Make Favorite'); thisbtn.parent('div.favorite_btn').find('a').addClass('vote'); thisbtn.parent('div.favorite_btn').find('a').removeClass('undo-vote'); let currentRouteName = 'subject.chapter'; if (currentRouteName == 'profile.favourite') thisbtn.closest('div.card.card-bordered').fadeOut(); } }); }) /**##### end::undo vote ########**/ /**#### begin::description like #####**/ $(document).on('click', '.description-like', function() { var id = $(this).data('description_id'); var val = $(this).find('span.des-like').text(); var type = $(this).data('btntype'); var click_element = $(this); $.ajax({ type: "GET", url: "https://sattacademy.com/description/like" + '/' + id, data: { btntype: type }, dataType: 'json', success: function(data) { if (data.success) { click_element.find('span.des-like').text(parseInt(val) + 1); if (type == 'like') { click_element.find('i.fa-thumbs-up').addClass('text-primary'); } else { click_element.find('i.fa-thumbs-down').addClass('text-primary'); } click_element.removeClass('description-like'); click_element.addClass('undo-description-like'); click_element.data('vote_id', data.vote); //toastr.success(data.message); } else { toastr.error(data.message); } } }) }) /**#### end::description like ######**/ /**##### begin::undo-description-like ######**/ $(document).on('click', '.undo-description-like', function() { var id = $(this).data('vote_id'); var description_id = $(this).data('description_id'); var val = $(this).find('span.des-like').text(); var type = $(this).data('btntype'); //console.log(type); var thisbtn = $(this); $.ajax({ type: "GET", url: "https://sattacademy.com/question/undo-description-like", data: { 'vote_id': id, 'description_id': description_id, 'btntype': type }, dataType: 'json', success: function(data) { if (data.success) { thisbtn.removeClass('undo-description-like'); thisbtn.addClass('description-like'); thisbtn.find('span.des-like').text(parseInt(val) - 1); if (type == 'like') { thisbtn.find('i.fa-thumbs-up').removeClass('text-primary'); } else { thisbtn.find('i.fa-thumbs-down').removeClass('text-primary'); } } else { toastr.error(data.message); } } }); }) /**##### end::undo-description-like #####**/ /**begin::Question Edit**/ //edit Question $(document).on('click', '.editQuestion', function() { var id = $(this).data('id'); var question = $(this).data('question'); var type = $(this).data('type'); //console.log(question); Swal.fire({ text: "Are you sure you want to edit this question?", icon: "warning", showCancelButton: !0, buttonsStyling: !1, confirmButtonText: "Confirm", cancelButtonText: "No, cancel", customClass: { confirmButton: "btn fw-bold btn-danger", cancelButton: "btn fw-bold btn-active-light-primary" } }).then((function(o) { if (o.value) { //if agree if (type == 'written') { myEditor3.setData(question); $("input[name='question']").val(question); $("input[name='question_id']").val(id); $("#kk_edit_written_question_modal").modal('show'); // $.ajax({ // type:"GET", // url: "https://sattacademy.com/question/edit-written-question"+'/'+id, // dataType: 'json', // success:function(data){ // $("#edit_question_data").html(data.html); // $("#kk_edit_question_modal").modal('show'); // } // }); } else if (type == 'mcq') { $.ajax({ type: "GET", url: "https://sattacademy.com/question/edit-question" + '/' + id, dataType: 'json', success: function(data) { $("#edit_question_data").html(data.html); $("#kk_edit_question_modal").modal('show'); } }); } else if (type == 'samprotik') { $.ajax({ type: "GET", url: "https://sattacademy.com/samprotik-question/edit" + '/' + id, dataType: 'json', success: function(data) { $("#edit_question_data").html(data.html); $("#kk_edit_question_modal").modal('show'); } }); } } })) }); //edit question cancel button $(document).on('click', '#kk_modal_new_service_cancel', function() { //console.log('here'); $('.indicator-label').show() $('.indicator-progress').hide() $('#kk_modal_new_service_submit').removeAttr('disabled') $("#kk_edit_question_modal").modal('hide'); $("#kk_edit_written_question_modal").modal('hide'); }) //update mcq edited question $(document).on('submit', '#kk_modal_question_update_form', function(e) { e.preventDefault() //console.log('here') $('.with-errors').text(''); $('.indicator-label').hide(); $('.indicator-progress').show(); var formData = new FormData(this); $.ajax({ type: "POST", url: "https://sattacademy.com/question/edit-question/update", data: formData, cache: false, contentType: false, processData: false, success: function(data) { if (data.success == false || data.success == "false") { var arr = Object.keys(data.errors); var arr_val = Object.values(data.errors); for (var i = 0; i < arr.length; i++) { $('.' + arr[i] + '-error').text(arr_val[i][0]) } } else if (data.error || data.error == 'true') { var alertBox = '<div class="alert alert-danger alert-dismissable">' + data .message + '</div>'; $('#kk_modal_question_update_form').find('.messages').html(alertBox).show(); } else { // empty the form $('#kk_modal_question_update_form')[0].reset(); $("#kk_edit_question_modal").modal('hide'); toastr.success(data.message); } $('.indicator-label').show() $('.indicator-progress').hide() $('#kk_modal_new_service_submit').removeAttr('disabled') } }); }) /**end::Question Edit**/ //update written edited question $(document).on('submit', '#kk_modal_written_question_update_form', function(e) { e.preventDefault() //console.log('here') $('.with-errors').text(''); $('.indicator-label').hide(); $('.indicator-progress').show(); var formData = new FormData(this); $.ajax({ type: "POST", url: "https://sattacademy.com/written-question/edited-question/store", data: formData, cache: false, contentType: false, processData: false, success: function(data) { if (data.success == false || data.success == "false") { var arr = Object.keys(data.errors); var arr_val = Object.values(data.errors); for (var i = 0; i < arr.length; i++) { $('.' + arr[i] + '-error').text(arr_val[i][0]) } } else if (data.error || data.error == 'true') { var alertBox = '<div class="alert alert-danger alert-dismissable">' + data .message + '</div>'; $('#kk_modal_written_question_update_form').find('.messages').html(alertBox) .show(); } else { // empty the form $('#kk_modal_written_question_update_form')[0].reset(); $("#kk_edit_written_question_modal").modal('hide'); toastr.success(data.message); } $('.indicator-label').show() $('.indicator-progress').hide() $('#kk_modal_new_service_submit').removeAttr('disabled') } }); }) //update samprotik edited question $(document).on('submit', '#kk_modal_samprotik_question_update_form', function(e) { e.preventDefault() //console.log('here') $('.with-errors').text(''); $('.indicator-label').hide(); $('.indicator-progress').show(); var formData = new FormData(this); $.ajax({ type: "POST", url: "https://sattacademy.com/samprotik-question/edit-question/update", data: formData, cache: false, contentType: false, processData: false, success: function(data) { if (data.success == false || data.success == "false") { var arr = Object.keys(data.errors); var arr_val = Object.values(data.errors); for (var i = 0; i < arr.length; i++) { $('.' + arr[i] + '-error').text(arr_val[i][0]) } } else if (data.error || data.error == 'true') { var alertBox = '<div class="alert alert-danger alert-dismissable">' + data .message + '</div>'; $('#kk_modal_samprotik_question_update_form').find('.messages').html(alertBox) .show(); } else { // empty the form $('#kk_modal_samprotik_question_update_form')[0].reset(); $("#kk_edit_question_modal").modal('hide'); toastr.success(data.message); } $('.indicator-label').show() $('.indicator-progress').hide() $('#kk_modal_new_service_submit').removeAttr('disabled') } }); }) /**end::Question Edit**/ /**#########begin::Description ########**/ //get description// $(document).on('click', '.getDescription', function() { var id = $(this).data('id'); var type = $(this).data('type'); //console.log(type); var thisbtn = $(this); $.ajax({ type: "GET", beforeSend: function() { thisbtn.closest('span').find('.indicator-progress').show(); }, url: "https://sattacademy.com/description/get-des" + '/' + id + '/' + type, dataType: 'json', success: function(data) { thisbtn.parents('div.card-footer').find('div.all-description').html(data.html); thisbtn.removeClass('getDescription'); $('.indicator-progress').hide(); MathJax.Hub.Typeset(); }, complete: function() { //call the function on page load tableWrap(); imageSize(); $('.indicator-progress').hide(); } }); }) //add new description $(document).on('click', '.addDescription', function() { var id = $(this).data('id'); var type = $(this).data('type'); //console.log(id); $('.with-errors').text(''); $('.messages').text(''); myEditor.setData(''); $('#kk_modal_new_question_des_form')[0].reset(); $('input[name="question_id"]').val(id); $('input[name="type"]').val(type); $('#kk_modal_new_question_des').modal('show'); }); //new description save// $('#kk_modal_new_question_des_form').on('submit', function(e) { e.preventDefault() $('.with-errors').text(''); $('.indicator-label').hide(); $('.indicator-progress').show(); var formData = new FormData(this); formData.append('description', myEditor.getData()); $.ajax({ type: "POST", url: "https://sattacademy.com/description/store", data: formData, cache: false, contentType: false, processData: false, success: function(data) { if (data.success == false || data.success == "false") { var arr = Object.keys(data.errors); var arr_val = Object.values(data.errors); for (var i = 0; i < arr.length; i++) { $('.' + arr[i] + '-error').text(arr_val[i][0]) } } else if (data.error || data.error == 'true') { var alertBox = '<div class="alert alert-danger" alert-dismissable">' + data .message + '</div>'; $('#kk_modal_new_question_des_form').find('.messages').html(alertBox).show(); } else { // empty the form myEditor.setData(''); $('#kk_modal_new_question_des_form')[0].reset(); $("#kk_modal_new_question_des").modal('hide'); toastr.success(data.message); } $('.indicator-label').show(); $('.indicator-progress').hide(); $('#kk_modal_new_service_submit').removeAttr('disabled'); } }); }) //add description cancel button// $(document).on('click', '#kk_modal_add_description_cancel', function() { $('.with-errors').text(''); $('.indicator-label').show(); $('.indicator-progress').hide(); $('#kk_modal_new_service_submit').removeAttr('disabled'); $('#kk_modal_new_question_des_form')[0].reset(); $("#kk_modal_new_question_des").modal('hide'); }) /**########begin::edit-description#########**/ $(document).on('click', '.edit-description', function() { var des_id = $(this).data('description_id'); var short_description = $(this).data('short_description'); var description = $(this).data('description'); var question_id = $(this).data('question_id'); var type = $(this).data('type'); // console.log(des_id); Swal.fire({ text: "Are you sure you want to edit this description?", icon: "warning", showCancelButton: !0, buttonsStyling: !1, confirmButtonText: "Confirm", cancelButtonText: "No, cancel", customClass: { confirmButton: "btn fw-bold btn-danger", cancelButton: "btn fw-bold btn-active-light-primary" } }).then((function(o) { if (o.value) { //if agree myEditor4.setData(description); $("textarea[name='short_description']").val(short_description); $("textarea[name='description']").val(description); $("input[name='description_id']").val(des_id); $("input[name='question_id']").val(question_id); $("input[name='type']").val(type); $("#kk_modal_edit_description").modal('show'); // $("#kk_modal_edit_description").modal({ // focus: false // }); // $.ajax({ // type:"GET", // url: "https://sattacademy.com/description/edit-des", // dataType: 'json', // data:{ // 'description_id' : des_id // }, // success:function(data){ // $("#edit_description_data").html(data.html); // $("#kk_modal_edit_description").modal('show'); // } // }); } })) }); //update description// $(document).on('submit', '#kk_modal_edit_description_form', function(e) { e.preventDefault() $('.with-errors').text(''); $('.indicator-label').hide(); $('.indicator-progress').show(); var formData = new FormData(this); //formData.append('description', myEditor.getData()); $.ajax({ type: "POST", url: "https://sattacademy.com/description/update", data: formData, cache: false, contentType: false, processData: false, success: function(data) { if (data.success == false || data.success == "false") { var arr = Object.keys(data.errors); var arr_val = Object.values(data.errors); for (var i = 0; i < arr.length; i++) { $('.' + arr[i] + '-error').text(arr_val[i][0]) } } else if (data.error || data.error == 'true') { var alertBox = '<div class="alert alert-danger" alert-dismissable">' + data .message + '</div>'; $('#kk_modal_edit_description_form').find('.messages').html(alertBox).show(); } else { // empty the form $('#kk_modal_edit_description_form')[0].reset(); $("#kk_modal_edit_description").modal('hide'); toastr.success(data.message); } $('.indicator-label').show(); $('.indicator-progress').hide(); $('#kk_modal_new_service_submit').removeAttr('disabled'); } }); }) //description edit cancel button// $(document).on('click', '#kk_modal_edit_description_cancel', function() { $('.indicator-label').show(); $('.indicator-progress').hide(); $('#kk_modal_new_service_submit').removeAttr('disabled'); $('#kk_modal_edit_description_form')[0].reset(); $("#kk_modal_edit_description").modal('hide'); }) /**######### Show Hide Description #######*/ $(document).on('click', '.show-des', function() { $(this).closest('span').find('.fa-caret-right').css({ "transform": "rotate(90deg)" }); $(this).addClass('hide-des'); $(this).parents('div.card-footer').find('div.all-description').removeClass('d-none'); }) $(document).on('click', '.hide-des', function() { $(this).closest('span').find('.fa-caret-right').css({ "transform": "rotate(360deg)" }); $(this).parents('div.card-footer').find('div.all-description').addClass('d-none'); $(this).removeClass('hide-des'); }) /**########## end::Description #######**/ /**###### begin:: Bookmark ######**/ $(document).ready(function() { var thisbtn; $(document).on('click', '.bookmark', function() { var id = $(this).data('id'); var catid = $(this).data('catid'); var type = $(this).data('type'); //console.log('type'); // console.log(catid); thisbtn = $(this); $('.with-errors').text(''); $('#kk_modal_new_bookmark_form')[0].reset(); //append category_id and question_id into bookmark form $('input[name="question_id"]').val(id); $('input[name="catid"]').val(catid); $('input[name="type"]').val(type); $('#kk_modal_new_bookmark').modal('show'); }); //new bookmark save// $('#kk_modal_new_bookmark_form').on('submit', function(e) { e.preventDefault() $('.with-errors').text(''); $('.indicator-label').hide(); $('.indicator-progress').show(); var formData = new FormData(this); $.ajax({ type: "POST", url: "https://sattacademy.com/question/bookmark", data: formData, cache: false, contentType: false, processData: false, success: function(data) { if (data.success == false || data.success == "false") { var arr = Object.keys(data.errors); var arr_val = Object.values(data.errors); for (var i = 0; i < arr.length; i++) { $('.' + arr[i] + '-error').text(arr_val[i][0]) } } else if (data.error || data.error == 'true') { var alertBox = '<div class="alert alert-danger alert-dismissable">' + data .message + '</div>'; $('#kk_modal_new_bookmark_form').find('.messages').html(alertBox) .show(); } else { // empty the form $('#kk_modal_new_bookmark_form')[0].reset(); $("#kk_modal_new_bookmark").modal('hide'); toastr.success(data.message); //footer btn change on footer btn click thisbtn.addClass('remove-bookmark'); thisbtn.data('bookmark_id', data.bookmark.id); thisbtn.removeClass('bookmark') thisbtn.children().addClass('text-primary'); //tolbar html change on footer btn click thisbtn.parents('div.card-footer').siblings('div.card-header').find( 'div.bookmark-btn').find('a').addClass('remove-bookmark'); thisbtn.parents('div.card-footer').siblings('div.card-header').find( 'div.bookmark-btn').find('a').data('bookmark_id', data .bookmark.id); thisbtn.parents('div.card-footer').siblings('div.card-header').find( 'div.bookmark-btn').find('a').removeClass('bookmark'); thisbtn.parents('div.card-footer').siblings('div.card-header').find( 'div.bookmark-btn').find('a').text('Remove Bookmark'); //toolbar btn chnage on toolbar btn click thisbtn.parent('div.bookmark-btn').find('a').text( 'Remove Bookmark'); thisbtn.parent('div.bookmark-btn').find('a').addClass( 'remove-bookmark'); thisbtn.parent('div.bookmark-btn').find('a').removeClass( 'bookmark'); //footer button change on toolbar btn click thisbtn.parents('div.card-header').siblings('div.card-footer').find( 'div.footer-bookmark').find('a').addClass('remove-bookmark'); thisbtn.parents('div.card-header').siblings('div.card-footer').find( 'div.footer-bookmark').find('a').data('bookmark_id', data .bookmark.id); thisbtn.parents('div.card-header').siblings('div.card-footer').find( 'div.footer-bookmark').find('a').children().addClass( 'text-primary'); } $('.indicator-progress').hide(); $('.indicator-label').show(); $('#bookmark_type').val(null).trigger('change'); } }); }); //cancel button// $('#kk_modal_bookmark_cancel').on('click', function() { console.log('working'); $('.messages').empty(); $('.with-errors').text(''); $('.indicator-label').show(); $('.indicator-progress').hide(); $('#kk_modal_new_bookmark_form')[0].reset(); $('#kk_modal_new_bookmark').modal('hide'); $('#bookmark_type').val(null).trigger('change'); }) }); /**####### end:: Bookmark ###########**/ /**######## begin::remove from bookmark ########**/ $(document).on('click', '.remove-bookmark', function() { var id = $(this).data('bookmark_id'); //console.log('remove'); var thisbtn = $(this); Swal.fire({ text: "Are you sure you want to remove this Question from your bookmarks?", icon: "warning", showCancelButton: !0, buttonsStyling: !1, confirmButtonText: "Yes, remove", cancelButtonText: "No, cancel", customClass: { confirmButton: "btn fw-bold btn-danger", cancelButton: "btn fw-bold btn-active-light-primary" } }).then((function(o) { if (o.value) { //if agree $.ajax({ type: "GET", url: "https://sattacademy.com/question/remove-from-bookmark", dataType: 'json', data: { 'id': id }, success: function(data) { toastr.success(data.message); //footer btn change on footer btn click thisbtn.removeClass('remove-bookmark'); thisbtn.addClass('bookmark'); thisbtn.children().removeClass('text-primary'); //tolbar html change on footer btn click thisbtn.parents('div.card-footer').siblings('div.card-header') .find('div.bookmark-btn').find('a').addClass('bookmark'); thisbtn.parents('div.card-footer').siblings('div.card-header') .find('div.bookmark-btn').find('a').removeClass( 'remove-bookmark'); thisbtn.parents('div.card-footer').siblings('div.card-header') .find('div.bookmark-btn').find('a').text('Add Bookmark'); //toolbar btn chnage on toolbar btn click thisbtn.parent('div.bookmark-btn').find('a').text( 'Add Bookmark'); thisbtn.parent('div.bookmark-btn').find('a').addClass( 'bookmark'); thisbtn.parent('div.bookmark-btn').find('a').removeClass( 'remove-bookmark'); //footer button change on toolbar btn click thisbtn.parents('div.card-header').siblings('div.card-footer') .find('div.footer-bookmark').find('a').addClass('bookmark'); thisbtn.parents('div.card-header').siblings('div.card-footer') .find('div.footer-bookmark').find('a').removeClass( 'remove-bookmark'); thisbtn.parents('div.card-header').siblings('div.card-footer') .find('div.footer-bookmark').find('a').children() .removeClass('text-primary'); let currentRouteName = 'subject.chapter' if(currentRouteName == 'profile.bookmark') thisbtn.closest('div.card.card-bordered').fadeOut(); } }); } })) }) /**####### end::remove from bookmark ##########**/ /**####### begin::Video section ######**/ $(document).on('click', '.add-video', function() { $('#kk_modal_show_video').modal('hide'); var id = $(this).data('id'); // console.log(id); var type = $(this).data('type'); $('input[name="data_id"]').val(id); $('input[name="type"]').val(type); $('#kk_modal_add_video').modal('show'); }); $(document).on('click', '#kk_modal_add_video_cancel', function() { $('.messages').empty(); $('.with-errors').text(''); $('.indicator-label').show(); $('.indicator-progress').hide(); $('#kk_modal_add_video').modal('hide'); }) //add video// $(document).on('submit', '#kk_modal_new_video_form', function(e) { e.preventDefault(); $('.messages').empty(); $('.with-errors').text(''); $('.indicator-label').hide(); $('.indicator-progress').show(); var formData = new FormData(this); $.ajax({ type: "POST", url: "https://sattacademy.com/question/video/store", data: formData, cache: false, contentType: false, processData: false, success: function(data) { if (data.success == false || data.success == "false") { var arr = Object.keys(data.errors); var arr_val = Object.values(data.errors); for (var i = 0; i < arr.length; i++) { $('.' + arr[i] + '-error').text(arr_val[i][0]) } } else if (data.error || data.error == 'true') { var alertBox = '<div class="alert alert-danger" alert-dismissable">' + data .message + '</div>'; $('#kk_modal_new_video_form').find('.messages').html(alertBox).show(); } else { // empty the form $('#kk_modal_new_video_form')[0].reset(); $("#kk_modal_add_video").modal('hide'); toastr.success(data.message); } $('.indicator-label').show(); $('.indicator-progress').hide(); $('#kk_modal_new_service_submit').removeAttr('disabled'); } }); }) //show video// $(document).on('click', '.show-video', function() { var id = $(this).data('id'); // console.log(id); var type = $(this).data('type'); $.ajax({ type: "GET", url: "https://sattacademy.com/question/video/show" + '/' + id + '/' + type, dataType: 'json', beforeSend: function() { $('#kk_modal_add_video').modal('hide'); }, success: function(data) { $("#video_data").html(data.html); $("#kk_modal_show_video").modal('show'); }, complete: function() { var w = window.innerWidth; var h = window.innerHeight; // console.log(w); // console.log(h); if (w <= 390) { $('iframe').css({ 'width': '100%', 'height': 'auto' }) } else if (w > 390 && w <= 576) { $('iframe').css({ 'width': '100%', 'height': '200px' }) } else if (w > 576 && w <= 768) { $('iframe').css({ 'width': '100%', 'height': '250px' }) } else { $('iframe').css({ 'width': '100%', 'height': '315px' }) } } }); }); $(document).on('click', '#kk_modal_show_video_cancel', function() { $('#kk_modal_show_video').modal('hide'); }) /**###### end::Video section ########**/ /**####### begin::add tag ###########**/ //add new// $(document).on('click', '.tag', function() { var id = $(this).data('id'); var subject_id = $(this).data('subject_id'); var type = $(this).data('type'); // console.log(id); // console.log(subject_id); //clear $('input[name="question_id"]').val(''); $('input[name="subject_id"]').val(''); $('input[name="type"]').val(''); $('input[name="tag"]').val(''); $('div.result').html(''); $('div.tag-div_2').html(''); //append subject_id and question_id into tag modal// $('input[name="question_id"]').val(id); $('input[name="subject_id"]').val(subject_id); $('input[name="type"]').val(type); $('#kk_modal_add_tag').modal('show'); }); //search tag// $(document).ready(function() { var timeout = null; $(document).on('keyup', '.search_tag', function() { var question_id = $('input[name="question_id"]').val(); var subject_id = $('input[name="subject_id"]').val(); var type = $('input[name="type"]').val(); var this_input = $(this); //console.log(id) clearTimeout(timeout); timeout = setTimeout(() => { var val = $(this).val(); if (val == "") { $('.result').html(''); } //If val is not empty. else { //AJAX is called. $.ajax({ type: "POST", url: "https://sattacademy.com/question/tag/search", headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, data: { //Assigning value of "val" into "search" variable. search: val, question_id: question_id, subject_id: subject_id, type: type }, //If result found, this funtion will be called. success: function(data) { //console.log(data) this_input.closest('div').find('.result').html(data); //this_input.closest('#result').hide() //$('#result').html(data); } }); } }, 700); }); }) $(document).on('click', '#kk_modal_tag_close', function() { //clear $('input[name="question_id"]').val(''); $('input[name="subject_id"]').val(''); $('input[name="tag"]').val(''); $('input[name="type"]').val(''); $('div.result').html(''); $('div.tag-div_2').html(''); $('#kk_modal_add_tag').modal('hide'); }) //add tag $(document).on('click', '.add-tag', function() { var sid = $(this).data('sid'); var qid = $(this).data('qid'); var type = $(this).data('type'); var thisElement = $(this); //AJAX is called. $.ajax({ type: "POST", url: "https://sattacademy.com/question/tag/tag-added", headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, data: { //Assigning value of "val" into "search" variable. subject_id: sid, question_id: qid, type: type }, //If result found, this funtion will be called. success: function(data) { if (data.success) { toastr.success(data.message); // $('#kk_modal_add_tag').modal('hide'); // $('.result').html(''); // $('.search_tag').val(''); thisElement.removeClass('add-tag'); thisElement.addClass('remove-tag'); let html = `<span class="badge badge-info cursor-pointer fs-8 mb-3 me-2 remove-tag" data-sid="${data.subject.id}" data-qid="${data.question_id}" data-type="${data.type}" title="Remove">${data.subject.name}</span>`; thisElement.parents('div.modal-body').find('div.tag-div_2').append(html); } else { toastr.error(data.message); } } }); }) //remove tag// $(document).on('click', '.remove-tag', function() { var sid = $(this).data('sid'); var qid = $(this).data('qid'); var type = $(this).data('type'); //console.log(sid); //console.log(type); var thisBtn = $(this); console.log(thisBtn); //AJAX is called. $.ajax({ type: "POST", url: "https://sattacademy.com/admin/question/remove-tag", headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, data: { //Assigning value of "val" into "search" variable. subject_id: sid, question_id: qid, type: type }, //If result found, this funtion will be called. success: function(data) { if (data.success) { toastr.success(data.message); thisBtn.removeClass('remove-tag'); thisBtn.addClass('add-tag'); thisBtn.parents('div.modal-body').find('.tag-div_2 span[data-sid="' + sid + '"]').remove(); //location.reload(); } else { toastr.error(data.message) } } }); }) /**####### end::Tag #########**/ /*##### begin::Error Report #####*/ function cleanForm() { $('.messages').empty(); $('.with-errors').text(''); $('.indicator-label').show(); $('.indicator-progress').hide(); $('#kk_modal_error_report_form')[0].reset(); } $(document).on('click', '.error-report', function() { const id = $(this).data('id'); const type = $(this).data('type'); cleanForm(); $('input[name="id"]').val(id); $('input[name="type"]').val(type); $('#kk_modal_error_report').modal('show'); }) $(document).on('click', '#kk_modal_error_report_cancel', function() { cleanForm(); $('#kk_modal_error_report').modal('hide'); }) //submit $(document).on('submit', '#kk_modal_error_report_form', function(e) { e.preventDefault(); $('.messages').empty(); $('.with-errors').text(''); $('.indicator-label').hide(); $('.indicator-progress').show(); var formData = new FormData(this); $.ajax({ type: "POST", url: "https://sattacademy.com/error-report/store", data: formData, cache: false, contentType: false, processData: false, success: function(data) { if (data.success == false || data.success == "false") { var arr = Object.keys(data.errors); var arr_val = Object.values(data.errors); for (var i = 0; i < arr.length; i++) { $('.' + arr[i] + '-error').text(arr_val[i][0]) } } else if (data.error || data.error == 'true') { var alertBox = '<div class="alert alert-danger" alert-dismissable">' + data .message + '</div>'; $('#kk_modal_error_report_form').find('.messages').html(alertBox).show(); } else { // empty the form $('#kk_modal_error_report_form')[0].reset(); $("#kk_modal_error_report").modal('hide'); toastr.success(data.message); } $('.indicator-label').show(); $('.indicator-progress').hide(); } }); }) /*##### end::Error Report #####*/ /* begin::voteing script */ $(document).on('click', '.choosen-option', function() { if ($(this).is(':checked')) { var choosen = $(this).val(); } else { var choosen = 0; } let ques_id = $(this).data('ques_id'); //console.log(choosen); //set & get local storage data let previous = localStorage.getItem('key'); localStorage.setItem('key', choosen); //console.log(previous); const thisElement = $(this); incrementDecrement(thisElement, choosen, previous); //AJAX is called. $.ajax({ type: "POST", url: "https://sattacademy.com/mcq-question/answer-vote", headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, data: { ques_id: ques_id, choosen: choosen, }, //If result found, this funtion will be called. success: function(data) { if (data.success) { console.log(data.message); } else { toastr.error(data.message); } } }); }) /* end::voteing script */ function onlyOne(checkbox) { let name = $(checkbox).attr('name'); var checkboxes = document.getElementsByName(name) checkboxes.forEach((item) => { if (item !== checkbox) item.checked = false }) } function incrementDecrement(thisElement, choosen, previous) { var option1 = thisElement.parents('div.parent-card-body').find('span.vote_option_1'); var option2 = thisElement.parents('div.parent-card-body').find('span.vote_option_2'); var option3 = thisElement.parents('div.parent-card-body').find('span.vote_option_3'); var option4 = thisElement.parents('div.parent-card-body').find('span.vote_option_4'); var option5 = thisElement.parents('div.parent-card-body').find('span.vote_option_5'); if (choosen == 1) { let val = parseInt(option1.text()); option1.text(val + 1); } else if (choosen == 2) { let val = parseInt(option2.text()); option2.text(val + 1); } else if (choosen == 3) { let val = parseInt(option3.text()); option3.text(val + 1); } else if (choosen == 4) { let val = parseInt(option4.text()); option4.text(val + 1); } else if (choosen == 5) { let val = parseInt(option5.text()); option5.text(val + 1); } if (previous == 1) { let val = parseInt(option1.text()); if (val > 0) { option1.text(val - 1); } } else if (previous == 2) { let val = parseInt(option2.text()); if (val > 0) { option2.text(val - 1); } } else if (previous == 3) { let val = parseInt(option3.text()); if (val > 0) { option3.text(val - 1); } } else if (previous == 4) { let val = parseInt(option4.text()); if (val > 0) { option4.text(val - 1); } } else if (previous == 5) { let val = parseInt(option5.text()); if (val > 0) { option5.text(val - 1); } } } </script> <script type="text/javascript"> /**######begin::test mode & reading mode hide show #######**/ $(document).ready(function(){ $('.test-mode-data').addClass('d-none'); $('input[name="active_mode"]').val('reading'); $('.test-mode').on('click', function(){ $('.test-mode-data').removeClass('d-none'); $('.reading-mode-data').addClass('d-none'); $('.edit-btn-div').addClass('d-none'); $(this).addClass('d-none'); $('.mark-count').removeClass('d-none'); $('.reading-mode').removeClass('d-none'); $('input[name="active_mode"]').val('test'); $('.toolbar-div').addClass('d-none'); $('.tag-div').addClass('d-none'); $('.activity').addClass('d-none'); $('.custom-bookmark-card').addClass('d-none'); }) $('.reading-mode').on('click', function(){ $('.reading-mode-data').removeClass('d-none'); $('.test-mode-data').addClass('d-none'); $('.edit-btn-div').removeClass('d-none'); $(this).addClass('d-none'); $('.mark-count').addClass('d-none'); $('.test-mode').removeClass('d-none'); $('input[name="active_mode"]').val('reading'); $('.toolbar-div').removeClass('d-none'); $('.tag-div').removeClass('d-none'); $('.activity').removeClass('d-none'); $('.custom-bookmark-card').removeClass('d-none'); }) }) /**######end::test mode & reading mode hide show #######**/ /**######begin::Test #######**/ $(document).ready(function(){ $(document).on('click', '.click-option', function(){ var id = $(this).data('id') var option_value = $(this).data('option_value'); var answer = $(this).parents('div.parent-row').find('input[name="answer"]').val(); // console.log('question='+id); // console.log('option='+option_value); // console.log('answer='+answer); $(this).parents('div.parent-row').find('span').click(function() { return false; }); $(this).parents('div.parent-row').find('div.click-option').removeClass('cursor-pointer'); if(answer == 1){ $(this).parents('div.parent-row').find('i.option-1').removeClass('fa-dot-circle text-dark'); $(this).parents('div.parent-row').find('i.option-1').addClass('fa-check-circle fs-4 sa-success'); $(this).parents('div.parent-row').find('div.option-1-text').removeClass('text-dark'); $(this).parents('div.parent-row').find('div.option-1-text').addClass('sa-success fs-4 fw-bold'); }else if(answer == 2){ $(this).parents('div.parent-row').find('i.option-2').removeClass('fa-dot-circle text-dark'); $(this).parents('div.parent-row').find('i.option-2').addClass('fa-check-circle fs-4 sa-success'); $(this).parents('div.parent-row').find('div.option-2-text').removeClass('text-dark'); $(this).parents('div.parent-row').find('div.option-2-text').addClass('sa-success fs-2 fw-bold'); }else if(answer == 3){ $(this).parents('div.parent-row').find('i.option-3').removeClass('fa-dot-circle text-dark'); $(this).parents('div.parent-row').find('i.option-3').addClass('fa-check-circle fs-4 sa-success'); $(this).parents('div.parent-row').find('div.option-3-text').removeClass('text-dark'); $(this).parents('div.parent-row').find('div.option-3-text').addClass('sa-success fs-2 fw-bold'); }else if(answer == 4){ $(this).parents('div.parent-row').find('i.option-4').removeClass('fa-dot-circle text-dark'); $(this).parents('div.parent-row').find('i.option-4').addClass('fa-check-circle fs-4 sa-success'); $(this).parents('div.parent-row').find('div.option-4-text').removeClass('text-dark'); $(this).parents('div.parent-row').find('div.option-4-text').addClass('sa-success fs-2 fw-bold'); }else if(answer == 5){ $(this).parents('div.parent-row').find('i.option-5').removeClass('fa-dot-circle text-dark'); $(this).parents('div.parent-row').find('i.option-5').addClass('fa-check-circle fs-4 sa-success'); $(this).parents('div.parent-row').find('div.option-5-text').removeClass('text-dark'); $(this).parents('div.parent-row').find('div.option-5-text').addClass('sa-success fs-2 fw-bold'); } if(answer == option_value){ var val = $('#wright').html(); $('#wright').html(parseInt(val)+1); $(this).find('span.d-flex').append('<span class="ms-2"><i class="fas fa-check sa-success fs-3"></i></span>'); }else{ var val = $('#wrong').html(); //console.log(val) $('#wrong').html(parseInt(val)+1); $(this).find('span.d-flex').append('<span class="ms-2"><i class="fas fa-times sa-danger fs-3"></i></span>'); } }) }) /**######end::Test #######**/ /**########begin::edit-passage #########**/ $(document).on('click', '.edit-passage', function(){ var passage_id = $(this).data('passage_id'); //console.log(des_id); Swal.fire({ text: "Are you sure you want to edit this passage?", icon: "warning", showCancelButton: !0, buttonsStyling: !1, confirmButtonText: "Confirm", cancelButtonText: "No, cancel", customClass: { confirmButton: "btn fw-bold btn-danger", cancelButton: "btn fw-bold btn-active-light-primary" } }).then((function (o) { if(o.value){ //if agree $.ajax({ type:"GET", url: "https://sattacademy.com/question/passage/edit", dataType: 'json', data:{ 'passage_id' : passage_id }, success:function(data){ $("#edit_passage").html(data.html); $("#kk_modal_edit_passage").modal('show'); } }); } })) }); //update passage $(document).on('submit', '#kk_modal_edit_passage_form',function(e){ e.preventDefault() $('.with-errors').text(''); $('.indicator-label').hide(); $('.indicator-progress').show(); var formData = new FormData(this); // formData.append('passage', myPassaseEditor.getData()); $.ajax({ type:"POST", url: "https://sattacademy.com/question/passage/update", data:formData, cache:false, contentType: false, processData: false, success:function(data){ if(data.success == false || data.success == "false"){ var arr = Object.keys(data.errors); var arr_val = Object.values(data.errors); for(var i= 0;i < arr.length;i++){ $('.'+arr[i]+'-error').text(arr_val[i][0]) } }else if(data.error || data.error == 'true'){ var alertBox = '<div class="alert alert-danger" alert-dismissable">' + data.message + '</div>'; $('#kk_modal_edit_passage_form').find('.messages').html(alertBox).show(); }else{ // empty the form $('#kk_modal_edit_passage_form')[0].reset(); $("#kk_modal_edit_passage").modal('hide'); toastr.success(data.message); } $('.indicator-label').show(); $('.indicator-progress').hide(); $('#kk_modal_new_service_submit').removeAttr('disabled'); } }); }) //passage edit cancel button $(document).on('click', '#kk_modal_edit_passage_cancel', function(){ $('.indicator-label').show(); $('.indicator-progress').hide(); $('#kk_modal_new_service_submit').removeAttr('disabled'); $('#kk_modal_edit_passage_form')[0].reset(); $("#kk_modal_edit_passage").modal('hide'); }) /**#########end::edit-passage ##########**/ </script> <script type="text/javascript"> $(document).ready(function(){ $(document).on('click', '.test-yourself', function(){ $(this).text('Loading...'); var id = $(this).data('subject_id'); var total_ques = $(this).data('total_ques'); //console.log(id); $('.with-errors').text(''); $('#error-message').html(''); $('.messages').html(''); $('#kk_modal_self_test_form')[0].reset(); $('input[name="subject_id"]').val(id); var val = '<span class="">Total Question</span>' val += '<span class="badge badge-danger badge-lg ms-2 pb-1" id="total">' + total_ques + '</span>' $('#total_question').html(val); $('#kk_modal_new_service_submit_btn').attr('disabled' , true); $('#kk_modal_self_test').modal('show'); getChapter(id); setTimeout(() => { $(this).text('TEST'); }, 2000); }); // subject based get chapter function getChapter (id){ if(id){ $.ajax({ url: '/get-subject-chapter/' + id, type: "GET", dataType: "json", success: function(data) { if (data) { $('#chapter-self-test').empty(); traverseChapter(data, ''); } else { $('#chapter-self-test').empty(); } } }); } } function traverseChapter(chapters, prefix) { $.each(chapters, function(key, chap) { // console.log(chap); // Check if the category has children var hasChildren = chap.children && chap.children.length > 0; // Append the category name to the select element with appropriate indentation and styling $('#chapter-self-test').append( '<option class="options" data-parent-id="' + chap.parent_id + '" value="' + chap.id + '">' + prefix + chap.name + '(' + chap.num_of_mcq + ')' + (hasChildren ? ' →' : '') + '</option>' ); // If the category has children, recursively traverse them with an increased prefix if (hasChildren) { traverseChapter(chap.children, prefix + '\u00A0\u00A0\u00A0\u00A0\u00A0'); } }); } //calculate the mark, time, cut mark function calculatePassMark(totalQuestion, value) { let val = Math.round((value * totalQuestion) / 100); return val ; } function calculateDuration(totalQuestion, value) { let val = Math.round((value * totalQuestion) / 100); return val ; } //empty the error message $(document).on('keyup', ".number_of_ques", function () { if(isNaN($(this).val()) || $(this).val() == NaN || $(this).val() == '') { $('#error-message').html(''); $('#kk_modal_new_service_submit_btn').attr('disabled', true); $('input[name="duration"]').val(''); $('input[name="cut_mark"]').val(''); $('input[name="total_mark"]').val(''); } }) //count input number of question value $(document).on('keyup', ".number_of_ques", function () { //console.log('here'); var input_total = 0; input_total += parseInt($(this).val()) var total_question = parseInt($('#total').text()); // console.log(total_question) $('#error-message').html(''); if(isNaN(input_total) || input_total == NaN) { input_total = 0; //console.log(input_total); } if(input_total > 0) { //set the total mark value $('input[name="total_mark"]').val(input_total); let pass_mark = calculatePassMark(input_total, 40); $('input[name="cut_mark"]').val(pass_mark); let exam_duration = calculateDuration(input_total, 60); $('input[name="duration"]').val(exam_duration); }else { $('input[name="duration"]').val(''); $('input[name="cut_mark"]').val(''); $('input[name="total_mark"]').val(''); } if ( input_total > total_question || input_total > 200 || input_total < 5 && input_total > 0){ $('#error-message').html( `<span class="text-danger">Number of input question must be grater than or equal <span class="fw-bolder">5</span> and less than <span class="fw-bolder">100</span>.</span>` ); $('#kk_modal_new_service_submit_btn').attr('disabled', true); }else{ $('#error-message').html(''); $('#kk_modal_new_service_submit_btn').attr('disabled', false); } }) $(document).on('click', '#kk_modal_self_test_cancel', function(){ $('.with-errors').text(''); $('.messages').html(''); $('.test-yourself').text('TEST'); $('.indicator-label').show(); $('#error-message').html(''); $('.indicator-progress').hide(); $('#kk_modal_new_service_submit').removeAttr('disabled'); $('#kk_modal_self_test_form')[0].reset(); $('#kk_modal_self_test').modal('hide'); }) //submit// $(document).on('submit', '#kk_modal_self_test_form', function(e){ e.preventDefault() $('.with-errors').text(''); $('.indicator-label').hide(); $('.indicator-progress').show(); var formData = new FormData(this); $.ajax({ type:"POST", url: "https://sattacademy.com/test", data:formData, cache:false, contentType: false, processData: false, success:function(data){ if(data.success == false || data.success == "false"){ var arr = Object.keys(data.errors); var arr_val = Object.values(data.errors); for(var i= 0;i < arr.length;i++){ $('.'+arr[i]+'-error').text(arr_val[i][0]) } }else if(data.error || data.error == 'true'){ var alertBox = '<div class="alert alert-danger alert-dismissable">' + data.message + '</div>'; $('#kk_modal_self_test_form').find('.messages').html(alertBox).show(); }else{ // empty the form $('#kk_modal_self_test_form')[0].reset(); $("#kk_modal_self_test").modal('hide'); $('.messages').html(''); //console.log(data); let url = data.data.url + '?'; if (data.data.subject_id != null) { url += 's_id=' + encodeURIComponent(data.data.subject_id) + '&'; } if (data.data.number_of_question != null) { url += 'n_o_q=' + encodeURIComponent(data.data.number_of_question) + '&'; } if (data.data.total_mark != null) { url += 't_m=' + encodeURIComponent(data.data.total_mark) + '&'; } if (data.data.cut_mark != null) { url += 'c_m=' + encodeURIComponent(data.data.cut_mark) + '&'; } if (data.data.negative_mark != null) { url += 'n_m=' + encodeURIComponent(data.data.negative_mark) + '&'; } if (data.data.duration != null) { url += 'du=' + encodeURIComponent(data.data.duration) + '&'; } if (data.data.chapter_id != null) { url += 'chapter_id=' + encodeURIComponent(data.data.chapter_id); } // Remove the last '&' if there was one url = url.endsWith('&') ? url.slice(0, -1) : url; // Redirect to the generated URL window.location.href = url; } $('.indicator-label').show(); $('.test-yourself').text('TEST'); $('#error-message').html(''); $('.indicator-progress').hide(); $('#kk_modal_new_service_submit').removeAttr('disabled'); } }); }) }); </script> <script type="text/javascript"> $(document).ready(function () { var auth = ""; $('.customDropdownButton').on('click', function (event) { event.stopPropagation(); const $existingDropdown = $('.dynamic-dropdown-menu'); const $clickedButton = $(this); // Check if clicking the same button that has an open dropdown if ($existingDropdown.length && $existingDropdown.prev()[0] === this) { // Close the existing dropdown and return (toggle behavior) closeDropdown($existingDropdown); return; } // Close any existing dropdown first if ($existingDropdown.length) { closeDropdown($existingDropdown); } const mainCategory = $(this).data('main-category'); const subjectId = $(this).data('id'); const subjectSlug = $(this).data('slug'); const subjectSubSlug = $(this).data('sub-slug'); const numOfMcq = $(this).data('mcq'); const numOfWritten = $(this).data('written'); const mainSubjectId = $('#myInput').data('id'); if(auth){ checkFavorite(subjectId); checkBookmark(subjectId); } // Start building the dropdown menu HTML let dropdownHtml = ` <div class="dropdown-menu dropdown-menu-end fs-7 w-100px dynamic-dropdown-menu position-absolute end-0 top-100" data-kt-menu="true" style="display: none;"> <div class="menu-item"> <a href="javascript:void(0)" class="btn btn-white btn-sm btn-active-primary px-2 rounded-0 fs-7 d-block test-yourself border-bottom border-primary border-0" data-action="test-yourself" data-subject_id="${subjectId}" data-total_ques="${numOfMcq}"> Test Yourself </a>`; if(auth){ dropdownHtml += ` <a href="javascript:void(0)" class="btn btn-white btn-sm btn-active-primary px-2 rounded-0 fs-7 d-block border-bottom border-primary border-0 favorite-btn" data-action="favorite" data-id="${subjectId}" data-type="subject"> <i class="fa-solid fa-ellipsis" id="loading"></i> </a> <a href="javascript:void(0)" class="btn btn-white btn-sm btn-active-primary px-2 rounded-0 fs-7 d-block border-bottom border-primary border-0 bookmark-btn" data-action="bookmark" data-id="${subjectId}" data-type="subject"> <i class="fa-solid fa-ellipsis" id="loading"></i> </a> `; } // Only add the "View MCQ" option if numOfMcq is not 0 if (numOfMcq != 0) { dropdownHtml += ` <a href="${getRoute(mainCategory, subjectSlug, 'mcq', subjectId)}" class="btn btn-white btn-sm btn-active-primary px-2 rounded-0 fs-7 d-block border-bottom border-primary border-0"> View MCQ(${thousandsNumberFormat(numOfMcq)}) </a> `; } // Only add the "View Written" option if numOfWritten is not 0 if (numOfWritten != 0) { dropdownHtml += ` <a href="${getRoute(mainCategory, subjectSlug, 'written', subjectId)}" class="btn btn-white btn-sm btn-active-primary px-2 rounded-0 fs-7 d-block border-bottom border-primary border-0"> View Written(${thousandsNumberFormat(numOfWritten)}) </a> `; } // Only add the "Create Questions" option if numOfMcq is not 0 if (numOfMcq != 0) { let url = `/e-question-builder/select-question?subject_id=${mainSubjectId}${mainSubjectId == subjectId ? '' : `&chapter_id=${subjectId}`}`; dropdownHtml += ` <a href="${url}" class="btn btn-white btn-sm btn-active-primary px-2 rounded-0 fs-7 d-block border-bottom border-primary border-0"> প্রশ্ন তৈরি করুন </a> `; } dropdownHtml += ` <a href="javascript:void(0)" class="show-video btn btn-white btn-sm btn-active-primary px-2 rounded-0 fs-7 d-block border-bottom border-primary border-0" data-id="${subjectId}" data-type="subject"> Show Video </a> <a href="${getRoute(mainCategory, subjectSlug, 'mcq_add', subjectId)}" class="btn btn-white btn-sm btn-active-primary px-2 rounded-0 fs-7 d-block border-bottom border-primary border-0"> Add MCQ </a> <a href="${getRoute(mainCategory, subjectSlug, 'written_add', subjectId)}" class="btn btn-white btn-sm btn-active-primary px-2 rounded-0 fs-7 d-block"> Add Written </a> </div> </div> `; // Insert the dropdown menu after the button (not before) $clickedButton.after(dropdownHtml); const $dropdownMenu = $('.dynamic-dropdown-menu'); // Show dropdown with animation $dropdownMenu.fadeIn(200); // Remove any existing click handlers to prevent multiple bindings $(document).off('click.closeDropdown'); // Close the dropdown if clicked outside $(document).on('click.closeDropdown', function(event) { if (!$(event.target).closest($clickedButton).length && !$(event.target).closest($dropdownMenu).length) { closeDropdown($dropdownMenu); } }); // Also close on escape key $(document).off('keydown.closeDropdown').on('keydown.closeDropdown', function(event) { if (event.key === 'Escape') { closeDropdown($dropdownMenu); } }); }); // Helper function to close dropdown with proper cleanup function closeDropdown($dropdown) { if ($dropdown && $dropdown.length) { $dropdown.addClass('fade-out'); setTimeout(() => { $dropdown.remove(); $(document).off('click.closeDropdown keydown.closeDropdown'); }, 300); } } const routes = { chapter: { job: "https://sattacademy.com/guide/:slug", skill: "https://sattacademy.com/skill/:slug", admission: "https://sattacademy.com/admission/subject/:slug", academy: "https://sattacademy.com/academy/:slug" }, mcq: { job: "https://sattacademy.com/all-mcq/:slug", skill: "https://sattacademy.com/all-mcq/:slug", admission: "https://sattacademy.com/all-mcq/:slug", academy: "https://sattacademy.com/all-mcq/:slug" }, written: { job: "https://sattacademy.com/all-written/:slug", skill: "https://sattacademy.com/all-written/:slug", admission: "https://sattacademy.com/all-written/:slug", academy: "https://sattacademy.com/all-written/:slug" }, mcq_add: "https://sattacademy.com/subject/:id/add-mcq", written_add: "https://sattacademy.com/subject/:id/add-written" }; function getRoute(mainCategory, slug, actionType, id) { const categoryKey = { '1': 'job', '4': 'skill', '3': 'admission', '2': 'academy' }[mainCategory] || 'default'; let route; if (actionType === 'mcq_add' || actionType === 'written_add') { route = routes[actionType]; } else { route = routes[actionType]?.[categoryKey]; } if (!route) { console.error('Route not found', { mainCategory, slug, actionType, id }); return '#'; } return route.replace(':slug', slug || '').replace(':id', id || ''); } function checkBookmark(subjectId) { $.ajax({ url: "/check/bookmark", data: { question_id: subjectId, category_id: null, type: "subject", _token: $('meta[name="csrf-token"]').attr('content') }, success: function (data) { if (data.success === true) { $('.bookmark-btn').attr('data-bookmark_id', data.bookmark.id); $('.bookmark-btn').html('Remove Bookmark'); $('.bookmark-btn').addClass('remove-bookmark').removeClass('bookmark'); } else { $('.bookmark-btn').html('Bookmark'); $('.bookmark-btn').addClass('bookmark').removeClass('remove-bookmark'); } }, error: function (xhr, status, error) { $('.bookmark-btn').html('Bookmark'); $('.bookmark-btn').addClass('bookmark').removeClass('remove-bookmark'); } }); } function checkFavorite(subjectId){ $.ajax({ url: "/check/vote-like/" + subjectId + "/subject", success: function (data) { if (data.success === true) { $('.favorite-btn').attr('data-vote_id', data.vote); $('.favorite-btn').html('Remove Favorite'); $('.favorite-btn').addClass('undo-vote').removeClass('vote'); } else { $('.favorite-btn').html('Favorite'); $('.favorite-btn').addClass('vote').removeClass('undo-vote'); } }, error: function (xhr, status, error) { $('.favorite-btn').html('Favorite'); $('.favorite-btn').addClass('vote').removeClass('undo-vote'); } }); } // Format numbers into thousands, millions, billions etc. function thousandsNumberFormat(num) { if (num >= 1e9) return (num / 1e9).toFixed(1).replace(/\.0$/, '') + 'B'; if (num >= 1e6) return (num / 1e6).toFixed(1).replace(/\.0$/, '') + 'M'; if (num >= 1e3) return (num / 1e3).toFixed(1).replace(/\.0$/, '') + 'K'; return num.toString(); } }); </script> <script type="text/javascript"> $(document).on('click', '.kt_user_follow_button', function() { //console.log('Follow btn click'); var id = $(this).data('id'); var thisBtn = $(this); $.ajax({ type: "GET", url: "https://sattacademy.com/user-follow" + "/" + id, data: {}, beforeSend: function() { thisBtn.find('.indicator-label').hide(); thisBtn.find('.indicator-progress').show(); }, success: function(data) { let follower_count_html = thisBtn.parent('div.d-flex').find('.follower_count') .html(); let blog_following_count_html = thisBtn.parent().parent().find( '.blog_follower_count').html(); if (data.success) { if (data.value == 'follow') { $('.indicator-label').show(); $('.indicator-progress').hide(); thisBtn.removeClass('btn-primary').addClass('btn-success'); thisBtn.find('.indicator-label').text(' Following'); if ($('.follower_count').length > 0) { if (!follower_count_html.includes('k')) { let followers = parseInt(follower_count_html); thisBtn.parent('div.d-flex').find('.follower_count').html( `${followers + 1}`); } } // blog details if ($('.blog_follower_count').length > 0) { if (!blog_following_count_html.includes('k')) { let followersBlog = parseInt(blog_following_count_html); thisBtn.parent().parent().find('.blog_follower_count').html( `${followersBlog + 1}`); } } } else { $('.indicator-label').show(); $('.indicator-progress').hide(); thisBtn.removeClass('btn-success').addClass('btn-primary'); thisBtn.find('.indicator-label').text(' Follow'); if ($('.follower_count').length > 0) { if (!follower_count_html.includes('k')) { let followers = parseInt(follower_count_html); thisBtn.parent('div.d-flex').find('.follower_count').html( `${followers - 1}`); } } // blog details if ($('.blog_follower_count').length > 0) { if (!blog_following_count_html.includes('k')) { let followersBlog = parseInt(blog_following_count_html); thisBtn.parent().parent().find('.blog_follower_count').html( `${followersBlog - 1}`); } } } } else { toastr.error(data.message); $('.indicator-label').show(); $('.indicator-progress').hide(); } }, error: function(data) { toastr.error('Please login to follow'); $('.indicator-label').show(); $('.indicator-progress').hide(); } }); }); </script> <script type="text/javascript"> //user short statistics $(document).on('mouseover', '.user-statistics', function(){ let id = $(this).data('id'); let flug = $(this).data('flug'); //console.log(flug); const thisElement = $(this); if(flug == '-1'){ $.ajax({ type:"GET", url: "https://sattacademy.com/user-short-statistics"+'/'+id, data:{}, dataType: 'json', success:function(data){ if(data.success == true || data.success == 'true'){ thisElement.prepend(data.html); thisElement.data('flug', '1'); }else{ toastr.error(data.message); } } }); } }); // //close $(document).on('mouseleave', '.user-statistics', function(){ //console.log('leave'); let flug = $(this).data('flug', '-1'); $('div.statistics-data').hide(); }) </script> <script type="text/javascript"> const url = window.location.href; //console.log(url); const shareData = { title: 'SATT ACADEMY', // text: 'Learn web development on MDN!', url: url } $(document).on('click', '.share', async() => { //console.log('click'); try { await navigator.share(shareData); //toastr.success('Shared successfully'); } catch (err) { console.error(err); } }); </script> <script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script> <script src="https://unpkg.com/highlightjs-copy/dist/highlightjs-copy.min.js"></script> <script> hljs.configure({ ignoreUnescapedHTML: true }); hljs.highlightAll(); hljs.addPlugin(new CopyButtonPlugin()); </script> <script type="text/javascript" src="https://sattacademy.com/easyui/codejar.min.js"></script> <script type="text/javascript"> $(document).ready(function() { //call the function on page load tableWrap(); imageSize(); //table wrap function function tableWrap() { $("table").wrap(`<div class="table-responsive w-100"></div>`); $("table").addClass('table table-striped table-bordered'); $("table").find('thead').addClass('thead-dark fw-bolder fs-4'); $("table").find('th').addClass('ps-2'); $("table").find('td').addClass('ps-2'); $("table").css({ 'max-width': '100%', 'margin-top': '10px', 'margin-bottom': '10px', }); $("table").find('thead').css({ 'background-color': 'gray', 'color': 'white' }); }; //image sizeing function function imageSize() { $(".subject-all-topic img").not('.toolbar-img, .subject-icon, .subject-banner. .dopamine').each(function() { // Wrap each image with a div having a class of 'w-100' if not already wrapped if (!$(this).parent().hasClass('w-100')) { $(this).wrap('<div class="w-100"></div>'); } }); $(".subject-all-topic img").not('.subject-icon, .subject-banner').css({ 'max-width': '100%', 'margin-top': '10px', 'margin-bottom': '10px', }); } /*toggle btn*/ $('#toggle-subject-chapter').on('click', function() { $("#toggle-div").slideToggle(500); $(this).find('i.fas').toggleClass('fa-chevron-down fa-chevron-up'); }) }) </script> <script> var editors = []; $("p:contains('kt_satt_skill_example_id')").each(function(index) { // console.log(this,index); const thisElement = $(this); let text = $(this).text(); text = $.trim(text); //console.log(text); exampleId = text.slice(25); //console.log(exampleId); let url = "https://sattacademy.com/skill/examples/:id"; url = url.replace(':id', exampleId); //console.log(url); $.ajax({ url: url, success: function(data) { // console.log(data); thisElement.html(data.html); // Delay the initialization to ensure content is rendered setTimeout(() => { const codeMirror = thisElement.find('.code-mirror')[0]; codeMirror.dataset.index = index; // Assign dataset index codeMirror.id = `code-mirror-${index}`; // Use a unique id pattern // console.log(codeMirror.innerHTML) if (codeMirror) { let options = { tab: ' '.repeat(4) }; // Create a highlighting function const highlight = (editor) => { hljs.highlightAll(); hljs.addPlugin(new CopyButtonPlugin()); } editors[index] = CodeJar(codeMirror, highlight, options); } else { console.error('.code_box not found in injected content.'); } }, 100); } }); }); $.fn.isInViewport = function(margin) { var elementTop = $(this).offset().top + margin; var elementBottom = elementTop + $(this).outerHeight(); var viewportTop = window.pageYOffset || document.documentElement.scrollTop; var viewportBottom = viewportTop + $(window).height(); return elementBottom > viewportTop && elementTop < viewportBottom; }; function getDocHeight(doc) { doc = doc || document; var body = doc.body, html = doc.documentElement; var height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html .offsetHeight); return height; } function resizeFrame(iframe) { const doc = iframe.contentDocument ? iframe.contentDocument : iframe.contentWindow.document; const height = getDocHeight(doc) + 50; if (height > 450) { iframe.style.height = "450px"; } else { iframe.style.height = height + 'px'; } } $(document).on('click', '.satt-open-compiler', function() { const url = $(this).data('href'); window.open(url, '_blank'); }); $(document).on('click', '.console-close', function() { $(this).hide(); $(this).parent().hide(); }); $(document).on('click', '.execute', function() { const parent = $(this).closest('.code-wrapper'); const preview = parent.find('.code-mirror'); var index = preview.data("index"); const lang = preview.data('lang'); var editor = editors[index]; // console.log(editors) var code = editor.toString().replace('Copy', '').replace('Copied!Copied to clipboard', ''); // console.log(code) // if (lang == "sql") { // return; // } // if (lang == "mysql") { // return; // } // var url = "/"; // if (lang == "c" || lang == "cpp" || lang == "c99" || lang == "cpp0x" || lang == "cpp11" || lang == // "objc" || lang == "swift" || lang == "ada" || lang == "algol" || lang == "asm" || lang == "awk" || // lang == "bash" || lang == "befunge" || lang == "brainfuck" || lang == "fbc" || lang == "csharp" || // lang == "fsharp" || lang == "vb.net" || lang == "ilasm" || lang == "elixir" || lang == "basic" || // lang == "cobol" || lang == "cbasic" || lang == "yasm" || lang == "fortran" || lang == "erlang" || // lang == "factor") { // url = "/"; // } else if (lang === "javascript" || lang === "java" || lang === "rexx" || lang === "clojure" || lang === // "fantom" || lang === "golang" || lang === "groovy" || lang === "haxe" || lang === "haskell" || // lang === "dart" || lang === "d" || lang === "julia" || lang === "scala") { // url = "/"; // } else if (lang === "kotlin" || lang === "perl" || lang === "ruby" || lang === "rubyterm" || lang === // "matplotlib" || lang === "numpyterm" || lang === "scipyterm" || lang === "python3" || lang === // "python" || lang === "rscript" || lang === "octave" || lang === "octaveterm" || lang === "rterm" || // lang === "nodejsterm" || lang === "unixterm" || lang === "python3term" || lang == "pashterm" || // lang == "lua" || lang == "luaterm" || lang == "forth" || lang === "jython" || lang === "java8" || // lang === "ksh" || lang === "tcl" || lang === "lisp" || lang === "icon" || lang === "intercal" || // lang === "sqlite") { // url = "/"; // } // if (lang === "typescript") { // url = "/"; // } const wrapper = parent.find('.output-wrapper').show(); if (!wrapper.isInViewport(100)) { const rect = wrapper[0].getBoundingClientRect(); const scrollTop = window.scrollY || document.documentElement.scrollTop; const windowHeight = window.innerHeight || document.documentElement.clientHeight; const targetY = rect.top + scrollTop - (windowHeight / 2) + (rect.height / 2); window.scrollTo({ top: targetY, behavior: 'smooth' }); } wrapper.find(".console-close").show(); wrapper.find(".code-output").html('<div class="loader"></div>'); if (['javascript', 'html', 'css', 'html5'].includes(lang)) { const iframe = document.createElement('iframe'); iframe.style = 'height:0; margin:0; padding:10px; width:100%; border:none; overflow:hidden; opacity:0; transition: opacity 1s ease-in-out;'; iframe.addEventListener('load', () => { setTimeout(() => { resizeFrame(iframe); $('.loader').hide(); }, 100); }); wrapper.find('.code-output').append(iframe); iframe.contentWindow.document.open(); iframe.contentWindow.document.write(code); iframe.contentWindow.document.close(); // Trigger fade-in by changing the opacity setTimeout(() => { iframe.style.opacity = 1; }, 50); // Small delay to ensure the iframe is appended before the fade starts return; } // other // var formData = new FormData(); // formData.append('lang', lang); // formData.append('code', code); // fetch(url, { // method: 'POST', // body: formData // }) // .then(response => { // console.log (response); // return response.text(); // }) // .then(data => { // wrapper.find(".code-output").html(data); // }) // .catch((error) => { // console.log( error ); // alert(error); // return false; // }); }); </script> <script> $(document).ready(function() { let activeItem = $('.leftmenu .active'); $('.prev-menu').click(function() { let prevItem = activeItem.prev(); if (activeItem && prevItem.length > 0 && prevItem.prop("tagName") == "A") { window.location.href = prevItem.attr('href'); } else { let parentRoute = $('.parent_route').attr('href'); window.location.href = parentRoute; } }); // Handle 'Next' button click $('.next-menu').click(function() { let nextItem = activeItem.next(); if (activeItem && nextItem.length > 0 && nextItem.prop("tagName") == "A") { window.location.href = nextItem.attr('href'); } else { Swal.fire({ icon: 'info', title: 'No more items to navigate', }); } }); }); /*toggle btn*/ $(document).ready(function() { $('.toggle-subchapter-btn').on('click', function(e) { //console.log('click') e.preventDefault(); let id = $(this).attr('data-id'); console.log(id); $(this).toggleClass('fa-arrow-down fa-arrow-up'); let targetSubchapter = $('.child[data-parent="' + id + '"]'); console.log(targetSubchapter); targetSubchapter.toggleClass('d-none'); }); }); function markAsComplete(completeableId, completeableType, completionType, name) { const checkbox = document.getElementById(`is-completed-${completeableId}`); const isChecked = checkbox.checked; // Prepare the data to be sent to the server const data = { completeable_id: completeableId, completeable_type: completeableType, type: completionType }; // Send the AJAX request $.ajax({ type: "GET", url: "https://sattacademy.com/iscomplete-progress", data: data, dataType: 'json', success: function(response) { if (response.success) { // Display success SweetAlert Swal.fire({ title: "Success!", text: response.message, icon: "success", confirmButtonText: "OK", confirmButtonColor: "#28a745" }); // update lable text if (isChecked) { checkbox.nextElementSibling.querySelector('span').innerText = 'Mark as Incomplete'; } else { checkbox.nextElementSibling.querySelector('span').innerText = 'Mark as Completed'; } } else { // If there is an error, revert the checkbox state checkbox.checked = !isChecked; // Display error SweetAlert Swal.fire({ title: "Error", text: response.message, icon: "error", confirmButtonText: "OK", confirmButtonColor: "#dc3545" }); } }, error: function() { // Handle errors and revert the checkbox state checkbox.checked = !isChecked; // Display generic error SweetAlert Swal.fire({ title: "Error", text: "An error occurred while processing your request.", icon: "error", confirmButtonText: "OK", confirmButtonColor: "#dc3545" }); } }); } // Intersection Observer to check chapter visibility document.addEventListener("DOMContentLoaded", function() { const isBot = /bot|googlebot|crawler|spider|robot|crawling/i.test(navigator.userAgent); if (isBot) { return; } // Select all chapters const chapters = document.querySelectorAll(".chapter-section"); // Create observer let observer = new IntersectionObserver((entries, obs) => { entries.forEach(entry => { if (entry.isIntersecting) { const chapterId = entry.target.getAttribute("id").split("-")[1]; const checkbox = document.getElementById(`is-completed-${chapterId}`); // ✅ call backend to check completion fetch(`/check-progress/subject/${chapterId}`) .then(res => res.json()) .then(data => { if (data.success) { if (checkbox) { checkbox.checked = data.completed; // backend truth } } }) .catch(err => console.error("Error checking progress:", err)); // Unobserve after first trigger obs.unobserve(entry.target); } }); }, { threshold: 0.6 }); // 60% visible // Observe all chapter sections chapters.forEach(chapter => { observer.observe(chapter); }); }); </script> <script> document.addEventListener("DOMContentLoaded", function() { const searchInput = document.getElementById("myInput"); const menu = document.getElementById("leftmenu"); searchInput.addEventListener("keyup", function() { const filter = searchInput.value.toLowerCase().trim(); const items = menu.querySelectorAll("a"); // all sidebar links if (filter === "") { // Reset: show all when empty items.forEach(item => { item.style.display = "flex"; }); return; } items.forEach(item => { const text = item.textContent.toLowerCase(); if (text.includes(filter)) { // Show matched item item.style.setProperty("display", "flex", "important"); // Show all parent <a> if any let parent = item.parentElement; while (parent && parent !== menu) { const parentLink = parent.previousElementSibling; if (parentLink && parentLink.tagName === "A") { parentLink.style.setProperty("display", "flex", "important"); } parent = parent.parentElement; } } else { item.style.setProperty("display", "none", "important"); } }); }); }); </script> <script> $(document).ready(function() { var dropdownLoaded = false; function loadDropdown() { if (dropdownLoaded) return; $.ajax({ url: "https://sattacademy.com/profile/dropdown", method: 'GET', beforeSend: function() { $('#header-dropdown-profile').html( '<div class="skeleton-c9ay7k6i5vw my-3"></div>' ); }, success: function(data) { dropdownLoaded = true; $('#header-dropdown-profile').html(data); }, error: function(xhr) { console.error(xhr.responseText); } }); } // Preload on hover $('#header-dropdown').on('mouseenter', loadDropdown); // Fallback: load on click if hover didn’t trigger $('#header-dropdown').on('click', loadDropdown); }); </script> <script type="text/javascript"> //Newsletter Subscriber $(document).on('click', '#kk_newsletter_subscriber', function(e) { e.preventDefault() //console.log('here') $('.with-errors').text('') var thisaddbtn = $(this); var email = $('input[name=email]').val(); // console.log(email); $.ajax({ type: "POST", url: "https://sattacademy.com/newsletter-subscriber/store", data: { "_token": "B0PHBRUcLPgnarRswzyGUVj9lpzF9AjrcABds5tb", email: email, }, dataType: "json", success: function(data) { if (data.success == false || data.success == "false") { var arr = Object.keys(data.errors); var arr_val = Object.values(data.errors); for (var i = 0; i < arr.length; i++) { $('.' + arr[i] + '-error').text(arr_val[i][0]) } } else if (data.error || data.error == 'true') { var alertBox = '<div class="alert alert-danger" alert-dismissable">' + data .message + '</div>'; $('#kk_modal_new_question_form').find('.messages').html(alertBox).show(); } else { toastr.success(data.message); $("#subscriber_email").val(''); } } }); }) </script> <!--end::Javascript--> <div class="page-spinner-wrapper" style="display: none" id="page-spinner"> <div class="spinner-grow" style="width: 3rem; height: 3rem;" role="status"></div> </div> <style> .chat-icon { position: fixed; bottom: 20px; right: 20px; width: 50px; height: 50px; background-color: #007bff; border-radius: 50%; display: flex; justify-content: center; align-items: center; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); cursor: pointer; z-index: 99; transition: all 0.3s ease; } .chat-icon:hover { transform: scale(1.05); box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3); } .chat-icon svg { width: 25px; height: 25px; fill: #fff; } /* Dark mode chat icon */ html[data-theme="dark"] .chat-icon { background-color: #0d6efd; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4); } html[data-theme="dark"] .chat-icon:hover { box-shadow: 0 6px 12px rgba(0, 0, 0, 0.6); } .chatbox { position: fixed; bottom: 90px; right: 20px; width: min(450px, 90%); max-height: 80svh; background-color: #ffffff; border-radius: 10px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2); display: none; flex-direction: column; overflow: hidden; z-index: 111; transition: all 0.3s ease; } .chatbox a { color: #217aff !important; } .chatbox a:hover { color: #0041ce !important; text-decoration: underline !important; } html[data-theme="dark"] .chatbox a { color: #138dff !important; } html[data-theme="dark"] .chatbox a:hover { color: #31b3ff !important; text-decoration: underline !important; } .chatbox[data-open="true"] { display: flex; } /* Dark mode chatbox */ html[data-theme="dark"] .chatbox { background-color: #1a1a1a; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6); border: 1px solid #333; } .chatbox-header { background-color: #007bff; color: #ffffff; padding: 15px; border-top-left-radius: 10px; border-top-right-radius: 10px; font-weight: bold; display: flex; align-items: center; justify-content: space-between; } .chatbox-header svg { width: 20px; height: 20px; fill: #fff; cursor: pointer; transition: opacity 0.2s ease; } .chatbox-header svg:hover { opacity: 0.8; } /* Dark mode header */ html[data-theme="dark"] .chatbox-header { background-color: #0d6efd; border-bottom: 1px solid #333; } .chatbox-body { padding: 10px; overflow-y: auto; background-color: #f4f4f9; display: flex; flex-direction: column; flex: 1; min-height: 200px; } /* Dark mode body */ html[data-theme="dark"] .chatbox-body { background-color: #1a1a1a; color: #e0e0e0; } .chatbox-footer { display: flex; padding: 10px; border-top: 1px solid #ddd; background-color: #fff; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; } /* Dark mode footer */ html[data-theme="dark"] .chatbox-footer { background-color: #222; border-top: 1px solid #444; } .chatbox-footer input { flex: 1; padding: 10px; border: 1px solid #ddd; border-radius: 20px; outline: none; margin-right: 10px; min-width: 0; background-color: #fff; color: #333; transition: all 0.2s ease; } .chatbox-footer input:focus { border-color: #007bff; box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1); } /* Dark mode input */ html[data-theme="dark"] .chatbox-footer input { background-color: #333; border-color: #555; color: #e0e0e0; } html[data-theme="dark"] .chatbox-footer input::placeholder { color: #999; } html[data-theme="dark"] .chatbox-footer input:focus { border-color: #0d6efd; box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.2); } .chatbox-footer button { padding: 10px 15px; background-color: #007bff; color: white; border: none; border-radius: 20px; cursor: pointer; transition: background-color 0.2s ease; white-space: nowrap; } .chatbox-footer button:hover { background-color: #0056b3; } .sample-message { cursor: pointer; border: 1px solid #ccc; border-radius: 10px; padding: 8px; margin: 5px; transition: border-color 0.2s ease; } .sample-message:hover { border: 1px solid #007bff; } html[data-theme="dark"] .sample-message { border: 1px solid #666; } html[data-theme="dark"] .sample-message:hover { border: 1px solid #0d6efd; } /* Dark mode send button */ html[data-theme="dark"] .chatbox-footer button { background-color: #0d6efd; } html[data-theme="dark"] .chatbox-footer button:hover { background-color: #0b5ed7; } .message { margin: 5px 0; max-width: 80%; display: flex; overflow-wrap: break-word; flex-direction: column; animation: fadeInUp 0.3s ease; } @keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } .message.user { align-self: flex-end; } .message.assistant { align-self: flex-start; } .message .time { font-size: 10px; color: #666; margin-top: 5px; } .message.user .time { text-align: right; } /* Dark mode time */ html[data-theme="dark"] .message .time { color: #999; } .message-box { padding: 10px; border-radius: 10px; position: relative; } .message-box.user { background-color: #007bff; color: #fff; } .message-box.assistant { background-color: #ebe6e6; overflow-x: auto; } .message-box.assistant p { color: #111 !important; } .message-box.assistant p:last-child { margin-bottom: 0; } /* Dark mode message boxes */ html[data-theme="dark"] .message-box.user { background-color: #0d6efd; } html[data-theme="dark"] .message-box.assistant { background-color: #2d2d2d; border: 1px solid #444; } html[data-theme="dark"] .message-box.assistant p { color: #e0e0e0 !important; } .typing { font-style: italic; color: #aaa; margin-top: 1rem; } /* Dark mode typing indicator */ html[data-theme="dark"] .typing { color: #666; } .start-over-confirmation-wrapper { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(255, 255, 255, 0.5); backdrop-filter: blur(3px); display: flex; justify-content: center; align-items: center; } /* Dark mode confirmation wrapper */ html[data-theme="dark"] .start-over-confirmation-wrapper { background-color: rgba(0, 0, 0, 0.7); } .start-over-confirmation { background-color: #f8f6f8; padding: 20px; border: 1px solid #f0b3f2; border-radius: 10px; width: 85%; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); } .start-over-confirmation p { color: #111 !important; margin-bottom: 15px; font-weight: 500; } /* Dark mode confirmation dialog */ html[data-theme="dark"] .start-over-confirmation { background-color: #2d2d2d; border-color: #555; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); } html[data-theme="dark"] .start-over-confirmation p { color: #e0e0e0 !important; } /* Button styles */ .btn { padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.2s ease; margin: 0 5px; } .btn-sm { padding: 6px 12px; font-size: 12px; } .btn-danger { background-color: #dc3545; color: white; } .btn-danger:hover { background-color: #c82333; } .btn-secondary { background-color: #6c757d; color: white; } .btn-secondary:hover { background-color: #5a6268; } /* Dark mode buttons */ html[data-theme="dark"] .btn-danger { background-color: #dc3545; } html[data-theme="dark"] .btn-danger:hover { background-color: #bb2d3b; } html[data-theme="dark"] .btn-secondary { background-color: #495057; } html[data-theme="dark"] .btn-secondary:hover { background-color: #3d4146; } /* Empty conversation text */ .text-muted { color: #6c757d; } html[data-theme="dark"] .text-muted { color: #999; } .text-center { text-align: center; } .py-3 { padding-top: 1rem; padding-bottom: 1rem; } /* Utility classes */ .m-0 { margin: 0; } .fs-3 { font-size: 1.25rem; } .text-white { color: white; } .d-flex { display: flex; } .gap-2 { gap: 0.5rem; } /* Scrollbar styling */ .chatbox-body::-webkit-scrollbar { width: 6px; } .chatbox-body::-webkit-scrollbar-track { background: transparent; } .chatbox-body::-webkit-scrollbar-thumb { background-color: #ccc; border-radius: 3px; } .chatbox-body::-webkit-scrollbar-thumb:hover { background-color: #999; } /* Dark mode scrollbar */ html[data-theme="dark"] .chatbox-body::-webkit-scrollbar-thumb { background-color: #555; } html[data-theme="dark"] .chatbox-body::-webkit-scrollbar-thumb:hover { background-color: #777; } /* Hide elements with x-cloak */ [x-cloak] { display: none !important; } .chat-tooltip { opacity: 0; position: absolute; bottom: 70px; right: 0; background: #00aaff; color: white; padding: 8px 12px; border-radius: 10px; animation: fadeInOut 8s ease-in-out forwards; animation-delay: 2s; width: max-content; } @keyframes fadeInOut { 0% { opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } } </style> <script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML"></script> <div id="chatbox" x-data="{ isOpen: false, newMessage: '', messages: [], isTyping: false, loading: false, botResponsePaused: false, interval: null, showStartOverConfirmation: false, chatSessionUuid: null, sampleMessages: [ 'স্যাট একাডেমি কী?', 'স্যাট একাডেমিতে কি কি ফিচার আছে?', 'আমি কীভাবে একটি প্যাকেজ কিনতে পারি?', 'আমি কীভাবে স্যাট একাডেমির সঙ্গে যোগাযোগ করতে পারি?', ], isUserLoggedIn: false, chatboxShown: false, init() { this.chatboxShown = localStorage.getItem('chatbox_shown') === 'true'; }, toggleChatbox() { this.isOpen = !this.isOpen; if (this.isOpen) { this.loadChatHistory(); // Refresh the chat history every 5 seconds and clear the interval when the chatbox is closed } else { } }, sendMessage() { if (this.newMessage.trim() === '') return; // Current page title and URL const pageTitle = document.title; const pageUrl = window.location.href; const userMessage = { role: 'user', content: this.newMessage.replace(/<\/?[^>]+(>|$)/g, ''), time: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }) }; this.messages.push(userMessage); this.newMessage = ''; this.isTyping = this.botResponsePaused ? false : true; setTimeout(() => { this.scrollToBottom(); }, 100); if (!this.isUserLoggedIn) { setTimeout(() => { this.messages.push({ role: 'assistant', content: `You are not logged in. Please <a href='/login'>login</a> to chat with me.`, time: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }) }); this.isTyping = false; this.scrollToBottom(); }, 1000); return; } let that = this; $.ajax({ url: '/chatbot', type: 'POST', data: { chatSessionUuid: that.chatSessionUuid, message: userMessage.content, pageTitle: pageTitle, pageUrl: pageUrl, botResponsePaused: that.botResponsePaused }, headers: { 'X-CSRF-TOKEN': $('meta[name=csrf-token]').attr('content') }, success: function(response) { if (response.responseText) { const botMessage = { role: 'assistant', content: response.responseText, time: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }) }; that.messages.push(botMessage); setTimeout(() => { MathJax.Hub.Typeset(); }, 300); } }, complete: function() { that.isTyping = false; that.scrollToBottom(); } }); }, loadChatHistory() { // Fetch the chat history from the server let that = this; $.ajax({ url: '/chatbot/history', type: 'GET', headers: { 'X-CSRF-TOKEN': $('meta[name=csrf-token]').attr('content') }, beforeSend: function() { that.loading = true; }, success: function(response) { // console.log(response); that.botResponsePaused = response.botResponsePaused; that.messages = response.chatHistory; that.chatSessionUuid = response.chatSessionUuid; setTimeout(() => { MathJax.Hub.Typeset(); }, 300); }, complete: function() { that.loading = false; that.scrollToBottom(); } }) }, scrollToBottom() { this.$nextTick(() => { const chatBody = this.$refs.chatBody; if (chatBody) { chatBody.scrollTop = chatBody.scrollHeight; } }); }, toggleStartOverConfirmation() { this.showStartOverConfirmation = !this.showStartOverConfirmation; }, startOver() { let that = this; that.messages = []; that.showStartOverConfirmation = false; $.ajax({ url: '/chatbot/clear', type: 'POST', headers: { 'X-CSRF-TOKEN': $('meta[name=csrf-token]').attr('content') }, data: { chatSessionUuid: that.chatSessionUuid }, success: function(response) { // console.log(response); } }); } }"> <div class="chat-icon" @click="toggleChatbox"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <path d="M12 2C6.48 2 2 6.48 2 12c0 3.25 1.54 6.15 3.96 8.04V22l3.71-1.85C10.44 20.59 11.21 20.7 12 20.7c5.52 0 10-4.48 10-10S17.52 2 12 2zm-1 14H8v-2h3v2zm5-4H8V8h8v4z" /> </svg> </div> <div class="chatbox" x-show="isOpen" data-open="true" x-cloak> <div class="chatbox-header p-5"> <h4 class="m-0 fs-3 text-white"> <a href="/satt-ai" style="font-weight: semibold; color: white !important;"> Satt AI <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="ms-1 inline-block" style="width: 16px;"> <path stroke-linecap="round" stroke-linejoin="round" d="m4.5 19.5 15-15m0 0H8.25m11.25 0v11.25" /> </svg> </a> </h4> <div class="d-flex gap-2"> <button type="button" style="background: none; border: none; padding: 0;" @click="toggleStartOverConfirmation" title="Start over" x-show="messages.length > 0 && !showStartOverConfirmation" x-cloak> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <path d="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.41 3.59 8 8 8s8-3.59 8-8-3.59-8-8-8z" /> </svg> </button> <button type="button" style="background: none; border: none; padding: 0;" @click="toggleChatbox" title="Close"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <path d="M18.3 5.71L12 12.01l-6.3-6.3-1.4 1.42L12 14.83l7.7-7.7z" /> </svg> </button> </div> </div> <div style="position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0;"> <div class="chatbox-body" x-ref="chatBody" :style="messages.length == 0 ? 'justify-content: center' : ''"> <template x-if="messages.length === 0"> <div class="py-4 px-3" x-ref="emptyConversationText"> <h5 class="mb-5 text-center fs-4">Hi, আমি <span class="text-primary">SATT AI</span>!</h5> <p class="mb-1 mt-8">আপনি আমাকে যেকোনো প্রশ্ন করতে পারেন, যেমনঃ</p> <ul class="list-unstyled d-inline-block text-start mx-auto" style="max-width: 320px;"> <template x-for="message in sampleMessages"> <li class="sample-message" x-text="message" @click="newMessage = message; sendMessage();"></li> </template> </ul> </div> </template> <template x-for="(message, index) in messages" :key="index"> <div :class="['message', message.role]"> <span class="time" x-text="message.time"></span> <div class="message-box" :class="message.role" x-html="message.content"></div> </div> </template> <div x-show="isTyping" class="message bot typing"> <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"> <path fill="currentColor" d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z" /> <circle cx="16" cy="10" r="0" fill="currentColor"> <animate attributeName="r" begin=".67" calcMode="spline" dur="1.5s" keySplines="0.2 0.2 0.4 0.8;0.2 0.2 0.4 0.8;0.2 0.2 0.4 0.8" repeatCount="indefinite" values="0;1.75;0;0" /> </circle> <circle cx="12" cy="10" r="0" fill="currentColor"> <animate attributeName="r" begin=".33" calcMode="spline" dur="1.5s" keySplines="0.2 0.2 0.4 0.8;0.2 0.2 0.4 0.8;0.2 0.2 0.4 0.8" repeatCount="indefinite" values="0;1.75;0;0" /> </circle> <circle cx="8" cy="10" r="0" fill="currentColor"> <animate attributeName="r" begin="0" calcMode="spline" dur="1.5s" keySplines="0.2 0.2 0.4 0.8;0.2 0.2 0.4 0.8;0.2 0.2 0.4 0.8" repeatCount="indefinite" values="0;1.75;0;0" /> </circle> </svg> </div> </div> <div class="start-over-confirmation-wrapper" x-show="showStartOverConfirmation || loading" x-cloak> <div class="start-over-confirmation" x-show="showStartOverConfirmation" x-cloak> <div class="text-center py-3"> <p>Are you sure to start over?</p> <button type="button" class="btn btn-sm btn-danger" @click="startOver">Yes</button> <button type="button" class="btn btn-sm btn-secondary" @click="showStartOverConfirmation = false">No</button> </div> </div> <div class="spinner-border text-primary" role="status" x-show="loading" x-cloak> <span class="visually-hidden">Loading...</span> </div> </div> </div> <div class="chatbox-footer"> <input class="message-input" type="text" x-model="newMessage" placeholder="Type a message..." @keydown.enter="sendMessage" :disabled="isTyping || loading"> <button class="send-button" @click="sendMessage">Send</button> </div> </div> </div> <i class="fas fa-angle-up back_to_top_btn"></i> <script> document.querySelector('.light-dark-btn').addEventListener('click', toggleTheme); let mobileSidebar = document.getElementById('mobile-sidebar'); function toggleTheme() { const currentTheme = document.documentElement.getAttribute('data-theme'); const newTheme = currentTheme === 'light' ? 'dark' : 'light'; document.documentElement.setAttribute('data-theme', newTheme); document.documentElement.classList.remove(currentTheme); document.documentElement.classList.add(newTheme); localStorage.setItem('theme', newTheme); } function toggleMobileSidebar() { if (!mobileSidebar) { return; } if (mobileSidebar.classList.contains('open')) { mobileSidebar.classList.remove('open'); } else { mobileSidebar.classList.add('open'); } } // Close sidebar on click outside document.addEventListener('click', function(event) { let toggleButton = document.getElementById('kt_aside_mobile_toggle'); if (!mobileSidebar) { return; } if (!mobileSidebar.contains(event.target) && !toggleButton.contains(event.target)) { mobileSidebar.classList.remove('open'); } }); </script> <script src="https://sattacademy.com/assets/js/custom/bengalitoenglishinput.js"></script> <script src="https://www.meanthemes.com/demo/meanmenu/jquery.meanmenu.js"></script> <script> jQuery(document).ready(function() { jQuery('.st-header-menu nav').meanmenu({ meanMenuContainer: '.mobile-menu', meanScreenWidth: '1200', }); }); $('.sa_aside_mobile_toggle').click(function() { $('#mobileSidebarOffcanvas').offcanvas('show'); // $('.menu-sidebar').addClass('active'); // $('.body-overlay').addClass('active'); }); $('.body-overlay, .mobile-menu-close').click(function() { $('#mobileSidebarOffcanvas').offcanvas('hide'); // $('.menu-sidebar').removeClass('active'); // $('.body-overlay').removeClass('active'); }); // back to top var $backToTop = $(".back_to_top_btn"); $(window).on('scroll', function() { if ($(this).scrollTop() > 200) { $backToTop.css({ 'bottom': '7rem', 'right': '2.5rem' }); } else { $backToTop.css({ 'bottom': '-100px', 'right': '2.5rem' }); } }); $backToTop.on('click', function(e) { $("html, body").animate({ scrollTop: 0 }, 500); }); // $('.select2').select2(); </script> <script> function viewNotificationDetails(e, el) { e.preventDefault(); let id = $(el).data('id'); $('#notification_item_modal').modal('show'); $.ajax({ url: 'https://sattacademy.com/notifications' + '/' + id + '/details', type: 'GET', beforeSend: function() { $('#notification-details-loader').removeClass('d-none'); $('.notification-media').addClass('d-none'); $('.notification-action').addClass('d-none'); }, success: function(notification) { let time = new Date(notification.created_at).toLocaleString(); // console.log(notification.data); $('#notification-details-loader').addClass('d-none'); $('.notification-media').removeClass('d-none'); $('#notification-title').text(notification.data.title); $('#notification-body').html(notification.data.body); $('#notification-time').text(time); if (notification.data.avatar) { $('#notification-avatar').attr('src', notification.data.avatar); } if (notification.data.action) { $('.notification-action').removeClass('d-none'); $('.notification-action').text(notification.data.action.text || 'Check it out'); $('.notification-action').attr('href', notification.data.action.url); } $(el).removeClass('unread'); // Fire a custom event window.dispatchEvent(new CustomEvent('notification-read', { detail: { id: id } })); } }); } $(document).ready(function() { // Remove google ad intent info banner setTimeout(() => { let allDivs = document.querySelectorAll('div'); allDivs.forEach((el) => { if (el.shadowRoot) { // console.log(el); el.shadowRoot.querySelector('.ipr-container').style.display = 'none'; } }); }, 3000); const isBot = /bot|googlebot|crawler|spider|robot|crawling/i.test(navigator.userAgent); if(isBot) { return; } // Track user online presence axios.post('/update-presence'); }); window.addEventListener('completionToggled', function(e) { let isCompleted = e.detail[0]; toastr.success(isCompleted ? 'Marked as Read!' : 'Marked as Unread!'); }); </script> <script type="text/javascript"> // Apply Copy limit document.addEventListener('DOMContentLoaded', () => { const dailyCopyLimit = 50; // Daily copy limit const copyCountKey = 'dcc'; // Daily copy count key const lastResetKey = 'dcc_lrt'; // Last reset time key // Helper function to reset the copy count daily const resetCopyCountIfNeeded = () => { const now = new Date(); const today = now.toISOString().split('T')[0]; // Get today's date in YYYY-MM-DD format const lastReset = localStorage.getItem(lastResetKey); if (lastReset !== today) { localStorage.setItem(copyCountKey, 0); // Reset count localStorage.setItem(lastResetKey, today); // Update reset time } }; resetCopyCountIfNeeded(); // Copy event listener document.addEventListener('copy', (e) => { e.preventDefault(); const selection = document.getSelection(); if (selection.toString().length === 0) { return; } let currentCount = parseInt(localStorage.getItem(copyCountKey)) || 0; if (currentCount >= dailyCopyLimit) { Swal.fire({ icon: 'error', title: 'Copy Limit Exceeded', text: `You have reached the daily copy limit of ${dailyCopyLimit}. Please come back tomorrow!`, }); return; } // Append additional text to copied content const additionalText = "\n\nCopied from SATT ACADEMY. Visit us at: https://sattacademy.com"; const modifiedText = selection + additionalText; e.clipboardData.setData('text/plain', modifiedText); // Increment copy count currentCount++; localStorage.setItem(copyCountKey, currentCount); if (currentCount % 10 === 0) { alert( `You have used ${currentCount} out of ${dailyCopyLimit} copies available today.` ); } }); }); </script> <!--Start of Tawk.to Script--> <!--End of Tawk.to Script--> <script src="https://sattacademy.com/js/fob.js"></script> <!-- Global Loader --> <style> @media (min-width: 1024px) { #global-loader-container { display: none !important; } } </style> <div id="global-loader-container" style="position: fixed; top: 0; left: 0; width: 100%; height: 2px; z-index: 9999; pointer-events: none;"> <div id="global-loader-bar" style="height: 100%; width: 0%; background: linear-gradient(90deg, #2563eb, #22d3ee, #2563eb); transition: width 300ms ease-out, opacity 200ms linear; opacity: 0; position: relative;"> <div style="position: absolute; right: 0; top: 0; height: 100%; width: 100px; box-shadow: 0 0 10px #22d3ee, 0 0 5px #22d3ee; opacity: 1;"></div> </div> </div> <script> (function() { var loaderBar = document.getElementById('global-loader-bar'); var interval = null; var currentProgress = 0; function startLoader() { if (interval) clearInterval(interval); // Reset loaderBar.style.width = '0%'; loaderBar.style.opacity = '1'; loaderBar.style.transitionDuration = '0ms'; currentProgress = 0; setTimeout(function() { loaderBar.style.transitionDuration = '300ms'; currentProgress = 10; loaderBar.style.width = '10%'; interval = setInterval(function() { if (currentProgress < 90) { var amount = Math.random() * (90 - currentProgress) * 0.1; currentProgress += Math.max(0.5, amount); loaderBar.style.width = currentProgress + '%'; } }, 300); }, 20); } function stopLoader() { if (interval) clearInterval(interval); interval = null; loaderBar.style.transitionDuration = '200ms'; loaderBar.style.width = '100%'; setTimeout(function() { loaderBar.style.opacity = '0'; setTimeout(function() { loaderBar.style.width = '0%'; }, 300); }, 300); } document.addEventListener('click', function(e) { var link = e.target.closest('a'); if (link && link.href && link.target !== '_blank' && !link.hasAttribute('download') && link.hostname === window.location.hostname) { if (link.href.indexOf('#') !== -1 || link.href.startsWith('javascript:') || link.href.startsWith('mailto:') || link.href.startsWith('tel:')) return; if (!e.defaultPrevented) { startLoader(); } } }); // If page is restored from bfcache (back/forward cache), hide loader window.addEventListener('pageshow', function(event) { if (event.persisted) { stopLoader(); } }); // Standard load event to ensure it's hidden on fresh load window.addEventListener('load', function() { // Initially ensure hidden loaderBar.style.opacity = '0'; loaderBar.style.width = '0%'; }); })(); </script> </body> </html>