Live Helper Chat support forum.. Forum is locked. New place for questions - Github Discussions

You are not logged in.

Announcement

#1 2017-11-29 15:31:53

RichardO
Member
Registered: 2016-03-02
Posts: 24

Using lhc online status with JS to change <div> content

Hi

I'm not referring to customisation within lhc.

On www.donbur.co.uk, I use lhc and have been for some time - It's great!!

In the footer (right side) of our new page design *** http://www.donbur.co.uk/test I have a section with a graphic that I would like to change depending on whether someone is online or not.

The widget does this, but is there a javascript method to detect online status and change the content of a div?

For instance, I could have

[== HTML ==]
<div id="lhcstatusgraphic"></div>

Then a piece of js to put "online" or "offline" into the div.

I'm sure this is possible but I'm not sure how to go about it.

Any help would be appreciated.

Thanks, Richard

Last edited by RichardO (2017-11-29 15:33:04)

Offline

#2 2017-11-29 15:53:25

PeopleInside
Administrator
From: Italy
Registered: 2014-04-10
Posts: 4,046
Website

Re: Using lhc online status with JS to change <div> content


lol PeopleInside - Live helper chat - free limited forum support!
wink For commercial support or GitHub [see FAQ here]
ops If you want to support this open source project, just donate [see support page]
glasses Something wrong with the forum? [contact a superhero]

Offline

#3 2017-11-29 15:58:21

RichardO
Member
Registered: 2016-03-02
Posts: 24

Re: Using lhc online status with JS to change <div> content


Thank you for these links.

Unfortunately, most of these are very general links to various help topics but it doesn't answer my question.

If you read the question, you'll see I'm not trying to alter templates or modify lhc in any way.  I simply want to detect if lhc users are online or offline.

Offline

#4 2017-11-29 18:08:10

PeopleInside
Administrator
From: Italy
Registered: 2014-04-10
Posts: 4,046
Website

Re: Using lhc online status with JS to change <div> content

Sorry,
I cannot help more with that.

You can find some suggestions here:
https://forum.livehelperchat.com/viewtopic.php?id=2255


lol PeopleInside - Live helper chat - free limited forum support!
wink For commercial support or GitHub [see FAQ here]
ops If you want to support this open source project, just donate [see support page]
glasses Something wrong with the forum? [contact a superhero]

Offline

#5 2017-11-29 18:15:17

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,661
Website

Re: Using lhc online status with JS to change <div> content

What you should is see what html elements lhc renders and add CSS to your stylesheet smile

Offline

#6 2017-11-30 08:55:11

RichardO
Member
Registered: 2016-03-02
Posts: 24

Re: Using lhc online status with JS to change <div> content

remdex wrote:

What you should is see what html elements lhc renders and add CSS to your stylesheet smile

Thanks Remdex.

Not a bad idea although I want to add additional content rather than changing existing css.  I'll look at element.cloneNode() to see if I can copy/append the html elements and add alternative css.

Thanks for trying.

Kind regards

Richard

Offline

#7 2017-11-30 09:55:59

RichardO
Member
Registered: 2016-03-02
Posts: 24

Re: Using lhc online status with JS to change <div> content

This works so I'm implementing now...

[== Undefined ==]
<span class="lhc-text-status">Offline</span>

<div id="lhcStatusDuplicate"></div>

<script>

    var lhcStatus = document.getElementsByClassName("lhc-text-status");
    var lhcStatusClone = lhcStatus[0].cloneNode(true);
	document.getElementById("lhcStatusDuplicate").appendChild(lhcStatusClone);

</script>

lhc renders a span with the class "lhc-text-status" which is either Offline or Online - great starting point.

The javascript above takes that content and duplicates into the div with id "lhcStatusDuplicate", which I can use .

Thought I'd post to help anyone else asking.

Thanks

Richard

_____________

*edit* - no it doesn't work - I'm getting an "Uncaught TypeError: Cannot read property 'cloneNode' of undefined..." shame...

Last edited by RichardO (2017-11-30 10:02:53)

Offline

#8 2017-11-30 16:09:02

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,661
Website

Re: Using lhc online status with JS to change <div> content

You can use one of the callbacks to lhc object then status widget is rendered.
https://livehelperchat.com/integration- … -273a.html

See in this URL for
show_widget_cb

Offline

#9 2017-11-30 16:13:41

RichardO
Member
Registered: 2016-03-02
Posts: 24

Re: Using lhc online status with JS to change <div> content

remdex wrote:

You can use one of the callbacks to lhc object then status widget is rendered.
https://livehelperchat.com/integration- … -273a.html

See in this URL for
show_widget_cb

Great!!  Thank you.

Offline

#10 2017-12-04 16:00:50

PeopleInside
Administrator
From: Italy
Registered: 2014-04-10
Posts: 4,046
Website

Re: Using lhc online status with JS to change <div> content

smile


lol PeopleInside - Live helper chat - free limited forum support!
wink For commercial support or GitHub [see FAQ here]
ops If you want to support this open source project, just donate [see support page]
glasses Something wrong with the forum? [contact a superhero]

Offline

Board footer