51
|
1 |
var revisionview=null;
|
|
2 |
|
|
3 |
|
|
4 |
function PackageMercurialUrl () {
|
|
5 |
if (!Packageid) {return;}
|
|
6 |
MCLrepos = new Ajax();
|
|
7 |
MCLrepos.onreadystatechange = PackageMercurialUrlCompleted;
|
|
8 |
MCLrepos.open('GET', nocache(mercurialUrl), true);
|
|
9 |
debuglog.debug ("accessing mercurial url: "+ mercurialUrl);
|
|
10 |
MCLrepos.send(null);
|
|
11 |
|
|
12 |
}
|
|
13 |
|
|
14 |
function PackageMercurialUrlCompleted () {
|
|
15 |
|
|
16 |
if (MCLrepos.readyState == 4) {
|
|
17 |
var pagetext = MCLrepos.responseText;
|
|
18 |
|
|
19 |
var ind = pagetext.indexOf(Packageid +"/");
|
|
20 |
pagetext = pagetext.substr(1,ind+Packageid.length);
|
|
21 |
debuglog.debug("result of regexp search for url is " + ind + " Package name is "+Packageid);
|
|
22 |
|
|
23 |
if (ind==-1){
|
|
24 |
uiManager.showNotification(1000, "Warning", "Mercurial - Package Not Found");
|
|
25 |
debuglog.debug ("Error - Package not found in the FCL page");
|
|
26 |
return;
|
|
27 |
}
|
|
28 |
ind=pagetext.lastIndexOf("href");
|
|
29 |
|
|
30 |
mercurialPackageUrl = symbianOrgBaseUrl + pagetext.substr(ind+6,pagetext.length-ind-6) + mercurialrss;
|
|
31 |
debuglog.debug("mercurial FCL repo URL is:" + mercurialPackageUrl);
|
|
32 |
//save settings
|
|
33 |
if (window.widget) {
|
|
34 |
widget.setPreferenceForKey(mercurialPackageUrl, "mercurialPackageUrl");
|
|
35 |
} else {
|
|
36 |
debuglog.debug("mercurial - widget not found");
|
|
37 |
}
|
|
38 |
}
|
|
39 |
}
|
|
40 |
|
|
41 |
|
|
42 |
function MercurialFeedPresenter(rssreader) {
|
|
43 |
var myreader = rssreader;
|
|
44 |
|
|
45 |
ButtonFeedPresenter.prototype.init.call(this, rssreader);
|
|
46 |
}
|
|
47 |
|
|
48 |
MercurialFeedPresenter.prototype = new ButtonFeedPresenter(null);
|
|
49 |
|
|
50 |
// Handle the button-press
|
|
51 |
MercurialFeedPresenter.prototype.feedClicked = function(event){
|
|
52 |
var clickedButton = event.source;
|
|
53 |
var id = clickedButton.id;
|
|
54 |
var myitem = this.items[id]
|
|
55 |
revisionpresenter(myitem,this.rssreader);
|
|
56 |
}
|
|
57 |
|
|
58 |
function revisionpresenter(aItem, aParent) {
|
|
59 |
revisionview = new ListView(null, createCaption(aItem.title));
|
|
60 |
revisionview.previousView = aParent;
|
|
61 |
|
|
62 |
var mytext = new ContentPanel(null, null, null, true);
|
|
63 |
mytext.setExpanded(true);
|
|
64 |
|
|
65 |
revisionview.addControl(mytext);
|
|
66 |
var mybuf = "<br><div class=\"FeedItemLink\">";
|
|
67 |
mybuf += "<a href=\"JavaScript:void(0)\" onclick=\"openURL('" + symbianOrgBaseUrl + aItem.url + "'); return false;\">";
|
|
68 |
mybuf += "Open in browser..";
|
|
69 |
mybuf += "</a>";
|
|
70 |
mybuf += "</div><br>";
|
|
71 |
|
|
72 |
var description = "<table style="+bugzillaTableStyle+">";
|
|
73 |
description += "<tr><td>Author:" + "</td><td>" + aItem.author + "</td></tr>";
|
|
74 |
description += "<tr><td>Date:" + "</td><td>" + aItem.date + "</td></tr>";
|
|
75 |
description += "</table>";
|
|
76 |
description += "<table style="+bugzillaTableStyle+"><tr><td>";
|
|
77 |
description += mybuf;
|
|
78 |
description += "<div class=\"FeedItemDescription\">"
|
|
79 |
description += "<b>Description:</b><br>" + aItem.description ;
|
|
80 |
description += "</div>";
|
|
81 |
description += "</td></tr></table>";
|
|
82 |
|
|
83 |
mytext.setContent(description);
|
|
84 |
revisionview.show();
|
|
85 |
|
|
86 |
|
|
87 |
}
|
|
88 |
|
|
89 |
function parseRepoFeed (broker, responseStatus, xmlDoc) {
|
|
90 |
|
|
91 |
if (responseStatus == 200 && xmlDoc != null) {
|
|
92 |
// node ref for iterating
|
|
93 |
var node;
|
|
94 |
|
|
95 |
// for compatibility with rss
|
|
96 |
var lastModified = new Date();
|
|
97 |
|
|
98 |
// init result items array
|
|
99 |
var items = [];
|
|
100 |
|
|
101 |
var itemElements = xmlDoc.getElementsByTagName("item");
|
|
102 |
|
|
103 |
for (var i = 0; i < itemElements.length; i++) {
|
|
104 |
// iterate through child nodes of this item and gather
|
|
105 |
// all the data we need for a feed item
|
|
106 |
var title = null;
|
|
107 |
var date = null;
|
|
108 |
var description = null;
|
|
109 |
var url = null;
|
|
110 |
var author = null;
|
|
111 |
var changeset = null;
|
|
112 |
node = itemElements[i].firstChild;
|
|
113 |
while (node != null) {
|
|
114 |
if (node.nodeType == Node.ELEMENT_NODE) {
|
|
115 |
if (node.nodeName == "title") {
|
|
116 |
// item title
|
|
117 |
title = getTextOfNode(node);
|
|
118 |
if ( title.length > 48) {
|
|
119 |
title = title.substring(0,45) + "...";
|
|
120 |
}
|
|
121 |
} else if (node.nodeName == "pubDate" ) {
|
|
122 |
// item publishing date
|
|
123 |
date = getTextOfNode(node);
|
|
124 |
} else if (node.nodeName == "description" && !this.ignoreContent ) {
|
|
125 |
// item description
|
|
126 |
description = getTextOfNode(node);
|
|
127 |
} else if (node.nodeName == "guid") {
|
|
128 |
// link URL
|
|
129 |
url = getTextOfNode(node);
|
|
130 |
// extract bug revision
|
|
131 |
ind=url.indexOf("rev/");
|
|
132 |
rev = url.substr(ind,url.length-ind);
|
|
133 |
|
|
134 |
} else if (node.nodeName == "author" ) {
|
|
135 |
author = getTextOfNode(node);
|
|
136 |
}
|
|
137 |
}
|
|
138 |
node = node.nextSibling;
|
|
139 |
}
|
|
140 |
items.push({ title: title, date: date, description: description, url: url, author: author, rev: rev });
|
|
141 |
}
|
|
142 |
|
|
143 |
// update was completed successfully
|
|
144 |
return { status: "ok", lastModified: lastModified, items: items };
|
|
145 |
} else {
|
|
146 |
// update failed
|
|
147 |
return { status: "error" };
|
|
148 |
}
|
|
149 |
}
|
|
150 |
|
|
151 |
|