Double Slider not running on ESP, but running well locally

All that relates to Javascript, CSS, HTML, ....
ulli
Posts: 47
Joined: Tue Feb 09, 2021 9:48 am
Location: Monschau, Germany
Has thanked: 8 times
Been thanked: 2 times

Double Slider not running on ESP, but running well locally

Post by ulli »

Hi all,

I'm running crazy to get some javascript and css running on an ESP8266. It runs very well directly on my browser (FireFox) from local files, but if I upload these files to an ESP, it refuses to display the slider.

The necessary js and css files are:
nouislider.min.js
nouislider.css

They can be downloaded here:
https://github.com/leongersen/noUiSlide ... aster/dist

The html file to try it (I called it aha.html) is

Code: [Local Link Removed for Guests]

<!DOCTYPE html>
<html>
	<head>
<link rel="stylesheet" href="./nouislider.css">
	</head>
	<body>
<div >
    <div id="kt_slider_basic"></div>

    <div >
        <div >Min: <span id="kt_slider_basic_min"></span></div>
	<!--     <div class="fw-semibold mb-2">Min: <textbox$(t_min,"kt_slider_basic_min")</div>a-->
        <div >Max: <span id="kt_slider_basic_max"></span></div>
    </div>
</div>

<script src='nouislider.min.js'></script>
<script src='aha.js'></script>
	</body>
</html>
and the js file needed (aha.js) is

Code: [Local Link Removed for Guests]

var slider = document.querySelector("#kt_slider_basic");
var valueMin = document.querySelector("#kt_slider_basic_min");
var valueMax = document.querySelector("#kt_slider_basic_max");

noUiSlider.create(slider, {
    start: [480, 1230],
    connect: true,
    range: {
    min: 360,
    max: 1380
    },
    step: 15
});

slider.noUiSlider.on("update", function (values, handle) {
	var hours1 = Math.floor(values[0] / 60);
        var minutes1 = values[0] - (hours1 * 60);
        if (hours1.length == 1) hours1 = '0' + hours1;
        if (minutes1.length == 1) minutes1 = '0' + minutes1;
        if (minutes1 == 0) minutes1 = '00';
        hours1 = hours1;
        if (hours1 == 0) {
            hours1 = 12;
            minutes1 = minutes1;
        }
        valueMin.innerHTML = (hours1 + ':' + minutes1);
        var hours2 = Math.floor(values[1] / 60);
        var minutes2 = values[1] - (hours2 * 60);
        if (hours2.length == 1) hours2 = '0' + hours2;
        if (minutes2.length == 1) minutes2 = '0' + minutes2;
        if (minutes2 == 0) minutes2 = '00';
        hours2 = hours2;
        valueMax.innerHTML = (hours2 + ':' + minutes2);

});

If I open aha.html with my browser, everything is as expected, but I don't get it running on my ESP.
What's the magic spell?

Thanks for your help

Ulli
User avatar
cicciocb
Site Admin
Posts: 2041
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 436 times
Been thanked: 1342 times
Contact:

Re: Double Slider not running on ESP, but running well locally

Post by cicciocb »

All depends on what you want do.
In my case it works well on an ESP8266 but, probably, this is not what you want do :D
image.png
You do not have the required permissions to view the files attached to this post.
User avatar
cicciocb
Site Admin
Posts: 2041
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 436 times
Been thanked: 1342 times
Contact:

Re: Double Slider not running on ESP, but running well locally

Post by cicciocb »

Probably you want do that :

Code: [Local Link Removed for Guests]

cls

jsexternal "/nouislider.min.js"
pause 300
cssexternal "/nouislider.css"
pause 300

A$ = ||
A$ = A$ + |<!DOCTYPE html>|
A$ = A$ + |<html>|
A$ = A$ + | <head>|
A$ = A$ + |<link rel="stylesheet" href="./nouislider.css">|
A$ = A$ + | </head>|
A$ = A$ + | <body>|
A$ = A$ + |<div >|
A$ = A$ + |    <div id="kt_slider_basic"></div>|
A$ = A$ + ||
A$ = A$ + |    <div >|
A$ = A$ + |        <div >Min: <span id="kt_slider_basic_min"></span></div>|
A$ = A$ + | <!--     <div class="fw-semibold mb-2">Min: <textbox$(t_min,"kt_slider_basic_min")</div>a-->|
A$ = A$ + |        <div >Max: <span id="kt_slider_basic_max"></span></div>|
A$ = A$ + |    </div>|
A$ = A$ + |</div>|
A$ = A$ + ||
A$ = A$ + |<script src='nouislider.min.js'></script>|
A$ = A$ + |<script src='aha.js'></script>|
A$ = A$ + | </body>|
A$ = A$ + |</html>|
html a$

A$ = ||
A$ = A$ + |var slider = document.querySelector("#kt_slider_basic");|
A$ = A$ + |var valueMin = document.querySelector("#kt_slider_basic_min");|
A$ = A$ + |var valueMax = document.querySelector("#kt_slider_basic_max");|
A$ = A$ + ||
A$ = A$ + |noUiSlider.create(slider, {|
A$ = A$ + |    start: [480, 1230],|
A$ = A$ + |    connect: true,|
A$ = A$ + |    range: {|
A$ = A$ + |    min: 360,|
A$ = A$ + |    max: 1380|
A$ = A$ + |    },|
A$ = A$ + |    step: 15|
A$ = A$ + |});|
A$ = A$ + ||
A$ = A$ + |slider.noUiSlider.on("update", function (values, handle) {|
A$ = A$ + | var hours1 = Math.floor(values[0] / 60);|
A$ = A$ + |        var minutes1 = values[0] - (hours1 * 60);|
A$ = A$ + |        if (hours1.length == 1) hours1 = '0' + hours1;|
A$ = A$ + |        if (minutes1.length == 1) minutes1 = '0' + minutes1;|
A$ = A$ + |        if (minutes1 == 0) minutes1 = '00';|
A$ = A$ + |        hours1 = hours1;|
A$ = A$ + |        if (hours1 == 0) {|
A$ = A$ + |            hours1 = 12;|
A$ = A$ + |            minutes1 = minutes1;|
A$ = A$ + |        }|
A$ = A$ + |        valueMin.innerHTML = (hours1 + ':' + minutes1);|
A$ = A$ + |        var hours2 = Math.floor(values[1] / 60);|
A$ = A$ + |        var minutes2 = values[1] - (hours2 * 60);|
A$ = A$ + |        if (hours2.length == 1) hours2 = '0' + hours2;|
A$ = A$ + |        if (minutes2.length == 1) minutes2 = '0' + minutes2;|
A$ = A$ + |        if (minutes2 == 0) minutes2 = '00';|
A$ = A$ + |        hours2 = hours2;|
A$ = A$ + |        valueMax.innerHTML = (hours2 + ':' + minutes2);|
A$ = A$ + ||
A$ = A$ + |});|
jscript a$
a$ = ""

That gives that :
image.png
You do not have the required permissions to view the files attached to this post.
ulli
Posts: 47
Joined: Tue Feb 09, 2021 9:48 am
Location: Monschau, Germany
Has thanked: 8 times
Been thanked: 2 times

Re: Double Slider not running on ESP, but running well locally

Post by ulli »

Hi cicciocb,

that's fantastic, thank you very much.

Just two questions remain:

1.) aha.js is included with
A$ = A$ + |<script src='aha.js'></script>|
It is then repeated verbosly to prepare it for execution with jscript a$. Why?

2.) How do I access the values (formatted or unformatted) from basic?

Thanks again for your help.

Cheers

Ulli
User avatar
cicciocb
Site Admin
Posts: 2041
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 436 times
Been thanked: 1342 times
Contact:

Re: Double Slider not running on ESP, but running well locally

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Thu Sep 28, 2023 5:10 pm Hi cicciocb,

that's fantastic, thank you very much.

Just two questions remain:

1.) aha.js is included with
A$ = A$ + |<script src='aha.js'></script>|
It is then repeated verbosly to prepare it for execution with jscript a$. Why?

2.) How do I access the values (formatted or unformatted) from basic?

Thanks again for your help.

Cheers

Ulli
Sorry,
that line is just a copy paste of your code and is not doing anything; can be removed.

For the exchange of the variables, I suggest to have a look at this post : [Local Link Removed for Guests] or [Local Link Removed for Guests]
ulli
Posts: 47
Joined: Tue Feb 09, 2021 9:48 am
Location: Monschau, Germany
Has thanked: 8 times
Been thanked: 2 times

Re: Double Slider not running on ESP, but running well locally

Post by ulli »

Hi cicciocb,

sorry, my command of Javascript is to weak. I tried several ideas from "Advice on a ESP8266 data logger/recorder/AP", but to no avail.

I'm unable to get the values of my double slider into basic vars. Can you please give me a hint?

Thank you

Ulli
The light at the end of the tunnel has been switched off for energy saving reasons.
User avatar
cicciocb
Site Admin
Posts: 2041
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 436 times
Been thanked: 1342 times
Contact:

Re: Double Slider not running on ESP, but running well locally

Post by cicciocb »

No problem, Now I'm not at home but I'll give some examples later today.
User avatar
Electroguard
Posts: 857
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 273 times
Been thanked: 321 times

Re: Double Slider not running on ESP, but running well locally

Post by Electroguard »

Hmm, if that double-ended gizmo allows setting the working range between min and max extremes it would be nicer than having separate top and tail sliders. Might be nice for setting a safe stepper travel zone within end limit switches, or to set the working range of a servo. A neat control idea.
User avatar
cicciocb
Site Admin
Posts: 2041
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 436 times
Been thanked: 1342 times
Contact:

Re: Double Slider not running on ESP, but running well locally

Post by cicciocb »

This is an example on how get the variables from javascript to basic
The values are printed in the console

Code: [Local Link Removed for Guests]

cls

jsexternal "/nouislider.min.js"
pause 300
cssexternal "/nouislider.min.css"
pause 300
valueMin$ = ""
valueMax$ = ""

A$ = ||
A$ = A$ + |<div >|
A$ = A$ + |    <div id="kt_slider_basic"></div>|
A$ = A$ + ||
A$ = A$ + |    <div >|
A$ = A$ + |        <div >Min: <span id="kt_slider_basic_min"></span></div>|
A$ = A$ + | <!--     <div class="fw-semibold mb-2">Min: <textbox$(t_min,"kt_slider_basic_min")</div>a-->|
A$ = A$ + |        <div >Max: <span id="kt_slider_basic_max"></span></div>|
A$ = A$ + |    </div>|
A$ = A$ + |</div>|
A$ = A$ + ||
html a$

A$ = ||
A$ = A$ + |var slider = document.querySelector("#kt_slider_basic");|
A$ = A$ + |var valueMin = document.querySelector("#kt_slider_basic_min");|
A$ = A$ + |var valueMax = document.querySelector("#kt_slider_basic_max");|
A$ = A$ + ||
A$ = A$ + |noUiSlider.create(slider, {|
A$ = A$ + |    start: [480, 1230],|
A$ = A$ + |    connect: true,|
A$ = A$ + |    range: {|
A$ = A$ + |    min: 360,|
A$ = A$ + |    max: 1380|
A$ = A$ + |    },|
A$ = A$ + |    step: 15|
A$ = A$ + |});|
A$ = A$ + ||
A$ = A$ + |slider.noUiSlider.on("update", function (values, handle) {|
A$ = A$ + | var hours1 = Math.floor(values[0] / 60);|
A$ = A$ + |        var minutes1 = values[0] - (hours1 * 60);|
A$ = A$ + |        if (hours1.length == 1) hours1 = '0' + hours1;|
A$ = A$ + |        if (minutes1.length == 1) minutes1 = '0' + minutes1;|
A$ = A$ + |        if (minutes1 == 0) minutes1 = '00';|
A$ = A$ + |        hours1 = hours1;|
A$ = A$ + |        if (hours1 == 0) {|
A$ = A$ + |            hours1 = 12;|
A$ = A$ + |            minutes1 = minutes1;|
A$ = A$ + |        }|
A$ = A$ + |        valueMin.innerHTML = (hours1 + ':' + minutes1);|
A$ = A$ + |        var hours2 = Math.floor(values[1] / 60);|
A$ = A$ + |        var minutes2 = values[1] - (hours2 * 60);|
A$ = A$ + |        if (hours2.length == 1) hours2 = '0' + hours2;|
A$ = A$ + |        if (minutes2.length == 1) minutes2 = '0' + minutes2;|
A$ = A$ + |        if (minutes2 == 0) minutes2 = '00';|
A$ = A$ + |        hours2 = hours2;|
A$ = A$ + |        valueMax.innerHTML = (hours2 + ':' + minutes2);|
' send to the basic with connection.send('cmd:immediatx var1$="xxx":var2$="yyyy");
A$ = A$ + |        connection.send('cmd:immediatx valueMin$="' + valueMin.innerHTML + '":' + |
A$ = A$ + |                        'valueMax$="' + valueMax.innerHTML + '"');|
A$ = A$ + ||
A$ = A$ + |});|
jscript a$
a$ = ""

timer0 500, update
wait

update:
print valueMin$, valueMax$
return
ulli
Posts: 47
Joined: Tue Feb 09, 2021 9:48 am
Location: Monschau, Germany
Has thanked: 8 times
Been thanked: 2 times

Re: Double Slider not running on ESP, but running well locally

Post by ulli »

Hi cicciocb,

this is absolutely great! Thanks a million.
Unfortunately, after a procedural life, I never got these objects right.

Hi Electroguard,

I found this to be the most user friendly way to control the opening and closing time of our henhouse door.
But I'm sure there are many other uses of this nice widget.

Cheers

Ulli
The light at the end of the tunnel has been switched off for energy saving reasons.
Post Reply