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.
57 lines
1.5 KiB
57 lines
1.5 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('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('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 %} |
|
Welcome! |
|
<p> |
|
<a href="{{ url_for('overview') }}">overview</a> |
|
<a href="{{ url_for('logout') }}">logout</a> |
|
</p> |
|
|
|
<input id="url" type="text"> |
|
<button id="create">ok</button> |
|
|
|
{% endblock %}
|
|
|