index.html 1.9 KB
Newer Older
Nyashes's avatar
Nyashes committed
1 2 3 4
<html>
<head>
    <title>page principale</title>
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js" ></script>
5
    <script type="text/javascript" src="config.jsonp"></script>
Nyashes's avatar
Nyashes committed
6
    <script type="text/javascript">
7 8 9 10 11 12 13 14 15 16
        function request() {
            $.ajax({
                url: config.url + "/" + config.collection + "/?" + decodeURI(document.location.href.split('#')[1]),
                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();
Nyashes's avatar
Nyashes committed
17
                        model.find("a[name='link']").attr("href", "title.html#" + encodeURI(myData.rows[item].title));
18 19 20
                        model.find("span[name='title']").text(myData.rows[item].title);
                        model.css("display", "block")
                        model.appendTo(jQuery("body").first());
Nyashes's avatar
Nyashes committed
21
                    }
22 23 24 25
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    console.log('error', errorThrown + " " + textStatus);
                }
Nyashes's avatar
Nyashes committed
26
            });
27 28
        }
        jQuery("document").ready(request);
Nyashes's avatar
Nyashes committed
29 30 31
    </script>
</head>
<body>
32
    <form onsubmit="document.location.href = document.location.href.split('#')[0] + '#' + encodeURI($('#search').val()); document.location.reload(); return false;"><input type="text" id="search" style="width:100%" /></form>
Nyashes's avatar
Nyashes committed
33 34 35 36 37 38 39 40 41 42 43
    <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>