page_message.anubis
6.15 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*
* Created by PyramIDE.
* User: フランスのトトロ aka (David RENÉ)
* Date: 20/02/2017
* Time: 04:31
* © David RENÉ
*/
read xlib/web/making_a_web_site.anubis
read xlib/web/widgets/icons_set.anubis
read xlib/web/types/web_session.anubis
public type Alignment:
left,
center,
right.
public type Page_Message:
no_message,
info(String message),
info_translate(String message),
ok(String message),
ok_translate(String message),
warning(String message),
warning_translate(String message),
error(String message, Alignment align),
error_translate(String message, Alignment align).
public define One
set_Page_Message
(
Var(List(Session_Field)) fields,
Page_Message p_message
)=
with step = get_Int(fields, "AWS_SESSION_STEP",0),
replace_Int(fields, "PAGE_MESSAGE_TTL", step+1);
if p_message is
{
no_message then
replace_String(fields, "PAGE_STATUS", "NO_MESSAGE");
replace_String(fields, "PAGE_MESSAGE", "")
info(msg_str) then
replace_String(fields, "PAGE_STATUS", "PAGE_INFO");
replace_String(fields, "PAGE_MESSAGE", msg_str)
info_translate(msg_str) then
replace_String(fields, "PAGE_STATUS", "PAGE_INFO_T");
replace_String(fields, "PAGE_MESSAGE", msg_str)
ok(msg_str) then
replace_String(fields, "PAGE_STATUS", "PAGE_OK");
replace_String(fields, "PAGE_MESSAGE", msg_str)
ok_translate(msg_str) then
replace_String(fields, "PAGE_STATUS", "PAGE_OK_T");
replace_String(fields, "PAGE_MESSAGE", msg_str)
warning(msg_str) then
replace_String(fields, "PAGE_STATUS", "PAGE_WARNING");
replace_String(fields, "PAGE_MESSAGE", msg_str)
warning_translate(msg_str) then
replace_String(fields, "PAGE_STATUS", "PAGE_WARNING_T");
replace_String(fields, "PAGE_MESSAGE", msg_str)
error(msg_str, align) then
replace_String(fields, "PAGE_STATUS", "PAGE_ERROR");
replace_String(fields, "PAGE_MESSAGE", msg_str)
error_translate(msg_str, align) then
replace_String(fields, "PAGE_STATUS", "PAGE_ERROR_T");
replace_String(fields, "PAGE_MESSAGE", msg_str)
}
.
public define One
set_Page_Message
(
WEB_Session _session,
Page_Message p_message
)=
set_Page_Message(_session.fields, p_message)
.
public define One
set_Page_Message
(
Session _session,
Page_Message p_message
)=
set_Page_Message(_session.fields, p_message)
.
public define Page_Message
error
(
String message
) = error(message, left).
public define Page_Message
error_translate
(
String message
) = error_translate(message, left).
public define Page_Message
get_Page_Message
(
Var(List(Session_Field)) fields,
(String) -> String _T
)=
with page_status = get_String(fields, "PAGE_STATUS", "NO_MESSAGE"),
page_string = get_String(fields, "PAGE_MESSAGE", ""),
page_ttl = get_Int(fields, "PAGE_MESSAGE_TTL", 0),
step = get_Int(fields, "AWS_SESSION_STEP", 0),
//the page Message is TimeOut. We remove it
if page_ttl < step then
remove_Int(fields, "PAGE_MESSAGE_TTL");
replace_String(fields, "PAGE_STATUS", "NO_MESSAGE");
replace_String(fields, "PAGE_MESSAGE", "");
no_message
else
if page_status = "NO_MESSAGE" then
no_message
else if page_status = "PAGE_INFO" then
info(page_string)
else if page_status = "PAGE_INFO_T" then
info(_T(page_string))
else if page_status = "PAGE_OK" then
ok(page_string)
else if page_status = "PAGE_OK_T" then
ok(_T(page_string))
else if page_status = "PAGE_WARNING" then
warning(page_string)
else if page_status = "PAGE_WARNING_T" then
warning(_T(page_string))
else if page_status = "PAGE_ERROR" then
error(page_string)
else if page_status = "PAGE_ERROR_T" then
error(_T(page_string))
else
no_message
.
define List(CoreAttrs)
get_info_line_attrbs
(
String html_class,
Alignment align
) =
if align is
{
left then [class(html_class)],
center then [class(html_class), style("margin-left: auto; margin-right: auto;")],
right then [class(html_class), style("margin-left: auto;")]
}.
public define HTML hide_info_line_btn = div([event(onclick, "this.parentNode.style.display="none";"), style("width: 16px; height: 16px; background: transparent url(""+icn16_cross+"") no-repeat scroll center center; float: right; display: inline; cursor: pointer;")], literal("")).
//public define HTML_In_Form
// display_info_line
// (
// String html_id,
// String html_class,
// String txt,
// Alignment align
// ) =
// div(get_info_line_attrbs(html_class, align), [partial(partial_content(hide_info_line_btn)), partial(partial_content(literal(txt)))]).
public define HTML
display_info_line
(
String html_id,
String html_class,
String txt,
Alignment align
) =
div(get_info_line_attrbs(html_class, align), sequence([hide_info_line_btn, text(txt)])).
public define HTML
display_main_info_line
(
String html_class,
String txt,
Alignment align
) =
display_info_line("informations", html_class, txt, align).
public define HTML
display_main_info_line
(
String html_class,
String txt
) =
display_info_line("informations", html_class, txt, left).
public define HTML
show_page_message
(
Page_Message page_message
)=
if page_message is
{
no_message then empty,
info(txt) then display_main_info_line("msg_infos", txt),
info_translate(txt) then display_main_info_line("msg_infos", txt),
ok(txt) then display_main_info_line("msg_success", txt),
ok_translate(txt) then display_main_info_line("msg_success", txt),
warning(txt) then display_main_info_line("msg_warning", txt),
warning_translate(txt) then display_main_info_line("msg_warning", txt),
error(txt, align) then display_main_info_line("msg_error",txt, align),
error_translate(txt, align) then display_main_info_line("msg_error",txt, align),
}
.