Skip to content
step1.html 5.01 KiB
Newer Older
<!DOCTYPE html>
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="http://getbootstrap.com/favicon.ico">

    <title>Search XNAT</title>

    <!-- Bootstrap core CSS -->
    <link href="static/bootstrap.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="static/dashboard.css" rel="stylesheet">

    <style type="text/css">
      .boxes {
         height: 150px;
         overflow: auto;
         width: 400px;
      }
    </style>

    <script>
Franziska Koehn's avatar
Franziska Koehn committed

      var handleFiles = function(file){
        console.log(file)
        var reader = new FileReader();
        reader.onload = function(file) {
          set_root_type(JSON.parse(file.target.result).root,
          function() {
            setquery(JSON.parse(file.target.result));
Franziska Koehn's avatar
Franziska Koehn committed
        };
        reader.readAsText(file[0]);
      }

      var set_root_type = function(rt, cb) {
        console.log("srt", rt);
       $('#step1_1').load("/set_root_type?t="+rt, cb);
       $("#roottypes button").html(rt + '<span class="caret"></span>');
       };

    </script>
  </head>

  <body>

    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">Search XNAT</a>
        </div>
      </div>
    </nav>

    <div class="col-sm-12 col-md-10 col-md-offset-1 main">
      <h1 class="page-header">Define and Send a Query</h1>

      {% with messages = get_flashed_messages() %}
        {% if messages %}
          {% for message in messages %}
          <div class="alert alert-danger" role="alert">
            <b>Error:</b>{{ message }}
          </div>
          {% endfor %}
        {% endif %}
      {% endwith %}
      {% block body %}{% endblock %}

Franziska Koehn's avatar
Franziska Koehn committed

      <h2 class="sub-header">Open a saved Query</h2>

      <input type="file" id="fileElem" onchange="handleFiles(this.files)">
      <p class="help-block">...or skip this point and define a new one.</p>

      <h2 class="sub-header">Define Your Constraints</h2>
      <div class="input-group">
        <span class="input-group-addon">Root-Type</span>

Franziska Koehn's avatar
Franziska Koehn committed
        <div class="btn-group" role="group" id="roottypes">
          <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
            {% if state.roottype %}
            {{state.roottype}}
            {% else %}
            Choose a Root-Type!
            {% endif %}
            <span class="caret"></span>
          </button>
          <ul class="dropdown-menu" role="menu">
             {% for rt in roottypes %}
Franziska Koehn's avatar
Franziska Koehn committed
                 <li role="presentation"><a role="menuitem" tabindex="-1" onclick="set_root_type('{{rt}}')">{{rt}}</a></li>
             {% endfor %}
          </ul>
        </div>
      </div>

Franziska Koehn's avatar
Franziska Koehn committed
      <div id="step1_1">
Franziska Koehn's avatar
Franziska Koehn committed
      </div>
Franziska Koehn's avatar
Franziska Koehn committed
</body>


<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="static/jquery.js"></script>
<script src="static/bootstrap.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="static/ie10-viewport-bug-workaround.js"></script>

<svg style="visibility: hidden; position: absolute; top: -100%; left: -100%;" preserveAspectRatio="none" viewBox="0 0 200 200" height="200" width="200"><defs></defs><text style="font-weight:bold;font-size:10pt;font-family:Arial, Helvetica, Open Sans, sans-serif;dominant-baseline:middle" y="10" x="0">200x200</text></svg></body></html>
Franziska Koehn's avatar
Franziska Koehn committed

<script>
$(function() {
  fileElem = document.getElementById("fileElem");
});

Franziska Koehn's avatar
Franziska Koehn committed

<script>
// http://www.filamentgroup.com/lab/jquery-plugin-for-requesting-ajax-like-file-downloads.html
jQuery.download = function(url, data, method){
//url and data options required
if( url && data ){
    //data can be string of parameters or array/object
    data = typeof data == 'string' ? data : jQuery.param(data);
    //split params into form inputs
    var inputs = '';
    jQuery.each(data.split('&'), function(){
        var pair = this.split('=');
        inputs+='<input type="hidden" name="'+ pair[0] +'" value="'+ pair[1] +'" />';
    });
    //send request
    jQuery('<form action="'+ url +'" method="'+ (method||'post') +'">'+inputs+'</form>')
    .appendTo('body').submit().remove();
    };
};
Franziska Koehn's avatar
Franziska Koehn committed
</script>