string entry
This commit is contained in:
parent
bcab963b99
commit
ce6572b81b
2
app.py
2
app.py
@ -165,7 +165,7 @@ def add_account():
|
||||
return redirect(url_for("user_accounts"))
|
||||
return render_template("add_account.html")
|
||||
|
||||
return render_template("add_account.html", ocr_enabled=app.config.get("OCR_ENABLED"))
|
||||
return render_template("add_account.html", ocr_enabled=app.config.get("OCR_ENABLED"), text_input_enabled=app.config.get("TEXT_INPUT_ENABLED"))
|
||||
|
||||
|
||||
@app.route("/accounts/delete", methods=["POST"])
|
||||
|
@ -88,6 +88,14 @@
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% if text_input_enabled %}
|
||||
<hr>
|
||||
<h2>Load Details Via Text</h2>
|
||||
<div class="form-group">
|
||||
<label for="accountDetails">Paste Account Details</label>
|
||||
<textarea class="form-control" id="accountDetails" rows="4"></textarea>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</main>
|
||||
<footer class="bg-dark text-white text-center py-3 mt-5">
|
||||
@ -108,12 +116,47 @@
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
var streamInput = document.getElementById("stream");
|
||||
var awesomplete;
|
||||
fetch('/get_stream_names')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
new Awesomplete(streamInput, {
|
||||
awesomplete = new Awesomplete(streamInput, {
|
||||
list: data
|
||||
});
|
||||
|
||||
{% if text_input_enabled %}
|
||||
const accountDetailsTextarea = document.getElementById('accountDetails');
|
||||
if (accountDetailsTextarea) {
|
||||
accountDetailsTextarea.addEventListener('input', function() {
|
||||
const text = this.value;
|
||||
const lines = text.split('\n');
|
||||
|
||||
const streamName = lines[0] ? lines[0].trim() : '';
|
||||
const usernameLine = lines.find(line => line.toUpperCase().startsWith('USER:'));
|
||||
const passwordLine = lines.find(line => line.toUpperCase().startsWith('PASS:'));
|
||||
|
||||
if (usernameLine) {
|
||||
document.getElementById('username').value = usernameLine.substring(5).trim();
|
||||
}
|
||||
if (passwordLine) {
|
||||
document.getElementById('password').value = passwordLine.substring(5).trim();
|
||||
}
|
||||
|
||||
if (awesomplete && streamName) {
|
||||
const streamList = awesomplete.list;
|
||||
// Find best match
|
||||
const match = streamList.find(item => item.toLowerCase().includes(streamName.toLowerCase()));
|
||||
if (match) {
|
||||
streamInput.value = match;
|
||||
} else {
|
||||
streamInput.value = streamName;
|
||||
}
|
||||
} else if (streamName) {
|
||||
streamInput.value = streamName;
|
||||
}
|
||||
});
|
||||
}
|
||||
{% endif %}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user