~autra/webapps-applications/deezer

« back to all changes in this revision

Viewing changes to src/LinkedIn/LinkedIn.user.js

  • Committer: autra
  • Date: 2013-04-11 12:34:24 UTC
  • mfrom: (406.1.108 trunk)
  • Revision ID: autra@autra-optiplex-380-20130411123424-3b0xa9ppaytxx3hr
sync from parent

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
window.Unity = external.getUnityObject(1);
8
8
 
 
9
/**
 
10
 * User script self validation
 
11
 * 
 
12
 * Called by the testing framework to make sure that
 
13
 * the page layout seems ok.
 
14
 */
 
15
function selfTest() {
 
16
    if (!getComposeNewMessageClickTargetNode()) {
 
17
        return;
 
18
    }
 
19
 
 
20
    // We are done
 
21
    reportTestState('PASS SELF TEST');
 
22
}
 
23
 
 
24
function getComposeNewMessageClickTargetNode() {
 
25
    return document.evaluate('//li[@id="nav-primary-inbox"]/ul/li[3]/a',
 
26
                             document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
 
27
};
 
28
 
9
29
function isCorrectPage() {
10
 
    var i, ids = ['header', 'nav-primary-news'];
 
30
    var i, ids = ['header'];
11
31
 
12
32
    for (i = 0; i < ids.length; i++) {
13
33
        if (!document.getElementById(ids[i])) {
45
65
}
46
66
 
47
67
function messagingIndicatorSetup() {
48
 
    setInterval(wrapCallback(function () {
 
68
    function checkMessagesCount() {
49
69
        var count = document.getElementById('header-messages-count');
50
70
 
51
71
        if (count) {
52
72
            count = count.textContent.match(/\d+/)[0];
53
 
            Unity.MessagingIndicator.showIndicator(_("Inbox"), { count: count,
54
 
                                                                 callback: makeRedirector('http://www.linkedin.com/inbox/messages/received?trk=hb_tab_inbox_top') });
55
73
        } else {
56
 
            Unity.MessagingIndicator.showIndicator(_("Inbox"), { count: 0,
57
 
                                                                 callback: makeRedirector('http://www.linkedin.com/inbox/messages/received?trk=hb_tab_inbox_top') });
 
74
            count = '0';
58
75
        }
59
 
    }), 4000);
 
76
        return [{ name: _("Inbox"),
 
77
                  count: count,
 
78
                  callback: makeRedirector('http://www.linkedin.com/inbox/messages/received?trk=hb_tab_inbox_top') }];
 
79
    }
 
80
    var indicatorsController = new Indicators(checkMessagesCount);
60
81
 
61
82
    function composeNewMessage() {
62
 
        var node = document.evaluate('//div[@id="inbox-overlay-messages-header"]/div[2]/a',
63
 
                          document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
 
83
        var node = getComposeNewMessageClickTargetNode();
64
84
        launchClickEvent(node);
65
85
    }
66
86
    Unity.Launcher.addAction(_("Compose New Message"),
67
87
                             wrapCallback(composeNewMessage));
68
88
 
69
89
    doMatrixIntegration();
 
90
 
 
91
    selfTest();
70
92
}
71
93
 
72
94
if (isCorrectPage()) {