mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-10 08:38:28 +00:00
restored working search>html + Added max curves display to all graphs.
This commit is contained in:
parent
8cd36982b8
commit
4ac448e71e
7 changed files with 201 additions and 40 deletions
|
@ -133,12 +133,14 @@ def monitoring():
|
||||||
|
|
||||||
@app.route("/wordstrending/")
|
@app.route("/wordstrending/")
|
||||||
def wordstrending():
|
def wordstrending():
|
||||||
return render_template("Wordstrending.html")
|
default_display = cfg.get("Flask", "default_display")
|
||||||
|
return render_template("Wordstrending.html", default_display = default_display)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/protocolstrending/")
|
@app.route("/protocolstrending/")
|
||||||
def protocolstrending():
|
def protocolstrending():
|
||||||
return render_template("Protocolstrending.html")
|
default_display = cfg.get("Flask", "default_display")
|
||||||
|
return render_template("Protocolstrending.html", default_display = default_display)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/trending/")
|
@app.route("/trending/")
|
||||||
|
|
|
@ -115,7 +115,7 @@ function Graph(id_pannel, path, header_size){
|
||||||
headings = this.graph.getLabels();
|
headings = this.graph.getLabels();
|
||||||
headings.splice(0,1);
|
headings.splice(0,1);
|
||||||
var sorted_list = new Array();
|
var sorted_list = new Array();
|
||||||
today = new Date().getDate();
|
today = new Date().getDate()-1; // Take the top from yesterday so that we can see the current evolution
|
||||||
for( i=0; i<headings.length; i++){
|
for( i=0; i<headings.length; i++){
|
||||||
the_heading = headings[i];
|
the_heading = headings[i];
|
||||||
//console.log('heading='+the_heading+' tab['+(today-1)+']['+(parseInt(i)+1)+']='+g.getValue(today-1, parseInt(i)+1));
|
//console.log('heading='+the_heading+' tab['+(today-1)+']['+(parseInt(i)+1)+']='+g.getValue(today-1, parseInt(i)+1));
|
||||||
|
|
|
@ -16,8 +16,12 @@
|
||||||
<script type="text/javascript" src="{{ url_for('static', filename='js/dygraph-combined.js') }}"></script>
|
<script type="text/javascript" src="{{ url_for('static', filename='js/dygraph-combined.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/jquery-1.4.2.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/jquery-1.4.2.js') }}"></script>
|
||||||
<script language="javascript" src="{{ url_for('static', filename='js/jquery.js')}}"></script>
|
<script language="javascript" src="{{ url_for('static', filename='js/jquery.js')}}"></script>
|
||||||
|
<script>
|
||||||
|
var default_display = {{ default_display }};
|
||||||
|
var current_displayed_graph;
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
|
@ -81,6 +85,14 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="btn-group btn-group-xs pull-right" style="margin-right: 5px;">
|
||||||
|
<button type="button" class="btn btn-primary" onclick="take_top(5);">5</button>
|
||||||
|
<button type="button" class="btn btn-primary" onclick="take_top(10);">10</button>
|
||||||
|
<button type="button" class="btn btn-primary" onclick="take_top(15);">15</button>
|
||||||
|
<button type="button" class="btn btn-primary" onclick="take_top(0);">...</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- /.panel-heading -->
|
<!-- /.panel-heading -->
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
@ -97,12 +109,40 @@
|
||||||
<!-- import graph function -->
|
<!-- import graph function -->
|
||||||
<script src="{{ url_for('static', filename='js/plot-graph.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/plot-graph.js') }}"></script>
|
||||||
|
|
||||||
<script>
|
<script type="text/javascript">
|
||||||
$(document).ready(function(){
|
// Create, plot and set the limit of displayed headers
|
||||||
var graph_tld = new Graph("ProtocolsTrending", "../static//csv/protocolstrendingdata.csv");
|
function create_and_plot(pannel, path){
|
||||||
|
//var graph_domain = new Graph($(event.target).attr('data-pannel'), $(event.target).attr('data-path'));
|
||||||
|
$.get(path, function(myContentFile) {
|
||||||
|
var lines = myContentFile.split("\r\n");
|
||||||
|
var header_size = lines[0].split(',').length-1;
|
||||||
|
current_displayed_graph = new Graph(pannel, path, header_size);
|
||||||
|
setTimeout(function() { current_displayed_graph.set_Visibility(default_display)}, 300);
|
||||||
|
}, 'text');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// When a pannel is shown, create_and_plot.
|
||||||
|
$('.nav-tabs a').on('shown.bs.tab', function(event){
|
||||||
|
create_and_plot($(event.target).attr('data-pannel'), $(event.target).attr('data-path'));
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
// Create the graph when the page has just loaded
|
||||||
|
create_and_plot("ProtocolsTrending", "../static//csv/protocolstrendingdata.csv")
|
||||||
|
});
|
||||||
|
|
||||||
|
function take_top(new_display){
|
||||||
|
current_displayed_graph.set_Visibility_andHide(new_display, default_display);
|
||||||
|
default_display = new_display;
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -95,12 +95,11 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span> </span>
|
|
||||||
<div class="btn-group btn-group-xs pull-right" style="margin-right: 5px;">
|
<div class="btn-group btn-group-xs pull-right" style="margin-right: 5px;">
|
||||||
<button type="button" class="btn btn-primary" onclick="myScript(5);">5</button>
|
<button type="button" class="btn btn-primary" onclick="take_top(5);">5</button>
|
||||||
<button type="button" class="btn btn-primary" onclick="myScript(10);">10</button>
|
<button type="button" class="btn btn-primary" onclick="take_top(10);">10</button>
|
||||||
<button type="button" class="btn btn-primary" onclick="myScript(15);">15</button>
|
<button type="button" class="btn btn-primary" onclick="take_top(15);">15</button>
|
||||||
<button type="button" class="btn btn-primary" onclick="myScript(0);">...</button>
|
<button type="button" class="btn btn-primary" onclick="take_top(0);">...</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -116,14 +115,6 @@
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<i class="fa fa-bar-chart-o fa-fw"></i> Top Domain Trending
|
<i class="fa fa-bar-chart-o fa-fw"></i> Top Domain Trending
|
||||||
|
|
||||||
<div class="btn-group btn-group-lg">
|
|
||||||
<button type="button" class="btn btn-primary">5</button>
|
|
||||||
<button type="button" class="btn btn-primary">10</button>
|
|
||||||
<button type="button" class="btn btn-primary">15</button>
|
|
||||||
<button type="button" class="btn btn-primary">...</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
|
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
|
||||||
|
@ -143,6 +134,14 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="btn-group btn-group-xs pull-right" style="margin-right: 5px;">
|
||||||
|
<button type="button" class="btn btn-primary" onclick="take_top(5);">5</button>
|
||||||
|
<button type="button" class="btn btn-primary" onclick="take_top(10);">10</button>
|
||||||
|
<button type="button" class="btn btn-primary" onclick="take_top(15);">15</button>
|
||||||
|
<button type="button" class="btn btn-primary" onclick="take_top(0);">...</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- /.panel-heading -->
|
<!-- /.panel-heading -->
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
@ -186,7 +185,7 @@
|
||||||
create_and_plot("TldsTrending", '../static//csv/tldstrendingdata.csv')
|
create_and_plot("TldsTrending", '../static//csv/tldstrendingdata.csv')
|
||||||
});
|
});
|
||||||
|
|
||||||
function myScript(new_display){
|
function take_top(new_display){
|
||||||
current_displayed_graph.set_Visibility_andHide(new_display, default_display);
|
current_displayed_graph.set_Visibility_andHide(new_display, default_display);
|
||||||
default_display = new_display;
|
default_display = new_display;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,12 @@
|
||||||
<script type="text/javascript" src="{{ url_for('static', filename='js/dygraph-combined.js') }}"></script>
|
<script type="text/javascript" src="{{ url_for('static', filename='js/dygraph-combined.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/jquery-1.4.2.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/jquery-1.4.2.js') }}"></script>
|
||||||
<script language="javascript" src="{{ url_for('static', filename='js/jquery.js')}}"></script>
|
<script language="javascript" src="{{ url_for('static', filename='js/jquery.js')}}"></script>
|
||||||
|
<script>
|
||||||
|
var default_display = {{ default_display }};
|
||||||
|
var current_displayed_graph;
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
|
@ -81,6 +85,14 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="btn-group btn-group-xs pull-right" style="margin-right: 5px;">
|
||||||
|
<button type="button" class="btn btn-primary" onclick="take_top(5);">5</button>
|
||||||
|
<button type="button" class="btn btn-primary" onclick="take_top(10);">10</button>
|
||||||
|
<button type="button" class="btn btn-primary" onclick="take_top(15);">15</button>
|
||||||
|
<button type="button" class="btn btn-primary" onclick="take_top(0);">...</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- /.panel-heading -->
|
<!-- /.panel-heading -->
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
@ -97,10 +109,36 @@
|
||||||
<!-- import graph function -->
|
<!-- import graph function -->
|
||||||
<script src="{{ url_for('static', filename='js/plot-graph.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/plot-graph.js') }}"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
// Create, plot and set the limit of displayed headers
|
||||||
|
function create_and_plot(pannel, path){
|
||||||
|
//var graph_domain = new Graph($(event.target).attr('data-pannel'), $(event.target).attr('data-path'));
|
||||||
|
$.get(path, function(myContentFile) {
|
||||||
|
var lines = myContentFile.split("\r\n");
|
||||||
|
var header_size = lines[0].split(',').length-1;
|
||||||
|
current_displayed_graph = new Graph(pannel, path, header_size);
|
||||||
|
setTimeout(function() { current_displayed_graph.set_Visibility(default_display)}, 300);
|
||||||
|
}, 'text');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// When a pannel is shown, create_and_plot.
|
||||||
|
$('.nav-tabs a').on('shown.bs.tab', function(event){
|
||||||
|
create_and_plot($(event.target).attr('data-pannel'), $(event.target).attr('data-path'));
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
var graph_tld = new Graph("WordTrending", "../static//csv/wordstrendingdata.csv");
|
// Create the graph when the page has just loaded
|
||||||
|
create_and_plot("WordTrending", '../static//csv/wordstrendingdata.csv')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function take_top(new_display){
|
||||||
|
current_displayed_graph.set_Visibility_andHide(new_display, default_display);
|
||||||
|
default_display = new_display;
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -12,10 +12,14 @@
|
||||||
<link href="{{ url_for('static', filename='font-awesome/css/font-awesome.css') }}" rel="stylesheet">
|
<link href="{{ url_for('static', filename='font-awesome/css/font-awesome.css') }}" rel="stylesheet">
|
||||||
<link href="{{ url_for('static', filename='css/sb-admin-2.css') }}" rel="stylesheet">
|
<link href="{{ url_for('static', filename='css/sb-admin-2.css') }}" rel="stylesheet">
|
||||||
<link href="{{ url_for('static', filename='css/dygraph_gallery.css') }}" rel="stylesheet" type="text/css" />
|
<link href="{{ url_for('static', filename='css/dygraph_gallery.css') }}" rel="stylesheet" type="text/css" />
|
||||||
|
<link href="{{ url_for('static', filename='css/dataTables.bootstrap.css') }}" rel="stylesheet" type="text/css" />
|
||||||
<!-- JS -->
|
<!-- JS -->
|
||||||
<script type="text/javascript" src="{{ url_for('static', filename='js/dygraph-combined.js') }}"></script>
|
<script type="text/javascript" src="{{ url_for('static', filename='js/dygraph-combined.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/jquery-1.4.2.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/jquery-1.4.2.js') }}"></script>
|
||||||
<script language="javascript" src="{{ url_for('static', filename='js/jquery.js')}}"></script>
|
<script language="javascript" src="{{ url_for('static', filename='js/jquery.js')}}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/jquery.dataTables.min.js') }}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/dataTables.bootstrap.js') }}"></script>
|
||||||
|
<!-- Custom style -->
|
||||||
<style>
|
<style>
|
||||||
.tooltip-inner {
|
.tooltip-inner {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
@ -25,6 +29,13 @@
|
||||||
max-height: 500px;
|
max-height: 500px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
xmp {
|
||||||
|
white-space:pre-wrap;
|
||||||
|
word-wrap:break-word;
|
||||||
|
}
|
||||||
|
.modal-backdrop.fade {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
@ -34,7 +45,7 @@
|
||||||
<nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
|
<nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
|
||||||
<div class="navbar-header">
|
<div class="navbar-header">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li class="active"><a href="{{ url_for('index') }}"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a></li><li><a href="{{ url_for('wordstrending') }}"><i class="glyphicon glyphicon-stats"></i> WordsTrendings</a></li><li><a href="{{ url_for('protocolstrending') }}"><i class="glyphicon glyphicon-stats"></i> ProtocolsTrendings</a></li><li><a href="{{ url_for('tldstrending') }}"><i class="glyphicon glyphicon-stats"></i> Top Level Domain Trending</a></li></ul>
|
<li class="active"><a href="{{ url_for('index') }}"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a></li><li><a href="{{ url_for('wordstrending') }}"><i class="glyphicon glyphicon-stats"></i> WordsTrendings</a></li><li><a href="{{ url_for('protocolstrending') }}"><i class="glyphicon glyphicon-stats"></i> ProtocolsTrendings</a></li><li><a href="{{ url_for('trending') }}"><i class="glyphicon glyphicon-stats"></i> Trending charts</a></li></ul>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.navbar-top-links -->
|
<!-- /.navbar-top-links -->
|
||||||
<div class="navbar-default sidebar" role="navigation">
|
<div class="navbar-default sidebar" role="navigation">
|
||||||
|
@ -57,14 +68,15 @@
|
||||||
|
|
||||||
<!-- Modal content-->
|
<!-- Modal content-->
|
||||||
<div id="mymodalcontent" class="modal-content">
|
<div id="mymodalcontent" class="modal-content">
|
||||||
<div id="mymodalbody" class="modal-body">
|
<div id="mymodalbody" class="modal-body" max-width="850px">
|
||||||
<p>Some text in the modal.</p>
|
<p>Loading paste information...</p>
|
||||||
|
<img id="loading-gif-modal" src="{{url_for('static', filename='image/loading.gif') }}" height="26" width="26" style="margin: 4px;">
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
<a id="button_show_path" target="_blank" href=""><button type="button" class="btn btn-info">Show saved paste</button></a>
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -74,31 +86,35 @@
|
||||||
<div class="row"> </div>
|
<div class="row"> </div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
|
</br>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<i class="glyphicon glyphicon-search"></i> {{ r|length }} Results
|
<i class="glyphicon glyphicon-search"></i> {{ r|length }} Results for "<strong>{{ query }}</strong>"
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.panel-heading -->
|
<!-- /.panel-heading -->
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<table class="table table-hover">
|
<table class="table table-striped table-bordered table-hover" id="myTable">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th>Path</th>
|
<th style="max-width: 800px;">Path</th>
|
||||||
|
<th>Date</th>
|
||||||
|
<th>Size (Kb)</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% set i = 0 %}
|
{% set i = 0 %}
|
||||||
{% for path in r %}
|
{% for path in r %}
|
||||||
{% set prev_content = c[i] %}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ i + 1 }}</td>
|
<td>{{ i + 1 }}</td>
|
||||||
<td><a target="_blank" href="{{ url_for('showsavedpaste') }}?paste={{ path }}"> {{ path }}</a></td>
|
<td><a target="_blank" href="{{ url_for('showsavedpaste') }}?paste={{ path }}&num={{ i+1 }}"> {{ path }}</a></td>
|
||||||
<td><p><span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="left" title="{{ prev_content }}"></span> <button type="button" class="btn-link" data-toggle="modal" data-target="#mymodal" data-url="{{ url_for('showsavedpaste') }}?paste={{ path }}"><span class="fa fa-search-plus"></span></button></p></td>
|
<td>{{ paste_date[i] }}</td>
|
||||||
|
<td>{{ paste_size[i] }}</td>
|
||||||
|
<td><p><span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="left" title="{{ c[i] }}"></span> <button type="button" class="btn-link" data-num="{{ i + 1 }}" data-toggle="modal" data-target="#mymodal" data-url="{{ url_for('showsavedpaste') }}?paste={{ path }}&num={{ i+1 }}" data-path="{{ path }}"><span class="fa fa-search-plus"></span></button></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% set i = i + 1 %}
|
{% set i = i + 1 %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -115,23 +131,89 @@
|
||||||
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<!-- enable tooltip -->
|
<!-- enable tooltip and dataTable -->
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
});
|
$("#button_show_path").hide();
|
||||||
|
$('#myTable').dataTable();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Dynamically update the modal -->
|
<!-- Dynamically update the modal -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
// static data
|
||||||
|
var alert_message = '<div class="alert alert-info alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><strong>No more data.</strong> Full paste displayed.</div>';
|
||||||
|
var complete_paste = null;
|
||||||
|
var char_to_display = {{ char_to_display }};
|
||||||
|
var start_index = 0;
|
||||||
|
|
||||||
// On click, get html content from url and update the corresponding modal
|
// On click, get html content from url and update the corresponding modal
|
||||||
$("[data-toggle='modal']").on("click", function (event) {
|
$("[data-toggle='modal']").on("click", function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var url = $(this).attr('data-url');
|
var modal=$(this);
|
||||||
var modal_id = $(this).attr('data-target');
|
var url = " {{ url_for('showpreviewpaste') }}?paste=" + $(this).attr('data-path') + "&num=" + $(this).attr('data-num');
|
||||||
$.get(url, function (data) {
|
$.get(url, function (data) {
|
||||||
$("#mymodalbody").html(data);
|
$("#mymodalbody").html(data);
|
||||||
|
var button = $('<button type="button" id="load-more-button" class="btn btn-info btn-xs center-block" data-url="' + $(modal).attr('data-path') +'" data-toggle="tooltip" data-placement="bottom" title="Load more content"><span class="glyphicon glyphicon-download"></span></button>');
|
||||||
|
button.tooltip();
|
||||||
|
$("#mymodalbody").children(".panel-default").append(button);
|
||||||
|
|
||||||
|
$("#button_show_path").attr('href', $(modal).attr('data-url'));
|
||||||
|
$("#button_show_path").show('fast');
|
||||||
|
$("#loading-gif-modal").css("visibility", "hidden"); // Hide the loading GIF
|
||||||
|
if ($("[data-initsize]").attr('data-initsize') < char_to_display) { // All the content is displayed
|
||||||
|
nothing_to_display();
|
||||||
|
}
|
||||||
|
// On click, donwload all paste's content
|
||||||
|
$("#load-more-button").on("click", function (event) {
|
||||||
|
if (complete_paste == null) { //Donwload only once
|
||||||
|
$.get("{{ url_for('getmoredata') }}"+"?paste="+$(modal).attr('data-path'), function(data, status){
|
||||||
|
complete_paste = data;
|
||||||
|
update_preview();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
update_preview();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// When the modal goes out, refresh it to normal content
|
||||||
|
$("#mymodal").on('hidden.bs.modal', function () {
|
||||||
|
$("#mymodalbody").html("<p>Loading paste information...</p>");
|
||||||
|
var loading_gif = "<img id='loading-gif-modal' class='img-center' src=\"{{url_for('static', filename='image/loading.gif') }}\" height='26' width='26' style='margin: 4px;'>";
|
||||||
|
$("#mymodalbody").append(loading_gif); // Show the loading GIF
|
||||||
|
$("#button_show_path").attr('href', '');
|
||||||
|
$("#button_show_path").hide();
|
||||||
|
complete_paste = null;
|
||||||
|
start_index = 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update the paste preview in the modal
|
||||||
|
function update_preview() {
|
||||||
|
if (start_index + char_to_display > complete_paste.length-1){ // end of paste reached
|
||||||
|
var final_index = complete_paste.length-1;
|
||||||
|
var flag_stop = true;
|
||||||
|
} else {
|
||||||
|
var final_index = start_index + char_to_display;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (final_index != start_index){ // still have data to display
|
||||||
|
$("#mymodalbody").find("#paste-holder").append(complete_paste.substring(start_index+1, final_index+1)); // Append the new content
|
||||||
|
start_index = final_index;
|
||||||
|
if (flag_stop)
|
||||||
|
nothing_to_display();
|
||||||
|
} else {
|
||||||
|
nothing_to_display();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Update the modal when there is no more data
|
||||||
|
function nothing_to_display() {
|
||||||
|
var new_content = $(alert_message).hide();
|
||||||
|
$("#mymodalbody").find("#panel-body").append(new_content);
|
||||||
|
new_content.show('fast');
|
||||||
|
$("#load-more-button").hide();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<button class="btn btn-default" type="submit">
|
<button class="btn btn-default" type="submit">
|
||||||
<i class="fa fa-search"></i>
|
<i class="fa fa-search"></i>
|
||||||
</button>
|
</button>
|
||||||
<img id="loading-gif" src="{{url_for('static', filename='image/loading2.gif') }}" height="26" width="26" style="margin: 4px; visibility: hidden;">
|
<img id="loading-gif" src="{{url_for('static', filename='image/loading.gif') }}" height="26" width="26" style="margin: 4px; visibility: hidden;">
|
||||||
</form>
|
</form>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue