-
Notifications
You must be signed in to change notification settings - Fork 5
/
notification.js
49 lines (43 loc) · 1.5 KB
/
notification.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Note: customDisplayPrefixes is already in scope in this file.
// It's a global, declared in domains/domains.js
var populate = function(options){
/*
* options contains:
* about
* knownPrefixes
* tabId
* tagValueHandler
*/
var about = options.about;
var truncatedAbout = valueUtils.truncateAbout(about, 35);
var url = 'http://' + lovemedoHost + '/about/' + encodeURIComponent(about);
document.getElementById('fi_url').innerHTML = Mustache.render(
'<a href="{{url}}" target="_blank">{{truncatedAbout}}</a>.', {
truncatedAbout: truncatedAbout,
url: url
}
);
document.getElementById('fi_open_sidebar').addEventListener(
'click',
function(evt){
var port = chrome.tabs.connect(options.tabId, {name: 'sidebar'});
port.postMessage({
about: options.about,
action: 'show sidebar'
});
evt.preventDefault();
evt.stopPropagation();
return false;
},
false
);
// Add the HTML for each of the custom prefixes on the object.
var content = [];
for (var i = 0; i < options.knownPrefixes.length; i++){
var prefix = options.knownPrefixes[i];
var func = customDisplayPrefixes[prefix];
var tagValues = options.tagValueHandler.cache;
content.push(func(tagValues, about));
}
document.getElementById('fi_tags').innerHTML = content.join('');
};