WordPanel.js 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  1. //此处放置iframe中的word中的功能面板,包括包括创建邀请协作人员,创建编辑历史,创建生成链接.创建热门模板。
  2. Namespace.register("U.MD.O.W.Panel");
  3. //协作统一命名为Collaborative,但牵涉的地方太多,暂时还是用Synergy
  4. //#region 本地转协同文档及新建保存为协同文档操作
  5. /**
  6. * 本地转协同文档及新建保存为协同文档操作,此函数逻辑不清,需要改写!
  7. *
  8. * @param fun {element} 回调函数
  9. */
  10. U.MD.O.W.Panel.isSynergy = function (fun) {
  11. //判断是登录
  12. if (!top.U.MD.U.L.isLogin()) {
  13. var _fileinfo = U.MD.O.W.fileinfo, //文件信息
  14. ////或者是什么意思?不严谨
  15. _filegroupid = _fileinfo.GroupID; //获取_filegroupid群id,判断是否是在自己的ftp下的文档
  16. //判断是否为互联办公文档,此处有问题。互联办公的权限有问题。
  17. if (U.MD.O.W.permission.web) {
  18. if (U.UF.C.isFunction(fun)) {//判断是否有点击事件的方法,如果有,运行它
  19. fun(_fileinfo);
  20. }
  21. return true;
  22. }
  23. else {
  24. var _filename = top.$('#UD_Word' + _fileinfo.UserDirectoryID + ' .U_MD_O_H_head_navigation_Title')[0]; //获取文件名
  25. //判断文档是否是保持文档,是否是可编辑文档
  26. if (U.MD.O.W.isSave() && U.MD.O.W.permission.edit) {
  27. //如果是保持的文档,那么直接提示是否转成系统文档
  28. new U.UF.UI.confirm("是否将此文档转成互联办公文档", function () {
  29. //保存到群里
  30. top.U.MD.DK.VW.saveSynergy(_fileinfo.UserDirectoryExtendType || "uw", _fileinfo, _filename.value, 'move', function (fileinfo) {
  31. U.MD.O.W.Panel.isSynergy.async(fileinfo, fun);
  32. });
  33. });
  34. }
  35. //新建保存为协同
  36. else {
  37. //否则是新建文档
  38. top.U.MD.DK.VW.saveSynergy(_fileinfo.UserDirectoryExtendType || "uw", _fileinfo, _filename.value, 'new', function (fileinfo) {
  39. U.MD.O.W.Panel.isSynergy.async(fileinfo, fun);
  40. });
  41. }
  42. }
  43. }
  44. return false;
  45. }
  46. /**
  47. * 本地转协同文档及新建保存为协同文档操作
  48. *
  49. * @param fileinfo {object} 文件信息
  50. * @param fun {element} 回调函数
  51. */
  52. U.MD.O.W.Panel.isSynergy.async = function (fileinfo, fun) {
  53. U.MD.O.W.fileinfo = fileinfo; //设置文件信息
  54. U.MD.O.W.Panel.disPlayUser(fileinfo); //获取协作人员
  55. var _eidtorel = $('#U_MD_O_H_wordEditor')[0]; //获取编辑器
  56. //导航文件转成互联
  57. if (fileinfo.UserDirectoryExtendType == 'un') {
  58. //保存文件到后台
  59. U.MD.O.W.T.N.saveAllPage(function () {
  60. U.MD.O.W.T.N.saveNav.asyn(true, fileinfo, _eidtorel);
  61. }, 0, true, _eidtorel.innerHTML);
  62. }
  63. else {
  64. //保存文件到后台
  65. 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]);
  66. }
  67. if (U.UF.C.isFunction(fun)) {//判断是否有点击事件的方法,如果有,运行它
  68. fun(fileinfo);
  69. }
  70. }
  71. U.MD.O.W.Panel.isSynergy.saveAsync = function (r) {
  72. var _fileinfo = r.context[1];
  73. var _eidtorel = r.context[2];
  74. U.MD.O.W.permission.edit = true;
  75. U.MD.O.W.permission.web = true;
  76. top.$('#UD_Word' + _fileinfo.UserDirectoryID + ' .U_MD_O_H_head_navigation_Title')[0].value = _fileinfo.UserDirectoryName; //设置文件名
  77. U.Alert("保存成功"); //提示保存成功
  78. U.MD.O.W.fileinfo.UsOffice = _eidtorel.innerHTML; //设置内容
  79. _eidtorel.editor.operaNotice = U.MD.O.W.E.operationNotice; //设置协同监听回调
  80. }
  81. //#endregion
  82. //#region 团队成员
  83. /**
  84. * 创建团队成员的窗体
  85. *
  86. * @param fileinfo {object} 文件信息
  87. */
  88. U.MD.O.W.Panel.loadPlayUser = function (fileinfo) {
  89. var _coopwindow, _frienddiv, _example, _shareLink, _cBox;
  90. //如果不存在团队成员窗口,则创建一个团队成员窗口。
  91. if (!$("#U_MD_O_H_body_left_invite_user")[0]) {
  92. //创建邀请协助人员窗口
  93. _coopwindow = $("#U_MD_O_H_body_left")[0];
  94. _cBox = $$("div", {});
  95. _shareLink = $$("div", { className: 'U_MD_O_H_body_left_invite_linkTxt', "onclick": function () {
  96. U.MD.O.W.Panel.isSynergy(U.MD.O.W.Panel.shareLink);
  97. }, "innerText": "第三方链接邀请"
  98. }, _cBox);
  99. _frienddiv = $$("div", { "className": "U_MD_O_H_body_left_invite_user", "id": "U_MD_O_H_body_left_invite_user" }, _cBox); //好友内容区域
  100. _example = $$("div", { "className": "U_MD_O_H_body_left_invite_user_a", "onclick": function () {
  101. U.MD.O.W.Panel.displayInsertUser();
  102. }
  103. }, _frienddiv); //默认邀请按钮
  104. $$("div", { "className": "U_MD_O_H_body_left_invite_user_a_img" }, _example);
  105. $$("div", { "className": "U_MD_O_H_body_left_invite_user_a_div", "innerHTML": "邀请" }, _example);
  106. 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"} },
  107. { isenlarge: false, isnarrow: false }, { style: { margin: "0px 5px", "border-bottom": "1px solid #d6def0", color: "#000", background: "#fff"} }, null, null, _coopwindow);
  108. }
  109. U.MD.O.W.Panel.disPlayUser(fileinfo); //获取协作人员
  110. }
  111. /**
  112. * 初始化查看团队成员
  113. *
  114. * @param fileinfo {object} 文件信息
  115. */
  116. U.MD.O.W.Panel.disPlayUser = function (fileinfo, el) {
  117. el = $("#U_MD_O_H_body_left_invite_user")[0]; //获取团队成员初始化的位置
  118. var _elchild = el.children[0] //获取元素的子元素;
  119. el.innerHTML = ""//清空内容
  120. $(el).append(_elchild);
  121. if (fileinfo) {//判断是否有文件信息
  122. //或者是什么意思?不严谨
  123. var _userinfo = U.Json.select(US.friend.groupusers, { "GroupManageID": fileinfo.GroupID }); //获取所有在群里的成员
  124. if (_userinfo) {//判断是否拥有群成员
  125. for (i = 0; i < _userinfo.length; i++) {//循环打印所有的群成员
  126. U.MD.O.W.Panel.createUser(_userinfo[i], el);
  127. }
  128. }
  129. }
  130. }
  131. /**
  132. * 打印团队编辑成员
  133. *
  134. * @param fileinfo {object} 文件信息
  135. */
  136. U.MD.O.W.Panel.createUser = function (userinfo, el) {
  137. var _elparent = $$("div", { "className": "U_MD_O_H_body_left_invite_user_a", "onclick": U.UF.C.closure(function (userid) {
  138. top.U.MD.U.V.ViewOtherUserInfo(userid);
  139. }, [userinfo.UserId])
  140. }, el); //好友头像父级元素
  141. var _elcontant = $$("div", { "className": "U_MD_O_H_body_left_invite_user_a_user", "style": { "background": ""} }, _elparent); //好友头像元素
  142. $$("img", { "onerror": U.MD.C.imgError, "src": top.U.MD.C.getHeadImage(userinfo.UserThumbnailImageHead) }, _elcontant); //好友头像图片
  143. $$("div", { "className": "U_MD_O_H_body_left_invite_user_a_div", "innerHTML": userinfo.UserNickName }, _elparent); //好友名称
  144. }
  145. /**
  146. * 单击邀请时,从普通文档转换为协同文档的过程!
  147. * 判断是否是已经新建过 弹出添加成员 异步回调
  148. *
  149. * @param {element} Wrod信息数组
  150. */
  151. U.MD.O.W.Panel.displayInsertUser = function () {
  152. //判断是否是协同文档
  153. if (U.MD.O.W.Panel.isSynergy()) {
  154. var _fileinfo = U.MD.O.W["fileinfo"];
  155. top.U.MD.F.J.selectFriendForm(function (groupid) {
  156. //或者是什么意思?不严谨
  157. var _filegroupid = _fileinfo.GroupID; //获取_filegroupid群id,判断是否是在自己的ftp下的文档
  158. var _groupinfo = U.Json.select(US.friend.group, { "GroupManageID": _filegroupid })[0]; //群信息
  159. var _needuser = top.U.MD.F.J.selectUserInfo.NeedUser; //选中好友集合
  160. var _groupname = _groupinfo.GroupManageName; // 群名
  161. var _groupdesc = _groupinfo.GroupManageDescript; //群描述
  162. var _selectfriend = U.Json.select(US.friend.groupusers, { "GroupManageID": _filegroupid }); //选择的好友信息
  163. //已经在群里的就不添加了
  164. var i;
  165. for (i = 0; i < _selectfriend.length; i++) {
  166. U.Json.del(_needuser, { "UserId": _selectfriend[i].UserId }); //删除所有在群里的用户id
  167. }
  168. //创建及添加群处理
  169. top.U.MD.F.J.determineCreateGroupAndAddGroupUser(_filegroupid, null, null, false, _groupname, _groupdesc, function (groupid, groupinfo) {
  170. var i, _userids = "";
  171. //U.MD.O.W.Panel.disPlayUser(_fileinfo);
  172. for (i = 0; i < _needuser.length; i++) {//循环打印所有的群成员
  173. _userids += _needuser[i].UserId + (i < _needuser.length - 1 ? "," : "");
  174. U.MD.O.W.Panel.createUser(_needuser[i]);
  175. }
  176. U.MD.O.W.Panel.addUser(_userids);
  177. });
  178. }, null, _fileinfo); //调用打印函数
  179. }
  180. }
  181. U.MD.O.W.Panel.addUser = function (userids) {
  182. var _type = U.MD.O.W["fileinfo"].UserDirectoryExtendType == "un" ? "nav" : "word";
  183. top.U.A.Request(US.SCOKET, ["addUser", _type, U.MD.O.W["fileinfo"].UserDirectoryID, userids, US.userInfo.UserId, top.US.pageId], function () { });
  184. }
  185. U.MD.O.W.Panel.syncAddUser = function (userids, senduserid) {
  186. userids = userids.split(",");
  187. var i, _userinfo;
  188. for (i = 0; i < userids.length; i++) {
  189. _userinfo = U.Json.selectOne(US.friend.groupusers, { UserId: userids[i] });
  190. if (!_userinfo) {
  191. top.U.A.Request(US.CD, [US.DB, "UseStudio_Users", "GetUserinfoByUserId", userids[i]], function (r) {
  192. _userinfo = r.value[0];
  193. U.MD.O.W.Panel.createUser(_userinfo);
  194. })
  195. }
  196. }
  197. }
  198. //#endregion
  199. //#region 分享文档链接
  200. /**
  201. * ----------------------------添加团队成员
  202. *
  203. * @param {object} 文件信息
  204. * @param {string} 文件提交到哪个群的id
  205. * @param {array} 用户id的数组
  206. */
  207. //U.MD.O.W.Panel.insertUser = function (fileinfo, groupid) {
  208. // // if (!fileinfo.UserId && !fileinfo.UserallDirectoryName) {
  209. // // fileinfo.GroupId = fileinfo.UserDirectoryEncrypt = groupid;
  210. // // var _groupuserid = U.Json.select(US.friend.group, { 'GroupManageID': groupid })[0].GroupManageUserID;
  211. // // var _dirinfo, _dirid, _diskinfo = US.disk.Disks[US.userInfo.UserId];
  212. // // if (_groupuserid == US.userInfo.UserId) {
  213. // // _dirinfo = U.Json.select(_diskinfo.directoryOrFiles, { 'UserDirectoryName': "我的协同" })[0];
  214. // // } else {
  215. // // _dirinfo = U.Json.select(_diskinfo.directoryOrFiles, { 'UserDirectoryName': "他人邀请" })[0];
  216. // // }
  217. // // var _dirchild = top.$('#L' + _dirinfo.UserDirectoryID).Child();
  218. // // !_dirchild[1] && _dirchild[0].onclick()
  219. // // top.$('#L' + groupid).Child()[0].onclick();
  220. // // } else if ((fileinfo.UserDirectoryEncrypt || fileinfo.GroupID) == US.userInfo.UserId) { //如果是新创建的文件,同时文件不在群里 就把文件拷贝到群里进行处理
  221. // // var _userid = fileinfo.UserId,
  222. // // _diskinfo = US.disk.Disks[US.userInfo.UserId],
  223. // // _dirinfo = U.Json.select(_diskinfo.directoryOrFiles, { "UserDirectoryID": groupid }, 1)[0]; //当前目录的信息
  224. // // var _pastecontent = US.disk.Disks[_userid].pasteDirOrFile = {
  225. // // "type": "shear", //复制或者剪切 "copy" || "shear"
  226. // // "UserDirectoryID": groupid, //在哪个目录复制或者剪切
  227. // // "dirorfile": fileinfo, //复制的内容
  228. // // "userid": _userid //用户id
  229. // // }
  230. // // top.U.A.Request(US.AUTH, ["CutAndPasteFiles", fileinfo.UserId, groupid, fileinfo.UserDirectoryID, groupid, groupid],
  231. // // top.U.MD.DK.RE.asynPaste, ["", _dirinfo, groupid, _pastecontent, _diskinfo]
  232. // // );
  233. // // fileinfo.GroupId = fileinfo.UserDirectoryEncrypt = groupid;
  234. // // }
  235. // // U.MD.O.W.Panel.disPlayUser(fileinfo);
  236. //}
  237. /**
  238. * 分享文档链接
  239. *
  240. * @param fileinfo {object} 文件信息
  241. */
  242. U.MD.O.W.Panel.shareLink = function (fileinfo) {
  243. var _template = U.MD.O.W.Panel.shareLinkTemplate(fileinfo); //生成窗体内容
  244. new U.UF.UI.form("邀请协助链接", _template, { id: "U_MD_O_W_Panel_InviteForm", style: { cssText: "width:600px; height:450px;"} }); //创建窗体
  245. }
  246. /**
  247. * 创建分享链接窗体内容模板
  248. *
  249. * @param {fileinfo} 文件信息
  250. */
  251. U.MD.O.W.Panel.shareLinkTemplate = function (fileinfo) {
  252. var _cBox = $$('div', { className: "U_MD_O_H_body_left_invite_form" }), //创建最外层元素
  253. _shareLinkEl = $$('div', { className: "U_MD_O_H_body_left_invite_formShare" }, _cBox), //分享链接盒子元素
  254. _QRCodeEl = $$('div', { className: "U_MD_O_H_body_left_invite_formQRCode" }, _cBox); //二维码元素
  255. $$('p', { innerText: "通过链接邀请:", style: { cssText: "font-size:18px; font-weight: bold;"} }, _shareLinkEl) //文字提示
  256. var _shareLinkInpBlock = $$('div', { className: "U_MD_O_H_body_left_invite_shareInpMargin" }, _shareLinkEl); //分享链接文本框
  257. $$('p', { style: { cssText: "margin-top: 8px;" }, innerText: "将下面的邀请链接通过QQ或微信发送给需要邀请的人" }, _shareLinkInpBlock); //文字提示
  258. var _fileType; //文档类型
  259. switch (fileinfo.UserDirectoryExtendType.toLowerCase()) { //字符串转换
  260. case 'uw':
  261. _fileType = 'word'; break;
  262. case 'ue':
  263. _fileType = 'execl'; break;
  264. case 'un':
  265. _fileType = 'word'; break;
  266. default:
  267. _fileType = false; break;
  268. }
  269. 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), //输出
  270. _shareLinkInpBlockBtn = $$('div', { style: { cssText: "margin-top: 5px;" }, className: "U_MD_O_H_body_left_invite_shareBtn", innerText: "复制", onclick: function () { //复制按钮
  271. var _inp = $$('input', { value: _shareLinkInpBlockShow.value }, $('body')[0]); //创建复制文本框
  272. _inp.select(); //选中
  273. document.execCommand("Copy"); //复制
  274. $(_inp).remove();
  275. U.Alert('复制成功,赶紧分享给小伙伴吧!'); //提示
  276. }
  277. }, _shareLinkInpBlock)
  278. $$('p', { innerText: "通过二维码邀请:", style: { cssText: "font-size:18px; font-weight: bold;"} }, _QRCodeEl); //文字
  279. var _QRCodeImg = $$('div', { style: { cssText: "margin-left:40px;margin-top: 20px;position:absolute;"} }, _QRCodeEl);
  280. $$('div', { innerHTML: "<span style='font-size:16px'>通过扫码,邀请好友</span><br>扫描二维码获取邀请函,转发给微信好友/群,<br/>即可邀请他们加入你的文档", style: { cssText: "margin-left: 270px;margin-top:40px;line-height:30px;"} }, _QRCodeEl);
  281. top.U.UF.QR.generate("150", "150", "black", "white", _shareLinkInpBlockShow.value, _QRCodeImg); //调用生成二维码函数
  282. return _cBox; //返回最外层元素
  283. }
  284. //#endregion
  285. //#region 热门模板
  286. /**
  287. * 创建热门模板窗体
  288. *
  289. * @param {element} 换页元素
  290. */
  291. U.MD.O.W.Panel.loadHotTemplates = function (fileinfo) {
  292. var _leftel, _el;
  293. //判断是否加载热门模板
  294. if (!$("#U_MD_O_H_body_left_template_hot")[0]) {
  295. _leftel = $("#U_MD_O_H_body_left")[0];
  296. //创建热门模板窗体
  297. _el = $$("div", { "className": "U_MD_O_H_body_left_template_user", id: "U_MD_O_H_body_left_template_hot" });
  298. 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);
  299. }
  300. U.MD.O.W.Panel.getHotTemplates("00000000-0000-0000-0000-000000000000", 1, 10); //热门模板
  301. }
  302. /**
  303. * 初始化加载模板
  304. *
  305. * @param {element} 换页元素
  306. */
  307. U.MD.O.W.Panel.getHotTemplates = function (hid, start, end) {
  308. var _el = $("#U_MD_O_H_body_left_template_hot")[0];
  309. U.A.Request(US.CD, [US.DB, "UseStudio_Office", "SelectHotTemplate", hid, start, end], U.MD.O.W.Panel.asynGetHotTemplates, [null, _el]);
  310. }
  311. /**
  312. * 获取热门模板
  313. *
  314. * @param {element} 换页元素
  315. */
  316. U.MD.O.W.Panel.asynGetHotTemplates = function (r) {
  317. var i, _el,
  318. _frag = $$("frag"),
  319. _hel = r.context[1];
  320. r = r.value;
  321. //循环答应热门模板
  322. for (i = 0; i < r.length; i++) {
  323. _el = $$("div", {
  324. "className": "U_MD_O_H_body_left_template_user_m",
  325. "onclick": U.UF.C.closure(function (info) {
  326. parent.U.A.Request(US.DISK, ["GetFileContent", info.FileId], function (r) {
  327. //获取到内容
  328. if (r.value && r.value.UsOffice !== undefined) {
  329. r = r.value.UsOffice;
  330. }
  331. //打开新的word处理
  332. top.U.MD.O.word(US.userInfo, { UserDirectoryID: Guid.newGuid(), UsOffice: r || "" });
  333. });
  334. }, [r[i]])
  335. }, _frag);
  336. $$("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);
  337. $$("div", { "className": "U_MD_O_H_body_left_template_user_m_x", "innerHTML": r[i]["UserFilesName"] }, _el);
  338. }
  339. $(_hel).append(_frag);
  340. }
  341. //#endregion
  342. //#region 链接查看
  343. /**
  344. *
  345. * 加载,生成连接区域
  346. *
  347. * @param wordinfo {object} 当前文档信息
  348. */
  349. U.MD.O.W.Panel.loadlink = function (wordinfo) {
  350. var _linkareael = $("#U_MD_O_H_body_left_href_pay_a")[0];
  351. //如果不存在添加链接区域,则创建。
  352. if (!_linkareael || (_linkareael && _linkareael.innerHTML == "")) {
  353. //加载word文件的短链接
  354. U.A.Request('http://cd.1473.cn/php', ["db.1473.cn", "UseStudio_DNS", 'GetDnsInfoByFileId', wordinfo.UserDirectoryID], function (r) {
  355. var _date = r.value; //获取短连接信息
  356. U.MD.O.W.Panel.formloadlink(_date); //加载链接,这里有可能没有设置过短连接
  357. });
  358. }
  359. }
  360. /**
  361. *
  362. * 加载,生成连接区域
  363. *
  364. * @param wordinfo {object} 当前文档信息
  365. */
  366. U.MD.O.W.Panel.formloadlink = function (date) {
  367. var _url,
  368. _linkdiv,
  369. _wordinfo = U.MD.O.W.fileinfo,
  370. _rightwindow = $("#U_MD_O_H_body_left")[0], //右边功能区
  371. _linkareael = $("#U_MD_O_H_body_left_href_pay_a")[0]
  372. ;
  373. //设置过域名的加载
  374. if (date.length) {
  375. _url = date[0].AppId + ".1473.cn/" + date[0].Domain
  376. _linkdiv = $$("div", { "className": "U_MD_O_H_body_left_href_pay_a", id: "U_MD_O_H_body_left_href_pay_a" });
  377. $$("a", { className: "U_MD_O_H_body_left_href_pay_aText", href: "//" + _url, innerText: _url, target: "_Blank" }, _linkdiv);
  378. //只有编辑权限才显示修改和分享按钮
  379. if (U.MD.O.W.permission.edit) {
  380. $$('div', { innerText: '分享', className: "U_MD_O_H_body_left_href_pay_Btn", onclick: function () {
  381. //判断是否保持文档
  382. if (U.MD.O.W.isSave()) {
  383. 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"} });
  384. new U.UF.UI.form("域名管理", _iframe, { id: "U_MD_DS_DomainShare", style: { "width": "370px", "height": "390px"} });
  385. }
  386. //点击保存处理
  387. else {
  388. $('#U_MD_O_H_save')[0].onclick();
  389. }
  390. }
  391. }, _linkdiv);
  392. $$("div", { innerText: '修改', className: "U_MD_O_H_body_left_href_pay_Btn", onclick: function () {
  393. //判断是否保持文档
  394. if (U.MD.O.W.isSave()) {
  395. 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"} });
  396. new U.UF.UI.form("域名管理", _iframe, { id: "U_MD_DS_DomainManage", style: { cssText: 'width: 1040px; height: 555px'} });
  397. }
  398. //点击保存处理
  399. else {
  400. $('#U_MD_O_H_save')[0].onclick();
  401. }
  402. }
  403. }, _linkdiv);
  404. }
  405. }
  406. //未设置过的
  407. else {
  408. _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 () { //生成链接
  409. //判断文件是否保存,此判断未成功
  410. if (U.MD.O.W.isSave()) { //如果保存的文档,点击直接弹出网页
  411. //得到编辑器
  412. var _wordContent = document.getElementById("U_MD_O_H_wordEditor");
  413. //如果文件变量中的word内容存在,编辑器内容不同于文件变量中的内容,则保存内容,否则,返回true
  414. if (_wordinfo.UsOffice && _wordinfo.UsOffice != _wordContent.innerHTML) {
  415. //保存到数据库
  416. top.U.A.Request(US.DISK, ["SaveFileContent", US.userInfo.UserId, _wordinfo.UserDirectoryID, _wordContent.innerHTML.escapeQuotes(), _wordinfo.UserallDirectoryName, "uw"], function (r) {
  417. //跳转新页面显示word内容
  418. window.open("http://" + U.MD.O.W.fileinfo.UserDirectoryID + ".1473.cn");
  419. }, ([''])); //保存到数据库
  420. }
  421. else {
  422. //先判断数据库是否存在该文件
  423. parent.U.A.Request(US.DISK, ["GetFileContent", _wordinfo.UserDirectoryID], function (r) {
  424. //能够获取到内容
  425. if (r.value && r.value.UsOffice !== null) {
  426. //跳转新页面显示word内容
  427. window.open("http://" + U.MD.O.W.fileinfo.UserDirectoryID + ".1473.cn");
  428. }
  429. else {
  430. //保存到数据库
  431. top.U.A.Request(US.DISK, ["SaveFileContent", US.userInfo.UserId, _wordinfo.UserDirectoryID, _wordContent.innerHTML.escapeQuotes(), _wordinfo.UserallDirectoryName, "uw"], function (r) {
  432. //跳转新页面显示word内容
  433. window.open("http://" + U.MD.O.W.fileinfo.UserDirectoryID + ".1473.cn");
  434. }, ([''])); //保存到数据库
  435. }
  436. });
  437. }
  438. }
  439. else { //未保存的文档查看站点,触发保存事件
  440. $('#U_MD_O_H_save')[0].onclick();
  441. }
  442. }
  443. });
  444. }
  445. //如果已经创建
  446. if (_linkareael && _linkareael.innerHTML == "") {
  447. _linkareael.appendChild(_linkdiv);
  448. }
  449. //如果生成链接的处理
  450. else {
  451. 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);
  452. }
  453. }
  454. //#endregion
  455. //#region 历史记录
  456. /**
  457. * 初始化历史记录
  458. *
  459. * @param
  460. */
  461. U.MD.O.W.Panel.loadOfficeHistory = function (fileinfo) {
  462. var _el, _leftel;
  463. //判断是否有历史记录
  464. if (!$("#U_MD_O_H_body_left_invite_history")[0]) {
  465. _leftel = $("#U_MD_O_H_body_left")[0];
  466. //编辑历史
  467. _el = $$("div", { "className": "U_MD_O_H_body_left_invite_user", "id": "U_MD_O_H_body_left_invite_history" });
  468. 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);
  469. }
  470. //判断文件是否保持的文件,如果保持的文件则有历史记录,未保存的没有
  471. if (U.MD.O.W.isSave()) {
  472. U.MD.O.W.Panel.viewEditHistory(fileinfo.UserDirectoryID, U.MD.O.W.historyid, 1, 100); //历史记录
  473. }
  474. //没有历史记录
  475. else {
  476. $$("div", { "innerHTML": "暂无历史", "style": { "text-align": "center", "margin-top": "50px"} }, _el);
  477. }
  478. }
  479. /**
  480. * 查看编辑历史
  481. *
  482. * @param {element} 换页元素
  483. * 创始人id 文件id 空的id 选取开始 选取长度 获取编辑历史的框
  484. */
  485. U.MD.O.W.Panel.viewEditHistory = function (id, hid, start, end) {
  486. var _el = $("#U_MD_O_H_body_left_invite_history")[0];
  487. U.A.Request(US.CD, [US.DB, "UseStudio_Office", "SelectOfficeHistory", id, hid, start, end], U.MD.O.W.Panel.asynViewEditHistory, [null, _el]);
  488. }
  489. /**
  490. * 查看编辑历史异步
  491. *
  492. * @param {element} 换页元素
  493. */
  494. U.MD.O.W.Panel.asynViewEditHistory = function (r) {
  495. $('#U_MD_O_H_body_left_invite_history')[0].innerHTML = '';
  496. var _value = r.value,
  497. _el = $('#U_MD_O_H_body_left_invite_history')[0]
  498. for (var i = 0; i < _value.length; i++) {
  499. _el.appendChild(U.MD.O.W.Panel.createHis(_value[i]))
  500. }
  501. }
  502. /**
  503. * 添加详细历史记录布局
  504. *
  505. * @param {object} data 数据
  506. */
  507. U.MD.O.W.Panel.createHis = function (data) {
  508. var _hisel, _imgel, _infoel, _textel, _btnel;
  509. _hisel = $$('div', { style: { cssText: 'min-height: 85px; border-bottom: 1px solid silver; margin: 0 3px'} });
  510. _imgel = $$('div', { style: { margin: '22px 12px 0', float: 'left'} }, _hisel);
  511. $$('img', { "onerror": U.MD.C.imgError, style: { cssText: 'width:40px; height: 40px;' }, src: top.U.MD.C.getHeadImage(data.UserThumbnailImageHead) }, _imgel);
  512. _infoel = $$('div', { style: { cssText: 'margin-left: 62px;'} }, _hisel);
  513. _textel = $$('div', { style: { 'padding-top': '25px', 'white-space': 'nowrap'} }, _infoel);
  514. $$('span', { innerText: data.UserName }, _textel);
  515. $$('span', { innerText: U.UF.D.getDateInterval(data.CreateTime) + '保存一次', style: { 'padding-left': '10px'} }, _textel);
  516. _btnel = $$('div', { style: { 'margin-top': '10px', 'white-space': 'nowrap'} }, _infoel);
  517. //判断是否是自己编辑历史记录,是则不打印对话
  518. if (data.UserId != U.MD.O.W.userinfo.UserId) {
  519. $$('button', { innerText: '对话', style: { cssText: 'color: #fff; background-color:#6d81a4; border-radius: 4px; border:none; outline:none; padding: 4px 8px; cursor: pointer;' }, onclick: function () {
  520. //这里有问题,这样获取不一定能获取用户数据,同时数据没有分离
  521. var _friendel = U.Json.select(US.friend.friends, { UserId: data.UserId });
  522. //如果未添加好友,则弹出添加好友框,否则直接弹出聊天窗口
  523. if (_friendel.length == 0) {
  524. top.U.MD.U.V.ViewOtherUserInfo(data.UserId);
  525. } else {
  526. _data = !_friendel.length ? U.Json.select(US.friend.recentcontacts, { UserId: data.UserId }) : _friendel;
  527. top.U.MD.F.W.popupFriendsForm(_data[0], this);
  528. }
  529. }
  530. }, _btnel);
  531. }
  532. $$('button', { innerText: '详细', style: { cssText: 'color: #fff; background-color:#6d81a4; border-radius: 4px; border:none; outline:none; padding: 4px 8px; margin-left: 4px;cursor: pointer;' },
  533. onclick: function () {
  534. U.MD.O.W.Panel.EditHistory(data)
  535. }
  536. }, _btnel);
  537. //返回最外的元素
  538. return _hisel
  539. }
  540. /**
  541. * 插入历史
  542. *
  543. * @param _fileinfo {string} 文件信息
  544. * @param {string} 历史记录内容
  545. *
  546. */
  547. U.MD.O.W.Panel.InsertOfficeHistory = function (fileinfo, html, name, contentel) {
  548. var _fileid = fileinfo.UserDirectoryID; //文件ID
  549. if (U.MD.O.W.permission.web) {
  550. //html,
  551. top.U.A.Request(US.SCOKET, ["insertModifyRecord", "word", _fileid, name, html, US.userInfo.UserId, US.pageId], function (r) {
  552. if (r.value) {
  553. var _historyid = r.value;
  554. U.MD.O.W.Panel.syncHistory(US.userInfo.UserId, _historyid);
  555. U.MD.O.W.fileinfo.UsOffice = contentel.innerHTML;
  556. U.Alert("保存成功");
  557. } else {
  558. U.Alert("系统有误,请稍后重试..");
  559. }
  560. });
  561. } else {
  562. //插入历史
  563. U.A.Request(US.CD, [US.DB, "UseStudio_Office", "InsertDocumentModifyRecord", US.userInfo.UserId, _fileid, html, name], function (r) {
  564. if (r.value[0]) {
  565. U.MD.O.W.Panel.syncHistory(US.userInfo.UserId, r.value[0].historyid);
  566. U.MD.O.W.fileinfo.UsOffice = contentel.innerHTML;
  567. U.Alert("保存成功");
  568. } else {
  569. U.Alert("系统有误,请稍后重试..");
  570. }
  571. });
  572. }
  573. }
  574. U.MD.O.W.Panel.syncHistory = function (userid, historyid, isbool) {
  575. if (!isbool) {
  576. var _data, _fileinfo = U.MD.O.W.fileinfo;
  577. _fileinfo.HistoryId = historyid; //记录历史ID
  578. if (userid == US.userInfo.UserId) {
  579. _data = U.MD.O.W.dataStructure(_fileinfo.UserDirectoryModifyTime, US.userInfo.UserName, US.userInfo.UserThumbnailImageHead, historyid, US.userInfo.UserId);
  580. } else {
  581. var _userinfo = U.Json.select(US.friend.groupusers, { UserId: userid })[0];
  582. _data = U.MD.O.W.dataStructure(_fileinfo.UserDirectoryModifyTime, _userinfo.UserName, _userinfo.UserThumbnailImageHead, historyid, _userinfo);
  583. }
  584. var _el = U.MD.O.W.Panel.createHis(_data), //创建历史记录
  585. _addel = $('#U_MD_O_H_body_left_invite_history')[0]; //历史记录区域
  586. $(_el).appendTo(_addel, 0, _addel.firstElementChild); //置顶插入
  587. }
  588. }
  589. /**
  590. * 历史数据结构
  591. *
  592. * @param creattime {string} 创建时间
  593. * @param username {string} 用户名
  594. * @param userbgimg {string} 用户头像
  595. * @param historyid {string} 历史ID
  596. * @param userid {string} 用户ID
  597. *
  598. */
  599. U.MD.O.W.dataStructure = function (creattime, username, userbgimg, historyid, userid) {
  600. return {
  601. CreateTime: creattime || U.UF.D.toTimeStamp(new Date()), //创建时间
  602. UserName: username, //用户名
  603. UserThumbnailImageHead: userbgimg, //用户头像
  604. HistoryId: historyid, //历史ID
  605. UserId: userid //用户ID
  606. }
  607. }
  608. /**
  609. * 添加详细历史记录
  610. *
  611. * @param {element} e 子元素
  612. * @param {element} el 父亲元素
  613. * @param {object} data 数据
  614. */
  615. U.MD.O.W.Panel.AddDetailedHis = function (e, el, data) {
  616. var _conEl = e.lastElementChild,
  617. _hisInfoDate = $$('span', {
  618. innerText: U.UF.D.getDateInterval(new Date(parseInt(data.CreateTime.replace(/[^0-9]/ig, "")))) + '修改了一次',
  619. style: { 'padding-left': '10px' }
  620. }, _conEl.firstElementChild),
  621. _conText = $$('div', { innerHTML: data.OfficeContent }, _conEl)
  622. el.appendChild(e);
  623. }
  624. /**
  625. * 编辑历史弹出全部
  626. *
  627. */
  628. U.MD.O.W.Panel.EditHistoryc = function (UDE) {//此参数为历史记录的信息
  629. var _el = $$("div"),
  630. // _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);
  631. _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);
  632. var i, _UDBD, _UDTD, _UDSD;
  633. for (var a = 0; a < UDE.length; a++) {//循环历史记录的长度 用来显示多个历史记录在"显示按钮"的打开的窗体上
  634. _UDBD = $$("div", { "className": "U_MD_O_W_History_all", "id": UDE[a].HistoryId + "-" + a }, _el);
  635. _UDTD = $$("div", { "className": "U_MD_O_W_History_Head" }, _UDBD);
  636. _UDBB = $$("div", {
  637. "className": "U_MD_O_H_body_btn",
  638. "innerHTML": "展开",
  639. "onclick": U.MD.O.W.Panel.btn
  640. },
  641. _UDBD);
  642. $$("div", { "className": "U_MD_O_H_body_btn_img1" }, _UDBB);
  643. $$("img",
  644. {
  645. "src": U.MD.C.getHeadImage(UDE[a].UserThumbnailImageHead),
  646. "onerror": U.MD.C.imgError,
  647. "alt": UDE[a].UserName,
  648. "title": UDE[a].UserName
  649. },
  650. _UDTD);
  651. $$("div", { "innerHTML": (UDE[a].UserNickName) + " " + U.UF.D.getDateInterval(UDE[a].CreateTime) + " 更改了以下内容" }, _UDTD);
  652. $$("div", { "className": "U_MD_O_H_body_right_user_o_r_all_nr", "innerHTML": UDE[a].OfficeContent }, _UDTD);
  653. }
  654. }
  655. /**
  656. * 点击显示全部
  657. *
  658. */
  659. U.MD.O.W.Panel.EditHistoryonc = function () {
  660. var _wordinfo = U.MD.O.W; //word全局变量 包含了uw文件的文件信息 等
  661. var _fileinfo = _wordinfo["fileinfo"]; //uw文件的文件信息
  662. var _fileid = _fileinfo.UserDirectoryID;
  663. var UDOD = $("#U_MD_O_H_body_left_invite_history")[0]; //历史记录框
  664. U.A.Request(US.CD, [US.DB, "UseStudio_Office", "SelectOfficeHistory", _fileid, "00000000-0000-0000-0000-000000000000", 1, 10], U.MD.O.W.Panel.OnDisplayD, [null, UDOD]); //
  665. }
  666. /**
  667. * 更新历史弹出全部
  668. *
  669. */
  670. U.MD.O.W.Panel.OnDisplayD = function (r) {
  671. if ($(".U_MD_O_H_body_right_user_o_r_all")) {//如果存在则删除
  672. $(".U_MD_O_H_body_right_user_o_r_all").remove();
  673. }
  674. divall = $$("div", { "className": "U_MD_O_H_body_right_user_o_r_all" }, r.context[1].parentNode.parentNode);
  675. $$("div",
  676. {
  677. "className": "U_MD_O_H_body_right_user_o_r_all_a",
  678. "innerHTML": "显示全部",
  679. "onclick": [U.MD.O.W.Panel.EditHistoryonc]
  680. },
  681. divall);
  682. U.MD.O.W.Panel.EditHistoryc(r.value);
  683. }
  684. /**
  685. * 编辑历史的展开与关闭
  686. *
  687. */
  688. U.MD.O.W.Panel.btn = function () {//编辑历史记录底端的显示全部的展开与关闭
  689. if (this.parentNode.children[0].lastChild.children[0].scrollHeight > 100) {//根据内容的高度来判断
  690. if (this.innerText == "展开") {
  691. this.innerHTML = "收起<div class='U_MD_O_H_body_btn_img2'></div>";
  692. this.parentNode.style.cssText = "height:100%;min-height:100px;overflow:visible;float:left;width:95%;"
  693. this.style.cssText = "margin-right:-7px;"
  694. }
  695. else if (this.innerText == "收起") {
  696. this.innerHTML = "展开<div class='U_MD_O_H_body_btn_img1'></div>";
  697. this.parentNode.style.cssText = "height:100px;overflow:hidden;float:none;width:none";
  698. this.style.cssText = "margin-right: 0px; "
  699. }
  700. } else {
  701. if (this.innerText == "展开") {
  702. this.innerHTML = "收起<div class='U_MD_O_H_body_btn_img2'></div>";
  703. this.parentNode.style.cssText = "height:100%;min-height:100px;overflow:visible;float:left;width:95%;"
  704. this.style.cssText = "margin-right:-7px;"
  705. }
  706. else if (this.innerText == "收起") {
  707. this.innerHTML = "展开<div class='U_MD_O_H_body_btn_img1'></div>";
  708. this.parentNode.style.cssText = "height:100px;overflow:hidden;";
  709. this.style.cssText = "margin-right: 0px;"
  710. }
  711. }
  712. }
  713. /**
  714. * 编辑历史弹出
  715. *
  716. */
  717. U.MD.O.W.Panel.EditHistory = function (UDE) {//此参数为历史记录的信息
  718. var _el = $$("div", { style: { cssText: "padding: 0 10px;"} }),
  719. _UCT = new U.UF.UI.form("历史记录", _el, { id: "Bjls", style: { width: "680px", height: "550px", overflow: "hidden", 'box-shadow': 'rgb(180, 180, 180) 1px 1px 5px 2px', 'border-radius': '0', 'border': 'none'} }, { isdrag: false, isenlarge: false, isnarrow: false }, { style: { 'background-color': '#3c475b', 'padding': '4px'} });
  720. if (UDE.OfficeContent == undefined) {
  721. U.A.Request(US.CD, [US.DB, "Usestudio_Office", "SelectHistoryDetails", UDE.HistoryId], function (r) {
  722. UDE.OfficeContent = r.value[0].OfficeContent.unEscapeQuotes().unEscapeQuotes();
  723. U.MD.O.W.Panel.AsynEditHistory(UDE, _el);
  724. }, [_el]);
  725. } else {
  726. U.MD.O.W.Panel.AsynEditHistory(UDE, _el);
  727. }
  728. }
  729. /**
  730. * 编辑历史弹出异步
  731. *
  732. */
  733. U.MD.O.W.Panel.AsynEditHistory = function (docinfo, element) {
  734. var _UDBD = $$("div", { "class": "U_MD_O_W_History" }, element);
  735. var _UDTD = $$("div", { "class": "U_MD_O_W_History_Head" }, element);
  736. $$("img",
  737. {
  738. "onerror": U.MD.C.imgError,
  739. "src": (top.U.MD.C.getHeadImage(docinfo.UserThumbnailImageHead) || 'http://www.1473.cn/img/UserHead/UseHead.jpg'),
  740. "alt": docinfo.UserNickName || docinfo.UserName,
  741. "title": docinfo.UserNickName || docinfo.UserName
  742. },
  743. _UDTD);
  744. $$("div", { "innerHTML": (docinfo.UserNickName || docinfo.UserName) + " " + U.UF.D.getDateInterval(docinfo.CreateTime || new Date()) + " 更改了以下内容", style: { cssText: "display: inline-block; margin-left:10px"} }, _UDTD);
  745. $$("div", { "className": "U_MD_O_H_body_right_user_o_r_nr", "innerHTML": docinfo.OfficeContent }, _UDTD);
  746. }
  747. //#endregion