2016-02-23 34 views
0

Oracle Application Express代码编辑器只是在白色背景下的纯文本。没有代码突出显示。此外,我不能按“标签”没有文本框失去焦点。代码高亮顶点(Firefox 31)

我使用的是firefox 31(无法升级,在这里工作时由Admin重新定义)另外我无法安装插件。我知道你可以使用firefox中的特殊文件夹(“chrome”-folder/userContent.css)在特定网站上更改css。我已经使用它来改变文本字段的默认大小,因为每次打开编辑页面时它都会变得很小。

那么你知道我可以在Apex中使用的任何框架或脚本吗? (我可以复制狗屎jsfiddle.net每次但是,吸

(我还发现在Firefox暂存器,它可以运行JS和jQuery。这是否帮助?)

回答

1

[解决] 因为你不能使用

<script src = ""> 

等纯JS,我不得不使用loadScript。CSS文件的它更加复杂,但我得到了它所有的工作。

这是我的代码,我跑它在scratchpad(firefox)中,它使用ACE将div更改为带有h的编辑器ighlighting。当点击应用程序时,我还原DOM中的编辑器更改,但保留文本/代码。

// Load Ace js 
    loadScript("http://cdnjs.cloudflare.com/ajax/libs/ace/1.1.01/ace.js", function(){ 
     //initialization code 
    }); 
    // Load Ace css 
    var cssId = 'myCss'; // you could encode the css path itself to generate id.. 
    if (!document.getElementById(cssId)){ 
     var head = document.getElementsByTagName('head')[0]; 
     var link = document.createElement('link'); 
     link.id = cssId; 
     link.rel = 'stylesheet'; 
     link.type = 'text/css'; 
     link.href = 'http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.0/css/bootstrap.min.css'; 
     link.media = 'all'; 
     head.appendChild(link); 
    } 
    // change textarea to div 
    var editorRegion = document.getElementById('F4000_P4651_PLUG_SOURCE_fieldset'); 
    editorRegion.innerHTML = editorRegion.innerHTML.replace("textarea","div"); 

    // run ACE 
    highlight(); 


    // Modify the apply Button in Apex to first revert ACE-Editor to normal, then do the usual apply. 
    var applyChanges = document.getElementById('B3456326662'); 
    applyChanges.setAttribute("onclick","modifiedApply()"); 
    function modifiedApply(){ 
     close(); 
     setTimeout(normalApply, 500); 
    } 
    function normalApply(){ 
     javascript:apex.submit('Apply_Changes'); 
    } 

    // Revert ACE-Changes, but keep changed text/code. 
    function close(){ 
     var value = editor.getValue(); 
     editor.destroy(); 
     var oldDiv = editor.container; 
     var newDiv = oldDiv.cloneNode(false); 
     newDiv.textContent = value; 
     oldDiv.parentNode.replaceChild(newDiv, oldDiv); 
     newDiv.outerHTML = newDiv.outerHTML.replace("div","textarea"); 
     var old_new_old = document.getElementById('F4000_P4651_PLUG_SOURCE'); 
     old_new_old.textContent = old_new_old.textContent.substring(0, old_new_old.textContent.length - 6); 
    } 
    var editor; 
    function highlight() { 
     editor = ace.edit("F4000_P4651_PLUG_SOURCE"); 
     editor.setTheme("ace/theme/monokai"); 
     editor.getSession().setUseWorker(false); 
     editor.getSession().setMode("ace/mode/javascript"); 
     document.getElementsByClassName('ace_print-margin')[0].setAttribute("style","left:1000px"); 
    } 


    function loadScript(url, callback){ 
     var script = document.createElement("script") 
     script.type = "text/javascript"; 

     if (script.readyState){ //IE 
      script.onreadystatechange = function(){ 
       if (script.readyState == "loaded" || 
         script.readyState == "complete"){ 
        script.onreadystatechange = null; 
        callback(); 
       } 
      }; 
     } else { //Others 
      script.onload = function(){ 
       callback(); 
      }; 
     } 
     script.src = url; 
     document.getElementsByTagName("head")[0].appendChild(script); 
    }