Adding Printer Profiles feature to the Label Creator.
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / includes / file-upload.inc
1 <!-- AJAX file upload stuff -->
2 <script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/ajaxfileupload.js"></script>
3 <script type="text/javascript">
4     //<![CDATA[
5     function updateProgress() {
6         $.getJSON("/cgi-bin/koha/tools/upload-file-progress.pl", function(json) {
7             $("#fileuploadprogress").text(json.progress + '%');
8             if (json.progress < 100) {
9                 setTimeout("updateProgress()",200);
10             }
11         });
12     }
13     function ajaxFileUpload()
14     {
15
16         $("#fileuploadstatus").show();
17         setTimeout("updateProgress()",2000);
18         $.ajaxFileUpload (
19             {
20                 url:'/cgi-bin/koha/tools/upload-file.pl',
21                 secureuri:false,
22                 global:false,
23                 fileElementId:'fileToUpload',
24                 dataType: 'json',
25                 success: function (data, status) {
26                     if (data.status == 'denied') {
27                         $("#fileuploadstatus").hide();
28                         $("#fileuploadfailed").show();
29                         $("#fileuploadfailed").text("Upload failed -- no permission to upload files");
30                     } else if (data.status == 'failed') {
31                         $("#fileuploadstatus").hide();
32                         $("#fileuploadfailed").show();
33                         $("#fileuploadfailed").text("Upload failed -- unable to store file on server");
34                     } else if (data.status == 'maintenance') {
35                         $("#fileuploadstatus").hide();
36                         $("#fileuploadfailed").show();
37                         $("#fileuploadfailed").text("Upload failed -- database in maintenance state");
38                     } else {
39                          $("#uploadedfileid").val(data.fileid);
40                     }
41                 },
42                 error: function (data, status, e) {
43                     alert(e);
44                 }
45             }
46         )
47         updateProgress();
48         return false;
49
50     }
51     //]]>
52 </script>