-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogress_bar.pl
57 lines (43 loc) · 1.48 KB
/
progress_bar.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_dispatch)).
:- use_module(library(http/http_error)).
:- use_module(library(http/html_write)).
% we need this module from the HTTP client library for http_read_data
:- use_module(library(http/http_client)).
:- http_handler('/', web_form, []).
:-include('../listprologinterpreter/la_strings.pl').
server(Port) :-
http_server(http_dispatch, [port(Port)]).
browse http:localhost:8000
This demonstrates handling POST requests
web_form(_Request) :-
format('Content-type: text/html~n~n', []),
*/
progress_bar(Ratio) :-
%Ratio=1,
Percentage1 is 100*Ratio,
Percentage2 is 100-Percentage1,
(Percentage1=0->
concat_list(["Progress: ",Percentage1,"%<br>
<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\" width=\"200px\">
<tr>
<td bgcolor='white' width=\"",Percentage2,"%\"> </td>
</tr>
</table>"],String);
(Percentage1=100->
concat_list(["Progress: ",Percentage1,"%<br>
<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\" width=\"200px\">
<tr>
<td bgcolor='green' width=\"",Percentage1,"%\"> </td>
</tr>
</table>"],String);
concat_list(["Progress: ",Percentage1,"%<br>
<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\" width=\"200px\">
<tr>
<td bgcolor='green' width=\"",Percentage1,"%\"> </td>
<td bgcolor='white' width=\"",Percentage2,"%\"> </td>
</tr>
</table>"],String)
)),
format(String,[]).