Skip to content

Commit

Permalink
quality of life improvements to UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ilude committed Mar 25, 2024
1 parent 52d9551 commit c91a8c4
Showing 1 changed file with 33 additions and 21 deletions.
54 changes: 33 additions & 21 deletions app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,39 @@
<link rel="stylesheet" href="{{ url_for('static', filename='css/index.css') }}">
<script>
$(document).ready(function () {
$('#expandForm').submit(function (event) {
event.preventDefault();
var userUrl = $('#urlInput').val();
$('#expandBtn').prop('disabled', true);
$('#spinner').show();
$('#expandedUrl').empty();
$('#screenshot').hide().empty();
$.ajax({
type: 'POST',
url: '/',
data: { url: userUrl },
success: function (response) {
$('#expandedUrl').append($('<a>').attr('href', response).text(response));
$('#screenshot').append($('<a>').attr('href', response).append($('<img>').attr('src', "{{ url_for('static', filename='screenshots/screenshot.png') }}"))).show();
},
complete: function () {
$('#spinner').hide();
$('#expandBtn').prop('disabled', false);
}
});
$('#expandForm').submit(function (event) {
event.preventDefault();
var userUrl = $('#urlInput').val();
$('#expandBtn').prop('disabled', true);
$('#spinner').show();
$('#expandedUrl').empty();
$('#screenshot').hide().empty();
$.ajax({
type: 'POST',
url: '/',
data: { url: userUrl },
success: function (response) {
$('#expandedUrl').append(
$('<a>').attr('href', response).text(response)
).show();
$('#screenshot').append(
$('<a>').attr('href', response).append($('<img>').attr('src',
"{{ url_for('static', filename='screenshots/screenshot.png') }}"
))
).show();
},
complete: function () {
$('#spinner').hide();
$('#expandBtn').prop('disabled', false);
}
});
});
$('input').on('focus', function (e) {
$(this).one('mouseup', function () {
$(this).select();
return false;
}).select();
});
});
</script>
</head>
Expand All @@ -42,7 +54,7 @@ <h1 class="mb-0">OnGoing URL Expander</h1>
<div class="card-body">
<form id="expandForm">
<div class="input-group mb-3">
<input type="text" class="form-control" id="urlInput" value="{{ url }}" placeholder="Enter a URL" />
<input type="text" class="form-control" id="urlInput" value="{{ url }}" placeholder="Enter a URL" onFocus="this.select()" autofocus />
<button type="submit" class="btn btn-primary" id="expandBtn">
Expand
</button>
Expand Down

0 comments on commit c91a8c4

Please sign in to comment.