This commit is contained in:
lisida 2019-02-15 16:30:31 +08:00
parent 36651673d9
commit 375e339439

View File

@ -21,7 +21,7 @@
<nav class="col-md-3 d-none d-md-block bg-light sidebar"> <nav class="col-md-3 d-none d-md-block bg-light sidebar">
<div class="sidebar-sticky"> <div class="sidebar-sticky">
<ul class="nav flex-column"> <ul id="nav-content" class="nav flex-column">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link active" href="/rpc/doc.html"> <a class="nav-link active" href="/rpc/doc.html">
<span data-feather="home"></span> <span data-feather="home"></span>
@ -145,7 +145,9 @@
<script type="text/javascript"> <script type="text/javascript">
var editor = ace.edit("editor"); var editor = ace.edit("editor");
var params = <?php echo $params; ?>; var params = <?php echo $params; ?>;
var data = <?php echo $data; ?>;
var error_empty = <?php echo isset($error) ? 0 : 1; ?>; var error_empty = <?php echo isset($error) ? 0 : 1; ?>;
console.log(params)
editor.setTheme("ace/theme/monokai"); editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/json"); editor.session.setMode("ace/mode/json");
editor.on('change', function (e) { editor.on('change', function (e) {
@ -156,11 +158,17 @@
var valKey =$("#method option:first-child").text(); var valKey =$("#method option:first-child").text();
var data = <?php echo $data; ?>; var data = <?php echo $data; ?>;
var methodArray = data[valKey]; var methodArray = data[valKey];
changeTable(methodArray) changeTable(methodArray);
}); if (error_empty > 0) {
$('#method').bind('change', function() { var storage = window.localStorage;
var valKey = $("#method").find("option:selected").text();
var d = JSON.stringify(params);
storage.setItem(valKey, d);
}
changeNavShow()
});
$('#method').on('change', function() {
var valKey = $("#method").find("option:selected").text(); var valKey = $("#method").find("option:selected").text();
var data = <?php echo $data; ?>;
var methodArray = data[valKey]; var methodArray = data[valKey];
intTable() intTable()
changeTable(methodArray) changeTable(methodArray)
@ -217,15 +225,22 @@
for(var i=0;i<storage.length;i++){ for(var i=0;i<storage.length;i++){
var key=storage.key(i); var key=storage.key(i);
var $trTemp = $('<li class="nav-item"></li>'); var $trTemp = $('<li class="nav-item"></li>');
$trTemp.append('<span class="nav-link">'+ key +'</span>'); $trTemp.append('<a class="nav-link">'+ key +'</a>');
$trTemp.appendTo("#nav-content");
$trTemp.attr('methond',key)
} }
} }
$('#submit-btn').bind('click',function(params) { $('#nav-content').on('click','.nav-item', function(){
var storage=window.localStorage; var activeKey = $(this).attr('methond');
var valKey = $("#method").find("option:selected").text(); var param = localStorage.getItem(activeKey)
var data=editor.getValue(); $('.nav-item').removeClass('bg-info');
var d=JSON.stringify(data); $(this).addClass('bg-info');
storage.setItem(valKey,d); $("#method").val(activeKey);
var methodArray = data[activeKey];
intTable();
changeTable(methodArray);
$('#params').val(param);
editor.setValue(param)
}) })
</script> </script>
<script>hljs.initHighlightingOnLoad();</script> <script>hljs.initHighlightingOnLoad();</script>