index.html 1.75 KB
Newer Older
Nyashes's avatar
Nyashes committed
1 2 3 4 5 6
<html>
<head>
    <title>page principale</title>
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js" ></script>
    <script type="text/javascript">
        jQuery("document").ready(function () {
Nyashes's avatar
Nyashes committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
            $.getJSON('config.json', function (config) {
                $.ajax({
                    url: config.url + "/" + config.collection + "/",
                    type: 'get',
                    dataType: 'jsonp',
                    jsonp: 'jsonp', // mongod is expecting the parameter name to be called "jsonp"
                    cache: false,
                    success: function (myData) {
                        for (var item in myData.rows) {
                            var model = jQuery("div[name='toFill']").first().clone();
                            model.find("a[name='link']").attr("href", "title.html#" + encodeURI(JSON.stringify(myData.rows[item])));
                            model.find("span[name='title']").text(myData.rows[item].title);
                            model.css("display", "block")
                            model.appendTo(jQuery("body").first());
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        console.log('error', errorThrown + " " + textStatus);
                    }
                });
            });
Nyashes's avatar
Nyashes committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
        });
    </script>
</head>
<body>
    <input type="text" id="search" style="width:100%"/>
    <div name="toFill" style="display:none;">
        <a href="" name="link">
             <div style="width:100%; text-align: center; border: solid 1px black; padding: 5px; margin: 3px;">
                <span name="title">

                </span>
            </div>
        </a>
    </div>
</body>
</html>