| | |
| | | let aceEditor; |
| | | let containExamples = true; |
| | | |
| | | function initPage() { |
| | | function initPage () { |
| | | initEditor(); |
| | | screenResize(); |
| | | } |
| | | |
| | | function screenResize() { |
| | | function screenResize () { |
| | | window.onresize = function () { |
| | | mapHeight(); |
| | | }; |
| | | } |
| | | |
| | | function findConfig(locationParam, search) { |
| | | function findConfig (locationParam, search) { |
| | | let exConfig = haoutil.storage.get("mars3d-es5-example"); |
| | | if (!exConfig) { |
| | | return; |
| | |
| | | for (let index3 = 0; index3 < item2.children.length; index3++) { |
| | | let item3 = item2.children[index3]; |
| | | if (item3.fileName == locationParam) { |
| | | console.log(item, item2, item3, "itemitemite") |
| | | document.title = item3.name + " 【" + item2.name + " " + item.name + "】 | Mars3D示例 | 合肥火星科技有限公司"; |
| | | return; |
| | | } |
| | |
| | | } |
| | | |
| | | //初始化编辑器 |
| | | function initCodeEditor() { |
| | | function initCodeEditor () { |
| | | if (!aceEditor) { |
| | | aceEditor = ace.edit("editor"); |
| | | aceEditor.setTheme("ace/theme/xcode"); |
| | |
| | | } |
| | | |
| | | //初始化编辑器以及预览内容 |
| | | function initEditor() { |
| | | function initEditor () { |
| | | loadExampleHtml(); |
| | | initCodeEditor(); |
| | | } |
| | | |
| | | function loadExampleHtml() { |
| | | function loadExampleHtml () { |
| | | let locationParam = getLocationParam(); |
| | | if (!locationParam) { |
| | | return; |
| | |
| | | } |
| | | } |
| | | |
| | | function getLocationParam() { |
| | | function getLocationParam () { |
| | | let id = haoutil.system.getRequestByName("id"); |
| | | if (id) { |
| | | return id; |
| | |
| | | } |
| | | |
| | | //运行代码 |
| | | function run() { |
| | | function run () { |
| | | let iframeContent = $("#editor").val(); |
| | | if (editor) { |
| | | iframeContent = aceEditor.getValue(); |
| | |
| | | } |
| | | |
| | | //填充预览效果内容 |
| | | function loadPreview(content) { |
| | | function loadPreview (content) { |
| | | let iFrame = createIFrame(), |
| | | iframeDocument = iFrame.contentWindow.document; |
| | | |
| | |
| | | mapHeight(); |
| | | } |
| | | |
| | | function loadIFrameForSrc(url) { |
| | | function loadIFrameForSrc (url) { |
| | | createIFrame(); |
| | | $("#innerPage").attr("src", url); |
| | | |
| | | mapHeight(); |
| | | } |
| | | |
| | | function createIFrame() { |
| | | function createIFrame () { |
| | | let preViewPane = $("#previewPane"); |
| | | preViewPane.empty(); |
| | | let iframe = document.createElement("iframe"); |
| | |
| | | } |
| | | |
| | | //重置编辑器 |
| | | function refresh() { |
| | | function refresh () { |
| | | initEditor(); |
| | | run(); |
| | | } |
| | |
| | | // selectMenu(id) |
| | | // } |
| | | |
| | | function mapHeight() { |
| | | function mapHeight () { |
| | | let doc = $("#innerPage").contents(); |
| | | doc.find("html").height("100%"); |
| | | doc.find("body").height("100%"); |
| | | } |
| | | |
| | | function bindEvents() { |
| | | function bindEvents () { |
| | | $("#sidebar ul.third-menu a").click(function (evt) { |
| | | let target = $(evt.target).parent().parent(); |
| | | let nodeId = evt.target.id; |