1 var nmbug_server = 'http://localhost:5000';
4 show: function (message_id) {
10 regexp: /gmane[.]org/,
11 handle: function (callback) {
12 var article = this._get_article();
13 this._get_message_id(article, callback);
15 _article_from_url: function (url) {
16 var regexp = new RegExp('http://article.gmane.org/([^/]+)/([0-9]+)');
17 var match = regexp.exec(url);
18 console.log('nmbug: get article from ' + url, match);
20 return {'group': match[1], 'id': parseInt(match[2])};
23 _get_article: function () {
24 var article = this._article_from_url(document.URL);
26 for (var i = 0; !article && i < window.frames.length; i++) {
27 article = this._article_from_url(window.frames[i].document.URL);
30 throw "Cannot extract an article from Gmane's " + document.URL;
34 _get_message_id: function (article, callback) {
41 console.log('nmbug: get Message-ID from ' + url);
42 var request = new XMLHttpRequest();
43 request.onload = function () {
44 var message_id = this.responseText;
47 request.open('get', url, true);
56 function _check_handler(handler) {
57 var match = handler.regexp.test(document.URL);
58 console.log('nmbug: testing', handler, match);
60 console.log('nmbug: matched', handler);
61 handler.handle(nmbug.show);
63 return match; /* break after the first match */
67 var matched = handlers.some(_check_handler);
69 throw 'No handler for ' + document.URL;