summaryrefslogtreecommitdiffabout
path: root/src/components
Unidiff
Diffstat (limited to 'src/components') (more/less context) (ignore whitespace changes)
-rwxr-xr-xsrc/components/xriProtocolHandler.js2
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)
200 knownServiceType = t.nodeValue; 200 knownServiceType = t.nodeValue;
201 } 201 }
202 202
203 serviceType = t.nodeValue; 203 serviceType = t.nodeValue;
204 html_types += "<strong>Type:</strong> " + t.nodeValue + "<br/>"; 204 html_types += "<strong>Type:</strong> " + t.nodeValue + "<br/>";
205 } 205 }
206 } 206 }
207 207
208 // get the paths 208 // get the paths
209 res = runExpr(doc, srv, "xrd:Path/text()"); 209 res = runExpr(doc, srv, "xrd:Path/text()");
210 var p; 210 var p;
211 var qxri_prefix = qxri; 211 var qxri_prefix = qxri;
212 if (qxri_prefix.charAt(qxri_prefix.length - 1) != '/') { 212 if (qxri_prefix.charAt(qxri_prefix.length - 1) != '/') {
213 qxri_prefix += '/'; 213 qxri_prefix += '/';
214 } 214 }
215 215
216 while (p = res.iterateNext()) { 216 while (p = res.iterateNext()) {
217 if (p.nodeValue) { 217 if (p.nodeValue) {
218 html_paths += "<strong>Path:</strong> " + p.nodeValue 218 html_paths += "<strong>Path:</strong> " + p.nodeValue
219 + " [ <tt><a href=\"" + qxri_prefix + p.nodeValue + "\">" 219 + " [ <tt><a href=\"" + qxri_prefix + p.nodeValue + "\">"
220 + qxri_prefix + p.nodeValue + "</a></tt> ]" 220 + qxri_prefix + p.nodeValue + "</a></tt> ]"
221 + "<br/>\n"; 221 + "<br/>\n";
222 } 222 }
223 } 223 }
224 224
225 225
226 // get the mediatypes 226 // get the mediatypes
227 mediaTypes = new Array(); 227 mediaTypes = new Array();
228 res = runExpr(doc, srv, "xrd:MediaType/text()"); 228 res = runExpr(doc, srv, "xrd:MediaType/text()");
229 var m; 229 var m;
230 while (m = res.iterateNext()) { 230 while (m = res.iterateNext()) {
231 if (!knownServiceType) { 231 if (!knownServiceType) {
232 var srvType = guessServiceTypeByMime(m.nodeValue); 232 var srvType = guessServiceTypeByMime(m.nodeValue);
233 knownServiceType = srvType? srvType : null; 233 knownServiceType = srvType? srvType : null;
234 } 234 }
235 235
236 mediaTypes.push(m.nodeValue); 236 mediaTypes.push(m.nodeValue);
237 if (m.nodeValue) { 237 if (m.nodeValue) {
238 html_mediatypes += "<strong>Media Type:</strong> " + m.nodeValue + "<br/>"; 238 html_mediatypes += "<strong>Media Type:</strong> " + m.nodeValue + "<br/>";
239 } 239 }
240 } 240 }
241 241
242 242
243 res = runExpr(doc, srv, "xrd:URI"); 243 res = runExpr(doc, srv, "xrd:URI");
244 var uu; 244 var uu;
245 while (uu = res.iterateNext()) { 245 while (uu = res.iterateNext()) {
246 var u = uu.firstChild; 246 var u = uu.firstChild;
247 if (!(u.nodeValue && u.nodeType==3)) 247 if (!(u.nodeValue && u.nodeType==3))
248 continue; 248 continue;
249 249
250 var srvType = guessServiceTypeByURI(u.nodeValue); 250 var srvType = guessServiceTypeByURI(u.nodeValue);
251 if (!knownServiceType) { 251 if (!knownServiceType) {
252 knownServiceType = srvType; 252 knownServiceType = srvType;
253 } 253 }
254 254
255 html_uris += "<div class=\"" + getServiceClass(srvType) + "\">"; 255 html_uris += "<div class=\"" + getServiceClass(srvType) + "\">";
256 256
257 var linkContent = u.nodeValue; 257 var linkContent = u.nodeValue;
258 var uriParts = u.nodeValue.match('^(.*):(.*)$'); 258 var uriParts = u.nodeValue.match('^(.*):(.*)$');
259 if (!uriParts) 259 if (!uriParts)
260 continue; 260 continue;
261 261
262 if (uriParts[1] == 'data') { 262 if (uriParts[1] == 'data') {
263 uriParts = uriParts[2].match('^(.*/.*),(.*)'); 263 uriParts = uriParts[2].match('^(.*/.*),(.*)');
264 if (uriParts && uriParts[1].match('^image/', 'i')) { 264 if (uriParts && uriParts[1].match('^image/', 'i')) {
265 linkContent = "<img src=\"" + u.nodeValue + "\"/>"; 265 linkContent = "<img src=\"" + u.nodeValue + "\"/>";
266 } 266 }
267 else if (uriParts) { 267 else if (uriParts) {
268 linkContent = uriParts[1] + " data"; 268 linkContent = uriParts[1] + " data";
269 } 269 }
270 } 270 }
271 else if (uriParts[1] == 'skype') { 271 else if (uriParts[1] == 'skype') {
272 uriParts = uriParts[2].match('^(.*)\\?(.*)'); 272 uriParts = uriParts[2].match('^(.*)\\?(.*)');
273 if (uriParts) { 273 if (uriParts) {
274 if (uriParts[2] == "call") { 274 if (uriParts[2] == "call") {
275 linkContent = "<img src=\"chrome://foxri/content/skype_call_large.png\" alt=\"Call " + uriParts[1] + "\"/>"; 275 linkContent = "<img src=\"chrome://foxri/content/skype_call_large.png\" alt=\"Call " + uriParts[1] + "\"/>";
276 } 276 }
277 else if (uriParts[2] == "chat") { 277 else if (uriParts[2] == "chat") {
278 linkContent = "<img src=\"chrome://foxri/content/skype_chat_large.png\" alt=\"Chat with " + uriParts[1] + "\"/>"; 278 linkContent = "<img src=\"chrome://foxri/content/skype_chat_large.png\" alt=\"Chat with " + uriParts[1] + "\"/>";
279 } 279 }
280 else if (uriParts[2] == "add") { 280 else if (uriParts[2] == "add") {
281 linkContent = "<img src=\"chrome://foxri/content/skype_add_large.png\" alt=\"Add " + uriParts[1] + " to Skype\"/>"; 281 linkContent = "<img src=\"chrome://foxri/content/skype_add_large.png\" alt=\"Add " + uriParts[1] + " to Skype\"/>";
282 } 282 }
283 } 283 }
284 } 284 }
285 else if (uriParts[1] == 'aim') { 285 else if (uriParts[1] == 'aim') {
286 uriParts = uriParts[2].match('^(.*)\\?.*screenname=([^&]*)', 'i'); 286 uriParts = uriParts[2].match('^(.*)\\?.*screenname=([^&]*)', 'i');
287 if (uriParts) { 287 if (uriParts) {
288 linkContent = "<img src=\"chrome://foxri/content/aim_logo.gif\" alt=\"Chat with " + uriParts[2] + "\"/> Chat with " + uriParts[2]; 288 linkContent = "<img src=\"chrome://foxri/content/aim_logo.gif\" alt=\"Chat with " + uriParts[2] + "\"/> Chat with " + uriParts[2];
289 } 289 }
290 } 290 }
291 291
292 var linkhref = u.nodeValue; 292 var linkhref = u.nodeValue;
293 var xrap = uu.getAttribute('append'); 293 var xrap = uu.getAttribute('append');
294 if(xrap=='qxri') { 294 if(xrap=='qxri') {
295 linkhref += qxri.replace(/^xri:\/\//,''); 295 linkhref += qxri.replace(/^xri:\/\//,'');
296 }else if(xrap=='authority') {
297 linkhref += qxri.replace(/^xri:\/\//,'').replace(/\//.*,'');
296 }else if(xrap!=null){ 298 }else if(xrap!=null){
297 dump("Unhandled @append: "+xrap+"\n"); 299 dump("Unhandled @append: "+xrap+"\n");
298 } 300 }
299 html_uris += "<a href=\""+linkhref+"\">" 301 html_uris += "<a href=\""+linkhref+"\">"
300 + linkContent + "</a>"; 302 + linkContent + "</a>";
301 html_uris += "</div>"; 303 html_uris += "</div>";
302 } 304 }
303 305
304 var html = "<div class=\"service srv_" + getServiceClass(knownServiceType) + "\">\n"; 306 var html = "<div class=\"service srv_" + getServiceClass(knownServiceType) + "\">\n";
305 html += html_types; 307 html += html_types;
306 html += html_paths; 308 html += html_paths;
307 html += html_mediatypes; 309 html += html_mediatypes;
308 if (html_uris) { 310 if (html_uris) {
309 html += "<strong>URI(s):</strong><br/>\n"; 311 html += "<strong>URI(s):</strong><br/>\n";
310 html += html_uris; 312 html += html_uris;
311 } 313 }
312 html += "</div>"; 314 html += "</div>";
313 315
314 return html; 316 return html;
315} 317}
316 318
317 319
318 320
319function isKnownServiceType(type) 321function isKnownServiceType(type)
320{ 322{
321 if (type.toLowerCase() in SERVICE_CLASSES) { 323 if (type.toLowerCase() in SERVICE_CLASSES) {
322 return true; 324 return true;
323 } 325 }
324 return false; 326 return false;
325} 327}
326 328
327function getServiceClass(type) 329function getServiceClass(type)
328{ 330{
329 if (type && isKnownServiceType(type)) { 331 if (type && isKnownServiceType(type)) {
330 return SERVICE_CLASSES[type.toLowerCase()]; 332 return SERVICE_CLASSES[type.toLowerCase()];
331 } 333 }
332 return type; 334 return type;
333} 335}
334 336
335 337
336function guessServiceTypeByURI(uri) 338function guessServiceTypeByURI(uri)
337{ 339{
338 if (uri == null || uri == "") { 340 if (uri == null || uri == "") {
339 return "unknown"; 341 return "unknown";
340 } 342 }
341 if (uri.match(/^https?:/i)) { 343 if (uri.match(/^https?:/i)) {
342 return "www"; 344 return "www";
343 } 345 }
344 else if (uri.match(/^skype:/i)) { 346 else if (uri.match(/^skype:/i)) {
345 return "skype"; 347 return "skype";
346 } 348 }
347 else if (uri.match(/^aim:/i)) { 349 else if (uri.match(/^aim:/i)) {
348 return "aim"; 350 return "aim";
349 } 351 }
350 else if (uri.match(/^xmpp:/i)) { 352 else if (uri.match(/^xmpp:/i)) {
351 return "jabber"; 353 return "jabber";
352 } 354 }
353 else if (uri.match(/^tel:/i)) { 355 else if (uri.match(/^tel:/i)) {
354 return "tel"; 356 return "tel";
355 } 357 }
356 else if (uri.match(/^callto:/i)) { 358 else if (uri.match(/^callto:/i)) {
357 return "callto"; 359 return "callto";
358 } 360 }
359 else if (uri.match(/^telnet:/i)) { 361 else if (uri.match(/^telnet:/i)) {
360 return "telnet"; 362 return "telnet";
361 } 363 }
362 else if (uri.match(/^news:/i)) { 364 else if (uri.match(/^news:/i)) {
363 return "news"; 365 return "news";
364 } 366 }
365 else if (uri.match(/^nntp:/i)) { 367 else if (uri.match(/^nntp:/i)) {
366 return "nntp"; 368 return "nntp";
367 } 369 }
368 else if (uri.match(/^ftp:/i)) { 370 else if (uri.match(/^ftp:/i)) {
369 return "ftp"; 371 return "ftp";
370 } 372 }
371 else if (uri.match(/^mailto:/i)) { 373 else if (uri.match(/^mailto:/i)) {
372 return "email"; 374 return "email";
373 } 375 }
374 else if (uri.match(/^urn:/i)) { 376 else if (uri.match(/^urn:/i)) {
375 return "urn"; 377 return "urn";
376 } 378 }
377 else if (uri.match(/^data:/i)) { 379 else if (uri.match(/^data:/i)) {
378 return "data"; 380 return "data";
379 } 381 }
380 else if (uri.match(/^feed:/i)) { 382 else if (uri.match(/^feed:/i)) {
381 return "feed"; 383 return "feed";
382 } 384 }
383 return "unknown"; 385 return "unknown";
384} 386}
385 387
386 388
387function guessServiceTypeByMime(mimeType) 389function guessServiceTypeByMime(mimeType)
388{ 390{
389 if (mimeType.match(/^application\/(rss|atom)\+xml/i)) { 391 if (mimeType.match(/^application\/(rss|atom)\+xml/i)) {
390 dump("feed detected!\n"); 392 dump("feed detected!\n");
391 return "feed"; 393 return "feed";