Make use of enforce_default_text function (#203)
This commit is contained in:
1 parent
e2e22c5dc7
commit
1b490c48f1
1 file changed
+9
-21
@@ -3,6 +3,14 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
{% load mytags %}
|
{% load mytags %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
<script src="{% static 'default_text.js' %}?{{ static_version }}"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
enforce_default_text('new-engine-repo', 'https://github.com/');
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<form method="POST" action="/profile/">
|
<form method="POST" action="/profile/">
|
||||||
@@ -66,27 +74,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<input id="new-engine-repo" name="new-engine-repo" placeholder="https://github.com/">
|
<input id="new-engine-repo" name="new-engine-repo" value="https://github.com/">
|
||||||
<script>
|
|
||||||
window.addEventListener('DOMContentLoaded', function(){
|
|
||||||
var textField = document.getElementById("new-engine-repo");
|
|
||||||
var defaultText = "https://github.com/";
|
|
||||||
|
|
||||||
textField.value = defaultText;
|
|
||||||
|
|
||||||
textField.addEventListener('input', function(){
|
|
||||||
if (!textField.value.startsWith(defaultText)){
|
|
||||||
if (textField.value !== defaultText){
|
|
||||||
if (textField.value.endsWith('/')) {
|
|
||||||
textField.value = defaultText + textField.value.substr(defaultText.length).replace(/\/+$/, '');
|
|
||||||
} else {
|
|
||||||
textField.value = defaultText + textField.value.substr(defaultText.length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="hidden" name="deleted-repos" id="deleted-repos" value="[]">
|
<input type="hidden" name="deleted-repos" id="deleted-repos" value="[]">
|
||||||
|
|||||||
Reference in new issue
Block a user