<!--
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Copyright (c) 2014 Mozilla Corporation

Contributors:
Jeff Bryner jbryner@mozilla.com

contains two ways to display the same whois data
non-modal: for http(s)://servername/ipwhois/1.2.3.4
modal: for  Session.set('ipwhoisipaddress','1,2.3.4') then
            $('#modalwhoiswindow').modal()
-->

<template name="ipwhois">
<style>
    .row { color: white;
    }
</style>
<body>


<div class="container">
    <div class="well">
        whois: {{whois.status}} {{whois.error}}
    </div>
    <div class="row"><a class="showmodal" href=#>click me for modal</a></div>
    <div class="row center">
        <ul class="unstyled">
            {{#each objKeyValue whois.data}}
                    {{#if isNotEqual value null}}
                        <li>{{key}}: {{value}}</li>
                    {{/if}}
            {{/each}}
        </ul>
        <ul class="unstyled">
            {{#each whois.data.nets}}
                {{#each objKeyValue this}}
                        <li>{{key}}: {{value}}</li>
                {{/each}}                
            {{/each}}
            
        </ul>
    </div>
    <div class="row center">
        <span>raw json:</span>
        <span class="unstyled">
                {{whois.content}}
        </span>
    </div>
    {{>whoismodal}}
</div>
</body>
</template>

<template name="whoismodal">
    <style>
    .modal-body .row {
        color: black;
    }
    </style>
    <div class="modal fade" id="modalwhoiswindow">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                   <button type="button" class="close" data-dismiss="modal">&times;</button>
                   <h4>Whois Results</h4>
                </div>
                <div class="modal-body">
                    <div class="row center">
                        <div class="well">
                            whois: {{whois.status}} {{whois.error}}
                        </div>
                    </div>
                    <div class="row  center">
                        <ul class="list-unstyled">
                            {{#each objKeyValue whois.data false}}
                                    {{#if isNotEqual value null}}
                                        <li>{{key}}: {{value}}</li>
                                    {{/if}}
                            {{/each}}
                        </ul>
                        <ul class="list-unstyled">
                            {{#each whois.data.nets}}
                                {{#each objKeyValue this}}
                                        <li>{{key}}: {{value}}</li>
                                {{/each}}                
                            {{/each}}
                            
                        </ul>
                    </div>
                    <div class="col-xs-1"><button class="btn btn-xs" data-toggle="collapse" data-target="#rawwhoisjson">raw json</button></div>
                    <div class="col-xs-7 col-xs-offset-1">
                        <div id='rawwhoisjson' class="collapse">
                            <pre>{{whois.content}}</pre>
                        </div>
                    </div>            
                </div>
                <div class="modal-footer">
                  <a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>
                </div>
          </div>
        </div>
    </div>
</template>