mirror of
https://github.com/jlengrand/twitterboard.git
synced 2026-03-10 08:51:22 +00:00
starts creating the form to add hashtags to track
Not functional yet
This commit is contained in:
@@ -24,6 +24,7 @@ def connect():
|
||||
|
||||
return Session(), engine # Bridges class to db
|
||||
|
||||
|
||||
@app.route('/nb_trendy')
|
||||
def nb_trendy():
|
||||
|
||||
@@ -47,11 +48,11 @@ def nb_trendy():
|
||||
return jsonify(hashs=hashs, tweets=tweets, members=members)
|
||||
|
||||
|
||||
@app.route('/_add_numbers')
|
||||
def add_numbers():
|
||||
a = request.args.get('a', 0, type=int)
|
||||
b = request.args.get('b', 0, type=int)
|
||||
return jsonify(result=a + b)
|
||||
@app.route('/_add_hashtag')
|
||||
def add_hashtag():
|
||||
new_hash = request.args.get('new_hash', 0)
|
||||
print "Request to add %s !" % (new_hash)
|
||||
return jsonify(result="Added %s" % (new_hash))
|
||||
|
||||
|
||||
@app.route('/')
|
||||
|
||||
@@ -1,31 +1,61 @@
|
||||
{% extends "layout.html" %}
|
||||
{% block body %}
|
||||
<script>
|
||||
(function worker() {
|
||||
$.ajax({
|
||||
url : $SCRIPT_ROOT + '/nb_trendy',
|
||||
success: function(data) {
|
||||
$('#hashs').text(data.hashs);
|
||||
$('#tweets').text(data.tweets);
|
||||
$('#members').text(data.members);
|
||||
},
|
||||
complete: function() {
|
||||
setTimeout(worker, 1000);
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
(function worker() {
|
||||
$.ajax({
|
||||
url : $SCRIPT_ROOT + '/nb_trendy',
|
||||
success: function(data) {
|
||||
$('#hashs').text(data.hashs);
|
||||
$('#tweets').text(data.tweets);
|
||||
$('#members').text(data.members);
|
||||
},
|
||||
complete: function() {
|
||||
setTimeout(worker, 1000);
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<script type=text/javascript>
|
||||
$(function() {
|
||||
var submit_form = function(e) {
|
||||
$.getJSON($SCRIPT_ROOT + '/_add_hashtag', {
|
||||
a: $('input[name="new_hash"]').val()
|
||||
}, function(data) {
|
||||
$('#result').text(data.result);
|
||||
$('input[name=new_hash').focus().select();
|
||||
});
|
||||
return false;
|
||||
};
|
||||
|
||||
$('new_hash#add_hash').bind('click', submit_form);
|
||||
|
||||
$('input[type=text]').bind('keydown', function(e) {
|
||||
if (e.keyCode == 13) {
|
||||
submit_form(e);
|
||||
}
|
||||
});
|
||||
|
||||
$('input[name=new_hash]').focus();
|
||||
});
|
||||
</script>
|
||||
<h1>Database information</h1>
|
||||
<p>
|
||||
Current number of active hastags in database :
|
||||
<span id='hashs'>?</span>
|
||||
Current number of active hastags in database :
|
||||
<span id='hashs'>?</span>
|
||||
</p>
|
||||
<p>
|
||||
Current number of tweets in database :
|
||||
<span id='tweets'>?</span>
|
||||
Current number of tweets in database :
|
||||
<span id='tweets'>?</span>
|
||||
</p>
|
||||
<p>
|
||||
Current number of members in database :
|
||||
<span id='members'>?</span>
|
||||
Current number of members in database :
|
||||
<span id='members'>?</span>
|
||||
</p>
|
||||
|
||||
<h2>Hashtags</h2>
|
||||
<p> <input type=text size=10 name=new_hash>
|
||||
<a href='#' id='add_hash'>Add new hashtag!</a>
|
||||
<br/>
|
||||
<span id='result'>?</span>
|
||||
</p>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user