-
Notifications
You must be signed in to change notification settings - Fork 9
/
button-upload-ext.prg
97 lines (61 loc) · 1.88 KB
/
button-upload-ext.prg
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
// {% LoadHrb( 'lib/tweb/tweb.hrb' ) %}
#include {% TWebInclude() %}
function main()
LOCAL o
DEFINE WEB oWeb TITLE 'Button Upload' INIT
DEFINE FORM o
HTML o FILE 'templates/title_test.tpl' PARAMS 'Test Button Upload - Extended'
INIT FORM o
ROWGROUP o
BUTTON ID 'myupload' LABEL ' Upload' GRID 6 FILES ACTION 'UploadFile()' ICON '<i class="fas fa-cloud-upload-alt"></i>' OF o
ENDROW o
ROWGROUP o
SAY ID 'log' VALUE '<h5>Log</h5><hr>' BORDER GRID 12 OF o
ENDROW o
HTML o
<script>
function UploadFile() {
var oPar = new Object()
oPar[ 'age' ] = 53
oPar[ 'name' ] = 'James Brown'
oPar[ 'married' ] = true
var o = new TWebUpload( 'myupload', 'srv_upload_ext.prg', Post_UploadFile, oPar )
o.onprogress = Imp_OnProgress
o.onloadstart = Imp_OnLoadStart
o.onloadend = Imp_OnLoadEnd
o.onreading = Imp_OnReading
o.Init()
}
function Post_UploadFile( dat ) {
console.log( 'Post_UploadFile', dat )
Log( 'End process' )
if ( dat.success )
MsgInfo( 'File uploaded!' )
else
MsgError( dat.msg )
}
function Imp_OnLoadStart(e) {
$('#log').html( '<h5>Log</h5><hr>' )
Log( 'OnLoadStart !' )
}
function Imp_OnLoadEnd( e ) {
Log( 'OnLoad end! Init Upload')
}
function Imp_OnProgress( e, n ) {
Log( 'OnProgress - Uploading... ' + n + ' %' )
if ( n >= 100 ) {
Log( 'OnProgress - Commit file - Working...' )
}
}
function Imp_OnReading( e, n ) {
Log( 'OnReading: ' + e.loaded + '/' + e.total )
}
function Log( cText ) {
var cLog = $('#log').html()
cLog += cText + '<br>'
$('#log').html( cLog )
}
</script>
ENDTEXT
END FORM o
retu nil