mirror of
https://github.com/sorenpeter/timeline.git
synced 2025-12-15 19:07:01 +00:00
Working progress bar using some JS
This commit is contained in:
parent
37a9d77d7b
commit
8272067347
2 changed files with 45 additions and 38 deletions
|
|
@ -1,34 +0,0 @@
|
||||||
# | |___ _| |___ _| |_
|
|
||||||
# | __\ \ /\ / / __\ \/ / __|
|
|
||||||
# | |_ \ V V /| |_ > <| |_
|
|
||||||
# \__| \_/\_/ \__/_/\_\\__|
|
|
||||||
#
|
|
||||||
# Twtxt is an open, distributed and decentralized microblogging platform
|
|
||||||
# for hackers and friends that uses raw text files, easy to read by humans,
|
|
||||||
# and with common protocols and free and open.
|
|
||||||
#
|
|
||||||
# Using twtxt-php from: https://github.com/eapl-gemugami/twtxt-php
|
|
||||||
# Know more about twtxt here: https://github.com/buckket/twtxt
|
|
||||||
# Using the following extensions:
|
|
||||||
# https://github.com/eapl-gemugami/twtxt-php/blob/master/docs/02-metadata-extension.md
|
|
||||||
#
|
|
||||||
# nick = timeline
|
|
||||||
# url = http://example.com/timeline/twtxt.txt
|
|
||||||
# avatar = http://example.com/timeline/avatar.png
|
|
||||||
# emoji = 👾
|
|
||||||
# link =
|
|
||||||
# lang =
|
|
||||||
# description =
|
|
||||||
# discovery =
|
|
||||||
#
|
|
||||||
# following = 123
|
|
||||||
# follow = eapl.me https://eapl.me/twtxt.txt
|
|
||||||
# follow = eapl.mx https://eapl.mx/twtxt.txt
|
|
||||||
# follow = lyse https://lyse.isobeef.org/twtxt.txt
|
|
||||||
# follow = prologic https://twtxt.net/user/prologic/twtxt.txt
|
|
||||||
# follow = sorenpeter http://darch.dk/twtxt.txt
|
|
||||||
# follow = stigatle https://yarn.stigatle.no/user/stigatle/twtxt.txt
|
|
||||||
# follow = thecanine https://twtxt.net/user/thecanine/twtxt.txt
|
|
||||||
#~~~#
|
|
||||||
|
|
||||||
2023-09-10T18:55:27+02:00 Hello twtxt world!
|
|
||||||
|
|
@ -44,6 +44,7 @@ $fileContent = mb_convert_encoding($fileContent, 'UTF-8');
|
||||||
$fileLines = explode("\n", $fileContent);
|
$fileLines = explode("\n", $fileContent);
|
||||||
|
|
||||||
$twtFollowingList = [];
|
$twtFollowingList = [];
|
||||||
|
|
||||||
foreach ($fileLines as $currentLine) {
|
foreach ($fileLines as $currentLine) {
|
||||||
if (str_starts_with($currentLine, '#')) {
|
if (str_starts_with($currentLine, '#')) {
|
||||||
if (!is_null(getDoubleParameter('follow', $currentLine))) {
|
if (!is_null(getDoubleParameter('follow', $currentLine))) {
|
||||||
|
|
@ -54,13 +55,53 @@ foreach ($fileLines as $currentLine) {
|
||||||
|
|
||||||
# Load all the files
|
# Load all the files
|
||||||
# Save a flag to know it's loading files in the background
|
# Save a flag to know it's loading files in the background
|
||||||
|
/*
|
||||||
foreach ($twtFollowingList as $following) {
|
foreach ($twtFollowingList as $following) {
|
||||||
echo "Updating: $following[1]<br>\n";
|
echo "Updating: $following[1]<br>\n";
|
||||||
#ob_flush();
|
#ob_flush();
|
||||||
|
flush();
|
||||||
updateCachedFile($following[1]);
|
updateCachedFile($following[1]);
|
||||||
}
|
}
|
||||||
echo 'Finished';
|
*/
|
||||||
#ob_flush();
|
//echo 'Finished';
|
||||||
|
//ob_flush();
|
||||||
|
|
||||||
|
//header('Location: /');
|
||||||
|
//exit();
|
||||||
|
|
||||||
|
/* from: https://github.com/w3shaman/php-progress-bar */
|
||||||
|
|
||||||
|
echo '<div id="progress" style="width:500px;border:1px solid #ccc;"></div>';
|
||||||
|
|
||||||
|
echo '<div id="information" style="width"></div>';
|
||||||
|
|
||||||
|
|
||||||
|
$i = 1;
|
||||||
|
foreach ($twtFollowingList as $following) {
|
||||||
|
$total = count($twtFollowingList);
|
||||||
|
// Calculate the percentation
|
||||||
|
$percent = intval($i/$total * 100)."%";
|
||||||
|
|
||||||
|
// Javascript for updating the progress bar and information
|
||||||
|
echo '<script language="javascript">
|
||||||
|
document.getElementById("progress").innerHTML="<div style=\"width:'.$percent.';background-color:#ddd;\"> </div>";
|
||||||
|
document.getElementById("information").innerHTML="'.$i.' row(s) processed.";
|
||||||
|
</script>';
|
||||||
|
|
||||||
|
|
||||||
|
// This is for the buffer achieve the minimum size in order to flush data
|
||||||
|
|
||||||
|
echo "Updating: $following[1]"." (".$i."/".$total.")<br>\n";
|
||||||
|
updateCachedFile($following[1]);
|
||||||
|
|
||||||
|
// Send output to browser immediately
|
||||||
|
flush();
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo 'Finished';
|
||||||
|
|
||||||
|
|
||||||
|
// Tell user that the process is completed
|
||||||
|
echo '<script language="javascript">document.getElementById("information").innerHTML="Process completed"</script>';
|
||||||
|
|
||||||
header('Location: /');
|
|
||||||
exit();
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue