root 2 years ago
parent
commit
8c4795482c
5 changed files with 972 additions and 699 deletions
  1. 3 2
      Office/Word/WordEditArea.htm
  2. 303 355
      js/Office/Word/Word.js
  3. 289 321
      js/Office/Word/WordPanel.js
  4. 53 21
      js/UForm/Editor.js
  5. 324 0
      js/UForm/UPload.js

+ 3 - 2
Office/Word/WordEditArea.htm

@@ -38,12 +38,13 @@
     <div id="tools" style="position: fixed; width: 100%; background: #f7f8f9; border-bottom: 1px solid silver;
         z-index: 999;" onmousedown="U.MD.O.W.E.onmousedown();" onclick="U.MD.O.W.E.onclick();">
         <div class="U_MD_O_H_Area">
-            <button title="新建" id="U_MD_O_H_new" onclick="U.MD.O.W.newDoc(US.userInfo)" style="margin-left: 10px;">
+            <button title="新建" id="U_MD_O_H_new" onclick="U.MD.O.W.newDoc(US.userInfo)"
+                style="margin-left: 10px; display: none;">
                 <div class="U_MD_O_H_icon" style="background-position: -10px -592px;">
                 </div>
                 新建
             </button>
-            <button title="保存" id="U_MD_O_H_save" onclick="U.MD.O.W.save()">
+            <button title="保存" id="U_MD_O_H_save" onclick="U.MD.O.W.save()" style=" display: none;">
                 <div class="U_MD_O_H_icon" style="background-position: -38px -592px;">
                 </div>
                 保存

+ 303 - 355
js/Office/Word/Word.js

@@ -1,8 +1,10 @@
 //查看指定文件,,判断是否保存或者覆盖,包括创建邀请协作人员,创建编辑历史,创建生成链接.创建热门模板。加载当前word文档的内容。创建光标,监控键盘输入等。这里是iframe中的word起始点。
 //监控输入输出,
 //添加成员,共同编辑。
-
 Namespace.register("U.MD.O.W");
+
+document.oncontextmenu = U.UF.EV.stopDefault; //禁止右键菜单
+
 //由于当前文档的js是加载在ifame里面的,获取不到外部的文档(www.1473.cn)信息。所以通过传递参数设置全局变量的形式保存当前文档信息。
 //id是word文档id,PID是文档归属的目录id,fileinfo是文档的实体信息fileinfo,OL初始化回调函数,userid是当前文档创建者的id。 historyid就是最新历史记录的id
 U.MD.O.W = {
@@ -29,29 +31,53 @@ US = parent.US;
 * @param   {object}    登录用户信息  
 * @return  {object}    返回当前窗体 
 */
-U.MD.O.W.load = function (fileid) {
+U.MD.O.W.load = function (fileid, userinfo) {
     var fileinfo = U.MD.O.W.getfile(fileid),
-        userinfo = U.MD.O.W.getuser();
+        userinfo = await U.MD.O.W.getuser();
 
     U.MD.O.W.variable(fileinfo, userinfo); //初始化全局变量
-    U.MD.O.W.LoadContent(fileinfo); //加载内容
+    U.MD.O.W.setPermission();  //获取权限
     U.MD.O.W.setEvent(); //设置事件
+    U.MD.O.W.E.createSelection(); //创建下拉框
+    U.MD.O.W.E.toolsbind(); //初始化工具栏
+    U.MD.O.W.loadContent(fileinfo); //加载内容
     //加载功能
-    U.MD.O.W.Panel.LoadPlayUser(fileinfo); //加载协助人员窗体
     U.MD.O.W.Panel.loadlink(fileinfo); //加载链接窗体
-    U.MD.O.W.Panel.LoadHotTemplates(); //加载热门模板
-    U.MD.O.W.Panel.LoadOfficeHistory(fileinfo); //加载历史记录
+    U.MD.O.W.Panel.loadHotTemplates(); //加载热门模板
+    U.MD.O.W.Panel.loadOfficeHistory(fileinfo); //加载历史记录
+    //如果是协作文档,加载协作窗体
+    if (U.MD.O.W.permission.web) {
+        U.MD.O.W.Panel.loadPlayUser(fileinfo); //加载协助人员窗体
+    }
+    //如果不是协同文档,那么协同文档的窗体不显示,那么热门和链接窗体向上移
+    else {
+        $("#LoadOfficeHistory")[0].style.top = "140px";
+        $("#LoadHotTemplates")[0].style.top = "434px";
+    }
 }
 
 /**
 * 根据cookie获取用户
 *
 */
-U.MD.O.W.getuser = function () {
-    return {};
+U.MD.O.W.getuser = async function () {
+    await new Promise((resolve, reject) => {
+        U.A.Request(US.Config.server + "profile", [], function (res) {
+            if (res.value && res.value[0] && res.value[0][0]) {
+                US.userinfo = res.value[0][0]; //记录用户数据
+                U.A.Request(US.Config.edu + "admin/userinfo/userinfoById/" + US.userinfo.userid, [], function (res) {
+                    if (res.value && res.value[0] && res.value[0][0]) {
+                        resolve(res.value[0][0]); //记录用户数据
+                    }
+                }, [], { "type": "GET", "withCredentials": true });
+            }
+            else {
+                resolve({})
+            }
+        }, [], { "type": "GET", "withCredentials": true });
+    });
 }
 
-
 /**
 * 根据文件id获取文件
 *
@@ -64,19 +90,60 @@ U.MD.O.W.getfile = function (fileid) {
     };
 }
 
+/**
+* 初始化全局变量
+* @param   {object}    文档信息
+* @param   {object}    登录用户信息  
+*
+*/
+U.MD.O.W.variable = function (fileinfo, userinfo) {
+    //如果已经有全局变量 说明该文档已经是加载过了,不需要重复设置
+    if (!U.MD.O.W.fileinfo) {
+        U.MD.O.W.fileinfo = fileinfo //文档信息
+    }
+    //设置用户信息,为什么上面的不需要重复设置下面的需要呢,因为用户可能会注销
+    U.MD.O.W.userinfo = userinfo; //用户信息
+}
+
+/**
+* 编辑器权限函数
+* @return 返回用户权限json
+*/
+U.MD.O.W.setPermission = function () {
+    var _iseditor, _isgroup; //是否可编辑  //群用户
+    //权限主要包含了是否可编辑,是否互联办公文档查看
+
+    //判断文件是否是用户的群文档 US.friend.group这个变量需要独立
+    if (U.MD.O.W.fileinfo.GroupID && US.friend.group) {
+        _isgroup = U.Json.select(US.friend.group, { "GroupManageID": U.MD.O.W.fileinfo.GroupID })
+
 
 
+
+
+
+            ;
+        if (_isgroup) {
+            U.MD.O.W.permission.web = true;     //互联办公的权限
+            U.MD.O.W.permission.edit = true;    //就给其编辑权限
+        }
+    }
+    //如果是共享文档,那么谁都可以编辑,如果是自己的文档那么也可以编辑
+    else if (((U.MD.O.W.fileinfo.GroupID && U.MD.O.W.fileinfo.GroupID == U.MD.O.W.userinfo.UserId) || U.MD.O.W.fileinfo.UserId == US.userInfo.UserId)) {//判断是否是有编辑权限
+        U.MD.O.W.permission.edit = true;    //就给其编辑权限
+        if (U.MD.O.W.fileinfo.UserId == US.userInfo.UserId) {
+            U.MD.O.W.permission.web = true;//互联办公的权限
+        }
+    }
+}
+
 /**
 * 设置事件
 *
 */
 U.MD.O.W.setEvent = function () {
-    //设置建站文件的保存及新建事件
+    //un文件设置事件
     if (U.MD.O.W.fileinfo.UserDirectoryExtendType == 'un') {
-        //设置新建事件
-        $('#U_MD_O_H_new')[0].onclick = function () {
-            U.MD.O.W.T.N.newNav();
-        }
         //设置保存事件
         $('#U_MD_O_H_save')[0].onclick = function () {
             U.MD.O.W.T.N.saveNav(function () {
@@ -84,68 +151,77 @@ U.MD.O.W.setEvent = function () {
             });
         }
         $('body').addClass('U_MD_O_W_Nav');
+
+    }
+    //uw文件设置事件
+    else {
+        //设置保存事件
+        $('#U_MD_O_H_save')[0].onclick = function () {
+            U.MD.O.W.save()
+        }
+        $('body').removeClass('U_MD_O_W_Nav');
+    }
+
+    //设置新建事件
+    $('#U_MD_O_H_new')[0].onclick = function () {
+        U.MD.O.W.newdocument();
+    }
+    //下载处理
+    $("#U_MD_O_H_Area_Down")[0].onclick = function () {
+        top.U.MD.C.D.downloadFileOrDir([U.MD.O.W.fileinfo], "true"); //下载文档
     }
     //添加Ctrl+S快捷保存事件
-    $('body').bind('keydown', function (e) {
+    $('body')[0].onkeydown = function (e) {
         var currKey = 0;
         e = e || event || window.event;
         currKey = e.keyCode;
         if (currKey == 83 && (e.ctrlKey || e.metaKey)) {
             $('#U_MD_O_H_save')[0].onclick();
             U.UF.EV.stopDefault();
-            U.UF.EV.stopBubble()
+            U.UF.EV.stopBubble();
         }
-    });
+    };
 }
 
 
-/**
-* 初始化全局变量
-* @param   {object}    文档信息
-* @param   {object}    登录用户信息  
-*
-*/
-U.MD.O.W.variable = function (fileinfo, userinfo) {
-    if (!U.MD.O.W.fileinfo) {
-        U.MD.O.W.fileinfo = fileinfo //文档信息
-        //        return true;
-    }
-    U.MD.O.W.userinfo = userinfo; //用户信息
-    U.MD.O.W.setPermission();  //获取权限
-    return false;
-}
-
 /**
 * 加载Word编辑区域的内容
 * @param   {string}    文档信息
 */
-U.MD.O.W.LoadContent = function (fileinfo) {
-    var _permission = U.MD.O.W.permission;  //获取权限
-    var _synergy = _permission.web; //获取协同权限
-    var _fileid = fileinfo.UserDirectoryID; //文档id
+U.MD.O.W.loadContent = function (fileinfo) {
+    var _defaultnav,
+        _permission = U.MD.O.W.permission,  //获取权限
+        _fileid = fileinfo.UserDirectoryID; //文档id
     //新建文件的处理
     if (fileinfo.newfile) {
         //un新建文件的处理
         if (U.MD.O.W.fileinfo.UserDirectoryExtendType == 'un') {
-            var _defaultnav;
+            //默认导航的处理
             try {
                 _defaultnav = JSON.parse(U.MD.O.W.fileinfo.UsOffice);
-            } catch (e) {
+            }
+            catch (e) {
                 _defaultnav = { logo: "", nav: [{ pageId: Guid.newGuid(), name: "初始页面" }] };
             }
+            //创建默认导航文档
+
             U.MD.O.W.T.N.form(_defaultnav);
         }
-        //初始化编辑器
-        U.MD.O.W.E.initEditor();
+        //uw文件新建处理
+        else {
+            //初始化编辑器
+            U.MD.O.W.E.initEditor();
+        }
+        //清楚文件新建的属性,说明文件不是新建
         delete fileinfo.newfile;
     }
     //互联办公文档获取数据
-    else if (_synergy) {
-        parent.U.A.Request(US.SCOKET, [U.MD.O.W.fileinfo.UserDirectoryExtendType == 'un' ? 'getNav' : "getWord", _fileid, US.pageId, U.MD.O.W.userinfo.UserId], U.MD.O.W.AsynLoad, ["", fileinfo, _synergy]); //获取office内容
+    else if (_permission.web) {
+        parent.U.A.Request(US.SCOKET, [U.MD.O.W.fileinfo.UserDirectoryExtendType == 'un' ? 'getNav' : "getWord", _fileid, US.pageId, U.MD.O.W.userinfo.UserId], U.MD.O.W.asynLoad, [$("#U_MD_O_H_wordEditor")[0], fileinfo, _permission.web]); //获取office内容
     }
     //普通文档在数据库里面获取数据
     else {
-        parent.U.A.Request(US.AUTH, ["GetFileContent", _fileid], U.MD.O.W.AsynLoad, ["", fileinfo, _synergy]);
+        parent.U.A.Request(US.DISK, ["GetFileContent", _fileid], U.MD.O.W.asynLoad, [$("#U_MD_O_H_wordEditor")[0], fileinfo, _permission.web]);
     }
 }
 
@@ -153,33 +229,56 @@ U.MD.O.W.LoadContent = function (fileinfo) {
 * 异步获取Word编辑区域的数据
 *
 */
-U.MD.O.W.AsynLoad = function (r) {     //object 值
+U.MD.O.W.asynLoad = function (r) {     //object 值
     var _permission,
+        _fileinfo = U.MD.O.W.fileinfo,
         _context = r.context, //获取array值
         _fileinfo = _context[1], //获取文件信息
         _synergy = _context[2]; //互联权限
-    //内容处理
+
+    //获取后台返回的值,第一个是直接从数据库获取的,所以必须要从UsOffice获取值
     if (r.value && r.value.UsOffice !== undefined) {
         r = r.value.UsOffice;
-    } else {
+    }
+    else {
         r = r.value;
     }
+
     //un文件 导航文件处理
     if (U.MD.O.W.fileinfo.UserDirectoryExtendType == 'un') {
+        //因为导航文件默认是json格式的,如果这里从后台获取的值不是json那么进行转化
         if (typeof r != 'object') {
             try {
                 r = JSON.parse(r);
-            } catch (e) {
-                r = { logo: "", nav: [{ pageId: Guid.newGuid(), name: "恢复内容" }] };
+            }
+            catch (e) {
+                r = { logo: "", nav: [{ pageId: Guid.newGuid(), name: "初始页面" }] };;
             }
         }
+        //加载导航和内容
         U.MD.O.W.T.N.form(r);
     }
     //word文件处理
     else {
-        U.MD.O.W.fileinfo.UsOffice = (r || _fileinfo.UsOffice || "").unEscapeQuotes();  //word内容
-        //加载编辑器和内容
-        U.MD.O.W.E.initEditor(_synergy); //初始化编辑器
+        //如果数据库里面有内容或者不是服务器文件,直接加载内容
+        if (r || !_fileinfo.UserFilesServerName) {
+            _fileinfo.UsOffice = (r || "").unEscapeQuotes(); //word内容
+            //加载编辑器和内容
+            U.MD.O.W.E.initEditor(_synergy); //初始化编辑器
+        }
+        //如果是office文件第一次初始化的处理
+        else {
+            //微软的office上传打开的方式
+            U.A.Request("http://office.1473.cn/Officetohtml.ashx", ["Open", _fileinfo.UserDirectoryExtendType, _fileinfo.UserFilesServerName], function (r) {
+                if (r.value && r.value.value != undefined) {
+                    r = r.value;
+                    _fileinfo.UsOffice = r.value.getBodyHtml().replace(/src=[\'\"]?([^\'\"]*)[\'\"]?/ig, function (str1, str2) {
+                        return "src=\"http://office.1473.cn/usoffice/" + str2 + "\"";
+                    });
+                }
+                U.MD.O.W.E.initEditor(_synergy); //初始化编辑器
+            }, [""]);
+        }
     }
 }
 
@@ -187,344 +286,193 @@ U.MD.O.W.AsynLoad = function (r) {     //object 值
 
 //#region 保存区域
 
+/**
+* 判断当前文件是否保存
+*
+* @param  {function} 保存回调函数
+*/
+U.MD.O.W.isSave = function () {
+    var _fileinfo = U.MD.O.W.fileinfo, //word文件
+        _fileid = _fileinfo.UserDirectoryID; //文件id
+    return ((_fileid && _fileinfo.UserId && _fileinfo.UserallDirectoryName) && U.MD.O.W.permission.edit);    //判断文档是否是已经保存到数据库的文档(判断的依据在于这个文件除了有文件id还有文件名和创建者id) 
+}
+
+
+
 /**
 * 保存Word
 *
 * @param  {function} 保存回调函数
 */
 U.MD.O.W.save = function () {
+    var _islogin = top.U.MD.U.L.isLogin(function (userinfo) { U.MD.O.W.userinfo = userinfo; });
     //判断用户是否登录,只有登录用户才能保存信息
     if (!top.U.MD.U.L.isLogin(function (userinfo) { U.MD.O.W.userinfo = userinfo; })) {
         var _isftp,
             _isgroupuser,
+            _r, //返回值
             _uid = U.MD.O.W.userinfo.UserId,
             _el = $("#U_MD_O_H_wordEditor")[0], //word编辑区域
             _fileinfo = U.MD.O.W.fileinfo, //文件信息
             _fileid = _fileinfo.UserDirectoryID, //文件ID
             _name = top.$('#UD_Word' + _fileid + ' .U_MD_O_H_head_navigation_Title')[0].value, //文件名
             _html = _el.innerHTML.escapeQuotes(); //内容
-
-        //判断文档是否是已经保存到数据库的文档
-        if (_fileid && _fileinfo.UserId && _fileinfo.UserallDirectoryName && U.MD.O.W.permission.edit) { //如果是已经保存到数据库的文档,那么直接保存内容
-            U.MD.O.W.Panel.InsertOfficeHistory(_fileinfo, _html, _name, _el); //插入历史记录
-            //保存到数据库
-
-            top.U.A.Request(US.AUTH, ["SaveFileContent", US.userInfo.UserId, _fileid, _html, _name], function (r) {
-                U.MD.O.W.fileinfo.UsOffice = r.context[1].innerHTML;
-                U.Alert("保存成功");
-            }, (['', _el])); //保存到数据库
+        if (top.window.location.href.split("/")[2] != "www.1473.cn") {
+            U.MD.O.W.saveFileOther();
         }
-        //如果文件没有保存,那么直接新建文件
         else {
-            var _newfileid = Guid.newGuid();
-            //调用word新建文档的处理
-            top.U.MD.DK.VW.chosenSaveFile('uw', _newfileid, _name, function (fileinfo) {
-                top.$('#UD_Word' + _fileid)[0].id = 'UD_Word' + _newfileid;
-                top.$('#UD_Word' + _newfileid + ' .U_MD_O_H_head_navigation_Title')[0].value = fileinfo.UserDirectoryName;
-                U.MD.O.W.fileinfo = fileinfo //文档信息
-                _isgroup = U.Json.select(US.friend.group, {
-                    "GroupManageID": fileinfo.GroupID
-                })[0];
-                if (_isgroup) {
-                    U.MD.O.W.permission.web = true;
-                    top.U.A.Request(US.SCOKET, ["newWordSave", _newfileid, _html, fileinfo.UserDirectoryName, US.userInfo.UserId, US.pageId], function (r) {
-                        U.Alert("保存成功");
-                        U.MD.O.W.fileinfo.UsOffice = _el.innerHTML;
-                        $('#U_MD_O_H_wordEditor')[0].editor.operaNotice = U.MD.O.W.E.operationNotice;
-                        U.MD.O.W.permission.edit = true;
-                    });
-                } else {
-                    //保存到数据库
-                    top.U.A.Request(US.AUTH, ["SaveFileContent", US.userInfo.UserId, _newfileid, _html, fileinfo.UserDirectoryName], function (r) {
-                        U.MD.O.W.fileinfo.UsOffice = r.context[1].innerHTML;
-                        U.MD.O.W.permission.edit = true;
-                        U.Alert("保存成功");
-                    }, (['', _el])); //保存到数据库
-                }
-            });
-        }
-    }
-}
+            //判断文档是否是已经保存到数据库的文档
+            // U.A.Request(US.CD, [US.DB, "UseStudio_Disk", _fileid, "FB1CB716-E42E-4DEA-9A66-F14F0771826F"], function (r) {  _r  = r.value });
+            //if (_fileid && _fileinfo.UserId && _fileinfo.UserallDirectoryName && U.MD.O.W.permission.edit) {
+            if (_fileid && _fileinfo.UserId && _fileinfo.UserallDirectoryName && U.MD.O.W.permission.edit) { //如果是已经保存到数据库的文档,那么直接保存内容
+                U.MD.O.W.Panel.InsertOfficeHistory(_fileinfo, _html, _name, _el); //插入历史记录
+                //保存到数据库
+
+                //保存到数据库
+                top.U.A.Request(US.DISK, ["SaveFileContent", US.userInfo.UserId, _fileid, _html, _name, "uw"], function (r) {
+                    U.MD.O.W.fileinfo.UsOffice = r.context[1].innerHTML;
+                    U.Alert("保存成功");
+                }, (['', _el])); //保存到数据库
 
-U.MD.O.W.updateName = function () {
-    if (!top.U.MD.U.L.isLogin(function (userinfo) { U.MD.O.W.userinfo = userinfo; })) {
-        var _fileinfo = U.MD.O.W.fileinfo, //文件信息
-            _type = U.MD.O.W.fileinfo.UserDirectoryExtendType == 'un' ? 'nav' : 'word',
-            _fileid = _fileinfo.UserDirectoryID,             //文件ID
-            _name = top.$('#UD_Word' + _fileid + ' .U_MD_O_H_head_navigation_Title')[0].value; //文件名
-        //判断文档是否是已经保存到数据库的文档
-        if (U.MD.O.W.permission.edit && _fileid && _fileinfo.UserId && _fileinfo.UserallDirectoryName) { //如果是已经保存到数据库的文档,那么直接保存内容
-            if (U.MD.O.W.permission.web) {
-                top.U.A.Request(US.SCOKET, ["updateName", _type, _fileid, _name, US.userInfo.UserId, US.pageId], function (r) {
-                    if (r.value == "updateNameSuccess") {
-                        _fileinfo.UserallDirectoryName = _name; //文件全写的名字
-                        _fileinfo.UserDirectoryName = _name.addEllipsis(20); //文件的缩略名
-                    }
-                });
             }
+            //如果文件没有保存,那么直接新建文件
             else {
-                top.U.A.Request(US.DISK, ["UpdateFileInfo", _fileid, _name], function (r) {
-                    if (r.value) {
-                        _fileinfo.UserallDirectoryName = _name; //文件全写的名字
-                        _fileinfo.UserDirectoryName = _name.addEllipsis(20); //文件的缩略名
+                //调用word新建文档的处理
+                top.U.MD.DK.VW.chosenSaveFile('uw', _fileid, _name, function (fileinfo) {
+                    U.MD.O.W.fileinfo = fileinfo; //文档信息
+                    top.$('#UD_Word' + _fileid + ' .U_MD_O_H_head_navigation_Title')[0].value = fileinfo.UserDirectoryName; //文件名设置
+                    U.MD.O.W.setPermission(); //新建的文件设置权限,根据新建的位置
+                    //如果是互联办公文档的处理(第一次新建的文件需要从保存到redis全局变量中,第二次之后都是直接从redis初始化的)
+                    if (U.MD.O.W.permission.web) {
+                        top.U.A.Request(US.SCOKET, ["newWordSave", _fileid, _html, fileinfo.UserDirectoryName, US.userInfo.UserId, US.pageId], function (r) {
+                            U.MD.O.W.Panel.loadPlayUser(fileinfo); //加载协助人员窗体
+                            U.Alert("保存成功");
+                            U.MD.O.W.fileinfo.UsOffice = _el.innerHTML;
+                            //设置互联办公编辑回调的事件,这样设置不合理
+                            $('#U_MD_O_H_wordEditor')[0].editor.operaNotice = U.MD.O.W.E.operationNotice;
+                        });
+                    }
+                    //如果是普通文档的处理
+                    else {
+                        //保存到数据库
+                        top.U.A.Request(US.DISK, ["SaveFileContent", US.userInfo.UserId, _fileid, _html, fileinfo.UserDirectoryName, "uw"], function (r) {
+                            U.Alert("保存成功");
+                            U.MD.O.W.fileinfo.UsOffice = r.context[1].innerHTML;
+                        }, (['', _el])); //保存到数据库
                     }
                 });
             }
         }
     }
-}
-
-//#endregion
-
-//#region 新建文档
-
-/**
-* 文件文档
-*
-*/
-U.MD.O.W.newDoc = function () {
-    parent.U.MD.D.I.openApplication("word", { "userid": US.userInfo.UserId, "directoryid": US.FTPFOLDERID }); //打开文档处理
-}
 
-//#endregion
-
-//#region 纸张大小
-
-/**
-* 编辑器权限函数
-* @return 返回用户权限json
-*/
-U.MD.O.W.setPermission = function () {
-    var _iseditor,              //是否可编辑
-        _isgroup;            //群用户
-
-    if (!U.MD.O.W.fileinfo.UserId && !U.MD.O.W.fileinfo.UserID) { //新建文档给予编辑权限
-        U.MD.O.W.permission.edit = false;    //就给其编辑权限
-        return;
-    }
-    if (U.MD.O.W.fileinfo && US.friend.group) {//判断用户是否在群里操作群文件
-        _isgroup = U.Json.select(US.friend.group, {
-            "GroupManageID": U.MD.O.W.fileinfo.GroupID
-        })[0];
-    }
-    if (U.MD.O.W.fileinfo && ((U.MD.O.W.fileinfo.GroupID && U.MD.O.W.fileinfo.GroupID == U.MD.O.W.userinfo.UserId) || U.MD.O.W.fileinfo.UserId == US.userInfo.UserId)) {//判断是否是有编辑权限
-        _iseditor = true;
-    }
-    if (_isgroup) {//是ftp用户就判断是不是群用户
-        U.MD.O.W.permission.web = true;     //互联办公的权限
-        U.MD.O.W.permission.edit = true;    //就给其编辑权限
-    } else if (_iseditor) {
-        U.MD.O.W.permission.edit = true;    //就给其编辑权限
-    }
-}
-
-/**
-* 文档分享
-*/
-U.MD.O.W.shareFileToChat = function () {
-    top.U.MD.F.J.selectFriendForm(function (groupid) {
-        var _fileInfo = U.MD.O.W.fileinfo,
-            _message = {
-                fileName: _fileInfo.UserallDirectoryName,
-                fileType: _fileInfo.UserDirectoryExtendType,
-                fileSize: _fileInfo.UserDirectorySize,
-                fileID: _fileInfo.UserDirectoryID
+    /**
+    * 修改文件名处理
+    *
+    * @param  {function} 保存回调函数
+    */
+    U.MD.O.W.updateName = function () {
+        var _islogin = top.U.MD.U.L.isLogin(function (userinfo) { U.MD.O.W.userinfo = userinfo; }); //判断是否登录
+        if (!_islogin) {
+            var _fileinfo = U.MD.O.W.fileinfo, //文件信息
+                _userinfo = U.MD.O.W.userinfo,
+                _type = U.MD.O.W.fileinfo.UserDirectoryExtendType == 'un' ? 'nav' : 'word',
+                _fileid = _fileinfo.UserDirectoryID, //文件ID
+                _name = top.$('#UD_Word' + _fileid + ' .U_MD_O_H_head_navigation_Title')[0].value;
+
+            //文件名必须本人才能修改
+            if (_userinfo.UserId == _fileinfo.UserId) {
+                //判断文档是否是已经保存到数据库的文档(判断的依据在于这个文件除了有文件id还有文件名和创建者id) 
+                if ((_fileid && _fileinfo.UserId && _fileinfo.UserallDirectoryName) && U.MD.O.W.permission.edit) { //如果是已经保存到数据库的文档,那么直接保存内容
+                    //如果是互联办公文档的操作
+                    if (U.MD.O.W.permission.web) {
+                        top.U.A.Request(US.SCOKET, ["updateName", _type, _fileid, _name, US.userInfo.UserId, US.pageId], function (r) {
+                            if (r.value == "updateNameSuccess") {
+                                _fileinfo.UserallDirectoryName = _name; //文件全写的名字
+                                _fileinfo.UserDirectoryName = _name.addEllipsis(20); //文件的缩略名
+                            }
+                        });
+                    }
+                    //普通文档修改信息
+                    else {
+                        top.U.A.Request(US.DISK, ["UpdateFileInfo", _fileid, _name], function (r) {
+                            if (r.value) {
+                                _fileinfo.UserallDirectoryName = _name; //文件全写的名字
+                                _fileinfo.UserDirectoryName = _name.addEllipsis(20); //文件的缩略名
+                            }
+                        });
+                    }
+                }
             }
-        if (!groupid) {
-            var _chooseNumber = top.U.MD.F.J.selectUserInfo.NeedUser;
-
-            for (var i = 0; i < _chooseNumber.length; i++) {
-                U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "SentMessageToFriend", US.userInfo.UserId, _chooseNumber[i].UserId, US.userInfo.UserNickName, JSON.stringify(_message), 6, false], function () {
-                    U.alert('文档已分享到小伙伴!');
-                });
+            //其他用户不允许修改文件名
+            else {
+                top.$('#UD_Word' + _fileid + ' .U_MD_O_H_head_navigation_Title')[0].value = _fileinfo.UserallDirectoryName;
+                U.alert('非本人操作,修改失败!');
             }
-        } else {
-            U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "SendMessageToGroup", groupid, Guid.newGuid(), US.userInfo.UserId, JSON.stringify(_message), US.userInfo.UserNickName], function () {
-                U.alert('文档分享成功,到群看看吧!');
-            });
         }
-    });
-}
-
-document.oncontextmenu = U.UF.EV.stopDefault; //禁止右键菜单
-
-/**
-* 附件
-*/
-U.MD.O.W.accessory = function () {
-    if (!U.MD.U.L.isLogin()) {
-        var _confirm = $$('div'),
-            _pickarea = $$("div", { "style": { "cssText": "display:table; width: 100%; height: auto; " } }, _confirm),
-            _picklocal = $$("div", { "style": { "cssText": "display:table-cell; width:235px; height:170px; background-color:#f5f5f5;text-align:center; vertical-align: middle;cursor: pointer;" } }, _pickarea),
-            _pickline = $$("div", { "style": { "cssText": "display:table-cell; width:1px; height: 100%; background-color:#cecece;" } }, _pickarea),
-            _pickoa = $$("div", { "style": { "cssText": "display:table-cell; width:234px; height:100%; background-color:#f5f5f5;text-align:center; vertical-align: middle;cursor: pointer;" } }, _pickarea);
-        $$("img", { "onerror": U.MD.C.imgError, src: "/img/officefileicon.png", style: { "vertical-align": "middle" } }, _picklocal);
-        $$("img", { "onerror": U.MD.C.imgError, src: "/img/oaofficeicon.png", style: { "vertical-align": "middle" } }, _pickoa);
-        $$('span', { innerText: '从网盘添加', style: { "margin-left": "10px" } }, _pickoa);
-        $$('span', { innerText: '从本地上传', style: { "margin-left": "10px" } }, _picklocal);
-        var _locaInp = $$('input', { id: "U_MD_O_cloud", type: "file", style: { cssText: "position: absolute; visibility: hidden;" }, multiple: "" }, _picklocal);
-        var _range;
-        var _form = new U.UF.UI.form(
-            "上传附件",
-            _confirm,
-            {
-                "style": {
-                    "cssText": "font-size: 16px; background: rgb(255,255,255); width: 470px; position: fixed; box-shadow: rgb(0, 0, 0) 2px 1px 5px; "
-                }
-            },
-            {
-                "istop": true,
-                "isenlarge": false,
-                "isstretching": false,
-                "isnarrow": false
-            },
-            {
-                "style": {
-                    "cssText": " background: #3c475b;padding:4px 0 ; color: rgb(255,255,255); "
-                }
-            });
-
-        $(_picklocal).bind({
-            "mouseover": function () { _picklocal.style.backgroundColor = "#dcdcdc"; },
-            "mouseout": function () { _picklocal.style.backgroundColor = "#f5f5f5"; },
-            "mousedown": function () {
-                _range = U.UF.E.getRangeAt();
-
-                _locaInp.click();
-            }
-        });
-        $(_pickoa).bind({
-            "mouseover": function () { _pickoa.style.backgroundColor = "#dcdcdc"; },
-            "mouseout": function () { _pickoa.style.backgroundColor = "#f5f5f5"; },
-            "mousedown": function () {
-                _range = U.UF.E.getRangeAt();
-            },
-            "click": function () {
-                top.U.MD.DK.VW.choseFile(function (file) {
-                    //                    var _ppel = $$('span', { style: { cssText: "display:inline-block; position: relative; max-width: 300px;"} }),
-                    //                        _parent = $$('img', { "src": "http://fs.1473.cn/" + file.UserDirectoryUrl, style: { cssText: "width: 100%;"} }, _ppel),
-                    //                        _videoStart = $$("span", { "style": { "width": "97px", "height": "96px", "background-image": "url('/img/YS2017.png')", "display": "inline-block", "background-repeat": "no-repeat", "background-position": "-1015px -362px", "position": "absolute", "top": "25%", "left": "35%"} }, _ppel);
-
-                    //                    var _message = {
-                    //                        fileName: file.UserallDirectoryName,
-                    //                        fileType: file.UserDirectoryExtendType,
-                    //                        fileSize: file.UserDirectorySize,
-                    //                        fileID: file.UserDirectoryID,
-                    //                        fileUrl: file.UserDirectoryUrl
-                    //                    };
-                    //                    U.UF.E.reSelectRange(_range);
-                    U.UF.E.reSelectRange(_range);
-                    var _box = $$('div');
-                    var _img = $$('img', { src: "http://fs.1473.cn/" + file.UserDirectoryUrl }, _box)
-
-                    U.UF.E.textFormat(_box.outerHTML, $('#U_MD_O_H_wordEditor')[0])
+    }
 
-                });
+    //#endregion
+
+    //#region 新建文档
+
+    /**
+    * 新建文档的处理
+    *
+    */
+    U.MD.O.W.newdocument = function () {
+        var _divel = $$("div", { "className": "U_MD_O_newBtn" });
+        $$("button", {
+            "className": "U_MD_O_newDoc", "innerHTML": "普通word",
+            "onclick": function () {
+                parent.U.MD.D.I.openApplication("word", { "userid": US.userInfo.UserId, "directoryid": US.FTPFOLDERID }); //打开文档处理
+                $('#U_MD_O_Set')[0].style.display = "none";
             }
-        });
-
-        $(_locaInp).bind({
-            "mousedown": function () {
-                _range = U.UF.E.getRangeAt(); //记录失焦前光标的位置
-            },
-            "change": function (e) {
-                U.UF.E.reSelectRange(_range); //重新聚焦光标
-                var _file = e.target.files[0], //获取本地选中文件
-                    _type = _file.type.split('/'); //获取选中文件的类型
-
-                switch (_type[0]) {
-                    case "image": //图片
-                        U.UF.E.picture(this, $('#U_MD_O_H_wordEditor')[0]);
-                        break;
-                    case "audio": //音频
-                        U.UF.UP.inputUpload([this], "http://disk.1473.cn/USUpfile.ashx?typename=UseStudioEditor&UserId=c1fd0834-ea9a-44eb-b216-2a051c2240d8", function (data) {
-                            var _el = U.MD.O.W.accessory.printFile('video', data.value); //样式
-
-                            //以下代码仅仅提供展示,音频暂时无法上传
-                            if ($('#showplace').length) {
-                                $('#showplace').find('div[usbody="true"]')[0].appendchild(_el);
-                                return;
-                            }
-                            var _box = $$('div', {});
-                            _box.appendChild(_el);
-                            new U.UF.UI.form("展示位", _box, { id: "showplace", style: { cssText: "width: 600px; height: 500px" } });
-                        })
-                        break;
-                    case "video":
-                        //                        U.UF.UP.inputUpload([this], "http://disk.1473.cn/USUpfile.ashx?typename=UseStudioEditor&UserId=c1fd0834-ea9a-44eb-b216-2a051c2240d8", function (data) { //最终用例
-                        //                            //var _el = U.MD.O.W.accessory.printFile('video', data.value, _file);
-                        //                            
-                        //                        })
-
-                        var _box = $$('span'), //测试能否将canvas插入文档中用例
-                            _canvas = $$('canvas', {}, _box);
-                        var _ctx = _canvas.getContext('2d');
-                        _canvas.width = 300;
-                        _canvas.height = 200;
-                        _ctx.fillRect(0, 0, 300, 200);
-
-                        U.UF.E.insertContent(_box, _range, $('#U_MD_O_H_wordEditor')[0]);
-                        break;
-                }
+        }, _divel);
+        $$("button", {
+            "className": "U_MD_O_newNav", "innerHTML": "导航模板",
+            "onclick": function () {
+                parent.U.MD.D.I.openApplication("word", { UserDirectoryExtendType: "un" }); //新建导航文档
+                $('#U_MD_O_Set')[0].style.display = "none";
             }
-        })
+        }, _divel);
+        new U.UF.UI.form("新建", _divel, { "id": "U_MD_O_Set", "style": { "width": "300px", "height": "150px" } }, { isenlarge: false, isstretching: false }).form;
     }
-}
-
-/**
-* 打开视频控件
-*/
-U.MD.O.W.accessory.openVideo = function () {
-    alert(11);
-}
-
-/**
-* 输出文件样式
-*/
-U.MD.O.W.accessory.printFile = function (type, data, files) {
-    var _div = $$('span', { style: { cssText: "display: inline-block" } });
-
-    switch (type) {
-        case "video":
-            var video = document.createElement('video'),
-                _second, _mintue;
-            video.src = "http://fs.1473.cn/" + data[0]
-
-            video.addEventListener('canplaythrough', function (e) { //拿到视频的时长
-                var s = Math.ceil(e.target.duration) % 60,
-                    m = Math.floor(e.target.duration / 60);
-                _second = s < 10 ? "0" + s : s;
-                _mintue = m < 10 ? "0" + m : m;
-
-                var _img = $$('img', { src: "/img/YS2017.png" }),
-                    _img2 = $$('img', { src: "http://fs.1473.cn/" + data[1] });
-
-                _img2.onload = function () { //当图片加载好后
-                    _ctx.drawImage(_img2, 0, 0, 300, 150); //关键帧图片
-                    _ctx.drawImage(_img, 1015, 362, 97, 97, 110, 20, 97, 97); //播放图片
-                    _ctx.fillStyle = "#ffffff"; //填充颜色
-                    _ctx.fillText(_mintue + ":" + _second, 10, 140);
-                }
-            })
-
-            var _canvas = $$('canvas', { style: { cssText: "border:1px solid #000000;" } }, _div),
-                _ctx = _canvas.getContext('2d');
-
-            _canvas.width = 300;
-            _canvas.height = 150;
-
-            _canvas.onclick = function () {
-                U.MD.UI.video("http://fs.1473.cn/" + data[0], 300, 150, false, $('#showplace').find('div[usbody="true"]')[0]);
-            }
-            break;
-        case "audio":
-            //            var _box = $$('div', { style: { cssText: "display:inline-block; width: 146px; background-color: #3F8BDD; color: #ffffff;"} }, _div);
-            //            $$('img', { src: "#", style: { cssText: "width: 17px; height: 20px; background-color: #ffffff;"} });
-            //            $$('span', { innerText: '15"' });
 
-            break;
+    //#endregion
+    //#region 文档转化
+
+    /**
+    * 导航文件转化成普通文件
+    */
+    U.MD.O.W.newDocSwitch = function () {
+        var _fileinfo = U.MD.O.W.fileinfo,
+            _fileid = _fileinfo.UserDirectoryID;
+        if (_fileinfo.UserDirectoryExtendType == "un") {
+            $("#U_MD_O_H_Nav")[0].style.display = "none";
+            $("#U_MD_O_W_N").Parent({ usform: "true" }).style.display = "none";
+        }
+        //获取文件内容异步
+        U.A.Request(US.CD, ([US.DB, "UseStudio_Disk", "GetFileContent", "d17a2910-11ba-df39-cd8a-5cac851c2148"]), function (r) {
+            _fileinfo.UserDirectoryExtendType = 'uw'; //设置格式为uw
+            _fileinfo.UsOffice = r.value[0].UsOffice.unEscapeQuotes(); //获取值
+            _fileinfo.newfile = true; //设置为新建文件
+            U.MD.O.W.load(_fileinfo, U.MD.O.W.userinfo); //初始化
+        });
     }
 
-    return _div;
+    /** * 普通文件转化成导航文件
+    */
+    U.MD.O.W.newNavSwitch = function () {
+        var _fileinfo = U.MD.O.W.fileinfo,
+            _fileid = _fileinfo.UserDirectoryID;
+        //获取文件内容异步,此为获取默认的宣传文档
+        U.A.Request(US.CD, ([US.DB, "UseStudio_Disk", "GetFileContent", "6a8a235a-41c4-c3d2-8dd5-b6ee851e1967"]), function (r) {
+            _fileinfo.UserDirectoryExtendType = 'un'; //设置格式为un
+            _fileinfo.UsOffice = r.value[0].UsOffice.unEscapeQuotes(); //获取值
+            _fileinfo.newfile = true; //设置为新建文件
+            U.MD.O.W.load(_fileinfo, U.MD.O.W.userinfo); //初始化
+        });
+    }
 }
+
 //#endregion

+ 289 - 321
js/Office/Word/WordPanel.js

@@ -2,70 +2,48 @@
 
 Namespace.register("U.MD.O.W.Panel");
 
-//#region 初始化区域
-/**
-* 加载编辑区域
-*
-* @param  {element} 
-* @param  {element} 
-*/
-U.MD.O.W.Panel.Loadeditor = function (fileid, fileinfo) {
-    var _worddiv, _UDTD, _UDGD, _wordeditor, _UDKD;
-    //$("#U_MD_O_W_E_body")[0] 是word的编辑区域,如果不存在,则创建一个。
-    if (!$("#U_MD_O_W_E_body")[0]) {
-        _worddiv = $("#U_MD_O_R_Parent")[0]; //包含word编辑区域的div
-        _wordeditor = $$("div", { "id": "U_MD_O_W_E_body" }, _worddiv); //创建word编辑器区域
-        _pagediv = $$("div", { "className": "U_MD_O_H_body_main_m" }, _wordeditor); //由于是多页,所以需要另外建立一个div,包含下面的头部,内容,底部
-        _header = $$("div", { "className": "U_MD_O_H_body_main_border" }, _pagediv); //头部信息
-        $$("div", { "className": "U_MD_O_H_body_main_bordero" }, _header); //头部的左上角
-        $$("div", { "className": "U_MD_O_H_body_main_bordert" }, _header); //头部的右上角
-        $$("div", { "className": "U_MD_O_H_body_main_text", contentEditable: "true", spellcheck: "false", "innerHTML": "", "id": "Txt" + Guid.newGuid() }, _pagediv); //编辑器区域
-        _footer = $$("div", { "className": "U_MD_O_H_body_main_border" }, _pagediv);
-        $$("div", { "className": "U_MD_O_H_body_main_borders" }, _footer);
-        $$("div", { "className": "U_MD_O_H_body_main_borderf" }, _footer);
-
-        //把编辑器区域放入窗体。
-
-        //new U.UF.UI.form("", _worddiv, { className: 'U_MD_F_S', style: { "backgroundColor": "transparent", "border": "0", "width": "auto", "top": "15px", "left": "30px"} }, {});
-
-        new U.UF.UI.form(false, _worddiv, { style: { backgroundColor: "transparent", border: "0", width: "auto", top: "50px", left: "0px", margin: "0px 20px", "box-shadow": "none"} }, { isdrag: false, isstretching: false });
-
-        U.MD.O.W.LoadContent(fileid, fileinfo)
-    }
-}
 
-//#endregion  
+
+//协作统一命名为Collaborative,但牵涉的地方太多,暂时还是用Synergy
 
 //#region 本地转协同文档及新建保存为协同文档操作
 
 /**
-* 本地转协同文档及新建保存为协同文档操作
+* 本地转协同文档及新建保存为协同文档操作,此函数逻辑不清,需要改写!
 *
 * @param fun {element} 回调函数
 */
-U.MD.O.W.Panel.IsSynergy = function (fun) {
-    if (!top.U.MD.U.L.isLogin()) { //判断是登录
-        var _fileinfo = U.MD.O.W.fileinfo;
-        var _filegroupid = _fileinfo.UserDirectoryEncrypt || _fileinfo.GroupID; //获取_filegroupid群id,判断是否是在自己的ftp下的文档
-        if (_filegroupid == US.userInfo.UserId) { //判断是本地文档还是互联文档
-            _filegroupid = false;
-        }
-        if (_filegroupid && U.MD.O.W.permission.edit) { //是否为群
+U.MD.O.W.Panel.isSynergy = function (fun) {
+    //判断是登录
+    if (!top.U.MD.U.L.isLogin()) {
+        var _fileinfo = U.MD.O.W.fileinfo, //文件信息
+            ////或者是什么意思?不严谨
+            _filegroupid = _fileinfo.GroupID; //获取_filegroupid群id,判断是否是在自己的ftp下的文档
+
+        //判断是否为互联办公文档,此处有问题。互联办公的权限有问题。
+        if (U.MD.O.W.permission.web) {
             if (U.UF.C.isFunction(fun)) {//判断是否有点击事件的方法,如果有,运行它
                 fun(_fileinfo);
             }
             return true;
-        } else {
+        }
+        else {
             var _filename = top.$('#UD_Word' + _fileinfo.UserDirectoryID + ' .U_MD_O_H_head_navigation_Title')[0]; //获取文件名
-            if (_fileinfo.UserDirectoryID && _fileinfo.UserId && _fileinfo.UserallDirectoryName && U.MD.O.W.permission.edit) { //如果是已经保存到数据库的文档,那么直接保存内容
-                new U.UF.UI.confirm("是否将此文档转成互联办公文档", function () {   //本地转协同
+            //判断文档是否是保持文档,是否是可编辑文档
+            if (U.MD.O.W.isSave() && U.MD.O.W.permission.edit) {
+                //如果是保持的文档,那么直接提示是否转成系统文档
+                new U.UF.UI.confirm("是否将此文档转成互联办公文档", function () {
+                    //保存到群里
                     top.U.MD.DK.VW.saveSynergy(_fileinfo.UserDirectoryExtendType || "uw", _fileinfo, _filename.value, 'move', function (fileinfo) {
-                        U.MD.O.W.Panel.IsSynergy.Async(fileinfo, fun);
+                        U.MD.O.W.Panel.isSynergy.async(fileinfo, fun);
                     });
                 });
-            } else { //新建保存为协同
+            }
+            //新建保存为协同
+            else {
+                //否则是新建文档
                 top.U.MD.DK.VW.saveSynergy(_fileinfo.UserDirectoryExtendType || "uw", _fileinfo, _filename.value, 'new', function (fileinfo) {
-                    U.MD.O.W.Panel.IsSynergy.Async(fileinfo, fun);
+                    U.MD.O.W.Panel.isSynergy.async(fileinfo, fun);
                 });
             }
         }
@@ -79,26 +57,27 @@ U.MD.O.W.Panel.IsSynergy = function (fun) {
 * @param fileinfo {object} 文件信息
 * @param fun {element} 回调函数
 */
-U.MD.O.W.Panel.IsSynergy.Async = function (fileinfo, fun) {
+U.MD.O.W.Panel.isSynergy.async = function (fileinfo, fun) {
     U.MD.O.W.fileinfo = fileinfo; //设置文件信息
-    U.MD.O.W.Panel.disPlayUser(fileinfo); //获取协作人员   
+    U.MD.O.W.Panel.disPlayUser(fileinfo); //获取协作人员
     var _eidtorel = $('#U_MD_O_H_wordEditor')[0]; //获取编辑器
+    //导航文件转成互联
     if (fileinfo.UserDirectoryExtendType == 'un') {
         //保存文件到后台
         U.MD.O.W.T.N.saveAllPage(function () {
             U.MD.O.W.T.N.saveNav.asyn(true, fileinfo, _eidtorel);
         }, 0, true, _eidtorel.innerHTML);
-        //        U.A.Request(US.SCOKET, ["newNavSave", fileinfo.UserDirectoryID, JSON.stringify(U.MD.O.W.T.N.navInfo), fileinfo.UserDirectoryName, U.MD.O.W.T.N.nowNavId, _eidtorel.innerHTML.escapeQuotes(), US.userInfo.UserId, US.pageId], U.MD.O.W.Panel.IsSynergy.saveAsync, [null, fileinfo, _eidtorel]);
-    } else {
+    }
+    else {
         //保存文件到后台
-        U.A.Request(US.SCOKET, ["newWordSave", fileinfo.UserDirectoryID, _eidtorel.innerHTML.escapeQuotes(), fileinfo.UserDirectoryName, US.userInfo.UserId, top.US.pageId], U.MD.O.W.Panel.IsSynergy.saveAsync, [null, fileinfo, _eidtorel]);
+        U.A.Request(US.SCOKET, ["newWordSave", fileinfo.UserDirectoryID, _eidtorel.innerHTML.escapeQuotes(), fileinfo.UserDirectoryName, US.userInfo.UserId, top.US.pageId], U.MD.O.W.Panel.isSynergy.saveAsync, [null, fileinfo, _eidtorel]);
     }
     if (U.UF.C.isFunction(fun)) {//判断是否有点击事件的方法,如果有,运行它
         fun(fileinfo);
     }
 }
 
-U.MD.O.W.Panel.IsSynergy.saveAsync = function (r) {
+U.MD.O.W.Panel.isSynergy.saveAsync = function (r) {
     var _fileinfo = r.context[1];
     var _eidtorel = r.context[2];
     U.MD.O.W.permission.edit = true;
@@ -117,25 +96,29 @@ U.MD.O.W.Panel.IsSynergy.saveAsync = function (r) {
 *
 * @param  fileinfo {object} 文件信息
 */
-// U.MD.O.W.Panel.LoadPlayUser = function (fileinfo) {
-//     var _coopwindow, _frienddiv, _example, _wordsize, _marginleft, _shareLink, _cBox;
-//     //如果不存在团队成员窗口,则创建一个团队成员窗口。
-//     if (!$("#U_MD_O_H_body_left_invite_user")[0]) {
-//         _wordsize = U.UF.EL.getElementInfo($("#U_MD_O_W_E_body")[0]); //获取编辑器域的父亲。用于获取长度大小,用于定位
-//         _marginleft = _wordsize["OW"] + 50; //团队窗口的位置间距编辑器50像素
-//         //创建邀请协助人员窗口
-//         _coopwindow = $("#U_MD_O_H_body_left")[0];
-//         _cBox = $$("div", {});
-//         _shareLink = $$("div", { className: 'U_MD_O_H_body_left_invite_linkTxt', "onclick": function () { U.MD.O.W.Panel.IsSynergy(U.MD.O.W.Panel.shareLink); }, "innerText": "第三方链接邀请" }, _cBox);
-//         _frienddiv = $$("div", { "className": "U_MD_O_H_body_left_invite_user", "id": "U_MD_O_H_body_left_invite_user" }, _cBox); //好友内容区域
-//         _example = $$("div", { "className": "U_MD_O_H_body_left_invite_user_a", "onclick": function () { U.MD.O.W.Panel.displayInsertUser(); } }, _frienddiv); //默认邀请按钮
-//         $$("div", { "className": "U_MD_O_H_body_left_invite_user_a_img" }, _example);
-//         $$("div", { "className": "U_MD_O_H_body_left_invite_user_a_div", "innerHTML": "邀请" }, _example);
-//         new U.UF.UI.form("邀请协作人员", _cBox, { style: { border: "none", position: "absolute", width: "300px", "min-width": "200px", height: "250px", top: "140px", left: "auto", "box-shadow": "none"} },
-//                         { isenlarge: false, isnarrow: false }, { style: { margin: "0px 5px", "border-bottom": "1px solid #d6def0", color: "#000", background: "#fff"} }, null, null, _coopwindow);
-//     }
-//     U.MD.O.W.Panel.disPlayUser(fileinfo); //获取协作人员   
-// }
+U.MD.O.W.Panel.loadPlayUser = function (fileinfo) {
+    var _coopwindow, _frienddiv, _example, _shareLink, _cBox;
+    //如果不存在团队成员窗口,则创建一个团队成员窗口。
+    if (!$("#U_MD_O_H_body_left_invite_user")[0]) {
+        //创建邀请协助人员窗口
+        _coopwindow = $("#U_MD_O_H_body_left")[0];
+        _cBox = $$("div", {});
+        _shareLink = $$("div", { className: 'U_MD_O_H_body_left_invite_linkTxt', "onclick": function () {
+            U.MD.O.W.Panel.isSynergy(U.MD.O.W.Panel.shareLink);
+        }, "innerText": "第三方链接邀请"
+        }, _cBox);
+        _frienddiv = $$("div", { "className": "U_MD_O_H_body_left_invite_user", "id": "U_MD_O_H_body_left_invite_user" }, _cBox); //好友内容区域
+        _example = $$("div", { "className": "U_MD_O_H_body_left_invite_user_a", "onclick": function () {
+            U.MD.O.W.Panel.displayInsertUser();
+        }
+        }, _frienddiv); //默认邀请按钮
+        $$("div", { "className": "U_MD_O_H_body_left_invite_user_a_img" }, _example);
+        $$("div", { "className": "U_MD_O_H_body_left_invite_user_a_div", "innerHTML": "邀请" }, _example);
+        new U.UF.UI.form("邀请协作人员", _cBox, { id: "LoadPlayUser", style: { border: "none", position: "absolute", width: "300px", "min-width": "200px", height: "250px", top: "140px", left: "auto", "box-shadow": "none"} },
+                        { isenlarge: false, isnarrow: false }, { style: { margin: "0px 5px", "border-bottom": "1px solid #d6def0", color: "#000", background: "#fff"} }, null, null, _coopwindow);
+    }
+    U.MD.O.W.Panel.disPlayUser(fileinfo); //获取协作人员   
+}
 
 /**
 * 初始化查看团队成员
@@ -143,12 +126,13 @@ U.MD.O.W.Panel.IsSynergy.saveAsync = function (r) {
 * @param  fileinfo {object} 文件信息
 */
 U.MD.O.W.Panel.disPlayUser = function (fileinfo, el) {
-    el = el || $("#U_MD_O_H_body_left_invite_user")[0]; //获取团队成员初始化的位置
+    el = $("#U_MD_O_H_body_left_invite_user")[0]; //获取团队成员初始化的位置
     var _elchild = el.children[0] //获取元素的子元素;
     el.innerHTML = ""//清空内容
     $(el).append(_elchild);
     if (fileinfo) {//判断是否有文件信息
-        var _userinfo = U.Json.select(US.friend.groupusers, { "GroupManageID": fileinfo.UserDirectoryEncrypt || fileinfo.GroupID }); //获取所有在群里的成员
+        //或者是什么意思?不严谨
+        var _userinfo = U.Json.select(US.friend.groupusers, { "GroupManageID": fileinfo.GroupID }); //获取所有在群里的成员
         if (_userinfo) {//判断是否拥有群成员
             for (i = 0; i < _userinfo.length; i++) {//循环打印所有的群成员
                 U.MD.O.W.Panel.createUser(_userinfo[i], el);
@@ -157,9 +141,12 @@ U.MD.O.W.Panel.disPlayUser = function (fileinfo, el) {
     }
 }
 
-
+/**
+* 打印团队编辑成员
+*
+* @param  fileinfo {object} 文件信息
+*/
 U.MD.O.W.Panel.createUser = function (userinfo, el) {
-    el = el || $("#U_MD_O_H_body_left_invite_user")[0]; //获取团队成员初始化的位置
     var _elparent = $$("div", { "className": "U_MD_O_H_body_left_invite_user_a", "onclick": U.UF.C.closure(function (userid) {
         top.U.MD.U.V.ViewOtherUserInfo(userid);
     }, [userinfo.UserId])
@@ -169,17 +156,20 @@ U.MD.O.W.Panel.createUser = function (userinfo, el) {
     $$("div", { "className": "U_MD_O_H_body_left_invite_user_a_div", "innerHTML": userinfo.UserNickName }, _elparent); //好友名称
 }
 
-
 /**
-* 判断是否是已经新建过 弹出添加成员 异步回调 
+* 单击邀请时,从普通文档转换为协同文档的过程!
+ * 判断是否是已经新建过 弹出添加成员 异步回调 
 *
 * @param  {element} Wrod信息数组
 */
 U.MD.O.W.Panel.displayInsertUser = function () {
-    if (U.MD.O.W.Panel.IsSynergy()) {
+
+    //判断是否是协同文档
+    if (U.MD.O.W.Panel.isSynergy()) {
         var _fileinfo = U.MD.O.W["fileinfo"];
         top.U.MD.F.J.selectFriendForm(function (groupid) {
-            var _filegroupid = _fileinfo.GroupID || _fileinfo.UserDirectoryEncrypt; //获取_filegroupid群id,判断是否是在自己的ftp下的文档
+            //或者是什么意思?不严谨
+            var _filegroupid = _fileinfo.GroupID; //获取_filegroupid群id,判断是否是在自己的ftp下的文档
             var _groupinfo = U.Json.select(US.friend.group, { "GroupManageID": _filegroupid })[0]; //群信息
             var _needuser = top.U.MD.F.J.selectUserInfo.NeedUser; //选中好友集合
             var _groupname = _groupinfo.GroupManageName; // 群名
@@ -190,7 +180,6 @@ U.MD.O.W.Panel.displayInsertUser = function () {
             for (i = 0; i < _selectfriend.length; i++) {
                 U.Json.del(_needuser, { "UserId": _selectfriend[i].UserId }); //删除所有在群里的用户id
             }
-
             //创建及添加群处理
             top.U.MD.F.J.determineCreateGroupAndAddGroupUser(_filegroupid, null, null, false, _groupname, _groupdesc, function (groupid, groupinfo) {
                 var i, _userids = "";
@@ -207,7 +196,7 @@ U.MD.O.W.Panel.displayInsertUser = function () {
 
 U.MD.O.W.Panel.addUser = function (userids) {
     var _type = U.MD.O.W["fileinfo"].UserDirectoryExtendType == "un" ? "nav" : "word";
-    top.U.A.Request(US.SCOKET, ["addUser", _type, U.MD.O.W["fileinfo"].UserDirectoryID, userids, US.userInfo.UserId, top.US.pageId]);
+    top.U.A.Request(US.SCOKET, ["addUser", _type, U.MD.O.W["fileinfo"].UserDirectoryID, userids, US.userInfo.UserId, top.US.pageId], function () { });
 }
 
 U.MD.O.W.Panel.syncAddUser = function (userids, senduserid) {
@@ -216,9 +205,12 @@ U.MD.O.W.Panel.syncAddUser = function (userids, senduserid) {
     for (i = 0; i < userids.length; i++) {
         _userinfo = U.Json.selectOne(US.friend.groupusers, { UserId: userids[i] });
         if (!_userinfo) {
-            _userinfo = top.U.A.Request(US.CD, [US.DB, "UseStudio_Users", "GetUserinfoByUserId", userids[i]]).value[0];
+            top.U.A.Request(US.CD, [US.DB, "UseStudio_Users", "GetUserinfoByUserId", userids[i]], function (r) {
+                _userinfo = r.value[0];
+                U.MD.O.W.Panel.createUser(_userinfo);
+            })
         }
-        U.MD.O.W.Panel.createUser(_userinfo);
+
     }
 }
 
@@ -302,7 +294,7 @@ U.MD.O.W.Panel.shareLinkTemplate = function (fileinfo) {
             _fileType = false; break;
     }
 
-    var _shareLinkInpBlockShow = $$('input', { style: { cssText: "margin-top: 5px;" }, className: "U_MD_O_H_body_left_invite_shareInp", value: "/#" + _fileType + '/join/' + fileinfo.UserDirectoryID, disabled: "disabled" }, _shareLinkInpBlock), //输出
+    var _shareLinkInpBlockShow = $$('input', { style: { cssText: "margin-top: 5px;" }, className: "U_MD_O_H_body_left_invite_shareInp", value: "http://www.1473.cn/#" + _fileType + '/join/' + fileinfo.UserDirectoryID, disabled: "disabled" }, _shareLinkInpBlock), //输出
 
         _shareLinkInpBlockBtn = $$('div', { style: { cssText: "margin-top: 5px;" }, className: "U_MD_O_H_body_left_invite_shareBtn", innerText: "复制", onclick: function () { //复制按钮
             var _inp = $$('input', { value: _shareLinkInpBlockShow.value }, $('body')[0]); //创建复制文本框
@@ -328,34 +320,30 @@ U.MD.O.W.Panel.shareLinkTemplate = function (fileinfo) {
 //#region 热门模板
 
 /**
-* 创建历史记录窗体
+* 创建热门模板窗体
 *
 * @param  {element} 换页元素
 */
-// U.MD.O.W.Panel.LoadHotTemplates = function (fileinfo) {
-//     var _UDTD, _el, _USM, _UW;
-//     if (!$("#U_MD_O_H_body_left_template_hot")[0]) {
-//         _UDTD = $("#U_MD_O_H_body_left")[0];
-//         _USM = U.UF.EL.getElementInfo($("#U_MD_O_W_E_body")[0]);
-//         _UW = _USM["OW"] + 50;
-//         //热门模板提供
-//         _el = $$("div", { "className": "U_MD_O_H_body_left_template_user", id: "U_MD_O_H_body_left_template_hot" });
-
-//         //new U.UF.UI.form("<div class='U_MD_F_S_TI'>热门模板提供</div>", _UDTD, { "className": "U_MD_F_S", "style": { "border": "1px #d6dff0 solid", "width": "300px", "height": "270px", "position": "absolute", "top": "840px", "left": _UW + "px"} }, { isdrag: false, isenlarge: false, isnarrow: false });
-//         new U.UF.UI.form("热门模板提供", _el, { style: { border: "none", width: "300px", height: "477px", position: "absolute", top: "695px", left: "auto", "box-shadow": "none"} }, { isenlarge: false, isnarrow: false }, { style: { margin: "0px 5px", "border-bottom": "1px solid #d6def0", color: "#000", background: "#fff"} }, null, null, _UDTD);
-//     }
-//     U.MD.O.W.Panel.GetHotTemplates("00000000-0000-0000-0000-000000000000", 1, 10); //热门模板
-
-// }
+U.MD.O.W.Panel.loadHotTemplates = function (fileinfo) {
+    var _leftel, _el;
+    //判断是否加载热门模板
+    if (!$("#U_MD_O_H_body_left_template_hot")[0]) {
+        _leftel = $("#U_MD_O_H_body_left")[0];
+        //创建热门模板窗体
+        _el = $$("div", { "className": "U_MD_O_H_body_left_template_user", id: "U_MD_O_H_body_left_template_hot" });
+        new U.UF.UI.form("热门模板提供", _el, { id: "LoadHotTemplates", style: { border: "none", width: "300px", height: "477px", position: "absolute", top: "695px", left: "auto", "box-shadow": "none"} }, { isenlarge: false, isnarrow: false }, { style: { margin: "0px 5px", "border-bottom": "1px solid #d6def0", color: "#000", background: "#fff"} }, null, null, _leftel);
+    }
+    U.MD.O.W.Panel.getHotTemplates("00000000-0000-0000-0000-000000000000", 1, 10); //热门模板
+}
 
 /**
 * 初始化加载模板
 *
 * @param  {element} 换页元素
 */
-U.MD.O.W.Panel.GetHotTemplates = function (UDID, S, E, UDOD) {
-    UDOD = UDOD || $("#U_MD_O_H_body_left_template_hot")[0];
-    U.A.Request(US.CD, [US.DB, "UseStudio_Office", "SelectHotTemplate", UDID, S, E], U.MD.O.W.Panel.AsynGetHotTemplates, [null, UDOD]);
+U.MD.O.W.Panel.getHotTemplates = function (hid, start, end) {
+    var _el = $("#U_MD_O_H_body_left_template_hot")[0];
+    U.A.Request(US.CD, [US.DB, "UseStudio_Office", "SelectHotTemplate", hid, start, end], U.MD.O.W.Panel.asynGetHotTemplates, [null, _el]);
 }
 
 /**
@@ -363,51 +351,36 @@ U.MD.O.W.Panel.GetHotTemplates = function (UDID, S, E, UDOD) {
 *
 * @param  {element} 换页元素
 */
-U.MD.O.W.Panel.AsynGetHotTemplates = function (r) {
+U.MD.O.W.Panel.asynGetHotTemplates = function (r) {
     var i, _el,
-    _UDFD = $$("frag"),
-    _context = r.context,
+        _frag = $$("frag"),
+        _hel = r.context[1];
     r = r.value;
-    _context[1].innerHTML = "";
+    //循环答应热门模板
     for (i = 0; i < r.length; i++) {
-        _el = $$("div",
-        {
+        _el = $$("div", {
             "className": "U_MD_O_H_body_left_template_user_m",
-            "onclick": U.UF.C.closure(function (tempinfo) {
-
-                parent.U.A.Request(US.AUTH, ["GetFileContent", tempinfo.FileId], function (r) {
+            "onclick": U.UF.C.closure(function (info) {
+                parent.U.A.Request(US.DISK, ["GetFileContent", info.FileId], function (r) {
+                    //获取到内容
                     if (r.value && r.value.UsOffice !== undefined) {
                         r = r.value.UsOffice;
-                    } else {
-                        r = r.value;
                     }
-                    var _newfileid = Guid.newGuid();
-                    top.U.MD.O.word(US.userInfo, {
-                        UserDirectoryID: _newfileid,
-                        UsOffice: r || ""
-                    });
+                    //打开新的word处理
+                    top.U.MD.O.word(US.userInfo, { UserDirectoryID: Guid.newGuid(), UsOffice: r || "" });
                 });
-
             }, [r[i]])
-        },
-          _UDFD);
-        $$("div",
-        {
-            "className": "U_MD_O_H_body_left_template_user_m_s",
-            "style":
-          {
-              "background-image": "url(" + (r[i].UseFilesServerThumbnailName || "/Boomyun/img/pc/NImg.png") + ")"
-          }
-        },
-           _el);
+        }, _frag);
+        $$("div", { "className": "U_MD_O_H_body_left_template_user_m_s", "style": { "background-image": "url(" + (r[i].UseFilesServerThumbnailName || "http://www.1473.cn/Boomyun/img/pc/NImg.png") + ")"} }, _el);
         $$("div", { "className": "U_MD_O_H_body_left_template_user_m_x", "innerHTML": r[i]["UserFilesName"] }, _el);
     }
-    $(_context[1]).append(_UDFD);
+    $(_hel).append(_frag);
 }
 
 //#endregion
 
 //#region 链接查看
+
 /**  
 *
 * 加载,生成连接区域
@@ -415,161 +388,210 @@ U.MD.O.W.Panel.AsynGetHotTemplates = function (r) {
 * @param wordinfo {object} 当前文档信息
 */
 U.MD.O.W.Panel.loadlink = function (wordinfo) {
-    var _rightwindow, //域名生成链接区域
-         _wordsize, //左侧编辑区dom元素信息
-        _linkdiv, //生成链接元素       
-        _marginleft, //距离左侧编辑区的距离
-        linkareael = $("#U_MD_O_H_body_left_href_pay_a")[0]
-    if (!linkareael || (linkareael && linkareael.innerHTML == "")) {  //如果不存在添加链接区域,则创建。
-        _rightwindow = $("#U_MD_O_H_body_left")[0];  //右侧功能区域,链接区域要追加到这里
-        _wordsize = U.UF.EL.getElementInfo($("#U_MD_O_W_E_body")[0]);    //获取左侧编辑区dom元素信息
-        _marginleft = _wordsize["OW"] + 50;  //定义左侧编辑区的距离
-        var _date = [];
+    var _linkareael = $("#U_MD_O_H_body_left_href_pay_a")[0];
+    //如果不存在添加链接区域,则创建。
+    if (!_linkareael || (_linkareael && _linkareael.innerHTML == "")) {
+        //加载word文件的短链接
+        U.A.Request('http://cd.1473.cn/php', ["db.1473.cn", "UseStudio_DNS", 'GetDnsInfoByFileId', wordinfo.UserDirectoryID], function (r) {
+            var _date = r.value; //获取短连接信息
+            U.MD.O.W.Panel.formloadlink(_date); //加载链接,这里有可能没有设置过短连接
+        });
+    }
+}
+
+/**  
+*
+* 加载,生成连接区域
+*
+* @param wordinfo {object} 当前文档信息
+*/
+U.MD.O.W.Panel.formloadlink = function (date) {
+    var _url,
+        _linkdiv,
+        _wordinfo = U.MD.O.W.fileinfo,
+        _rightwindow = $("#U_MD_O_H_body_left")[0], //右边功能区
+        _linkareael = $("#U_MD_O_H_body_left_href_pay_a")[0]
+    ;
+    //设置过域名的加载
+    if (date.length) {
+        _url = date[0].AppId + ".1473.cn/" + date[0].Domain
+        _linkdiv = $$("div", { "className": "U_MD_O_H_body_left_href_pay_a", id: "U_MD_O_H_body_left_href_pay_a" });
+        $$("a", { className: "U_MD_O_H_body_left_href_pay_aText", href: "//" + _url, innerText: _url, target: "_Blank" }, _linkdiv);
+        //只有编辑权限才显示修改和分享按钮
         if (U.MD.O.W.permission.edit) {
-            _date = U.A.Request('http://cd.1473.cn/php', ["db.1473.cn", "UseStudio_DNS", 'GetDnsInfoByFileId', wordinfo.UserDirectoryID]).value;
-        }
-        var _wordinfo = U.MD.O.W.fileinfo,
-            _type = _wordinfo.UserDirectoryExtendType && _wordinfo.UserDirectoryExtendType.toLowerCase();
-        _callback = {
-            modifyDomain: function (res) { $('#U_MD_O_H_body_left_href_pay_a')[0].innerHTML = ""; U.MD.O.W.Panel.loadlink({ UserDirectoryID: res.FileId }) },
-            addDomain: function (res) { $('#U_MD_O_H_body_left_href_pay_a')[0].innerHTML = ""; U.MD.O.W.Panel.loadlink({ UserDirectoryID: res.FileId }) },
-            deleteDomain: function (res) { $('#U_MD_O_H_body_left_href_pay_a')[0].innerHTML = ""; U.MD.O.W.Panel.loadlink({ UserDirectoryID: res.FileId }) }
-        };
-
-        switch (_type) {
-            case 'uw': case 'un': _type = 'word'; break;
-            case 'ue': _type = 'execl'; break;
-            default: _type = 'word'; break;
-        }
-        if (!_date.length) {
-            // _linkdiv = $$("div", { "className": "U_MD_O_H_body_left_href_pay_a", id: "U_MD_O_H_body_left_href_pay_a", "innerHTML": "将此站点生成链接", "onclick": function () {    //生成链接
-            //     var _wordinfo = U.MD.O.W.fileinfo;
-            //     if (_wordinfo.UserDirectoryID && _wordinfo.UserId && _wordinfo.UserallDirectoryName) {
-            //         top.U.MD.DS.autoCreateDomain(_wordinfo, _type, function (dnsinfo) {
-            //             var _hrefEl = $("#U_MD_O_H_body_left_href_pay_a")[0]
-            //             _hrefEl.parentNode.removeChild(_hrefEl);
-            //             U.MD.O.W.Panel.loadlink(wordinfo);
-            //         });
-            //         //                    $$('div', { innerText: '自动生成', style: { cssText: "display:inline-block; width: 100px; padding:10px 0; background-color: #444; color: #fff;cursor: pointer" }, onclick: function () {
-            //         //                        top.U.MD.DS.autoCreateDomain(_wordinfo, _type);
-            //         //                    }
-            //         //                    }, _box)
-            //         //                    $$('div', { innerText: '自定义', style: { cssText: "display:inline-block; width: 100px; padding:10px 0; background-color: #444; color: #fff; margin-left: 14px;cursor: pointer" }, onclick: function () {
-            //         //                        if (_wordinfo.UserDirectoryID && _wordinfo.UserId && _wordinfo.UserallDirectoryName) {
-            //         //                            top.U.MD.DS.dnsInit(_wordinfo, _type)
-            //         //                        }
-            //         //                    }
-            //         //                    }, _box);
-            //     } else {
-            //         $('#U_MD_O_H_save')[0].onclick();
-            //     }
-            // }
-            // });
-        } else {
-            var _url = _date[0].AppId + ".1473.cn/" + _date[0].Domain;
-            _linkdiv = $$("div", { "className": "U_MD_O_H_body_left_href_pay_a", id: "U_MD_O_H_body_left_href_pay_a" });
-            $$("a", { className: "U_MD_O_H_body_left_href_pay_aText", href: "http://" + _url, innerText: _url, target: "_Blank" }, _linkdiv);
             $$('div', { innerText: '分享', className: "U_MD_O_H_body_left_href_pay_Btn", onclick: function () {
-                if (_wordinfo.UserDirectoryID && _wordinfo.UserId && _wordinfo.UserallDirectoryName) {
-                    top.U.MD.DS.createDefaultDomainInit(_wordinfo, _type, _callback);
-                } else {
-                    U.MD.O.W.save();
+                //判断是否保持文档
+                if (U.MD.O.W.isSave()) {
+                    var _iframe = $$('iframe', { src: '//domain.1473.cn/DomainSystem.aspx/?fileId=' + _wordinfo.UserDirectoryID + '&type=word&mode=share', frameborder: "0", style: { cssText: "width:100%;height:100%;border:0px"} });
+                    new U.UF.UI.form("域名管理", _iframe, { id: "U_MD_DS_DomainShare", style: { "width": "370px", "height": "390px"} });
+                }
+                //点击保存处理
+                else {
+                    $('#U_MD_O_H_save')[0].onclick();
                 }
             }
-            }, _linkdiv)
+            }, _linkdiv);
             $$("div", { innerText: '修改', className: "U_MD_O_H_body_left_href_pay_Btn", onclick: function () {
-                if (_wordinfo.UserDirectoryID && _wordinfo.UserId && _wordinfo.UserallDirectoryName) {
-                    top.U.MD.DS.setCallBack(_callback);
-                    top.U.MD.DS.dnsInit(_wordinfo, _type);
-                } else {
-                    U.MD.O.W.save();
+                //判断是否保持文档
+                if (U.MD.O.W.isSave()) {
+                    var _iframe = $$('iframe', { src: '//domain.1473.cn/DomainSystem.aspx/?fileId=' + _wordinfo.UserDirectoryID + '&type=word&mode=base', frameborder: "0", style: { cssText: "width:100%;height:100%;border:0px"} });
+                    new U.UF.UI.form("域名管理", _iframe, { id: "U_MD_DS_DomainManage", style: { cssText: 'width: 1040px; height: 555px'} });
+                }
+                //点击保存处理
+                else {
+                    $('#U_MD_O_H_save')[0].onclick();
                 }
             }
             }, _linkdiv);
         }
+    }
+    //未设置过的
+    else {
+        _linkdiv = $$("div", { "className": "U_MD_O_H_body_left_href_pay_a", id: "U_MD_O_H_body_left_href_pay_a", "innerHTML": "将此站点生成链接", "onclick": function () { //生成链接
+            //判断文件是否保存,此判断未成功
+            if (U.MD.O.W.isSave()) { //如果保存的文档,点击直接弹出网页
+                //得到编辑器
+                var _wordContent = document.getElementById("U_MD_O_H_wordEditor");
+                //如果文件变量中的word内容存在,编辑器内容不同于文件变量中的内容,则保存内容,否则,返回true
+                if (_wordinfo.UsOffice && _wordinfo.UsOffice != _wordContent.innerHTML) {
+                    //保存到数据库
+                    top.U.A.Request(US.DISK, ["SaveFileContent", US.userInfo.UserId, _wordinfo.UserDirectoryID, _wordContent.innerHTML.escapeQuotes(), _wordinfo.UserallDirectoryName, "uw"], function (r) {
+                        //跳转新页面显示word内容
+                        window.open("http://" + U.MD.O.W.fileinfo.UserDirectoryID + ".1473.cn");
+                    }, ([''])); //保存到数据库
+                }
+                else {
+                    //先判断数据库是否存在该文件
+                    parent.U.A.Request(US.DISK, ["GetFileContent", _wordinfo.UserDirectoryID], function (r) {
+                        //能够获取到内容
+                        if (r.value && r.value.UsOffice !== null) {
+                            //跳转新页面显示word内容
+                            window.open("http://" + U.MD.O.W.fileinfo.UserDirectoryID + ".1473.cn");
+                        }
+                        else {
+                            //保存到数据库
+                            top.U.A.Request(US.DISK, ["SaveFileContent", US.userInfo.UserId, _wordinfo.UserDirectoryID, _wordContent.innerHTML.escapeQuotes(), _wordinfo.UserallDirectoryName, "uw"], function (r) {
+                                //跳转新页面显示word内容
+                                window.open("http://" + U.MD.O.W.fileinfo.UserDirectoryID + ".1473.cn");
+                            }, ([''])); //保存到数据库
+                        }
+                    });
 
-        if (linkareael && linkareael.innerHTML == "") {
-            linkareael.appendChild(_linkdiv);
-        } else {
-            new U.UF.UI.form("生成链接", _linkdiv, { style: { border: "none", position: "absolute", width: "300px", height: "70px", top: "60px", left: "auto", "box-shadow": "none"} },
-                { isenlarge: false, isnarrow: false }, { style: { margin: "0px 5px", "border-bottom": "1px solid #d6def0", color: "#000", background: "#fff"} }, null, null, _rightwindow);
-        }
+                }
 
+            }
+            else { //未保存的文档查看站点,触发保存事件
+                $('#U_MD_O_H_save')[0].onclick();
+            }
+        }
+        });
+    }
+    //如果已经创建
+    if (_linkareael && _linkareael.innerHTML == "") {
+        _linkareael.appendChild(_linkdiv);
+    }
+    //如果生成链接的处理
+    else {
+        new U.UF.UI.form("生成链接", _linkdiv, { style: { border: "none", position: "absolute", width: "300px", height: "70px", top: "60px", left: "auto", "box-shadow": "none"} }, { isenlarge: false, isnarrow: false }, { style: { margin: "0px 5px", "border-bottom": "1px solid #d6def0", color: "#000", background: "#fff"} }, null, null, _rightwindow);
     }
 }
 
-/**
-* 查看链接
-*
-* @param  {element} 换页元素
-*/
-U.MD.O.W.Panel.Getlink = function (UDID, UDOD) {
-    UDOD = UDOD || $("#U_MD_O_H_body_left_href_pay_a")[0];
-    U.A.Request(US.CD, [US.DB, "UseStudio_Office", "SelectHotTemplate", UDID, UOID, US, UE], U.MD.O.W.Panel.AsynGetlink, [null, UDOD]);
-}
+//#endregion
+
+//#region 历史记录
 
 /**
-* 查看链接异步
+* 初始化历史记录
 *
-* @param  {element} 换页元素
+* @param 
 */
-U.MD.O.W.Panel.AsynGetlink = function (r) {
-    var _context = r.context;
-    r = r.value;
-    if (r) {
-        _context[1].innerHTML = r;
+U.MD.O.W.Panel.loadOfficeHistory = function (fileinfo) {
+    var _el, _leftel;
+    //判断是否有历史记录
+    if (!$("#U_MD_O_H_body_left_invite_history")[0]) {
+        _leftel = $("#U_MD_O_H_body_left")[0];
+        //编辑历史
+        _el = $$("div", { "className": "U_MD_O_H_body_left_invite_user", "id": "U_MD_O_H_body_left_invite_history" });
+        new U.UF.UI.form("编辑历史", _el, { id: "LoadOfficeHistory", style: { width: "300px", height: "284px", position: "absolute", top: "400px", left: "auto", "border-radius": "0px", border: "none", "box-shadow": "none", "border-radius": "5px"} }, { isenlarge: false, isnarrow: false }, { style: { margin: "0px 5px", "border-bottom": "1px solid #d6def0", color: "#000", background: "#fff"} }, null, null, _leftel);
+    }
+    //判断文件是否保持的文件,如果保持的文件则有历史记录,未保存的没有
+    if (U.MD.O.W.isSave()) {
+        U.MD.O.W.Panel.viewEditHistory(fileinfo.UserDirectoryID, U.MD.O.W.historyid, 1, 100); //历史记录
+    }
+    //没有历史记录
+    else {
+        $$("div", { "innerHTML": "暂无历史", "style": { "text-align": "center", "margin-top": "50px"} }, _el);
     }
 }
 
 /**
-* 创建链接分享
+* 查看编辑历史
 *
 * @param  {element} 换页元素
+* 创始人id 文件id 空的id 选取开始 选取长度 获取编辑历史的框
 */
-U.MD.O.W.Panel.Createlink = function (UDE, UDOD) {
-    //#error 不要
-    U.A.Request(US.CD, [US.DB, "UseStudio_Disk", "UD_I_AddDns", UDE.UserFileId, US.userInfo.UserId, 1], U.MD.O.W.Panel.AsynCreatelink, [null, UDOD]);
+U.MD.O.W.Panel.viewEditHistory = function (id, hid, start, end) {
+    var _el = $("#U_MD_O_H_body_left_invite_history")[0];
+    U.A.Request(US.CD, [US.DB, "UseStudio_Office", "SelectOfficeHistory", id, hid, start, end], U.MD.O.W.Panel.asynViewEditHistory, [null, _el]);
 }
 
 /**
-* 创建链接分享
+* 查看编辑历史异步
 *
 * @param  {element} 换页元素
 */
-U.MD.O.W.Panel.AsynCreatelink = function (r) {
-    var _context = r.context;
-    r.value;
-    if (r) {
-        _context[1].innerHTML = r.UserDomain + ".1473.cn";
+U.MD.O.W.Panel.asynViewEditHistory = function (r) {
+    $('#U_MD_O_H_body_left_invite_history')[0].innerHTML = '';
+    var _value = r.value,
+        _el = $('#U_MD_O_H_body_left_invite_history')[0]
+
+    for (var i = 0; i < _value.length; i++) {
+        _el.appendChild(U.MD.O.W.Panel.createHis(_value[i]))
+       
     }
 }
 
-//#endregion
-
-//#region 历史记录
-
 /**
-* 初始化加载模板
+* 添加详细历史记录布局
 *
-* @param 
+* @param  {object} data 数据
 */
-// U.MD.O.W.Panel.LoadOfficeHistory = function (fileinfo) {
-//     var _el, _UDTD, _USM, _UW;
-//     if (!$("#U_MD_O_H_body_left_invite_history")[0]) {
-//         _UDTD = $("#U_MD_O_H_body_left")[0];
-//         _USM = U.UF.EL.getElementInfo($("#U_MD_O_W_E_body")[0]);
-//         _UW = _USM["OW"] + 50;
-//         //编辑历史
-//         _el = $$("div", { "className": "U_MD_O_H_body_left_invite_user", "id": "U_MD_O_H_body_left_invite_history" });
-//         //new U.UF.UI.form("<div class='U_MD_F_S_TI'>编辑历史</div>", _UDTD, { "className": "U_MD_F_S", "style": { "width": "300px", "height": "250px", "position": "absolute", "top": "300px", "left": _UW + "px", "border-radius": "0px", "border": "1px #d6dff0 solid"} }, { isdrag: false, isenlarge: false, isnarrow: false });
-//         new U.UF.UI.form("编辑历史", _el, { style: { width: "300px", height: "284px", position: "absolute", top: "400px", left: "auto", "border-radius": "0px", border: "none", "box-shadow": "none", "border-radius": "5px"} }, { isenlarge: false, isnarrow: false }, { style: { margin: "0px 5px", "border-bottom": "1px solid #d6def0", color: "#000", background: "#fff"} }, null, null, _UDTD);
-//     }
-//     if (fileinfo) {
-//         U.MD.O.W.Panel.ViewEditHistory(fileinfo.UserDirectoryID, U.MD.O.W.historyid, 1, 100); //历史记录
-//     } else {
-//         $$("div", { "innerHTML": "暂无历史", "style": { "text-align": "center", "margin-top": "50px"} }, _el);
-//     }
-// }
+U.MD.O.W.Panel.createHis = function (data) {
+
+
+    var _hisel, _imgel, _infoel, _textel, _btnel;
+    _hisel = $$('div', { style: { cssText: 'min-height: 85px; border-bottom: 1px solid silver; margin: 0 3px'} });
+    _imgel = $$('div', { style: { margin: '22px 12px 0', float: 'left'} }, _hisel);
+    $$('img', { "onerror": U.MD.C.imgError, style: { cssText: 'width:40px; height: 40px;' }, src: top.U.MD.C.getHeadImage(data.UserThumbnailImageHead) }, _imgel);
+    _infoel = $$('div', { style: { cssText: 'margin-left: 62px;'} }, _hisel);
+    _textel = $$('div', { style: { 'padding-top': '25px', 'white-space': 'nowrap'} }, _infoel);
+    $$('span', { innerText: data.UserName }, _textel);
+    $$('span', { innerText: U.UF.D.getDateInterval(data.CreateTime) + '保存一次', style: { 'padding-left': '10px'} }, _textel);
+    _btnel = $$('div', { style: { 'margin-top': '10px', 'white-space': 'nowrap'} }, _infoel);
+
+    //判断是否是自己编辑历史记录,是则不打印对话
+    if (data.UserId != U.MD.O.W.userinfo.UserId) {
+        $$('button', { innerText: '对话', style: { cssText: 'color: #fff; background-color:#6d81a4; border-radius: 4px; border:none; outline:none; padding: 4px 8px; cursor: pointer;' }, onclick: function () {
+            //这里有问题,这样获取不一定能获取用户数据,同时数据没有分离
+            var _friendel = U.Json.select(US.friend.friends, { UserId: data.UserId });
+            //如果未添加好友,则弹出添加好友框,否则直接弹出聊天窗口
+            if (_friendel.length == 0) {
+                top.U.MD.U.V.ViewOtherUserInfo(data.UserId);
+            } else {
+                _data = !_friendel.length ? U.Json.select(US.friend.recentcontacts, { UserId: data.UserId }) : _friendel;
+                top.U.MD.F.W.popupFriendsForm(_data[0], this);
+            }
+        }
+        }, _btnel);
+    }
+    $$('button', { innerText: '详细', style: { cssText: 'color: #fff; background-color:#6d81a4; border-radius: 4px; border:none; outline:none; padding: 4px 8px; margin-left: 4px;cursor: pointer;' },
+        onclick: function () {
+            U.MD.O.W.Panel.EditHistory(data)
+        }
+    }, _btnel);
+    //返回最外的元素
+    return _hisel
+}
 
 /**
 * 插入历史
@@ -607,18 +629,20 @@ U.MD.O.W.Panel.InsertOfficeHistory = function (fileinfo, html, name, contentel)
 
 }
 
-U.MD.O.W.Panel.syncHistory = function (userid, historyid) {
-    var _data, _fileinfo = U.MD.O.W.fileinfo;
-    _fileinfo.HistoryId = historyid; //记录历史ID
-    if (userid == US.userInfo.UserId) {
-        _data = U.MD.O.W.dataStructure(_fileinfo.UserDirectoryModifyTime, US.userInfo.UserName, US.userInfo.UserThumbnailImageHead, historyid, US.userInfo.UserId);
-    } else {
-        var _userinfo = U.Json.select(US.friend.groupusers, { UserId: userid })[0];
-        _data = U.MD.O.W.dataStructure(_fileinfo.UserDirectoryModifyTime, _userinfo.UserName, _userinfo.UserThumbnailImageHead, historyid, _userinfo);
-    }
-    var _el = U.MD.O.W.Panel.createHis(_data),  //创建历史记录
+U.MD.O.W.Panel.syncHistory = function (userid, historyid, isbool) {
+    if (!isbool) {
+        var _data, _fileinfo = U.MD.O.W.fileinfo;
+        _fileinfo.HistoryId = historyid; //记录历史ID
+        if (userid == US.userInfo.UserId) {
+            _data = U.MD.O.W.dataStructure(_fileinfo.UserDirectoryModifyTime, US.userInfo.UserName, US.userInfo.UserThumbnailImageHead, historyid, US.userInfo.UserId);
+        } else {
+            var _userinfo = U.Json.select(US.friend.groupusers, { UserId: userid })[0];
+            _data = U.MD.O.W.dataStructure(_fileinfo.UserDirectoryModifyTime, _userinfo.UserName, _userinfo.UserThumbnailImageHead, historyid, _userinfo);
+        }
+        var _el = U.MD.O.W.Panel.createHis(_data),  //创建历史记录
         _addel = $('#U_MD_O_H_body_left_invite_history')[0]; //历史记录区域
-    $(_el).appendTo(_addel, 0, _addel.firstElementChild); //置顶插入
+        $(_el).appendTo(_addel, 0, _addel.firstElementChild); //置顶插入
+    }
 }
 
 
@@ -642,16 +666,7 @@ U.MD.O.W.dataStructure = function (creattime, username, userbgimg, historyid, us
     }
 }
 
-/**
-* 查看编辑历史
-*
-* @param  {element} 换页元素
-* 创始人id 文件id 空的id 选取开始 选取长度 获取编辑历史的框
-*/
-U.MD.O.W.Panel.ViewEditHistory = function (UDID, UOID, S, E, UDOD) {
-    UDOD = UDOD || $("#U_MD_O_H_body_left_invite_history")[0];
-    U.A.Request(US.CD, [US.DB, "UseStudio_Office", "SelectOfficeHistory", UDID, UOID, S, E], U.MD.O.W.Panel.AsynViewEditHistory, [null, UDOD]);
-}
+
 
 /**
 * 添加详细历史记录
@@ -671,53 +686,6 @@ U.MD.O.W.Panel.AddDetailedHis = function (e, el, data) {
 }
 
 
-/**
-* 添加详细历史记录布局
-*
-* @param  {object} data 数据
-*/
-U.MD.O.W.Panel.createHis = function (data) {
-    var _hisBlock = $$('div', { style: { cssText: 'min-height: 85px; border-bottom: 1px solid silver; margin: 0 3px'} }),
-        _hisImgEl = $$('div', { style: { margin: '22px 12px 0', float: 'left'} }, _hisBlock),
-        _hisImg = $$('img', { "onerror": U.MD.C.imgError, style: { cssText: 'width:40px; height: 40px;' }, src: top.U.MD.C.getHeadImage(data.UserThumbnailImageHead) }, _hisImgEl),
-        _hisInfo = $$('div', { style: { cssText: 'margin-left: 62px;'} }, _hisBlock),
-        _hisInfoText = $$('div', { style: { 'padding-top': '25px', 'white-space': 'nowrap'} }, _hisInfo),
-        _hisInfoName = $$('span', { innerText: data.UserName }, _hisInfoText),
-        _hisInfoDate = $$('span', { innerText: U.UF.D.getDateInterval(new Date()) + '保存一次', style: { 'padding-left': '10px'} }, _hisInfoText),
-        _hisInfoBtn = $$('div', { style: { 'margin-top': '10px', 'white-space': 'nowrap'} }, _hisInfo),
-        _hisInfoDialogue;
-    //判断是否是自己编辑历史记录,是则不打印对话
-    if (US.disk.UserDisk && data.UserId != US.disk.UserDisk.userInfo.UserId) {
-        _hisInfoDialogue = $$('button', { innerText: '对话', style: { cssText: 'color: #fff; background-color:#6d81a4; border-radius: 4px; border:none; outline:none; padding: 4px 8px; cursor: pointer;' }, onclick: function () {
-            var _hasF = U.Json.select(US.friend.friends, { UserId: data.UserId }),
-                _data = !_hasF.length ? U.Json.select(US.friend.recentcontacts, { UserId: data.UserId }) : _hasF;
-            top.U.MD.F.W.popupFriendsForm(_data[0]);
-        }
-        }, _hisInfoBtn);
-    }
-    var _hisInfoDetailed = $$('button', { innerText: '详细', style: { cssText: 'color: #fff; background-color:#6d81a4; border-radius: 4px; border:none; outline:none; padding: 4px 8px; margin-left: 4px;cursor: pointer;' },
-        onclick: function () {
-            U.MD.O.W.Panel.EditHistory(data)
-        }
-    }, _hisInfoBtn);
-    //返回最外的元素
-    return _hisBlock
-}
-
-/**
-* 查看编辑历史异步
-*
-* @param  {element} 换页元素
-*/
-U.MD.O.W.Panel.AsynViewEditHistory = function (r) {
-    var _dataArr = r.value,
-        _addEl = $('#U_MD_O_H_body_left_invite_history')[0]
-
-    for (var i = 0; i < _dataArr.length; i++) {
-        _addEl.appendChild(U.MD.O.W.Panel.createHis(_dataArr[i], _addEl))
-    }
-}
-
 /**
 * 编辑历史弹出全部
 *
@@ -725,7 +693,7 @@ U.MD.O.W.Panel.AsynViewEditHistory = function (r) {
 U.MD.O.W.Panel.EditHistoryc = function (UDE) {//此参数为历史记录的信息
     var _el = $$("div"),
     // _UCT = new U.UF.UI.form("<div _el='U_MD_F_S_TI'>历史记录</div>",_el,{"className": "Bjlsall", "style": {"width": "950px", "height": "550px","overflow": "hidden"} },{isdrag: false,isenlarge: false, isnarrow: false }, null, null, null, _UDTD);
-    _UCT = new U.UF.UI.form("历史记录", _el, { className: 'Bjlsall', style: { width: "950px", height: "550px", overflow: "hidden"} }, { isdrag: false, isenlarge: false, isnarrow: false }, null, null, null, _UDTD);
+    _UCT = new U.UF.UI.form("历史记录", _el, { className: 'Bjlsall', style: { width: "950px", height: "550px", overflow: "hidden"} }, { isdrag: false, isenlarge: false, isnarrow: false }, null, null, null);
 
     var i, _UDBD, _UDTD, _UDSD;
     for (var a = 0; a < UDE.length; a++) {//循环历史记录的长度 用来显示多个历史记录在"显示按钮"的打开的窗体上
@@ -841,7 +809,7 @@ U.MD.O.W.Panel.AsynEditHistory = function (docinfo, element) {
     $$("img",
         {
             "onerror": U.MD.C.imgError,
-            "src": (top.U.MD.C.getHeadImage(docinfo.UserThumbnailImageHead) || '/img/UserHead/UseHead.jpg'),
+            "src": (top.U.MD.C.getHeadImage(docinfo.UserThumbnailImageHead) || 'http://www.1473.cn/img/UserHead/UseHead.jpg'),
             "alt": docinfo.UserNickName || docinfo.UserName,
             "title": docinfo.UserNickName || docinfo.UserName
         },

+ 53 - 21
js/UForm/Editor.js

@@ -1881,7 +1881,7 @@ U.UF.E.fomatBrushNext = function (el) {
 U.UF.E.attachment = function (input, editor) {
     if (input.files.length) { //判断是否存在文件
         var _range = U.UF.E.getRangeAt(); //获取光标处理
-        U.UF.UP.inputUpload([input], 'http://disk.1473.cn/USUpfile.ashx?typename=UseStudioEditor&UserId=FA92AAC5-4134-449F-9659-0DC12F4F68E9', function (r) { //调用统一上传处理
+        U.UF.UP.inputUpload([input], 'http://upload.1473.cn/upload', function (r) { //调用统一上传处理
             var _file, _filetype, _input = r.context[0];
             var _imgtype = /.*(jpg|png|gif|jpeg|JPG|PNG|GIF|JPEG|bmp|BMP)$/;
             var _filearray = []; //记录上传图片的数组
@@ -1999,29 +1999,61 @@ U.UF.E.attachment.fileNameSplice = function (name, maxlength) {
 */
 U.UF.E.picture = function (input, editor) {
     if (input.files.length) { //判断是否存在文件
-        var _range = U.UF.E.getRangeAt(); //获取光标处理
-        U.UF.UP.inputUpload([input], 'http://disk.1473.cn/USUpfile.ashx?typename=UseStudioEditor&UserId=FA92AAC5-4134-449F-9659-0DC12F4F68E9', function (r) { //调用统一上传处理
-            var _input = r.context[0];
-            var _imgarray = []; //记录上传图片的数组
-            if (Object.prototype.toString.call(r.value[0]) != "[object Array]") { //根据返回值类型判断是否多图上传
-                _imgarray = [r.value]; //单图用数组则直接记录
-            } else {
-                _imgarray = r.value; //多图则直接替换即可
-            }
-            //调用上传图片控件
-            var _img = ''; //设置img元素字符串
-            for (i = 0; i < _imgarray.length; i++) { //循环评接拼接
-                //                $$("span", { innerHTML: "&#8203;" }, _attachment);
-                _img += '<span>  <img src="http://fs.1473.cn/' + _imgarray[i][0] + '"> </span>'; //图片元素拼接
-            }
-            //$('#U_MD_O_H_wordEditor')[0],为什么要用或者?并且多条语句连写调试好困难,需要分开。
-            //找到编辑器
-            var _editor = editor || U.selectEl('#U_MD_O_H_wordEditor')[0];
-            U.UF.E.textFormat(_img, _editor); //生成img元素
-        }, [input]);
+        //给最后一个input以标识,在完成上传后更改input的value值为空,解决第二次上传onchange不响应的问题。
+        //按道理,如果能够精准判断到谁是最后一个上传最保险,但难以判断,此做法已经生效,有问题以后再考虑。
+        //js上传好像是数组最后一个最先上传,所以设置第0位进行传值。
+        input.files[0].input = input;
+        for (var i = 0; i < input.files.length;i++) {
+            U.UF.UP.HTML5.upload("http://upload.1473.cn/upload", input.files[i], function (r) {
+                //document.getElementById("product_u_i_displayImg").src = "http://fs.1473.cn/" + r.fileServerName;
+                //如需要生成缩略图,则调用
+                //调用上传图片控件
+                var _img = ''; //设置img元素字符串
+                //for (i = 0; i < _imgarray.length; i++) { //循环评接拼接
+                    //                $$("span", { innerHTML: "&#8203;" }, _attachment);
+                _img += '<span>  <img src="http://fs.1473.cn/' + r.fileServerName + '"> </span>'; //图片元素拼接
+                //}
+                //$('#U_MD_O_H_wordEditor')[0],为什么要用或者?并且多条语句连写调试好困难,需要分开。
+                //找到编辑器
+                var _editor = editor || U.selectEl('#U_MD_O_H_wordEditor')[0];
+                U.UF.E.textFormat(_img, _editor); //生成img元素
+                //获取input控件,清空其值,解决第二次上传onchange不触发的问题。
+                var _input = r.input;
+                if (_input) {
+                    _input.value = "";
+                }
+
+
+            }, function (r) {  }, function (r) {  });
+        }
     }
 }
 
+// U.UF.E.picture = function (input, editor) {
+//     if (input.files.length) { //判断是否存在文件
+//         var _range = U.UF.E.getRangeAt(); //获取光标处理
+//         U.UF.UP.inputUpload([input], 'http://upload.1473.cn/upload', function (r) { //调用统一上传处理
+//             var _input = r.context[0];
+//             var _imgarray = []; //记录上传图片的数组
+//             if (Object.prototype.toString.call(r.value[0]) != "[object Array]") { //根据返回值类型判断是否多图上传
+//                 _imgarray = [r.value]; //单图用数组则直接记录
+//             } else {
+//                 _imgarray = r.value; //多图则直接替换即可
+//             }
+//             //调用上传图片控件
+//             var _img = ''; //设置img元素字符串
+//             for (i = 0; i < _imgarray.length; i++) { //循环评接拼接
+//                 //                $$("span", { innerHTML: "&#8203;" }, _attachment);
+//                 _img += '<span>  <img src="http://fs.1473.cn/' + _imgarray[i][0] + '"> </span>'; //图片元素拼接
+//             }
+//             //$('#U_MD_O_H_wordEditor')[0],为什么要用或者?并且多条语句连写调试好困难,需要分开。
+//             //找到编辑器
+//             var _editor = editor || U.selectEl('#U_MD_O_H_wordEditor')[0];
+//             U.UF.E.textFormat(_img, _editor); //生成img元素
+//         }, [input]);
+//     }
+// }
+
 /* word复制粘贴图片及拖拽图片函数
 * 
 * @param e      {event}   事件对象

+ 324 - 0
js/UForm/UPload.js

@@ -366,6 +366,330 @@ U.UF.UP.html5Upload.deleteUploadAllFile = function () {
 
 }
 
+Namespace.register("U.UF.UP.HTML5");
+/**
+ * html5上传文件函数
+ * 可另外写一个函数封装为其他开发者也能上传的函数,需要多加2个参数,服务器文件名,已经上传大小
+ * 
+ * @param url 必填! 上传地址  
+ * @param file 必填! 上传文件对象,非input,是input里面的问题件 
+ * @param callback  必填!  上传成功回调,其值为文件对象file。里面有  
+ *                 返回值为文件对象,其值在file.fileServerName中。
+ *                    形如:fileHash: "8a4e8d737b1514414e84c3428fceaffc"
+                      fileReader: FileReader {readyState: 2, result: ArrayBuffer(57), error: null, onloadstart: null, onprogress: null, …}
+                      fileServerName: "0c66a100-568e-11ec-bd9b-a7f8f2b18a24.txt"
+                      lastModified: 1599451644496
+                      lastModifiedDate: Mon Sep 07 2020 12:07:24 GMT+0800 (中国标准时间) {}
+                      name: "文件.txt"
+                      size: 57
+                      type: "text/plain"
+                      uploadedSize: 0
+                      url: "http://upload.1473.cn/upload"
+ * @param md5callback  非必填项!  
+ *                md5验证进度条回调,上传大文件做md5验证进度条,  分片大小为2M
+ *    其取值如下:{ 'Loaded': currentChunk, 'Total': chunks } 共有多少分片,当前解析到哪一个分片
+ *                { 'Loaded': "success", 'Total': 100 }     全部完成
+ *                { 'Loaded': "error", 'Total': 'oops, something went wrong.' }  如果Loaded为error,表示发生错误,错误信息放置在Total中。
+ * @param upprogresscallback  非必填项!
+ *                     上传进度条回调,上传大文件做文件上传进度条用。 分片大小为500kb
+ *                     否则,progress为进度条{ 'Loaded': currentChunk, 'Total': chunks }
+ *                     上传成功后的返回值为{ 'Loaded': "success", 'Total': chunks }。
+ */
+U.UF.UP.HTML5.upload = function (url, file, callback, md5callback, upprogresscallback) {
+    //文件md5验证,并生成进度条
+    U.UF.UP.HTML5.fileMd5(file, function (progress, filehash) {
+        //错误处理
+        if (progress.Loaded == "error") {
+            console.log("上传错误:" + progress.Total);
+        }
+        //解析完成
+        if (progress.Loaded == "success") {
+            ////根据filehash去数据库判断是否以前已经上传过,已经上传,则不用再上传,否则,执行上传
+            //写自己的代码的地方
+            file.url = url;
+            file.fileHash = filehash;
+            //执行上传。去upload选取上传数据,此数据库没有做记录,是否已经上传,是采用文件覆盖的方式执行上传。
+            U.A.Request("http://upload.1473.cn/select", [file.name, file.fileHash, file.size], function (r) {
+                if (r.value) {
+                    //获取服务器返回值,包含了文件服务器名称,文件大小。
+                    var _result = r.value;
+                    //此处生成上传文件的服务器名称,即guid名称。
+                    file.fileServerName = _result.fileServerName;
+                    //_result.filesize为已经上传的文件大小
+                    file.uploadedSize = _result.filesize;
+                    //上传文件,并生成进度条。
+                    U.UF.UP.HTML5.loop(file.url, file, file.fileHash, file.fileServerName, file.uploadedSize,
+                        //回调函数,参数一为进度条
+                        function (progress) {
+                            //上传进度条。
+                            if (progress.Loaded == "success") {
+                                //上传成,回调。
+                                callback(file);
+                            }
+                            //上传中的处理
+                            else {
+                                //上传中的进度条
+                                upprogresscallback(progress);
+                            }
+                        }
+                    );
+                }
+                else {
+                    U.alert("上传异常,服务器未响应,此处需要做处理!");
+                }
+            });
+        }
+        //未解析完毕进度条处理
+        else {
+            //生成md5验证进度条
+            md5callback(progress);
+        }
+    });
+}
+
+/**
+ * 给使用uform框架的其他开发者封装的函数,未做验证
+ * html5上传文件函数,
+ * 可另外写一个函数封装为其他开发者也能上传的函数,需要多加2个参数,服务器文件名,已经上传大小
+ *
+ * @param url 必填! 上传地址
+ * @param file 必填! 上传文件对象,非input,是input里面的问题件
+ * @param fileservername 必填! 文件服务器名称
+ * @param uploadedsize 必填! 文件已经上传的大小,未上传填写0.
+ * @param callback  必填!  上传成功回调,其值为文件对象file。里面有
+ *     返回值为文件对象,其值在file.fileServerName中。
+ *                    形如:fileHash: "8a4e8d737b1514414e84c3428fceaffc"
+                      fileReader: FileReader {readyState: 2, result: ArrayBuffer(57), error: null, onloadstart: null, onprogress: null, …}
+                      fileServerName: "0c66a100-568e-11ec-bd9b-a7f8f2b18a24.txt"
+                      lastModified: 1599451644496
+                      lastModifiedDate: Mon Sep 07 2020 12:07:24 GMT+0800 (中国标准时间) {}
+                      name: "文件.txt"
+                      size: 57
+                      type: "text/plain"
+                      uploadedSize: 0
+                      url: "http://upload.1473.cn/upload"
+ * @param md5callback  非必填项!
+ *                md5验证进度条回调,上传大文件做md5验证进度条,  分片大小为2M
+ *    其取值如下:{ 'Loaded': currentChunk, 'Total': chunks } 共有多少分片,当前解析到哪一个分片
+ *                { 'Loaded': "success", 'Total': 100 }     全部完成
+ *                { 'Loaded': "error", 'Total': 'oops, something went wrong.' }  如果Loaded为error,表示发生错误,错误信息放置在Total中。
+ * @param upprogresscallback  非必填项!
+ *                     上传进度条回调,上传大文件做文件上传进度条用。 分片大小为500kb
+ *                     否则,progress为进度条{ 'Loaded': currentChunk, 'Total': chunks }
+ *                     上传成功后的返回值为{ 'Loaded': "success", 'Total': chunks }。
+ */
+U.UF.UP.HTML5.upload.Api = function (url, file, fileservername, uploadedsize, callback, md5callback, upprogresscallback) {
+    //文件md5验证,并生成进度条
+    U.UF.UP.HTML5.fileMd5(file, function (progress, filehash) {
+        //错误处理
+        if (progress.Loaded == "error") {
+            console.log("上传错误:" + progress.Total);
+        }
+        //解析完成
+        if (progress.Loaded == "success") {
+            ////根据filehash去数据库判断是否以前已经上传过,已经上传,则不用再上传,否则,执行上传
+            //写自己的代码的地方
+            file.url = url;
+            file.fileHash = filehash;
+
+            //此处生成上传文件的服务器名称,即guid名称。
+            file.fileServerName = fileservername;
+            //_result.filesize为已经上传的文件大小
+            file.uploadedSize = uploadedsize;
+            //上传文件,并生成进度条。
+            U.UF.UP.HTML5.loop(file.url, file, file.fileHash, file.fileServerName, file.uploadedSize,
+                //回调函数,参数一为进度条
+                function (progress) {
+                    //上传进度条。
+                    if (progress.Loaded == "success") {
+                        //上传成,回调。
+                        callback(file);
+                    }
+                    //上传中的处理
+                    else {
+                        //上传中的进度条
+                        upprogresscallback(progress);
+                    }
+                }
+            );
+        }
+        //未解析完毕进度条处理
+        else {
+            //生成md5验证进度条
+            md5callback(progress);
+        }
+    });
+}
+
+
+
+
+
+
+/*
+* @param  {element} 所需要上传的文件,
+* @param  {function} 解析回调函数,此回调函数传递参数不一致。
+*/
+U.UF.UP.HTML5.fileMd5 = function (file, callback) {//生成文件hash
+    var blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice, //分割文件的方法
+        chunkSize = 2097152, // Read in chunks of 2MB
+        chunks = Math.ceil(file.size / chunkSize), //分割的次数
+        currentChunk = 0,//当前第一个分割从0开始
+        spark = new U.UF.EC.SparkMD5.ArrayBuffer(),//得到md5编码
+        fileReader = new FileReader()
+    ;
+    file.fileReader = fileReader;
+    //解析监听
+    fileReader.onload = function (e) {
+        spark.append(e.target.result);
+        currentChunk++;
+        //判断md5是否解析成功
+        if (currentChunk < chunks) {
+            //未完成,则继续
+            loadNext();
+            //并且给出进度条
+            callback({ 'Loaded': currentChunk, 'Total': chunks }) // 参数:进度
+        }
+        else {
+            //获取md5完成,则执行回调函数
+            callback({ 'Loaded': "success", 'Total': 100 }, spark.end()) // 参数:进度、 文件hash
+        }
+    };
+
+    //解析失败监听
+    fileReader.onerror = function () {
+        callback({ 'Loaded': "error", 'Total': 'oops, something went wrong.' }) // 参数:进度
+    };
+
+    //解析下一步处理
+    var loadNext = function () {
+        var start = currentChunk * chunkSize,
+            end = ((start + chunkSize) >= file.size) ? file.size : start + chunkSize;
+        fileReader.readAsArrayBuffer(blobSlice.call(file, start, end));
+    }
+
+    loadNext();
+}
+
+/*
+* 判断上传的文件是否在服务器中,此函数未使用
+* @param  {file} 需要上传的input
+* @param  {string} 上传文件的hash值
+* @param  {function} 解析回调函数
+*/
+U.UF.UP.HTML5.selectFromDB = function (file, filehash, callback) {
+    //由于历史原因,有mysql数据库和sqlserver数据库保存了上传数据,两个数据库需要合一。此任务列为下学期任务。
+    //首先去sqlserver数据库去找,为何是此三个参数?
+    U.A.Request(US.DISK, ["GetFileByHash", filehash, file.size, file.name.getExtendName()], function (r) {
+        //如果找到,则返回
+        if (r.value) {
+
+        }
+        else {
+            //如果没找到,继续去mysql中查找。
+            //从html5上传接口去查询,此数据库为mysql数据库,由余中豪所做。
+            U.A.Request("http://upload.1473.cn/select", [file.name, filehash, file.size], function (r) {
+                //如果有怎么处理?如果没有怎么处理?
+                if(r.value){
+
+                }
+                else {
+                    //都没找到,回调回去上传
+                    callback(r.value.fileServerName, r.value.filesize);
+                }
+            });
+        }
+
+    });
+}
+
+
+/*
+* 断点续传函数,此处为html5的上传功能实现,参考upload.1473.cn下面的split-upload.js文件。
+* @param  {file} 文件对象
+* @param  {string} 文件hash
+* @param  {string} 文件服务器名,后端的guid名。由后端返回,同时需要向后端传递。以利于服务器定位文件。
+ *    每上传完一个片段需要返回一次,用于在服务器查找文件,此处多次返回。
+* @param  {int} 文件大小。每次增量大小。由后台返回,每上传完一个片段需要返回一次。
+* @param  {fun} 回调函数,如为上传完毕,回调函数处理进度条,否则,回调函数处理完成事宜。
+*/
+U.UF.UP.HTML5.loop = function (url,file, filehash, fileservername, filesize, callback) {
+    var _xhr,//ajax请求
+        _fd,//formdata的实例。
+        _thunkto,//
+        _islast=false, // 假定非最后一次上传
+        _totalsize = file.size, // 总大小
+        _eachsize = 1024 * 500, // 每次上传大小  这里是500kb
+        _count = filesize / _eachsize,//上传次数
+        _thunkfrom = filesize // 切割起始端
+    ;
+    //判断是否是最后一次上传
+    if (filesize >= _totalsize) {
+        _thunkto = _totalsize; //设置上传结束为止的大小
+        _islast = true; //设置本次上传为最后一次上传
+    }
+    //非最后一次上传,这是每次上传为500kb
+    else {
+        _thunkto = _eachsize + filesize;
+    }
+    //创建form表单发送数据
+    _fd = new FormData();
+    _fd.append('theFile', file.slice(_thunkfrom, _thunkto)); // 分好段的文件
+    _fd.append('filehash', filehash);
+    _fd.append('fileChunk', _count); // 上传次数
+    _fd.append('isFirstChunk', _count); // 是否第一次上传
+    _fd.append('isLastChunk', _islast); // 是否最后一次上传  count === counts - 1
+    _fd.append('fileServerName', fileservername); //文件名
+
+    //调用ajax请求发送form数据
+    _xhr = new XMLHttpRequest();
+    file.xhr = _xhr;
+    _xhr.open("post", url, true);
+    //_xhr.open("post", "http://upload.1473.cn/upload", true);
+    _xhr.onreadystatechange = function () {
+        if (_xhr.readyState == 4 && _xhr.status == 200) {
+            var _rs = JSON.parse(_xhr.responseText); //获取后台返回的值
+            if (_rs.status == 200) {
+                callback({ 'Loaded': _thunkto, 'Total': _totalsize }); //进度条处理
+                //判断是否继续上传
+                if (_rs.isLastChunk) {
+                    //上传完毕,返回success。
+                    callback({ 'Loaded': "success", 'Total': _totalsize });
+                    return;
+                }
+                //继续上传,必须放在这里。
+                U.UF.UP.HTML5.loop(url, file, filehash, fileservername, _thunkto, callback)
+            }
+            else {
+                U.alert("上传服务器出错!");
+            }
+        }
+    };
+    _xhr.send(_fd);
+}
+
+
+/**
+* 停止指定上传文件
+*
+*/
+U.UF.UP.HTML5.stopUploadFile = function (file) {
+    if (file.fileReader) {
+        file.fileReader.abort(); //停止解析
+    }
+    if (file.xhr) {
+        file.xhr.abort(); //停止上传
+    }
+}
+
+/**
+* 删除所有的文件
+*
+*/
+U.UF.UP.HTML5.deleteUploadAllFile = function () {
+
+}
+
 //#endregion
 
 //#region flash上传处理