Skip to content

Commit

Permalink
Playground fix + progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
rsashka committed Mar 23, 2024
1 parent a0a4f12 commit e58c1eb
Show file tree
Hide file tree
Showing 11 changed files with 198 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docs/en/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
/>
</url><url>
<loc>http://localhost:1313/playground/</loc>
<lastmod>2024-03-22T23:57:08+03:00</lastmod>
<lastmod>2024-03-23T11:35:05+03:00</lastmod>
<xhtml:link
rel="alternate"
hreflang="ru"
Expand Down
2 changes: 1 addition & 1 deletion docs/offline-search-index.json

Large diffs are not rendered by default.

35 changes: 32 additions & 3 deletions docs/playground/_print/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
</div>
<div>
<button onclick="run_playground()">Playground run</button>
<progress id="progress" max="0" value="0" style="display:none">0%</progress>
</div>
<div id="pg_out_div" class="pg_out" style="display:none">
<label class="pg_out" style="display:none" >Playground version:</label>
Expand Down Expand Up @@ -243,19 +244,35 @@




var reverse_counter;
var downloadTimer;

function run_playground(){

var max_timeout = 10000;
reverse_counter = max_timeout ;
downloadTimer = setInterval(function(){
document.getElementById("progress").value = max_timeout - reverse_counter;
reverse_counter -= 100;
if(reverse_counter <= 0) {
clearInterval(downloadTimer);
document.getElementById('progress').style.display = "none";
}
document.getElementById("progress").innerHTML= reverse_counter;
},100);
document.getElementById('progress').value = 0;
document.getElementById('progress').max = max_timeout;
document.getElementById('progress').style.display = "";

//document.getElementById('pg_out_div').style.display = 'none';

for (let el of document.querySelectorAll('.pg_out')) {
el.style.display="none";
}

// 1. Создаём новый XMLHttpRequest-объект
let xhr = new XMLHttpRequest();
xhr.timeout = 5000;
xhr.timeout = max_timeout;
xhr.responseType = 'json';

let server = 'http://81.200.157.226';
Expand Down Expand Up @@ -283,6 +300,10 @@
el.style.display="";
}

clearInterval(downloadTimer);
document.getElementById('progress').value = document.getElementById('progress').max;
document.getElementById('progress').style.display = "none";

if (xhr.status != 200) { // анализируем HTTP-статус ответа, если статус не 200, то произошла ошибка
alert(`Error ${xhr.status}: ${xhr.statusText}`); // Например, 404: Not Found
out.classList.add("error");
Expand All @@ -303,9 +324,17 @@
};

xhr.onerror = function() {
clearInterval(downloadTimer);
document.getElementById('progress').style.display = "none";
document.getElementById('playground_out').classList.add("error");
alert("Request failed!");
};

xhr.ontimeout = (e) => {
clearInterval(downloadTimer);
document.getElementById('progress').style.display = "none";
alert("Run query timeout!");
};
}
</script>
</main>
Expand Down
35 changes: 32 additions & 3 deletions docs/playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
</div>
<div>
<button onclick="run_playground()">Playground run</button>
<progress id="progress" max="0" value="0" style="display:none">0%</progress>
</div>
<div id="pg_out_div" class="pg_out" style="display:none">
<label class="pg_out" style="display:none" >Playground version:</label>
Expand Down Expand Up @@ -243,19 +244,35 @@




var reverse_counter;
var downloadTimer;

function run_playground(){

var max_timeout = 10000;
reverse_counter = max_timeout ;
downloadTimer = setInterval(function(){
document.getElementById("progress").value = max_timeout - reverse_counter;
reverse_counter -= 100;
if(reverse_counter <= 0) {
clearInterval(downloadTimer);
document.getElementById('progress').style.display = "none";
}
document.getElementById("progress").innerHTML= reverse_counter;
},100);
document.getElementById('progress').value = 0;
document.getElementById('progress').max = max_timeout;
document.getElementById('progress').style.display = "";

//document.getElementById('pg_out_div').style.display = 'none';

for (let el of document.querySelectorAll('.pg_out')) {
el.style.display="none";
}

// 1. Создаём новый XMLHttpRequest-объект
let xhr = new XMLHttpRequest();
xhr.timeout = 5000;
xhr.timeout = max_timeout;
xhr.responseType = 'json';

let server = 'http://81.200.157.226';
Expand Down Expand Up @@ -283,6 +300,10 @@
el.style.display="";
}

clearInterval(downloadTimer);
document.getElementById('progress').value = document.getElementById('progress').max;
document.getElementById('progress').style.display = "none";

if (xhr.status != 200) { // анализируем HTTP-статус ответа, если статус не 200, то произошла ошибка
alert(`Error ${xhr.status}: ${xhr.statusText}`); // Например, 404: Not Found
out.classList.add("error");
Expand All @@ -303,9 +324,17 @@
};

xhr.onerror = function() {
clearInterval(downloadTimer);
document.getElementById('progress').style.display = "none";
document.getElementById('playground_out').classList.add("error");
alert("Request failed!");
};

xhr.ontimeout = (e) => {
clearInterval(downloadTimer);
document.getElementById('progress').style.display = "none";
alert("Run query timeout!");
};
}
</script>
</main>
Expand Down
35 changes: 32 additions & 3 deletions docs/ru/playground/_print/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
</div>
<div>
<button onclick="run_playground()">Playground run</button>
<progress id="progress" max="0" value="0" style="display:none">0%</progress>
</div>
<div id="pg_out_div" class="pg_out" style="display:none">
<label class="pg_out" style="display:none" >Playground version:</label>
Expand Down Expand Up @@ -243,19 +244,35 @@




var reverse_counter;
var downloadTimer;

function run_playground(){

var max_timeout = 10000;
reverse_counter = max_timeout ;
downloadTimer = setInterval(function(){
document.getElementById("progress").value = max_timeout - reverse_counter;
reverse_counter -= 100;
if(reverse_counter <= 0) {
clearInterval(downloadTimer);
document.getElementById('progress').style.display = "none";
}
document.getElementById("progress").innerHTML= reverse_counter;
},100);
document.getElementById('progress').value = 0;
document.getElementById('progress').max = max_timeout;
document.getElementById('progress').style.display = "";

//document.getElementById('pg_out_div').style.display = 'none';

for (let el of document.querySelectorAll('.pg_out')) {
el.style.display="none";
}

// 1. Создаём новый XMLHttpRequest-объект
let xhr = new XMLHttpRequest();
xhr.timeout = 5000;
xhr.timeout = max_timeout;
xhr.responseType = 'json';

let server = 'http://81.200.157.226';
Expand Down Expand Up @@ -283,6 +300,10 @@
el.style.display="";
}

clearInterval(downloadTimer);
document.getElementById('progress').value = document.getElementById('progress').max;
document.getElementById('progress').style.display = "none";

if (xhr.status != 200) { // анализируем HTTP-статус ответа, если статус не 200, то произошла ошибка
alert(`Error ${xhr.status}: ${xhr.statusText}`); // Например, 404: Not Found
out.classList.add("error");
Expand All @@ -303,9 +324,17 @@
};

xhr.onerror = function() {
clearInterval(downloadTimer);
document.getElementById('progress').style.display = "none";
document.getElementById('playground_out').classList.add("error");
alert("Request failed!");
};

xhr.ontimeout = (e) => {
clearInterval(downloadTimer);
document.getElementById('progress').style.display = "none";
alert("Run query timeout!");
};
}
</script>
</main>
Expand Down
35 changes: 32 additions & 3 deletions docs/ru/playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
</div>
<div>
<button onclick="run_playground()">Playground run</button>
<progress id="progress" max="0" value="0" style="display:none">0%</progress>
</div>
<div id="pg_out_div" class="pg_out" style="display:none">
<label class="pg_out" style="display:none" >Playground version:</label>
Expand Down Expand Up @@ -243,19 +244,35 @@




var reverse_counter;
var downloadTimer;

function run_playground(){

var max_timeout = 10000;
reverse_counter = max_timeout ;
downloadTimer = setInterval(function(){
document.getElementById("progress").value = max_timeout - reverse_counter;
reverse_counter -= 100;
if(reverse_counter <= 0) {
clearInterval(downloadTimer);
document.getElementById('progress').style.display = "none";
}
document.getElementById("progress").innerHTML= reverse_counter;
},100);
document.getElementById('progress').value = 0;
document.getElementById('progress').max = max_timeout;
document.getElementById('progress').style.display = "";

//document.getElementById('pg_out_div').style.display = 'none';

for (let el of document.querySelectorAll('.pg_out')) {
el.style.display="none";
}

// 1. Создаём новый XMLHttpRequest-объект
let xhr = new XMLHttpRequest();
xhr.timeout = 5000;
xhr.timeout = max_timeout;
xhr.responseType = 'json';

let server = 'http://81.200.157.226';
Expand Down Expand Up @@ -283,6 +300,10 @@
el.style.display="";
}

clearInterval(downloadTimer);
document.getElementById('progress').value = document.getElementById('progress').max;
document.getElementById('progress').style.display = "none";

if (xhr.status != 200) { // анализируем HTTP-статус ответа, если статус не 200, то произошла ошибка
alert(`Error ${xhr.status}: ${xhr.statusText}`); // Например, 404: Not Found
out.classList.add("error");
Expand All @@ -303,9 +324,17 @@
};

xhr.onerror = function() {
clearInterval(downloadTimer);
document.getElementById('progress').style.display = "none";
document.getElementById('playground_out').classList.add("error");
alert("Request failed!");
};

xhr.ontimeout = (e) => {
clearInterval(downloadTimer);
document.getElementById('progress').style.display = "none";
alert("Run query timeout!");
};
}
</script>
</main>
Expand Down
2 changes: 1 addition & 1 deletion docs/ru/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
/>
</url><url>
<loc>http://localhost:1313/ru/playground/</loc>
<lastmod>2024-03-22T23:57:08+03:00</lastmod>
<lastmod>2024-03-23T11:35:05+03:00</lastmod>
<xhtml:link
rel="alternate"
hreflang="en"
Expand Down
4 changes: 2 additions & 2 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<sitemap>
<loc>http://localhost:1313/en/sitemap.xml</loc>

<lastmod>2024-03-22T23:57:08+03:00</lastmod>
<lastmod>2024-03-23T11:35:05+03:00</lastmod>

</sitemap>

<sitemap>
<loc>http://localhost:1313/ru/sitemap.xml</loc>

<lastmod>2024-03-22T23:57:08+03:00</lastmod>
<lastmod>2024-03-23T11:35:05+03:00</lastmod>

</sitemap>

Expand Down
1 change: 1 addition & 0 deletions site.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ rm -rf $root/docs/*
rm $root/site/content/ru/playground/*.src
cp $root/examples/*.src $root/site/content/ru/playground/
cp -f $root/site/content/ru/playground/* $root/site/content/en/playground/
cp -f $root/site/content/CNAME $root/docs/

echo Rename link in dir $root/content/en:

Expand Down
Loading

0 comments on commit e58c1eb

Please sign in to comment.