MajorHertz
Baseband Member
- Messages
- 32
Let me first explain what I am trying to do then give my example code. I want to have a widget that runs the command "ls -A" in a directory. If the directory is empty, i want it to print something to screen in the widget and if there are files there I want it to print something else.
I got it working but it only runs the command the first time it is launched and I want it to either do it everytime dashboard is triggered or by pressing a button. here is the code:
I messed with it a lot. It seems to work fine the first time but when I click the button, the entire widget disapears.
What am I doing wrong? I know how I would do it in PHP or python but javascript always gets me.
I got it working but it only runs the command the first time it is launched and I want it to either do it everytime dashboard is triggered or by pressing a button. here is the code:
PHP:
<html>
<head>
<style>
body {
margin: 0;
}
.helloText {
font: 16px "Lucida Grande";
font-weight: bold;
color: white;
text-align: center;
position: absolute;
top: 41px;
left: 18px;
width: 180px;
}
</style>
</head>
<body>
[img]Default.png[/img]
<div class="helloText">
<script type="text/javascript" language="javascript">
if (window.widget)
{
widget.onshow = onshow;
}
function onshow()
{
var authfail = null;
var authfail = widget.system("/bin/ls -A /var/log/authfail", null).outputString;
if(authfail == null) {
document.write("You are in the clear");
}
else {
document.write("Intruder Detected!");
}
}
</script>
<input type="button" value="Recheck" onClick="runfunction();">
</div>
</body>
</html>
I messed with it a lot. It seems to work fine the first time but when I click the button, the entire widget disapears.
What am I doing wrong? I know how I would do it in PHP or python but javascript always gets me.