You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
3.2 KiB
HTML
135 lines
3.2 KiB
HTML
1 year ago
|
<%+header%>
|
||
|
<!--
|
||
|
This module gives some convinience to access the shell via web, in
|
||
|
case that you don't have a uart console or telnet/ssh connection.
|
||
|
Hua Shao <nossiac@163.com>
|
||
|
-->
|
||
|
<h2><%:AT Commands%></h2>
|
||
|
<label><%:Web UI for sending AT Commands.%></label>
|
||
|
<p></p>
|
||
|
<h4><%:Sending commands to modem%></h4>
|
||
|
<div class="table" width="100%">
|
||
|
|
||
|
<div class="tr">
|
||
|
<div class="td left" width="15%"><%:User AT Commands%>:</div>
|
||
|
|
||
|
<div class="td left" style="width:41%;">
|
||
|
<select name="ussd" id="pl" onclick="copyFunction()">
|
||
|
|
||
|
</select>
|
||
|
</div>
|
||
|
<div class="td left" style="width:41%;"></div>
|
||
|
</div>
|
||
|
|
||
|
<div class="tr">
|
||
|
<div class="td left" style="width:15%;"><%:Command to send%>:</div>
|
||
|
<div class="td left" ><input type="text" id="code" required size="20" ></div>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div class="table" width="100%">
|
||
|
<div class="td left" style="width:90%;"><%:Reply%>:
|
||
|
<p>
|
||
|
<pre id="result" style="visibility: hidden; width:100%;"></pre></div>
|
||
|
|
||
|
<div class="tr cbi-rowstyle-2">
|
||
|
<div class="td center"><div style="float: left;">
|
||
|
<div class="ifacebadge"></div><input type="button" style="margin-left: 5px"; id="sendcmd" class="btn cbi-button cbi-button-neutral" value="<%:Send Command%>" /></div>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
|
||
|
window.onload = function readUSER() {
|
||
|
|
||
|
|
||
|
XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "atc", "user_atc")%>', null,
|
||
|
function(x, json)
|
||
|
{
|
||
|
select = document.getElementById('pl');
|
||
|
|
||
|
var count = Object.keys(json).length;
|
||
|
|
||
|
|
||
|
for(var d=0;d<=count;d++)
|
||
|
{
|
||
|
var opt = document.createElement('option');
|
||
|
|
||
|
var s = json[d].usd;
|
||
|
var fields = s.split(/;/);
|
||
|
var name = fields[0];
|
||
|
var code = fields[1];
|
||
|
opt.text = name;
|
||
|
opt.value = code.trim();
|
||
|
opt.innerHTML = name;
|
||
|
select.appendChild(opt);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
);
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
function copyFunction() {
|
||
|
|
||
|
var node = document.getElementById('result');
|
||
|
node.style.visibility = 'hidden';
|
||
|
|
||
|
var x = document.getElementById("pl").value;
|
||
|
document.getElementById("code").value = x;
|
||
|
document.getElementById("result").innerHTML = "";
|
||
|
}
|
||
|
|
||
|
|
||
|
function postcmd(cmd) {
|
||
|
(new XHR()).post("<%=luci.dispatcher.build_url("admin", "modem", "webcmd")%>", {"cmd":cmd}, function(x) {
|
||
|
console.log(x.response)
|
||
|
console.log(x)
|
||
|
|
||
|
var aStr = x.response;
|
||
|
var myre = /(^[ \t]*\n)/gm;
|
||
|
var bStr = aStr.replace(myre,"");
|
||
|
|
||
|
document.getElementById("result").innerHTML = bStr;
|
||
|
});
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
|
||
|
document.addEventListener('DOMContentLoaded', function (ev) {var button = document.getElementById("sendcmd");
|
||
|
button.addEventListener("click", function () {
|
||
|
|
||
|
|
||
|
var s = document.getElementById("code").value;
|
||
|
if ( s.length == 0 )
|
||
|
{
|
||
|
document.getElementById("result").innerHTML = "";
|
||
|
alert("<%:Please enter a AT Command%>");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
var cmd = document.getElementById("code");
|
||
|
postcmd(cmd.value);
|
||
|
cmd.value = "";
|
||
|
|
||
|
var node = document.getElementById('result');
|
||
|
if (node.style.visibility=='visible') {
|
||
|
node.style.visibility = 'hidden';
|
||
|
}
|
||
|
else
|
||
|
node.style.visibility = 'visible'
|
||
|
|
||
|
return true;
|
||
|
});
|
||
|
}, true);
|
||
|
|
||
|
|
||
|
</script>
|
||
|
|
||
|
<%+footer%>
|
||
|
|