-rwxr-xr-x | src/components/xriProtocolHandler.js | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/components/xriProtocolHandler.js b/src/components/xriProtocolHandler.js index 3d27784..2e09f64 100755 --- a/src/components/xriProtocolHandler.js +++ b/src/components/xriProtocolHandler.js @@ -200,192 +200,194 @@ function renderService(srv, doc, qxri) knownServiceType = t.nodeValue;
}
serviceType = t.nodeValue;
html_types += "<strong>Type:</strong> " + t.nodeValue + "<br/>";
}
}
// get the paths
res = runExpr(doc, srv, "xrd:Path/text()");
var p;
var qxri_prefix = qxri;
if (qxri_prefix.charAt(qxri_prefix.length - 1) != '/') {
qxri_prefix += '/';
}
while (p = res.iterateNext()) {
if (p.nodeValue) {
html_paths += "<strong>Path:</strong> " + p.nodeValue
+ " [ <tt><a href=\"" + qxri_prefix + p.nodeValue + "\">"
+ qxri_prefix + p.nodeValue + "</a></tt> ]"
+ "<br/>\n";
}
}
// get the mediatypes
mediaTypes = new Array();
res = runExpr(doc, srv, "xrd:MediaType/text()");
var m;
while (m = res.iterateNext()) {
if (!knownServiceType) {
var srvType = guessServiceTypeByMime(m.nodeValue);
knownServiceType = srvType? srvType : null;
}
mediaTypes.push(m.nodeValue);
if (m.nodeValue) {
html_mediatypes += "<strong>Media Type:</strong> " + m.nodeValue + "<br/>";
}
}
res = runExpr(doc, srv, "xrd:URI");
var uu;
while (uu = res.iterateNext()) {
var u = uu.firstChild;
if (!(u.nodeValue && u.nodeType==3))
continue;
var srvType = guessServiceTypeByURI(u.nodeValue);
if (!knownServiceType) {
knownServiceType = srvType;
}
html_uris += "<div class=\"" + getServiceClass(srvType) + "\">";
var linkContent = u.nodeValue;
var uriParts = u.nodeValue.match('^(.*):(.*)$');
if (!uriParts)
continue;
if (uriParts[1] == 'data') {
uriParts = uriParts[2].match('^(.*/.*),(.*)');
if (uriParts && uriParts[1].match('^image/', 'i')) {
linkContent = "<img src=\"" + u.nodeValue + "\"/>";
}
else if (uriParts) {
linkContent = uriParts[1] + " data";
}
}
else if (uriParts[1] == 'skype') {
uriParts = uriParts[2].match('^(.*)\\?(.*)');
if (uriParts) {
if (uriParts[2] == "call") {
linkContent = "<img src=\"chrome://foxri/content/skype_call_large.png\" alt=\"Call " + uriParts[1] + "\"/>";
}
else if (uriParts[2] == "chat") {
linkContent = "<img src=\"chrome://foxri/content/skype_chat_large.png\" alt=\"Chat with " + uriParts[1] + "\"/>";
}
else if (uriParts[2] == "add") {
linkContent = "<img src=\"chrome://foxri/content/skype_add_large.png\" alt=\"Add " + uriParts[1] + " to Skype\"/>";
}
}
}
else if (uriParts[1] == 'aim') {
uriParts = uriParts[2].match('^(.*)\\?.*screenname=([^&]*)', 'i');
if (uriParts) {
linkContent = "<img src=\"chrome://foxri/content/aim_logo.gif\" alt=\"Chat with " + uriParts[2] + "\"/> Chat with " + uriParts[2];
}
}
var linkhref = u.nodeValue;
var xrap = uu.getAttribute('append');
if(xrap=='qxri') {
linkhref += qxri.replace(/^xri:\/\//,'');
+ }else if(xrap=='authority') {
+ linkhref += qxri.replace(/^xri:\/\//,'').replace(/\//.*,'');
}else if(xrap!=null){
dump("Unhandled @append: "+xrap+"\n");
}
html_uris += "<a href=\""+linkhref+"\">"
+ linkContent + "</a>";
html_uris += "</div>";
}
var html = "<div class=\"service srv_" + getServiceClass(knownServiceType) + "\">\n";
html += html_types;
html += html_paths;
html += html_mediatypes;
if (html_uris) {
html += "<strong>URI(s):</strong><br/>\n";
html += html_uris;
}
html += "</div>";
return html;
}
function isKnownServiceType(type)
{
if (type.toLowerCase() in SERVICE_CLASSES) {
return true;
}
return false;
}
function getServiceClass(type)
{
if (type && isKnownServiceType(type)) {
return SERVICE_CLASSES[type.toLowerCase()];
}
return type;
}
function guessServiceTypeByURI(uri)
{
if (uri == null || uri == "") {
return "unknown";
}
if (uri.match(/^https?:/i)) {
return "www";
}
else if (uri.match(/^skype:/i)) {
return "skype";
}
else if (uri.match(/^aim:/i)) {
return "aim";
}
else if (uri.match(/^xmpp:/i)) {
return "jabber";
}
else if (uri.match(/^tel:/i)) {
return "tel";
}
else if (uri.match(/^callto:/i)) {
return "callto";
}
else if (uri.match(/^telnet:/i)) {
return "telnet";
}
else if (uri.match(/^news:/i)) {
return "news";
}
else if (uri.match(/^nntp:/i)) {
return "nntp";
}
else if (uri.match(/^ftp:/i)) {
return "ftp";
}
else if (uri.match(/^mailto:/i)) {
return "email";
}
else if (uri.match(/^urn:/i)) {
return "urn";
}
else if (uri.match(/^data:/i)) {
return "data";
}
else if (uri.match(/^feed:/i)) {
return "feed";
}
return "unknown";
}
function guessServiceTypeByMime(mimeType)
{
if (mimeType.match(/^application\/(rss|atom)\+xml/i)) {
dump("feed detected!\n");
return "feed";
|