javascriptkde-plasmaplasmoid

KDE plasmoid ind autorefresh


I'm trying to write KDE4 plasmoid in JavaScript, but have not success. So, I need to get some data via HTTP and display it in Label. That's working well, but I need regular refresh (once in 10 seconds), it's not working.

My code:

inLabel = new Label();
var timer= new QTimer();
var job=0;
var fileContent="";

function onData(job, data){
   if(data.length > 0){
      var content = new String(data.valueOf());
      fileContent += content;
   }
}

function onFinished(job) {
  inLabel.text=fileContent;
}

plasmoid.sizeChanged=function()
{
    plasmoid.update();
}

timer.timeout.connect(getData);
timer.singleShot=false;
getData();
timer.start(10000);

function getData()
{
    fileContent="";
    job = plasmoid.getUrl("http://192.168.0.10/script.cgi");
    job.data.connect(onData);
    job.finished.connect(onFinished);
    plasmoid.update();
}

It gets script once and does not refresh it after 10 seconds. Where is my mistake?


Solution

  • It is working just fine in here at least (running a recent build from git master), getData() is being called as expected. Can you see any errors in the console?

    EDIT: The problem was that getUrl() explicitly sets NoReload for KIO::get() which causes it load data from cache instead of forcing a reload from the server. Solution was to add a query parameter to the URL in order to make it force reload it.