mypackage_wrt/builds.js
changeset 42 20be4dd42b12
child 44 48bcd0bbc1ab
equal deleted inserted replaced
41:315255cd1aef 42:20be4dd42b12
       
     1 var BuildpageAjax = null;
       
     2 var startbuild = "<!-- production Builds  -->";
       
     3 var endbuild = "<!--START of footer-->";
       
     4 var buildtitle = null;
       
     5 var builddescription = null;
       
     6 
       
     7 function buildview (aParent) {
       
     8 	
       
     9 	this.previousView = aParent;
       
    10 	this.setupSoftKeys();
       
    11 		
       
    12 
       
    13 	buildtitle = new Label ("title_build","Latest Build Status:",null);
       
    14 	this.addControl (buildtitle);
       
    15 	builddescription = new Label ("description_build");
       
    16 	this.addControl (builddescription);
       
    17 	this.show();
       
    18 	this.update(true);
       
    19 }
       
    20 
       
    21 buildview.prototype = new ListView("buildview","<img src=logo.png>");
       
    22 
       
    23 buildview.prototype.update = function(myflag){
       
    24 	if (myflag) {
       
    25 		var mybuf = "<div class=\"FeedItemLink\">";
       
    26 		mybuf += "<a href=\"JavaScript:void(0)\" onclick=\"openURL('" + buildresultsUrl + Packageid + "'); return false;\">";
       
    27 		mybuf += "(Click here for more details...)";
       
    28 		mybuf += "</a>";
       
    29 		mybuf += "</div>";
       
    30 		if(!Packageid){return;}
       
    31 		buildtitle.setText(Packageid + " " + mybuf);
       
    32 		builddescription.setText("");
       
    33 		this.loadbuild(buildresultsUrl + Packageid);
       
    34 	}
       
    35 	
       
    36 }
       
    37 buildview.prototype.loadbuild =function (url) {
       
    38 	uiManager.showNotification(-1, "wait", "Please  wait...", -1);
       
    39 	BuildpageAjax = new Ajax();
       
    40 	BuildpageAjax.onreadystatechange = this.muchbuild;
       
    41 	BuildpageAjax.open('GET', nocache(url), true);
       
    42 	BuildpageAjax.send(null);	
       
    43 }
       
    44 
       
    45 buildview.prototype.setlabels = function(aTitle, aDescription){
       
    46 	this.title.setText(aTitle);
       
    47 	this.description.setText(aDescription);
       
    48 	
       
    49 }
       
    50 
       
    51 buildview.prototype.muchbuild =function () {
       
    52     if (BuildpageAjax.readyState == 4) {
       
    53 		
       
    54 		var content = BuildpageAjax.responseText;
       
    55 		var ind = content.indexOf(startbuild);
       
    56 		if (ind == -1) {
       
    57 			uiManager.showNotification(3000, "warning", "Failed to find start.");
       
    58 			return;
       
    59 		}
       
    60 	
       
    61 		ind += startbuild.length;
       
    62 		var ind2 = content.indexOf(endbuild);
       
    63 		content = content.substring(ind, ind2-1);
       
    64 		
       
    65 		ind2 = content.indexOf("<h4");
       
    66 				var ind3 = content.indexOf("</h4>",ind2);
       
    67 		while (ind2!= -1){
       
    68 			builddescription.setText(builddescription.getText() + content.substring(ind2, ind3)+ ":");
       
    69 			//find the first RAG
       
    70 			ind2=content.indexOf("<tr>",ind3);
       
    71 			ind3=content.indexOf("<tr>",ind2);
       
    72 			ind2=content.indexOf("<td>",ind3);
       
    73 			ind3=content.indexOf("<td>",ind2+4);
       
    74 			ind2=content.indexOf("<td>",ind3+4);
       
    75 			ind3=content.indexOf("<td>",ind2+4);
       
    76 			ind2=content.indexOf("</td>",ind3+4);
       
    77 			builddescription.setText(builddescription.getText() + content.substring(ind3+4, ind2));
       
    78 			
       
    79 			ind2 = content.indexOf("<h4",ind3);
       
    80 			ind3 = content.indexOf("</h4>",ind2);
       
    81 		}
       
    82 				
       
    83 		uiManager.hideNotification();
       
    84 		
       
    85 	}
       
    86 	
       
    87 }