PHPIndex

This page lists files in the current directory. You can view content, get download/execute commands for Wget, Curl, or PowerShell, or filter the list using wildcards (e.g., `*.sh`).

exceljs
luckysheet
mammothjs
pptxjs
sheetjs
page.css
wget 'https://sme10.lists2.roe3.org/kodbox/plugins/officeViewer/static/weboffice/page.css'
View Content
/* 错误提示页 */
.weboffice-page #msgbox{box-shadow: 0px 10px 40px rgba(0, 0, 0, 0.1);border-radius: 5px;border-radius: 5px;background: #fff;
        font-family: "Lantinghei SC","Hiragino Sans GB","Microsoft Yahei",Helvetica,arial,sans-serif;line-height: 1.5em;
        color:888;margin:0 auto;margin-top: 10%; margin-bottom: 10%; width:500px;font-size:13px;color:#666;word-wrap: break-word;word-break: break-all;max-width: 90%;box-sizing: border-box;max-height: 90%;overflow: auto;padding:30px 30px;}
        .weboffice-page #msgbox #info {margin-top: 10px; color: #aaa;}
        .weboffice-page #msgbox #title {color: #333; border-bottom: 1px solid #eee; padding: 10px 0; margin: 0 0 15px; font-size: 20px; font-weight:200;}
        .weboffice-page #msgbox #info a {color: #64b8fb; text-decoration: none; padding: 2px 0px; border-bottom: 1px solid;}
        .weboffice-page #msgbox a {text-decoration: none; color: #2196F3;}
        .weboffice-page #msgbox a:hover {color: #f60; border-bottom: 1px solid}
        .weboffice-page #msgbox .desc {padding: 10px 0; color: #faad14; }
        .weboffice-page #msgbox pre {word-break: break-all; word-wrap: break-word; white-space: pre-wrap; 
    background: #002b36; padding: 1em; color: #839496; border-left: 6px solid #8e8e8e; border-radius: 3px;}

/* 文档页 */
body.weboffice-page {background: #f6f6f6; margin: 8px 0px;}
body.weboffice-page.yz {background: #ebebeb; overflow: hidden;}
body.weboffice-page .page-box{background: #fff;}
body.weboffice-page .page-box.kod-pptxjs-box .slide::after{z-index: 1000000 !important;}
body.weboffice-page .page-box #output>iframe {
    position: absolute; 
    width: 100vw;
    /* height: 100vh; */
    /* pdf顶部菜单也是32px */
    height: calc(100vh + 32px);
}
/* body.weboffice-page.yz .page-box #output>iframe {
    height: calc(100vh + 32px);
} */
body.weboffice-page.lb .page-box #output>iframe {
    top: -32px
}
body.weboffice-page.ol .page-box #output>iframe {
    height: calc(100vh - 8px);
}
body.weboffice-page.ol .page-box.xls #output::after, 
body.weboffice-page.ol .page-box.xlsx #output::after {
    content: '';
    position: absolute;
    left: 0px;
    /* left: 30px; */
    right: 0px;
    bottom: 0px;
    height: 26px;
    background: #f5f5f5;
    border-top: 1px solid #ddd;
}
body.weboffice-page.ol.loaded .page-box.ppt #output::before, 
body.weboffice-page.ol.loaded .page-box.pptx #output::before,
body.weboffice-page.ol.loaded .page-box.ppt #output::after, 
body.weboffice-page.ol.loaded .page-box.pptx #output::after {
    content: '';
    position: absolute;
    /* right: 44px;
    width: 46px; */
    right: 2px;
    width: 100px;
    height: 22px;
    bottom: 1px;
    background: #444;
    border-top: 1px solid #555;
}
body.weboffice-page.ol.loaded .page-box.ppt #output::before, 
body.weboffice-page.ol.loaded .page-box.pptx #output::before {
    left: 2px;
    width: 100px;
    z-index: 9;
}
body.weboffice-page.loaded .page-box.kod-luckysheet-box #output::after, 
body.weboffice-page.loaded .page-box.kod-pptxjs-box #output::after {
    /* content: 'xxx'; */
    content: attr(data-content);
    position: absolute;
    bottom: 5px;
    font-size: 0.85em;
    left: 50%;
    transform: translateX(-50%);
    bottom: 3px;
    /* color: #f77714;
    background: #fff3cf;
    color: #c17500; */
    padding: 3px 10px;
    border-radius: 4px;
    /* width: max-content; */
    text-align: center;
    z-index: 9999;
	font-size:12px;min-width: 350px;
    color: #888;background: #f6f6f6;
    opacity: 0.9;white-space: nowrap;
}
/* body.weboffice-page.loaded .page-box.kod-luckysheet-box #output.tip-hide::after, 
body.weboffice-page.loaded .page-box.kod-pptxjs-box #output.tip-hide::after {
    opacity: 0;
} */

.weboffice-page .hidden {display: none;}
.weboffice-page .loading-msg .loading-msg-content .loading-msg-title{font-size: 14px;}

.weboffice-page>.edit-btn {
    position: fixed;
    right: 20px;
    z-index: 999;

    bottom: 60px;
    right: 40px;
    display: none;
}
.weboffice-page.edit-mode.loaded>.edit-btn {
    display: block;
}
.weboffice-page>.edit-btn.lky {
    right: 18px;
    top: 3px;
}
.weboffice-page>.edit-btn button {
    font-size: 12px;
    color: #666;
    cursor: pointer;
    background-color: #fff;
    border-radius: 4px;

    width: 55px;
    height: 55px;
    border-radius: 100%;
    border: none;
    box-shadow: 0 5px 20px rgb(0 0 0 / 15%);
}
.weboffice-page>.edit-btn.lky button {
    border-color: #7ec1ff;
    color: #7ec1ff;
}
.weboffice-page>.edit-btn button:hover,
.weboffice-page>.edit-btn button:focus,
.weboffice-page>.edit-btn button:active {
    background-color: #f9f9f9;
    box-shadow: 0 5px 20px rgb(0 0 0 / 20%);
}
.weboffice-page>.edit-btn button i {
    vertical-align: text-top;
}

/* iframe下的 loading 框 */
.loading-msg {
    position: absolute;
    left: 0px;
    top: 0px;
    right: 0px;
    bottom: 0px;
    z-index: 9999;
    color: #666;
    text-align: center;
    pointer-events: none
}
.loading-msg .loading-msg-content {
    position: absolute;
    width: 100px;
    padding-bottom: 10px;
    cursor: progress;
    left: 50%;
    top: 50%;
    margin: -50px 0 0 -50px;
    border-radius: 6px;
    background: rgba(255,255,255,0.7);
    box-shadow: 2px 4px 10px rgba(0,0,0,0.07)
}
.loading-msg .loading-msg-content .loading-msg-box {
    font-size: 30px;
    margin: 25px auto 6px auto
}
.loading-msg .loading-msg-content .loading-msg-box img {
    max-height: 32px;
    max-width: 32px;
    opacity: .8;
    border-radius: 4px
}
.loading-msg .loading-msg-content .loading-msg-box .loader {
    display: none
}
.loading-msg .loading-msg-content .loading-msg-title {
    padding: 2px 4px;
    color: #888;
    min-height: 10px;
    word-break: break-word
}
.loading-msg .loading-mask {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    background: #fff;
    -ms-transition: all .2s;
    -webkit-transition: all .2s;
    -moz-transition: all .2s;
    -o-transition: all .2s;
    transition: all .2s
}
.loading-msg.tips-small .loading-msg-content {
    background: none;
    box-shadow: none;
    width: 20px;
    height: 20px;
    padding: 0;
    margin: -10px 0 0 -10px
}
.loading-msg.tips-small .loading-msg-content .loading-msg-box {
    margin: 0;
    height: 18px;
    line-height: 14px
}
.loading-msg.tips-small .loading-msg-content .loading-msg-box img {
    width: 18px;
    height: 18px
}
.loading-msg.tips-small .loading-msg-content .loading-msg-title {
    display: none
}
page.js
wget 'https://sme10.lists2.roe3.org/kodbox/plugins/officeViewer/static/weboffice/page.js'
View Content
var page = {
    // 读取二进制流文件内容,转换成html
    getFileInfo: function(callback){
        var tipsLoading = Tips.loadingMask(false,kodSdkConfig.LNG['explorer.wordLoading'],0.5);
        var xhr = new XMLHttpRequest();
        xhr.timeout = 1000*30;  // 超时时间
        xhr.open('GET', FILE_INFO.link);
        xhr.responseType = "arraybuffer";
        xhr.addEventListener("progress", function (evt) {   //监听进度事件
            if (evt.lengthComputable) {
                var percent = evt.loaded / evt.total;
                var title = percent == 1 ? kodSdkConfig.LNG['officeViewer.webOffice.parsing'] : Math.round(percent*100)+'%';
                tipsLoading.title(title);
            }
        }, false);
        xhr.onload = function (e) {
            // var data = new Uint8Array(xhr.response);
            var data = xhr.response;
            if(!data){tipsLoading.close();tipsLoading = false;return;};
            var file = {name: FILE_INFO.name, ext: FILE_INFO.ext, content: data};
            callback(file, tipsLoading);
        };
        xhr.send();

        var self = this;
        xhr.onreadystatechange = function(){    // 请求状态
            if(xhr.readyState==4){
                if (xhr.status < 200 || (xhr.status > 300 && xhr.status != 304)) {
                    tipsLoading.close();tipsLoading = false;
                    self.showTips(kodSdkConfig.LNG['officeViewer.webOffice.reqErrPath']);
                }
            }
        };
        xhr.ontimeout = function() {
            self.showTips(kodSdkConfig.LNG['officeViewer.webOffice.reqErrNet']);
        }
    },
    // 错误提示
    showTips: function(msg){
        $("#msgbox #message").html(msg);
        $("#msgbox").removeClass('hidden');
        $(".page-box").addClass('hidden');
        // $("body").addClass('page-loaded');
    },
    // 设置用wb预览时的提示信息
    wbAlert: function(){
        var $dom = $('body.weboffice-page.loaded');
        if (!arguments[0]) $dom = $dom.find('#output');
        if (!$dom.length) return;
        $dom.attr("data-content", kodSdkConfig.LNG['officeViewer.webOffice.warning']);
        // // 10s关闭提示
        // _.delay(function(){
        //     // $dom.attr("data-content", '');
        //     // $dom.removeClass('active');
        //     $dom.addClass('tip-hide');
        // }, 10000);
    }
}
template.html
wget 'https://sme10.lists2.roe3.org/kodbox/plugins/officeViewer/static/weboffice/template.html'
View Content
<!doctype html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
	<meta name="apple-mobile-web-app-capable" content="yes"/>
	<title><?php echo clear_html($fileName);?></title>
	<link rel="icon" href="<?php $this->url('static/images/icon.png');?>">
	<script>var kodSdkConfig = {api:'<?php echo APP_HOST;?>', lang: '<?php echo I18n::getType();?>'};</script>
	<?php $this->link('app/dist/sdk.js','static');?>
	<!-- <?php $this->link('style/dist/main.css','static');?> -->
	<?php $this->link('style/lib/font-icon/style.css','static');?>
	<?php $this->link('static/weboffice/page.css');?>
	<script>
		var BASE_URL = "<?php echo $this->pluginHost.'static/';?>";
		var BASE_URL_API = "<?php echo $this->pluginApi;?>";
		var FILE_INFO = {
			link:	'<?php echo clear_quote($fileUrl);?>',	// 获取url
			name: 	'<?php echo clear_quote($fileName);?>', // 文件名
			path:	'<?php echo clear_quote($filePath);?>', // 文件路径;有则可以直接保存;没有且canWrite则可以另存为;
			app:	'<?php echo clear_quote($fileApp);?>',	// 文件打开方式
			ext:	'<?php echo clear_quote($fileExt);?>',	// 文件后缀
			write:	'<?php echo clear_quote($canWrite);?>',	// 是否可写; 可写才能编辑;
		};
		kodSdkConfig.LNG = <?php echo json_encode($LNG, JSON_HEX_TAG | JSON_HEX_APOS);?>;
		kodSdkConfig.LNG['common.edit'] = "<?php echo LNG('common.edit');?>";
		kodSdkConfig.LNG['explorer.wordLoading'] = "<?php echo LNG('explorer.wordLoading');?>";
	</script>
</head>

<body class="weboffice-page loading">
	<div class="edit-btn">
		<button><i class="font-icon ri-edit-line-2"></i><?php echo LNG('common.edit');?></button>
	</div>
	<div class="page-box <?php echo 'kod-' . clear_quote($fileApp) . '-box ' . clear_quote($fileExt);?>">
		<div id="output"></div>
	</div>
    <div id="msgbox" class="hidden">
		<!-- <div id="title">打开失败!</div> -->
		<div id="title">
			<span style="font-size:20px;">Office阅读器</span>
			<span style="font-size:14px;margin-left:5px;"> - WebOffice</span>
		</div>
		<div id="message"></div>
		<div id="info"></div>
	</div>

	<?php $this->link('static/weboffice/page.js');?>
	<?php switch(clear_quote($fileApp)) {
		case 'mammothjs':
			// $this->link('static/weboffice/mammothjs/mammoth.browser.kod.1.4.20--.js');
			$this->link('static/weboffice/mammothjs/mammoth.browser.kod.1.4.20.min.js');
			$this->link('static/weboffice/mammothjs/index.css');
			$this->link('static/weboffice/mammothjs/index.js');
			break;
		case 'luckysheet':
			$this->link('static/weboffice/luckysheet/plugins/css/pluginsCss.css');
			$this->link('static/weboffice/luckysheet/plugins/plugins.css');
			$this->link('static/weboffice/luckysheet/css/luckysheet.css');
			$this->link('static/weboffice/luckysheet/assets/iconfont/iconfont.min.css');
			$this->link('static/weboffice/luckysheet/index.css');
			$this->link('static/weboffice/luckysheet/plugins/js/plugin.js');
			$this->link('static/weboffice/luckysheet/luckysheet.umd.js');
			$this->link('static/weboffice/luckysheet/luckyexcel.umd.min.js');
			$this->link('static/weboffice/sheetjs/xlsx.core.min.js');
			$this->link('static/weboffice/exceljs/exceljs.min.js');
			$this->link('static/weboffice/luckysheet/utils.js');
			$this->link('static/weboffice/luckysheet/index.js');
			break;
		case 'pptxjs':
			$this->link('static/weboffice/pptxjs/css/pptxjs.css');
			$this->link('static/weboffice/pptxjs/css/nv.d3.min.css');
			$this->link('static/weboffice/pptxjs/index.css');
			$this->link('static/weboffice/pptxjs/js/jquery-1.11.3.min.js');
			$this->link('static/weboffice/pptxjs/js/jszip.min.js');
			$this->link('static/weboffice/pptxjs/js/filereader.js');
			$this->link('static/weboffice/pptxjs/js/d3.min.js');
			$this->link('static/weboffice/pptxjs/js/nv.d3.min.js');
			$this->link('static/weboffice/pptxjs/js/dingbat.js');
			$this->link('static/weboffice/pptxjs/js/pptxjs.kod.1.21.1.min.js');
			// $this->link('static/weboffice/pptxjs/js/pptxjs.kod.1.21.1--.js');
			$this->link('static/weboffice/pptxjs/js/divs2slides.min.js');
			// $this->link('static/weboffice/pptxjs/js/jquery.fullscreen-min.js');
			$this->link('static/weboffice/pptxjs/utils.js');
			$this->link('static/weboffice/pptxjs/index.js');
			break;
		case 'sheetjs':
			$this->link('static/weboffice/sheetjs/index.css');
			$this->link('static/weboffice/sheetjs/xlsx.core.min.js');
			// $this->link('static/weboffice/sheetjs/ppt.core.min.js');
			$this->link('static/weboffice/sheetjs/index.js');
			break;
		default:break;
	}?>

	<script>
		$(function(){
			// 非wb方式添加到iframe中,以保持样式一致
			var app = FILE_INFO.app;
			if (app == 'yz' || app == 'lb' || app == 'ol') {
				$('body').addClass(app);
				// var sandbox = 'allow-forms allow-popups allow-scripts allow-modals allow-same-origin';
				// $('#output').html('<iframe src="'+FILE_INFO.link+'" frameborder="0" sandbox="'+sandbox+'"></iframe>');
				$('#output').html('<iframe src="'+FILE_INFO.link+'" frameborder="0" ></iframe>');
				// wb方式在数据加载完成后添加
				$('#output>iframe').on('load', function() {
					setTimeout(function(){$('body.weboffice-page').addClass('loaded');}, 1000);
				});
			}

			// 添加编辑按钮:弹窗打开
			var editBtnDialog = function(){
				var _$ = false;
				try {_$ = window.parent.$;}catch(error){return;}
				var $dialog = _$(window.frameElement).parents('.aui-content');
				var data = base64Encode(jsonEncode({path:FILE_INFO.path, name:FILE_INFO.name, ext:FILE_INFO.ext}));
				var $button = _$('<div class="officeViewer-edit-btn">\
					<button data="'+data+'"><i class="font-icon ri-edit-line-2"></i>'+kodSdkConfig.LNG['common.edit']+'</button></div>').appendTo($dialog);
				$button.find('button').trigger('click');
			}
			// 添加编辑按钮:页面打开
			var editBtnPage = function(){
				var appRes = null;
				$.ajax({
					url:"<?php echo $this->pluginApi.'editApp';?>",
					data: {path: FILE_INFO.path, name: FILE_INFO.name, ext: FILE_INFO.ext},
					dataType:'json',
					success:function(result){
						appRes = result;
						if (result.code){
							$('body.weboffice-page').addClass('edit-mode');
							$('body.weboffice-page>.edit-btn button').attr('apptype', result.info);
						}
					}
				});
				// 点击编辑
				$('body.weboffice-page>.edit-btn button').click(function(){
					if (!appRes || !appRes.code) {
						var code = appRes.info ? 'warning' : false;
						return Tips.tips(appRes.data, code);
					}
					window.location.href = appRes.data;
				});
			}
			$(document).bind('ready',function(){
				if (FILE_INFO.write != '1'){return;}
				window.frameElement ? editBtnDialog() : editBtnPage();
			});

			// wb解析错误时,自动切换切换方式
			window.webOfficeAutoChange = function (err) {
				console.warn(err);
				if (window.frameElement) {
					var $dialog = $(window.frameElement).parents('.aui-dialog');
					var $button = $dialog.find('.aui-content .officeViewer-edit-btn button');
				} else {
					var $button = $('body.weboffice-page>.edit-btn button');
				}
				// 解析失败时,优先以可编辑的方式(如果有)打开
				if ($button.attr('apptype')) return $button.click();
				// 切换其他方式
				// page.showTips('正在加载...');	// 解析失败,正在切换...
				window.location.href = location.href+'&skip=wb';
				return false;
			}
		});
	</script>
</body>
</html>