懒羊羊
2023-08-30 1ac2bc1590406d9babec036e154d8d08f34a6aa1
提交 | 用户 | 时间
1ac2bc 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2         "http://www.w3.org/TR/html4/loose.dtd">
3 <html>
4 <head>
5     <title></title>
6     <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
7     <script type="text/javascript" src="../internal.js"></script>
8     <style type="text/css">
9         .wrapper{width: 600px;padding: 10px;height: 352px;overflow: hidden;position: relative;border-bottom: 1px solid #d7d7d7}
10         .localPath input{float: left;width: 350px;line-height: 20px;height: 20px;}
11         #clipboard{float:left;width: 70px;height: 30px; }
12         .description{ color: #0066cc; margin-top: 2px; width: 450px; height: 45px;float: left;line-height: 22px}
13         #upload{width: 100px;height: 30px;float: right; margin:10px 2px 0 0;cursor: pointer;}
14         #msg{ width: 140px; height: 30px; line-height:25px;float: left;color: red}
15     </style>
16 </head>
17 <body>
18     <div class="wrapper">
19         <div class="localPath">
20             <input id="localPath" type="text" readonly />
21             <div id="clipboard"></div>
22             <div id="msg"></div>
23         </div>
24         <div id="flashContainer"></div>
25         <div>
26             <div id="upload" style="display: none" ><img id="uploadBtn"></div>
27             <div class="description">
28                 <span style="color: red"><var id="lang_resave"></var>: </span><var id="lang_step"></var>
29             </div>
30           </div>
31     </div>
32     <script type="text/javascript" src="tangram.js"></script>
33     <script type="text/javascript" src="wordimage.js"></script>
34     <script type="text/javascript">
35         editor.setOpt({
36             wordImageFieldName:"upfile",
37             compressSide:0,
38             maxImageSideLength:900
39         });
40
41             //全局变量
42         var imageUrls = [],          //用于保存从服务器返回的图片信息数组
43             selectedImageCount = 0,  //当前已选择的但未上传的图片数量
44             optImageUrl = editor.getActionUrl(editor.getOpt('imageActionName')),
45             optImageFieldName = editor.getOpt('imageFieldName'),
46             optImageCompressBorder = editor.getOpt('imageCompressEnable') ? editor.getOpt('imageCompressBorder'):null,
47             maxSize = editor.getOpt('imageMaxSize') / 1024,
48             extension = editor.getOpt('imageAllowFiles').join(';').replace(/\./g, '*.');
49
50         /* 添加额外的GET参数 */
51         var params = utils.serializeParam(editor.queryCommandValue('serverparam')) || '',
52             urlWidthParams = optImageUrl + (optImageUrl.indexOf('?') == -1 ? '?':'&') + params;
53
54         utils.domReady(function(){
55             //创建Flash相关的参数集合
56             var flashOptions = {
57                 container:"flashContainer",                                                    //flash容器id
58                 url:urlWidthParams,                                           // 上传处理页面的url地址
59                 ext:editor.queryCommandValue('serverParam') || {},                                 //可向服务器提交的自定义参数列表
60                 fileType:'{"description":"'+lang.fileType+'", "extension":"' + extension + '"}',     //上传文件格式限制
61                 flashUrl:'imageUploader.swf',                                                  //上传用的flash组件地址
62                 width:600,          //flash的宽度
63                 height:272,         //flash的高度
64                 gridWidth:120,     // 每一个预览图片所占的宽度
65                 gridHeight:120,    // 每一个预览图片所占的高度
66                 picWidth:100,      // 单张预览图片的宽度
67                 picHeight:100,     // 单张预览图片的高度
68                 uploadDataFieldName: optImageFieldName,    // POST请求中图片数据的key
69                 picDescFieldName:'pictitle',      // POST请求中图片描述的key
70                 maxSize: maxSize,                         // 文件的最大体积,单位M
71                 compressSize:1,                   // 上传前如果图片体积超过该值,会先压缩,单位M
72                 maxNum:32,                         // 单次最大可上传多少个文件
73                 compressSide: 0,                 //等比压缩的基准,0为按照最长边,1为按照宽度,2为按照高度
74                 compressLength: optImageCompressBorder        //能接受的最大边长,超过该值Flash会自动等比压缩
75             };
76             //回调函数集合,支持传递函数名的字符串、函数句柄以及函数本身三种类型
77             var callbacks={
78                 selectFileCallback: function(selectFiles){                // 选择文件的回调
79                     selectedImageCount += selectFiles.length;
80                     if(selectedImageCount) baidu.g("upload").style.display = "";
81                     dialog.buttons[0].setDisabled(true); //初始化时置灰确定按钮
82                 },
83                 deleteFileCallback: function(delFiles){                 // 删除文件的回调
84                     selectedImageCount -= delFiles.length;
85                     if (!selectedImageCount) {
86                         baidu.g("upload").style.display = "none";
87                         dialog.buttons[0].setDisabled(false);         //没有选择图片时重新点亮按钮
88                     }
89                 },
90                 uploadCompleteCallback: function(data){               // 单个文件上传完成的回调
91                     try{var info = eval("(" + data.info + ")");
92                     info && imageUrls.push(info);
93                     selectedImageCount--;
94                     }catch(e){}
95                 },
96                 uploadErrorCallback: function (data){         // 单个文件上传失败的回调,
97                     console && console.log(data);
98                 },
99                 allCompleteCallback: function(){              // 全部上传完成时的回调
100                     dialog.buttons[0].setDisabled(false);    //上传完毕后点亮按钮
101                 }
102                 //exceedFileCallback: 'exceedFileCallback',   // 文件超出限制的最大体积时的回调
103                 //startUploadCallback: startUploadCallback    // 开始上传某个文件时的回调
104             };
105             wordImage.init(flashOptions,callbacks);
106         });
107
108     </script>
109
110 </body>
111 </html>