@@ -88,6 +88,10 @@ void EmbAJAXOutputDriverBase::printAttribute(const char* name, const int32_t val
8888 printContent (" " );
8989 printContent (name);
9090 printContent (" =" );
91+ printInt (value);
92+ }
93+
94+ void EmbAJAXOutputDriverBase::printInt (int32_t value) {
9195 char buf[12 ];
9296 printContent (itoa (value, buf, 10 ));
9397}
@@ -402,7 +406,7 @@ void EmbAJAXMomentaryButton::print() const {
402406 _driver->printFiltered (_id, EmbAJAXOutputDriverBase::JSQuoted, false );
403407 _driver->printContent (" );\n "
404408 " btn.onmousedown = btn.ontouchstart = function() { clearInterval(this.pinger); this.pinger=setInterval(function() {doRequest(this.id, 'p');}.bind(this)," );
405- _driver->printContent ( itoa ( _timeout / 1.5 , itoa_buf, 10 ) );
409+ _driver->printInt ( _timeout / 1.5 );
406410 _driver->printContent (" ); doRequest(this.id, 'p'); return false; };\n "
407411 " btn.onmouseup = btn.ontouchend = btn.onmouseleave = function() { clearInterval(this.pinger); doRequest(this.id, 'r'); return false;};}\n "
408412 " </script>" );
@@ -540,7 +544,7 @@ void EmbAJAXBase::printPage(EmbAJAXBase** _children, size_t NUM, const char* _ti
540544 " var prev_request = 0;\n "
541545 " function sendQueued() {\n "
542546 " var now = new Date().getTime();\n "
543- " if (num_waiting > 0 || (now - prev_request < " ); _driver->printContent ( itoa ( _min_interval, itoa_buf, 10 ) ); _driver->printContent (" )) return;\n "
547+ " if (num_waiting > 0 || (now - prev_request < " ); _driver->printInt ( _min_interval); _driver->printContent (" )) return;\n "
544548 " var e = request_queue.shift();\n "
545549 " if (!e && (now - prev_request < 1000)) return;\n "
546550 " if (!e) e = {id: '', value: ''};\n " // Nothing in queue, but last request more than 1000 ms ago? Send a ping to query for updates
@@ -560,7 +564,7 @@ void EmbAJAXBase::printPage(EmbAJAXBase** _children, size_t NUM, const char* _ti
560564 " req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');\n "
561565 " req.send('id=' + e.id + '&value=' + encodeURIComponent(e.value) + '&revision=' + serverrevision);\n "
562566 " }\n "
563- " window.setInterval(sendQueued, " ); _driver->printContent ( itoa ( _min_interval, itoa_buf, 10 ) ); _driver->printContent (" );\n " );
567+ " window.setInterval(sendQueued, " ); _driver->printInt ( _min_interval/ 2 + 1 ); _driver->printContent (" );\n " );
564568
565569 _driver->printContent (" function doUpdates(response) {\n "
566570 " serverrevision = response.revision;\n "
@@ -634,7 +638,7 @@ void EmbAJAXBase::handleRequest(EmbAJAXBase** _children, size_t NUM, void (*chan
634638 // then relay value changes that have occured in the server (possibly in response to those sent)
635639 _driver->printHeader (false );
636640 _driver->printContent (" {\" revision\" : " );
637- _driver->printContent ( itoa ( _driver->revision (), conversion_buf, 10 ));
641+ _driver->printInt ( _driver->revision ());
638642 _driver->printContent (" ,\n\" updates\" : [\n " );
639643 sendUpdates (_children, NUM, client_revision, true );
640644 _driver->printContent (" \n ]}\n " );
0 commit comments