forked from hunvreus/carte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·83 lines (74 loc) · 2.39 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
layout: default
---
<nav id='sidebar'>
{% include nav.html %}
</nav>
<section id='content'>
{% for post in site.posts %}
<article class='{{ post.type }}'>
<a name='{{ post.url }}' href='#{{ post.url }}'><h2>{% if post.type %}<code><b>{{ post.type }}</b> {{ post.path }}</code> {% endif %}{{ post.title }}</h2></a>
<section class='body'>
<!-- {% for h in post.headers %}
<p>{{ h.key }} {{ h.val }}<p>
{% endfor %}
-->
<!--
<table>
{% tablerow item in post.required_params %}
{{ item }}
{% endtablerow %}
</table>
<hr>
<table>
{% tablerow item in post.optional_params %}
{{ item }}
{% endtablerow %}
</table>
-->
<button class="btn-open btn btn-default" id="{{post.bid}}">Open this API</button>
<hr>
<div id="post-content">
{{ post.content }}
</div>
</section>
</article>
<script>
window.{{post.bid}} = {'category' : '{{post.category}}','path': '{{post.path}}', 'title': '{{post.title}}', 'type': '{{post.type}}' } ;
window.{{post.bid}}.headers = [];
{% for h in post.headers %}
window.{{post.bid}}.headers.push({ '{{h.key}}' : '{{h.val}}'});
{% endfor %}
window.{{post.bid}}.required_params = [];
window.{{post.bid}}.optional_params = [];
{% for r in post.required_params %}
window.{{post.bid}}.required_params.push('{{r}}');
{% endfor %}
{% for r in post.optional_params %}
window.{{post.bid}}.optional_params.push('{{r}}');
{% endfor %}
</script>
{% endfor %}
</section>
<section id="excute">
</section>
<script>
$(document).ready(function(){
$('.btn-open').click(function(e){
var id = $(this).attr('id');
console.log(window[id]);
var path = window[id].path;
var type = window[id].type;
var content = "<div class='containter'><h2>"+type+" "+ path+"</h2></br>";
$.each(window[id].required_params, function(i,val){
content = content + "<label>" + val + "</label>" + "<input type='text' class='request_param' data-key='"+val+"' /> <hr>";
});
content = content + "<button class='btn-submit btn btn-default submit'>Submit</button>";
content = content + "</div>"
$('#excute').html(content);
});
$(document).on('click', '.btn-submit', function(){
console.log("enter");
});
});
</script>