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(function(position) {
32 location_input.value = position.coords.latitude + ', ' + position.coords.longitude;
33 updateLocationButtonDisplay(location_button, location_input);
35 location_button.disabled = true;
36 updateLocationButtonDisplay(location_button, location_input);
43 function updateLocationButtonDisplay(location_button, location_input)
45 location_button.classList.remove('btn-primary');
46 if (location_input.value) {
47 location_button.disabled = false;
48 location_button.classList.add('btn-primary');
49 location_button.title = location_button.dataset.titleClear;
50 } else if (!"geolocation" in navigator) {
51 location_button.disabled = true;
52 location_button.title = location_button.dataset.titleUnavailable;
53 } else if (location_button.disabled) {
54 location_button.title = location_button.dataset.titleDisabled;
56 location_button.title = location_button.dataset.titleSet;