Insert text in the chat input

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

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.

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.

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

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

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

I'm injecting this code direct to room chat.

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

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.

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.

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.

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.

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...

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

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 14, 2018 in Hipchat Cloud

Hipchat Cloud and Stride End of Life: Just under 30 days away

Earlier this year we made the difficult decision to discontinue our team messaging tools, Stride and Hipchat. The end of life date for Stride and Hipchat Cloud is quickly approaching - February 15, 2...

30,502 views 0 7
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you