1 // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later
3 // Jot attachment live preview.
4 let $textarea = $("textarea[name=body]");
5 $textarea.linkPreview();
6 $textarea.keyup(function () {
7 var textlen = $(this).val().length;
8 $("#character-counter").text(textlen);
10 $textarea.editor_autocomplete(baseurl + "/search/acl");
11 $textarea.bbco_autocomplete("bbcode");
13 let location_button = document.getElementById("profile-location");
14 let location_input = document.getElementById("jot-location");
16 if (location_button && location_input) {
17 updateLocationButtonDisplay(location_button, location_input);
19 location_input.addEventListener("change", function () {
20 updateLocationButtonDisplay(location_button, location_input);
22 location_input.addEventListener("keyup", function () {
23 updateLocationButtonDisplay(location_button, location_input);
26 location_button.addEventListener("click", function () {
27 if (location_input.value) {
28 location_input.value = "";
29 updateLocationButtonDisplay(location_button, location_input);
30 } else if ("geolocation" in navigator) {
31 navigator.geolocation.getCurrentPosition(
33 location_input.value = position.coords.latitude + ", " + position.coords.longitude;
34 updateLocationButtonDisplay(location_button, location_input);
37 location_button.disabled = true;
38 updateLocationButtonDisplay(location_button, location_input);
46 function updateLocationButtonDisplay(location_button, location_input) {
47 location_button.classList.remove("btn-primary");
48 if (location_input.value) {
49 location_button.disabled = false;
50 location_button.classList.add("btn-primary");
51 location_button.title = location_button.dataset.titleClear;
52 } else if (!"geolocation" in navigator) {
53 location_button.disabled = true;
54 location_button.title = location_button.dataset.titleUnavailable;
55 } else if (location_button.disabled) {
56 location_button.title = location_button.dataset.titleDisabled;
58 location_button.title = location_button.dataset.titleSet;