1 line
1.6 KiB
JavaScript
1 line
1.6 KiB
JavaScript
function save_settings(){var e=$("#ta_language").val();localStorage.setItem("ta_language",e);var t=$("#ta_theme").val();localStorage.setItem("ta_theme",t);var a=$("#ta_font").val();localStorage.setItem("ta_font",a);var l=$("#ta_size").val();localStorage.setItem("ta_size",l),localStorage.setItem("ta_spellcheck",ta_spellcheck.checked),localStorage.setItem("ta_textwrap",ta_textwrap.checked),localStorage.setItem("ta_examples",ta_examples.checked),Toast("Settings saved")}function load_settings(){$("#ta_language").val(localStorage.getItem("ta_language")),$("#ta_theme").val(localStorage.getItem("ta_theme")),$("#ta_font").val(localStorage.getItem("ta_font")),$("#ta_size").val(localStorage.getItem("ta_size"));var e=JSON.parse(localStorage.getItem("ta_spellcheck"));$("#ta_spellcheck").prop("checked",e);var t=JSON.parse(localStorage.getItem("ta_textwrap"));$("#ta_textwrap").prop("checked",t);var a=JSON.parse(localStorage.getItem("ta_examples"));$("#ta_examples").prop("checked",a)}function show_default(){$("#ta_language").val("English"),$("#ta_theme").val("Light"),$("#ta_font").val("Roboto"),$("#ta_size").val("15px"),$("#ta_spellcheck").prop("checked",!1),$("#ta_textwrap").prop("checked",!0),$("#ta_examples").prop("checked",!0),Toast("Default settings applied")}$("#save_btn").click(function(){save_settings(),"Dark"==localStorage.getItem("ta_theme")?$("body").addClass("dark"):$("body").removeClass("dark")}),$("#reset_btn").click(function(){default_settings(),show_default(),$("body").removeClass("dark")}),load_settings(),localStorage.getItem("ta_language")||(default_settings(),show_default()); |