|
|
- {% extends "bootstrap/base.html" %}
- {% block title %}tia.paste{% endblock %}
-
- {% block styles %}
- {{super()}}
- <link rel="stylesheet" href="{{url_for('.static', filename='style.css')}}">
- {% endblock %}
-
- {% block navbar %}
- {% include "fragments/navbar.j2" %}
- {% endblock %}
-
- {% block content %}
- <iframe id="apps" src="https://technicalincompetence.club/frame" width="305" height="400" class="shadow-lg overlay-frame" style="display: none;"></iframe>
- <div id="overlay" style="display: none;" onclick="showApps();"></div>
- <div class="container" style="margin-top: 15px">
- <div id="success-alert" class="alert alert-success" role="alert" style="display: none;">
- This is a success alert—check it out!
- </div>
- <div id="error-alert" class="alert alert-danger" role="alert" style="display: none;">
- This is a danger alert—check it out!
- </div>
- <form>
- <div class="row justify-content-center">
- <div class="col-lg-12">
- <label for="formGroupExampleInput4">Enter a link to shorten:</label>
- <input id="link-form" type="text" class="form-control" placeholder="https://example.com">
- <br>
- <button type="button" class="btn btn-primary" onclick="shortenUrl();">Shorten Link</button>
- <br>
- </div>
- </div>
- </form>
- </div>
- {% endblock %}
-
- {% block scripts %}
- {{ super() }}
- <script>
- function shortenUrl() {
- url = $('#link-form').val();
-
- if (url.trim().length === 0) {
- showError('URL is required');
- return false;
- }
-
- $.ajax({
- url: '/shorten',
- method: 'POST',
- data: { "url": url },
- success: function(data) {
- if (data !== 'Error')
- showSuccess(data);
- else
- showError('URL cannot be empty');
- }
- });
- }
-
- function showError(error) {
- hideSuccess();
- $('#error-alert').text(error);
- $('#error-alert').show();
- }
-
- function showSuccess(message) {
- hideError();
- $('#success-alert').html(message);
- $('#success-alert').show();
- }
-
- function hideError(error) {
- $('#error-alert').hide();
- }
-
- function hideSuccess(error) {
- $('#success-alert').hide();
- }
-
- function showApps () {
- $("#apps").toggle();
- $("#overlay").toggle();
- }
- </script>
- {% endblock %}
|