A Minimalistic and Privary-by-default URL sortener
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

56 lines
1.9 KiB

{% extends "base.html" %}
{% block script %}
<script>
function isURL(str) {
try {
new URL(str)
return true;
} catch(e) {
return false;
}
}
function run() {
journalmarks_loadkey().catch(function() {
deleteKey();
window.location.href = '{{ url_for('journalmarks.login') }}';
});
document.getElementById('create').addEventListener('click', function() {
var url = document.getElementById('url').value;
if(isURL(url)) {
journalmarks_encrypturl(url).then(function (encurl) {
return post_object('{{ url_for('journalmarks.create') }}', {content: encurl});
}).then(function(tag) {
console.log('ok', tag);
});
} else if(url.match(/^[a-z0-9]{4}$/)) {
window.location.href = '/' + url;
} else {
console.log('not a URL and not a tag');
}
});
document.getElementById('url').addEventListener('keyup', function(e) {
if(e.keyCode == 13)
document.getElementById('create').click();
});
}
if (document.readyState!='loading') run();
else if (document.addEventListener) document.addEventListener('DOMContentLoaded', run);
else document.attachEvent('onreadystatechange', function(){
if (document.readyState=='complete') run();
});
</script>
{% endblock %}
{% block body %}
<h1>Welcome!</h1>
<p>You can now create a new Journalmark by simply pasting a URL into the text field. To access an existing Journalmark, enter its tag code. There's also a listing of all your Journalmarks on the <a href="{{ url_for('journalmarks.overview') }}">overview page</a>. Finally, you can also <a href="{{ url_for('journalmarks.logout') }}">logout</a> again.
</p>
<form class="pure-form">
<input id="url" type="text" placeholder="URL or Journalmark tag">
<button id="create" class="pure-button pure-button-primary">Go</button>
</form>
{% endblock %}