123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427 |
- Namespace.register("U.MD.O.W.SP");
- U.MD.O.W.SP.FILEINFO = null;
- window.onload = function () {
-
- U.UF.CD.loadPageCrossDomain(function () {
- });
-
- U.MD.O.W.SP.sitePreviewInit();
- U.MD.O.W.SP.LoadDiskDate();
- if (window.location.hash) {
- $(".U_MD_O_W_SP_Fixed_dnReset")[0].style.display = "block";
- } else {
- $(".U_MD_O_W_SP_Fixed_dnReset")[0].style.display = "none";
- $('.U_MD_O_W_SP_ToolsBar')[0].style.display = "block";
- }
- }
- U.MD.O.W.SP.sitePreviewInit = function () {
- var _pathname = window.location.pathname,
- _domename = U.UF.C.queryString("fid") || _pathname.split("/")[1];
-
- if (_domename) {
- U.A.Request("http://cd.1473.cn/php", ["db.1473.cn", "UseStudio_DNS", "GetFileIdToDomain", _domename], function (r) {
- var _value = r.value
- U.MD.O.W.SP.uwOpen(_value[0].FileId);
- U.MD.O.W.SP.initReply();
-
-
-
-
- });
- }
- }
- U.MD.O.W.SP.uwOpen = function (fileid) {
-
- U.A.Request(US.CD, [US.DB, "UseStudio_Disk", "GetFileById", fileid], function (r) {
- r = r.value;
- console.log(r[0].UsOffice);
- if (r[0]) {
-
- U.MD.O.W.SP.FILEINFO = r[0];
-
- if (r[0].UsOffice !== undefined && r[0].UsOffice != null) {
- U.MD.O.W.SP.uwOpen.asyn(r[0]);
- }
-
- else if (['doc', 'docx'].indexOf(r[0].UserFilesExtendName.toLocaleLowerCase()) > -1) {
-
- U.A.Request("http://office.1473.cn/Officetohtml.ashx", ["Open", r[0].UserFilesExtendName, r[0].UserFilesServerName], function (r) {
- var _fileinfo = r.context[1];
- if (r.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.SP.uwOpen.asyn(_fileinfo);
- }
- else {
- U.Alert("文档已丢失。。。");
- }
- }, [null, r[0]]);
- }
- else {
- U.Alert("该文件无法打开");
- }
- }
- else {
- U.Alert("文档已丢失。。。");
- }
- });
- }
- U.MD.O.W.SP.uwOpen.asyn = function (fileinfo) {
-
- if (!fileinfo.UsOffice && typeof (fileinfo.UsOffice) != "undefined" && fileinfo.UsOffice != 0) {
- fileinfo.UsOffice = " ";
- }
-
- if (fileinfo.UserFilesExtendName.toLowerCase() == 'un') {
- $('body').addClass('U_MD_O_W_SP_Nav');
- $('.U_MD_O_W_SP_Head_Main_Logo span')[0].innerText = fileinfo.UserFilesName;
- U.MD.O.W.SP.modelDataCreate(fileinfo);
- }
-
- else {
- $('.U_MD_O_W_SP_Head')[0].style.display = 'block';
- $('.U_MD_O_W_SP_Tool')[0].style.display = 'block';
- $("#U_MD_O_W_SP_Editor")[0].innerHTML = fileinfo.UsOffice.unEscapeQuotes();
- var _len = $("#U_MD_O_W_SP_Editor")[0].childNodes[0].children.length;
- for (var i = 0; i < _len; i++) {
- if ($("#U_MD_O_W_SP_Editor")[0].childNodes[0].children[i].innerText === "?") {
- $("#U_MD_O_W_SP_Editor")[0].childNodes[0].children[i].innerText = '';
- }
- else if ($("#U_MD_O_W_SP_Editor")[0].childNodes[0].children[i].innerText === " ") {
- $("#U_MD_O_W_SP_Editor")[0].childNodes[0].children[i].innerText = '';
- }
- }
- $(".U_MD_O_W_SP_Title")[0].innerText = fileinfo.UserFilesName;
- U.MD.O.W.SP.bindInit(fileinfo);
- }
- $$("meta", { name: "title", content: fileinfo.UserFilesName }, $('head')[0]);
- U.MD.O.W.SP.backTop();
- $('.U_MD_O_W_SP_ToolsBar')[0].onclick = function () {
- U.MD.O.W.SP.isLogin(fileinfo);
- }
- $('#U_MD_O_W_SP_Editor').bind('click', function (event) { U.MD.O.W.SP.pictureClick(event) });
- $('.U_MD_O_W_SP_Content').bind('mousedown', U.UF.EV.stopBubble);
- }
- U.MD.O.W.SP.eidtor = function (fileinfo) {
- if (US.userInfo.userid == fileinfo.UserID || (Guid.IsGuid(fileinfo.UserDirectoryEncrypt) && U.Json.select(US.friend.group, { GroupManageID: fileinfo.UserDirectoryEncrypt })[0])) {
- var _fileinfo = {
- UserId: fileinfo.UserID,
- GroupID: fileinfo.UserDirectoryEncrypt,
- UserDirectoryID: fileinfo.UserFilesID,
- UserallDirectoryName: fileinfo.UserFilesName,
- UserDirectoryExtendType: fileinfo.UserFilesExtendName
- }
- U.MD.O.word(US.userInfo, _fileinfo);
- } else {
- U.Alert("无编辑权限");
- }
- }
- U.MD.O.W.SP.isLogin = function (fileinfo) {
- if (!US.userInfo.userid) {
- U.MD.U.L.login(function () { U.MD.O.W.SP.eidtor(fileinfo) });
- } else {
- U.MD.O.W.SP.eidtor(fileinfo)
- }
- }
- U.MD.O.W.SP.modelDataCreate = function (fileinfo) {
- var _li, data = JSON.parse(fileinfo.UsOffice);
- for (var i = 0; i < data.nav.length; i++) {
- _li = i == 0 ? $$("li", { innerHTML: data.nav[i].name, className: 'DataLi_active' }, $(".U_MD_O_W_SP_Header_DataUl")[0]) : $$("li", { innerHTML: data.nav[i].name }, $(".U_MD_O_W_SP_Header_DataUl")[0]);
-
- _li.onclick = U.UF.C.closure(function (i) {
-
- U.A.Request(US.CD, [US.DB, "UseStudio_Office", "GetNavPageContent", data.nav[i].pageId], function (r) {
- var _el = $('#U_MD_O_W_SP_Editor')[0],
- _listLi = $('.U_MD_O_W_SP_Header_DataUl').find('.DataLi_active');
-
- if (_listLi.length) {
- (_listLi[0].className = '');
- }
- $('.U_MD_O_W_SP_Header_DataUl').find('li')[i].className = 'DataLi_active';
- _el.innerHTML = r.value[0].content.unEscapeQuotes();
- });
- }, [i]);
-
- if (i == 0) {
- _li.click();
- }
- }
- }
- U.MD.O.W.SP.bindInit = function (fileinfo) {
- var _shareEl = $('#U_MD_O_W_SP_Tool_ShareBtn')[0],
- _saveEl = $('#U_MD_O_W_SP_Tool_SaveBtn')[0],
- _showShareEl = U.MD.O.W.SP.shareFile(fileinfo, _shareEl),
- _winWidth;
- _saveEl.onclick = function () {
- U.MD.O.W.SP.saveSpecifiedFolder(fileinfo);
- }
- }
- U.MD.O.W.SP.backTop = function () {
- var _container = $('.U_MD_O_W_SP_ToolsBar_Container'),
- _topEl = $('.U_MD_O_W_SP_Top_Icon')[0],
- _winScrollTop, _clientheight;
- window.onscroll = function () {
- _winScrollTop = document.documentElement.scrollTop;
- _clientheight = document.documentElement.clientHeight;
- if (_winScrollTop >= 100) {
- if (_topEl.style.display == 'none')
- _topEl.style.display = 'block';
-
- } else if (_winScrollTop < 100 && _topEl.style.display == 'block') {
- _topEl.style.display = 'none';
- }
- if (_clientheight + _winScrollTop >= _container[0].offsetTop + _container[1].offsetHeight) {
-
- _container.css('position', 'fixed', 1);
- } else {
- _container.css('position', 'fixed', 1);
- }
- }
- window.onscroll();
-
-
- _topEl.onclick = function () {
- U.MD.O.W.SP.topAnimate(document.documentElement, 0)
- }
- }
- U.MD.O.W.SP.topAnimate = function (ele, target) {
- clearInterval(ele.timer);
- ele.timer = setInterval(function () {
-
- var step = (target - ele.scrollTop) / 10;
-
- step = step > 0 ? Math.ceil(step) : Math.floor(step);
-
- ele.scrollTop = ele.scrollTop + step;
-
- if (Math.abs(target - ele.scrollTop) <= Math.abs(step)) {
- ele.scrollTop = target;
- clearInterval(ele.timer);
- }
- }, 16);
- }
- U.MD.O.W.SP.shareFile = function (fileinfo, parentel) {
- var _content = $$('div', { className: "U_MD_O_W_SP_ShareBox" }),
- _shareTitle = $$('div', { className: "U_MD_O_W_SP_ShareTitle" }, _content),
- _shareBorder = $$('div', { className: "U_MD_O_W_SP_ShareBorder" }, _content),
- _wechat = $$('div', { className: "shareBlock" }, _content),
- _qq = _wechat.cloneNode(),
- _xin = _wechat.cloneNode();
- $$('span', { innerText: "分享" }, _shareTitle);
- $$('img', { src: "/img/xinlangRed.png", style: { width: '24px'} }, _xin);
- $$('img', { src: "/img/qq.png", style: { width: '24px'} }, _qq);
- $$('img', { src: "/img/wechat.png", style: { width: '24px'} }, _wechat);
- $$('div', { innerText: "新浪微博" }, _xin);
- $$('div', { innerText: "微信好友" }, _wechat);
- $$('div', { innerText: "QQ好友" }, _qq);
- $$('div', { className: "U_MD_O_W_SP_ShareBorder" }, _content);
- _wechat.className += " U_MD_O_W_SP_WeChat";
- _content.appendChild(_qq);
- $$('div', { className: "U_MD_O_W_SP_ShareBorder" }, _content);
- _content.appendChild(_xin);
- _qq.onclick = function () {
- var _title = "这个文档超赞的,赶快分享给大家吧!【" + fileinfo.Username + "--分享自-互联办公】";
- U.UF.OT.qqFriendShare('', _title);
- }
- _xin.onclick = function () {
- var _title = "这个文档超赞的,赶快分享给大家吧!【" + fileinfo.Username + "--分享自-互联办公】";
- U.UF.OT.weiboShare('', _title);
- }
- U.UF.OT.weChatShareCode(_wechat);
- parentel.appendChild(_content);
- return _content;
- }
- U.MD.O.W.SP.saveSpecifiedFolder = function () {
- var _loginChecked = U.MD.U.L.isLogin();
- if (!_loginChecked) {
- var _form = !Object.getOwnPropertyNames(US.disk.Disks).length && U.MD.DK.initDisk(US.userInfo.userid, 'f6d7a4b6-e34c-4964-beed-24187b2cb1ba');
- _form && (_form.style.display = 'none');
- if (Object.getOwnPropertyNames(US.disk.Disks).length) {
- var _guid = Guid.newGuid();
- U.MD.DK.VW.chosenSaveFile(U.MD.O.W.SP.FILEINFO.UserFilesExtendName.toLowerCase(), _guid, U.MD.O.W.SP.FILEINFO.UserFilesName, function (fileinfo) {
- var _fileInfo = fileinfo;
- U.A.Request(US.CD, [US.DB, "UseStudio_Disk", "SaveFileContent", fileinfo.UserDirectoryID, U.MD.O.W.SP.FILEINFO.UsOffice, fileinfo.UserallDirectoryname || U.MD.O.W.SP.FILEINFO.UserFilesName], function (r) {
- var _foldername = '';
- for (var i = 0; i < US.disk.initTree.length; i++) {
- if (US.disk.initTree[i][0] == _fileInfo.UserDirectoryParentID) {
- _foldername = US.disk.initTree[i][4];
- break;
- }
- }
- if (r.value) {
- U.Alert("以保存到云盘【" + _foldername + "】目录下!");
- } else {
- U.Alert("文档保存失败!")
- }
- });
- });
- } else {
- U.alert('数据加载中...');
- }
- } else {
- U.alert('登录失败!');
- };
- }
- U.MD.O.W.SP.initReply = function () {
- var _el = $(".U_MD_O_W_SP_Reply")[0];
- U.MD.R.reply({ 'type': true, 'el': _el, 'pid': "36341f7e-77a9-11e8-b499-005056b350a4" });
- }
- U.MD.O.W.SP.pictureClick = function (event) {
- var _nowel = event.target;
-
- if (_nowel.tagName.toLocaleLowerCase() == "img") {
- var _mark;
- var _arr = [];
- var _imgels = $('#U_MD_O_W_SP_Editor img');
- for (i = 0; i < _imgels.length; i++) {
- _arr.push(_imgels[i].src);
- if (_imgels[i] == _nowel) {
- _mark = i;
- }
- }
- U.MD.UI.picture(_arr, _mark);
- }
- }
- U.MD.O.W.SP.dnReset = function (el) {
- var _wordinfo = U.MD.O.W.SP.FILEINFO;
- var _type = U.MD.O.W.SP.FILEINFO.UserFilesExtendName == 'uw' ? 'word' : 'word';
- if (el == "cancel") {
- $(".U_MD_O_W_SP_Fixed_dnReset")[0].style.display = "none";
-
- } else {
- if ($('#U_MD_DM_B_Manage_Pop')[0]) {
- $('#U_MD_DM_B_Manage_Pop')[0].style.display = "block";
- } else {
- if (US.userInfo.userid) {
- top.U.MD.DS.dnsInit(_wordinfo, _type);
- } else {
- U.MD.O.W.SP.LoadDiskDate();
- }
- }
- }
-
- if ($(".U_MD_O_W_SP_Fixed_dnReset")[0].style.display == "none") {
- $('.U_MD_O_W_SP_ToolsBar')[0].style.display = "block";
- }else {
- $('.U_MD_O_W_SP_ToolsBar')[0].style.display = "none";
- }
- }
- U.MD.O.W.SP.LoadDiskDate = function () {
- if (JSON.stringify(US.disk.Disks) === '{}') {
- U.MD.U.L.login(function () {
- var _form = U.MD.DK.initDisk(US.userInfo.userid, "f6d7a4b6-e34c-4964-beed-24187b2cb1ba");
- setTimeout(function () {
- _form.style.display = 'none';
- }, 0);
- });
- }
- $('#U_D_' + US.userInfo.userid).length && ($('#U_D_' + US.userInfo.userid)[0].style.display = 'none');
- }
|