Gadget works fine until i reboot my pc then have to install gadget again for it to work

This is my 1st gadget , i need help because every time i reboot my pc the gadget will stop uploading content from the net .. but the graphic parts will still display . if i reinstall the gadget from the + gadget button it will work again until i re-start my pc .

this is my xml file

< xml version="1.0" encoding="utf-8" >
<gadget>
<name>NRL 2007 Draw</name>
<namespace>Paul Buttz</namespace>
<version>1.0</version>
<author name="Paul Buttz">
<info url="http://www.paulbuttz.com" />
<logo src="images/nrl.png"/>
</author>
<copyright>Paulbuttz.com 2006</copyright>
<description>
A Gadget allows a user to display NRl 2007 draw
</description>
<icons>
<icon height="48" width="48" src="images/nrl.png"/>
</icons>
<hosts>
<host name="sidebar">
<base type="HTML" apiVersion="1.0.0" src="gadget.html"/>
<permissions>Full</permissions>
<platform minPlatformVersion="1.0"/>
<defaultImage src="images/nrl.png"/>
</host>
</hosts>
</gadget>

and Javasript file as i have no javascript exp i have been copying some other gadget for some help

/ string used for testing in offline mode
var gPageString = "" ;
var gURL = "http://www.paulbuttz.com/test.html" ;
var gArticles = new Array() ;


function initializeMain() {

System.Gadget.Flyout.file = "flyout.html";

try {
var scraper = new WebScraper() ;
gPageString = scraper.Scrape(gURL) ;

parseDocument() ;
renderDocument() ;
} catch ( ex ) {
displayError( ex.message ) ;
}
}


function displayError(errorMessage) {
errorView.innerHTML = errorMessage ;
}


function parseDocument() {

var titlePattern = "<h3 class=\"entry-header\">(([^<]|.)+ )</h3>" ;
var bodyPattern = "<div class=\"entry-body\">(([^<]|.)+ )</div>" ;

var matches = new RegexHelper().Matches( gPageString, titlePattern ) ;

var titles = new Array() ;
for( i=0; i<matches.length; i++ ) {
titlesIdea = matchesIdea.Groups[0] ;
}

matches = new RegexHelper().Matches( gPageString, bodyPattern ) ;
for( i=0; i<matches.length; i++ ) {
var body = matchesIdea.Groups[0] ;
var article = new Article(titlesIdea, body, i) ;
gArticlesIdea = article ;
}
}


function renderDocument() {

for( i=0; i<gArticles.length; i++ ) {
var article = gArticlesIdea ;

var text = document.createTextNode(article.Title);
var e = document.createElement("li");
var a = document.createElement("a");
a.dataIndex = article.Index; // custom prop

a.attachEvent('onclick', handleClick);

a.appendChild(text);
e.appendChild(a);
myList.appendChild(e);
}
}


var gSelectedIndex = -1 ;

function handleClick(event){
var idx = event.srcElement.dataIndex ;

if( idx == gSelectedIndex ) {
gSelectedIndex = -1 ;
System.Gadget.Flyout.show = false ;
}else{
gSelectedIndex = idx ;

if(System.Gadget.Flyout.show) {
addContentToFlyout();
} else {
System.Gadget.Flyout.show = true;
System.Gadget.Flyout.onShow = function() {
addContentToFlyout();
}

System.Gadget.Flyout.onHide = function() {
gSelectedIndex = -1 ;
}
}
}
}

function addContentToFlyout() {
try {
if(System.Gadget.Flyout.show) {
var flyoutDoc = System.Gadget.Flyout.document;
var article = gArticles[gSelectedIndex] ;
flyoutDoc.getElementById("title").innerHTML = article.Title ;
flyoutDoc.getElementById("bodyContent").innerHTML = article.Body ;
}
} catch ( ex ) {
displayError( ex.message ) ;
}
}

/////////////////////////////////////////////////////////////////////////////
//
// WEBSCRAPER MODULE
// Author: Darren Neimke
//
/////////////////////////////////////////////////////////////////////////////

// WebScraper Class
function WebScraper() {
var xmlHttp = null;

this.Scrape = function( url ) {
var html = "" ;
initializeProxy() ;
try {
if (xmlHttp != null) {
xmlHttp.open("GET", url) ;
xmlHttp.send(null) ;
html = xmlHttp.responseText;
}
} catch(ex) {
throw new ErrorObject( ex.message ) ;
}

return html ;
}


function initializeProxy() {
xmlHttp = null ;
if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest()
} else if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")
}
}
}

/////////////////////////////////////////////////////////////////////////////
//
// REGEXHELPER MODULE
//
/////////////////////////////////////////////////////////////////////////////

// ErrorObject Class
function ErrorObject( message ) { this.message = message ; }

// RegexHelper Class
function RegexHelper() {
// accepts 2 overloads:
// - array Matches ( input, pattern )
// - array Matches ( input, pattern, opts )
this.Matches = function ( input, pattern, opts ) {
var re ;
var results = new Array() ;

try {
// overload
if( arguments.length == 3 )
re = new RegExp( pattern, opts ) ;
else
re = new RegExp( pattern, "gi" ) ;
}
catch ( ex ) { throw new ErrorObject( ex.message ) ; }
var arr = re.exec(input) ;
while(arr != null) {
var match = new Match() ;
match.Value = arr[0] ;

for (var i=0; i<arr.length; i++) {
match.Groups[i-1] = arrIdea ;
}

results[results.length] = match ;
arr = re.exec(input) ;
}
return results ;
}


// accepts 2 overloads:
// - array Replace ( input, pattern, replacement )
// - array Replace ( input, pattern, replacement, opts )
this.Replace = function( input, pattern, replacement, opts ) {
var re ;
var retVal = input ;

try {
// overload
if( arguments.length == 3 )
re = new RegExp( pattern, "gi" ) ;
else
re = new RegExp( pattern, opts ) ;
} catch ( ex ) { throw new ErrorObject( ex.message ) ; }

while( re.test( retVal ) ) {
retVal = retVal.replace( re, replacement ) ;
}
return retVal ;
}
}

// Match Class
function Match() {
this.Value = null ;
this.Groups = new Array() ;
}


function Article(title, body, index) {
this.Title = title ;
this.Body = body ;
this.Index = index ;
}

cheers

buttz




Answer this question

Gadget works fine until i reboot my pc then have to install gadget again for it to work

  • Boulderdude

    Now no content loads at all :( before it would display a message about content not being able to display at this time .

    now nothing just the html is being displayed

    i'm try to display foot ball rounds so i have links in the gadget part then click on the link and it displays the games for the round in flyout .it worked before just if you shut down you would have to install the gadget again for it to display the links again .

    i hope you can help

    cheers

    paul



  • Marauderz

    Could be an exception caused by the NIC not being initialized. If you Hibernate your PC, you should get the same result. Sleep should be okay though.

    If that is the problem, either trap it or put a 30 second delay in the startup. eg

    function initializeMain() {
    window.setTimeout(initMain2, 30000);
    }

    function initMain2() {
    System.Gadget.Flyout.file = "flyout.html";

    try {
    var scraper = new WebScraper() ;
    gPageString = scraper.Scrape(gURL) ;

    parseDocument() ;
    renderDocument() ;
    } catch ( ex ) {
    displayError( ex.message ) ;
    }
    }


  • Gadget works fine until i reboot my pc then have to install gadget again for it to work