Insert text in the chat input

brocoder1 December 4, 2015

Hello. I trying to do this. But i need it in firefox extension. I'm including:
bitbucket.org/atlassian/simple-xdm/raw/62355f436bb3966cf4098f41cef544b7dbc4c6bc/dist/iframe.min.js

ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js

aui-cdn.atlassian.com/aui-adg/5.8.14/js/aui.js

and do this:

require('chat', function(chat) {
chat.appendMessage('Hello');
});

So, iframe.min.js say me this:

Error: See almond README: incorrect module build, no module name.

Could anyone give me full code (outside the HipChat ext) or say what i missed? Thanks.

4 answers

0 votes
brocoder1 December 6, 2015

Generally, i'm writing firefox plugin which must send some message via chat input. Couldn't do it via javascript button pressing emulation and etc, so, i noticed to api. Ideally i want just set text to input.

rich
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 7, 2015

Ah... why don't you just access the chat input element directly and update the value then? The iframe.min.js you're including is specifically for use with HipChat Connect add-ons, not browser add-ons.

rich
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 7, 2015

Scratch that... use the `HC.api.appendMessage({text:"TEXT"})` js api to append text to the chat input. Assuming you'll be able to execute you JS directly on the page.

brocoder1 December 7, 2015

Rich, u are my savior! But where i can read about this api? Considering full task, i need to catch message sending, change message and send. It's real via hacks although...

brocoder1 December 8, 2015

I have tryed to foreach HC.api, but it haven't any interisting things :( Can i register message-catch event or clear the input?

brocoder1 December 8, 2015

Found! webpack://./src/js/app/api.js. It haven't input clearer but.. it have sendMessage smile

0 votes
oscar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 6, 2015

Hi,

Would you mind explaining what it is you're trying to build? The HipChat Connect framework is meant to be used for addons that run within HipChat, and will not work outside that scope.

So for example, if you're building an extension for Firefox, you won't be able to use HipChat Connect.

0 votes
brocoder1 December 4, 2015

ReferenceError: AP is not defined

<script>
    $.getScript(
        '//bitbucket.org/atlassian/simple-xdm/raw/62355f436bb3966cf4098f41cef544b7dbc4c6bc/dist/iframe.min.js',
        function() {
            $.getScript(
                '//aui-cdn.atlassian.com/aui-adg/5.8.14/js/aui.js',
                function() {
                    AP.require('chat', function(chat) {
                        chat.appendMessage('Hello!!');
                    });
                }
            );
        }
    );
</script>

Seems i missed some js libs to include.

rich
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 4, 2015

Why are you loading the script via ajax? Just add it to your <head>.

brocoder1 December 4, 2015

It's not about html, it's about my firefox plugin. This example - only for clarity

brocoder1 December 4, 2015

So, where is AP? How i can to include it?

brocoder1 December 4, 2015

I'm injecting this code direct to room chat.

brocoder1 December 5, 2015

And after including iframe.min.js i have: Uncaught Error: See almond README: incorrect module build, no module name I googled many times, but could not fix it. It want i define some name

0 votes
rich
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 4, 2015

You have to use the AP. prefix in front of require... like so:

AP.require('chat', function(chat) {
   chat.appendMessage('Hello!!');
});

BTW, aui.js and jquery aren't required for that to work.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events