Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 12-13-2006, 03:33 PM   #1 (permalink)
 
Newb Techie

Join Date: Dec 2005

Posts: 32

MajorHertz

Default JavaScripting in Widgets

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:

PHP Code:
<html>
<
head>

<
style>
    
body {
        
margin0;
    }

    .
helloText {
        
font16px "Lucida Grande";
        
font-weightbold;
        
colorwhite;
        
text-aligncenter;
        
positionabsolute;
        
top41px;
        
left18px;
        
width180px;
        
    }
</
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.
MajorHertz is offline  
Old 12-13-2006, 03:35 PM   #2 (permalink)
 
Newb Techie

Join Date: Dec 2005

Posts: 32

MajorHertz

Default

I forgot to say that in the code posted doesnt have in the body tag the "onload" and the button has the wrong function name. I know this and was messing with stuff so many times I pasted the wrong code.
MajorHertz is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On