fuchengshen
2022-06-14 722473e2b2cd4776a65ba0b620a9710728963611
public/hn3d/static/js/editor.js
@@ -14,18 +14,18 @@
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;
@@ -49,6 +49,7 @@
      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;
        }
@@ -58,7 +59,7 @@
}
//初始化编辑器
function initCodeEditor() {
function initCodeEditor () {
  if (!aceEditor) {
    aceEditor = ace.edit("editor");
    aceEditor.setTheme("ace/theme/xcode");
@@ -73,12 +74,12 @@
}
//初始化编辑器以及预览内容
function initEditor() {
function initEditor () {
  loadExampleHtml();
  initCodeEditor();
}
function loadExampleHtml() {
function loadExampleHtml () {
  let locationParam = getLocationParam();
  if (!locationParam) {
    return;
@@ -120,7 +121,7 @@
  }
}
function getLocationParam() {
function getLocationParam () {
  let id = haoutil.system.getRequestByName("id");
  if (id) {
    return id;
@@ -137,7 +138,7 @@
}
//运行代码
function run() {
function run () {
  let iframeContent = $("#editor").val();
  if (editor) {
    iframeContent = aceEditor.getValue();
@@ -146,7 +147,7 @@
}
//填充预览效果内容
function loadPreview(content) {
function loadPreview (content) {
  let iFrame = createIFrame(),
    iframeDocument = iFrame.contentWindow.document;
@@ -164,14 +165,14 @@
  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");
@@ -182,7 +183,7 @@
}
//重置编辑器
function refresh() {
function refresh () {
  initEditor();
  run();
}
@@ -199,13 +200,13 @@
//   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;