python-stdnum branch master updated. 1.7-17-gd5f97e9
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
python-stdnum branch master updated. 1.7-17-gd5f97e9
- From: Commits of the python-stdnum project <python-stdnum-commits [at] lists.arthurdejong.org>
- To: python-stdnum-commits [at] lists.arthurdejong.org
- Reply-to: python-stdnum-users [at] lists.arthurdejong.org
- Subject: python-stdnum branch master updated. 1.7-17-gd5f97e9
- Date: Sun, 26 Nov 2017 22:33:34 +0100 (CET)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-stdnum".
The branch, master has been updated
via d5f97e98150ca9a0fe84d929f7900ce40f015891 (commit)
via f7b46159ce2b3453f7a375217928485079675b25 (commit)
via 7cb114b2dc7e8f6c73c7c8ff7dcb87620859a674 (commit)
from 90067f7efde339a2b03ce79543c762746c498b21 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://arthurdejong.org/git/python-stdnum/commit/?id=d5f97e98150ca9a0fe84d929f7900ce40f015891
commit d5f97e98150ca9a0fe84d929f7900ce40f015891
Author: Arthur de Jong <arthur@arthurdejong.org>
Date: Fri Nov 24 18:08:00 2017 +0100
Change output of online lookups
This puts the number before the number name to make it a little clearer.
diff --git a/online_check/check.js b/online_check/check.js
index fda1175..2e069ad 100644
--- a/online_check/check.js
+++ b/online_check/check.js
@@ -37,10 +37,11 @@ $( document ).ready(function() {
var h = ["<ul>"];
$.each(results, function(index, result) {
h.push(
- "<li><b>",
- $("<div/>").text(result["name"]).html(),
- "</b><br/>",
+ "<li>",
$("<div/>").text(result["number"]).html(),
+ ": <b>",
+ $("<div/>").text(result["name"]).html(),
+ "</b>",
"<p>",
format(result["description"]),
$.map(result["conversions"], function(value, key){
diff --git a/online_check/stdnum.wsgi b/online_check/stdnum.wsgi
index e340d22..6a36e16 100755
--- a/online_check/stdnum.wsgi
+++ b/online_check/stdnum.wsgi
@@ -76,9 +76,9 @@ def format(data):
for name, conversion in data.get('conversions', {}).items():
description += '\n<br/><b><i>%s</i></b>: %s' % (
cgi.escape(name), cgi.escape(conversion))
- return '<li><b>%s</b><br/>%s<p>%s</p></li>' % (
- cgi.escape(data['name']),
+ return '<li>%s: <b>%s</b><p>%s</p></li>' % (
cgi.escape(data['number']),
+ cgi.escape(data['name']),
description)
https://arthurdejong.org/git/python-stdnum/commit/?id=f7b46159ce2b3453f7a375217928485079675b25
commit f7b46159ce2b3453f7a375217928485079675b25
Author: Arthur de Jong <arthur@arthurdejong.org>
Date: Fri Nov 24 17:59:18 2017 +0100
Store online check numbers in history
This updates the browser history with with the numbers that were checked
so that you can easily go back and forth between checked number.
diff --git a/online_check/check.js b/online_check/check.js
index 28528f6..fda1175 100644
--- a/online_check/check.js
+++ b/online_check/check.js
@@ -63,14 +63,31 @@ $( document ).ready(function() {
function checkfield(field) {
var value = field.val();
// only trigger update if value changed from previous validation
- if (value != $(this).data("oldvalue")) {
- $(this).data("oldvalue", value);
- $.get('', {number: value}, function(data) {
+ if (value != field.data("oldvalue")) {
+ field.data("oldvalue", value);
+ $.get('', {"number": value}, function(data) {
+ window.history.pushState({"value": value, "data": data},
$(document).find("title").text(), "?number=" + encodeURIComponent(value));
updateresults(field, data);
});
}
}
+ // update results based on history navigation
+ window.onpopstate = function(e) {
+ var field = $(".stdnum_check");
+ if (e.state) {
+ var value = e.state.value;
+ var data = e.state.data;
+ field.val(value)
+ field.data("oldvalue", value);
+ updateresults(field, data);
+ } else {
+ field.val("")
+ field.data("oldvalue", "");
+ updateresults(field, []);
+ }
+ };
+
// trigger a check when user stopped typing
$(".stdnum_check").on("input propertychange", function (event) {
if (window.event && event.type == "propertychange" && event.propertyName
!= "value")
@@ -103,4 +120,11 @@ $( document ).ready(function() {
// focus the text field
$(".stdnum_check").focus();
+ // save current state
+ var value = $(".stdnum_check").val();
+ $(".stdnum_check").data("oldvalue", value);
+ $.get('', {number: value}, function(data) {
+ window.history.replaceState({"value": value, "data": data},
$(document).find("title").text(), "?number=" + encodeURIComponent(value));
+ })
+
});
https://arthurdejong.org/git/python-stdnum/commit/?id=7cb114b2dc7e8f6c73c7c8ff7dcb87620859a674
commit 7cb114b2dc7e8f6c73c7c8ff7dcb87620859a674
Author: Arthur de Jong <arthur@arthurdejong.org>
Date: Fri Nov 24 17:51:49 2017 +0100
Correctly escape number for use in attribute
diff --git a/online_check/stdnum.wsgi b/online_check/stdnum.wsgi
index a69d167..e340d22 100755
--- a/online_check/stdnum.wsgi
+++ b/online_check/stdnum.wsgi
@@ -106,5 +106,5 @@ def application(environ, start_response):
return [json.dumps(results, indent=2, sort_keys=True)]
start_response('200 OK', [('Content-Type', 'text/html')])
return _template % dict(
- value=cgi.escape(number),
+ value=cgi.escape(number, True),
results='\n'.join(format(data) for data in results))
-----------------------------------------------------------------------
Summary of changes:
online_check/check.js | 37 +++++++++++++++++++++++++++++++------
online_check/stdnum.wsgi | 6 +++---
2 files changed, 34 insertions(+), 9 deletions(-)
hooks/post-receive
--
python-stdnum
--
To unsubscribe send an email to
python-stdnum-commits-unsubscribe@lists.arthurdejong.org or see
https://lists.arthurdejong.org/python-stdnum-commits/
- python-stdnum branch master updated. 1.7-17-gd5f97e9,
Commits of the python-stdnum project