2016-02-23 36 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); 
    }