add a global countrycode to phone_avail import and a conf for the default (some other...
[freeside.git] / httemplate / elements / file-upload.html
1 <SCRIPT TYPE="text/javascript">
2
3   function doUpload(form, callback) {
4     var name = 'form' + Math.floor(Math.random() * 99999); // perlize?
5     var d = document.createElement('DIV');
6     d.innerHTML = '<iframe style="display:none" src="about:blank" ' +
7                            'id="'   + name + '" ' +
8                            'name="' + name + '" ' +
9                            'onload="uploadComplete(\'' + name + '\')">' +
10                   '</iframe>';
11     document.body.appendChild(d);
12
13     var i = document.getElementById(name);
14     if (callback && typeof(callback) == 'function') {
15       i.onComplete = callback;
16     }
17
18     form.setAttribute('target', name);
19     return true;
20   }
21
22   function uploadComplete(id) {
23     var i = document.getElementById(id);
24     if (i.contentDocument) {
25       var d = i.contentDocument;
26     } else if (i.contentWindow) {
27       var d = i.contentWindow.document;
28     } else {
29       var d = window.frames[id].document;
30     }
31     if (d.location.href == "about:blank") {
32       return;
33     }
34
35     document.getElementById('r').innerHTML = d.body.innerHTML;
36     if (typeof(i.onComplete) == 'function') {
37       var p;
38       if (p = d.body.innerHTML.indexOf("File Upload Successful ") >= 0) {
39         var v = d.body.innerHTML.substr(p+24);
40         var u = document.getElementById('uploaded_files');
41         v = v.substr(0, v.indexOf(';'));
42         u.value = v;
43         i.onComplete(true, '');
44       }else{
45         i.onComplete(false, d.body.innerHTML);
46       }
47     }
48   }
49
50 </SCRIPT>
51
52 <INPUT TYPE="hidden" NAME="uploaded_files" ID="uploaded_files" VALUE="" />
53
54 <INPUT TYPE="hidden" NAME="upload_fields" VALUE="<% join(',', @field) %>" />
55
56 % foreach (@field) {
57     <TR>
58       <TH ALIGN="right"><% shift @label %></TH>
59       <TD><INPUT TYPE="file" NAME="<% $_ %>" /></TD>
60     </TR>
61 % }
62
63 <DIV STYLE="display:<% $param{debug} ? 'visible' : 'none' %>">
64   Debugging: <PRE ID="r"></PRE>
65 </DIV>
66
67 <%init>
68
69 my %param = @_;
70
71 my @label = ref($param{'label'}) ? @{$param{'label'}} : ($param{'label'});
72 my @field = ref($param{'field'}) ? @{$param{'field'}} : ($param{'field'});
73
74 </%init>