Plugin Directory

Changeset 1900373


Ignore:
Timestamp:
06/28/2018 07:02:06 AM (8 years ago)
Author:
rahburma
Message:

Introduced syntax highlighting support for languages for which compilation feature is not available yet.

Location:
code-editor-and-compiler/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code-editor-and-compiler/trunk/admin/compilebin-admin.php

    r1897955 r1900373  
    380380                   <div class="cdbx-div-right-2">
    381381                     <select name="cdbx-lang" id="cdbx-lang" style="margin-top:-0.1em"></select>
    382                      <input id="cdbx-filename" class="cdbx-textbox" placeholder="Filename" style=""></input>.<span id="cdbx-filename-ext"></span>
     382                     <input id="cdbx-filename" class="cdbx-textbox" placeholder="Filename" style=""></input><span id="cdbx-filename-ext"></span>
    383383                     <button type="button" id="cdbx-setting" class="button button-default" style="float:right" title="Enter your API key for code execution">
    384384                       <span class="dashicons dashicons-admin-network" aria-hidden="true" style="margin-top:0.2em"></span>
     
    388388                     </button>
    389389                   </div>
    390                    <div id="cdbx-div-output" style="width:100%">
     390                   <div id="cdbx-div-output" style="width:98%">
    391391                     Output Appears Here ...
    392392                   </div>
     
    556556                  </div>
    557557                  <div class="cdbx-div-right-2" style="width:100%;">
    558                     <input id="cdbx-filename" class="cdbx-textbox" style="margin-top:5px;float:left;font-size:13px;" placeholder="Filename"></input><span style="float:left;margin-top:5px;">.</span><span id="cdbx-filename-ext" style="float:left;margin-top:5px;"></span>
     558                    <input id="cdbx-filename" class="cdbx-textbox" style="margin-top:5px;float:left;font-size:13px;" placeholder="Filename"></input><span id="cdbx-filename-ext" style="float:left;margin-top:5px;"></span>
    559559                    <!--<button type="button" id="cdbx-code-help" class="cdbx-btn-1" style="float:right">
    560560                      <span class="dashicons dashicons-editor-help" aria-hidden="true"></span>
  • code-editor-and-compiler/trunk/admin/js/editor-handler.js

    r1897951 r1900373  
    9393           });                         
    9494        };
     95       
     96        var cdbx_updateDOM = function () {
     97          if (cdbx_curLangId == cdbx_defLangId || cdbx_run_btn_status == 0) {
     98             $(CDBX_FILENAME).hide();
     99             $(CDBX_FILENAME_EXT).hide();
     100             $(CDBX_RUN_CODE).prop("disabled", true);
     101             $(CDBX_STDIN).hide();
     102             $(CDBX_CMDLINE).hide();
     103             
     104             var cdbx_info_html = 'Syntax Highlighter Mode <br>';
     105             var cdbx_info_html_web = 'Syntax Highlighter Mode <br>'; 
     106
     107             if (cdbx_curLangId == cdbx_defLangId) {
     108                cdbx_info_html += '<p style="color:#696969"><label style="color:#008B8B">Default language is selected.</label><br> Code that you write in any language will only be automatically syntax highlighted in public view. Select a specific language from the drop down menu to run your code.</p>';
     109             }
     110
     111             if (cdbx_run_btn_status == 0) {
     112                /* run button needs to be hidden in web design editor also */
     113                $(CDBX_RUN_CODE_WEB).prop("disabled", true);
     114                //$(CDBX_OUTPUT_WEB_LINK).hide();
     115                cdbx_info_html_web += '<p style="color:#696969"><label style="color:#008B8B">Code execution is disabled.</label><br> Please enable it from <a href="" id="cdbx-global-setting">global settings</a></p>';
     116                cdbx_info_html += '<p style="color:#696969"><label style="color:#008B8B">Code execution is disabled.</label><br> Please enable it from <a href="" id="cdbx-global-setting">global settings</a></p>';
     117                $(CDBX_DIV_OUTPUT_WEB).html(cdbx_info_html_web);
     118             } else {
     119                $(CDBX_RUN_CODE_WEB).prop("disabled", false);
     120                $(CDBX_DIV_OUTPUT_WEB).html(cdbx_default_output);
     121             }
     122
     123             $(CDBX_DIV_OUTPUT).html(cdbx_info_html); 
     124             
     125          } else {
     126             $(CDBX_FILENAME).show();
     127             $(CDBX_FILENAME_EXT).show(); 
     128             $(CDBX_RUN_CODE).prop("disabled", false);
     129             $(CDBX_STDIN).show();
     130             $(CDBX_CMDLINE).show();
     131             $(CDBX_DIV_OUTPUT).html(cdbx_default_output);
     132             
     133             $(CDBX_RUN_CODE_WEB).prop("disabled", false);
     134             //$(CDBX_OUTPUT_WEB_LINK).show();
     135          }
     136        };
     137
    95138
    96139        var cdbx_executeHtmlCode = function(html, css, js, externalCss, externalJs, output_div) {
     
    159202        var initEditorDialog = function() {
    160203          $(CDBX_EDITOR_DIALOG).dialog({
    161             title: 'Code Editor',
     204            title: 'Code Editor and Compiler',
    162205            dialogClass: 'wp-dialog',
    163206            autoOpen: false,
     
    183226              });
    184227              $(CDBX_LANG).val(cdbx_curLangId);
     228              cdbx_updateDOM();   
    185229              $(CDBX_FILENAME).val(cdbx_progName);
    186230              if (cdbx_editorNode == null) {
     
    257301                         cdbx_curEditorIdPref = parseInt(setObj.editorPref);
    258302                      }
    259                       if (setObj.langPref.length > 0) {
     303 
     304                      if (setObj.langPref.length > 0) { 
    260305                         cdbx_curLangId = parseInt(setObj.langPref);
    261306                         cdbx_curLangIdPref = parseInt(setObj.langPref);
     
    298343            var file_name = $(CDBX_FILENAME).val();
    299344            var prefix = '<pre id="' + pre_id + '"' + ' class="prettyprint" style="padding:10px;border:1px solid rgba(231, 231, 230, 1);border-radius:10px;background-color:#FFFFFF;font-family: courier, sans-serif;font-size:13px;">';
    300             var suffix = '<input id="' + input_id + '"' +
     345           
     346            var suffix = '';
     347            if (lang_id == cdbx_defLangId) {
     348               suffix = '<input id="' + input_id + '"' +
     349                         'class="cdbx-try-code cdbx-btn-main-def"' +
     350                         'style="background-color:#FFFFFF;margin-bottom:0;color:#008B8B;border: 1px solid rgba(231, 231, 230, 1); border-radius: 10px;font-size:13px;height:30px;min-width:60px;max-width:150px;padding:4px;font-weight:normal;outline:none;display:none;"' +
     351                         'type="" value="Run" data-code="' + pre_id + '"' +
     352                         'data-lang="' + lang_id + '"' + 'data-filename="' + file_name + '" /><br></pre><br>';
     353            } else {
     354               suffix = '<input id="' + input_id + '"' +
    301355                         'class="cdbx-try-code cdbx-btn-main"' +
    302356                         'style="background-color:#FFFFFF;margin-bottom:0;color:#008B8B;border: 1px solid rgba(231, 231, 230, 1); border-radius: 10px;font-size:13px;height:30px;min-width:60px;max-width:150px;padding:4px;font-weight:normal;outline:none;"' +
    303357                         'type="button" value="Run" data-code="' + pre_id + '"' +
    304                          'data-lang="' + lang_id + '"' + 'data-filename="' + file_name + '" /><br></pre><br>';
     358                         'data-lang="' + lang_id + '"' + 'data-filename="' + file_name + '" /><br></pre><br>';   
     359            }
     360
    305361            wp.media.editor.insert(prefix + code + suffix);
    306362            $(CDBX_EDITOR_DIALOG).dialog(CDBX_EVENT_CLOSE);
     
    469525            cdbx_curLangId = $(this).find('option:selected').val();
    470526            cdbx_setMode();
     527            cdbx_updateDOM();
    471528        });
    472529
     
    676733                   cdbx_setTheme();
    677734                   cdbx_run_btn_status = cdbx_json.run_btn_status;
     735                   cdbx_updateDOM();
    678736               },
    679737               error: function(jqXHR, textStatus, errorThrown) {
     
    692750                       '<div class="cdbx-dialog-box">' +
    693751                       '<div id="cdbx-global-setting-save-msg" style="color:#000080"></div>' +
    694                        '<input type="checkbox" id="cdbx-run-btn-status">&nbsp;&nbsp;<span class="cdbx-label-text">Hide Run Button</span>&nbsp&nbsp&nbsp&nbsp<span class="cdbx-info-text-1">Syntax highlighter mode only. Run button will not be visible in code snippets.</span><br><br>' +
     752                       '<input type="checkbox" id="cdbx-run-btn-status">&nbsp;&nbsp;<span class="cdbx-label-text">Disable code execution</span>&nbsp&nbsp&nbsp&nbsp<span class="cdbx-info-text-1">Syntax highlighter mode only. Run button will not be visible in code snippets.</span><br><br>' +
    695753                       '<span class="cdbx-label-text">Preferred Editor</span> &nbsp;&nbsp;<select name="cdbx-pref-editor" id="cdbx-pref-editor" style=""></select>&nbsp&nbsp&nbsp&nbsp<span class="cdbx-info-text-1">Default code editor.</span><br><br>' +
    696754                       '<span class="cdbx-label-text">Preferred Language</span> &nbsp;&nbsp;<select name="cdbx-pref-lang" id="cdbx-pref-lang" style=""></select>&nbsp&nbsp&nbsp&nbsp<span class="cdbx-info-text-1">Default programming language.</span><br><br>' +
  • code-editor-and-compiler/trunk/common/css/editor-style.css

    r1897951 r1900373  
    5757    width:100%;
    5858    margin-top: 5px;
     59    padding: 4px;
    5960}
    6061
  • code-editor-and-compiler/trunk/common/js/include.js

    r1897848 r1900373  
    105105
    106106var cdbx_languages = [
    107     { id: 0,  name: 'C',           mode: 'ace/mode/c_cpp',      ext: 'c'     },
    108     { id: 1,  name: 'C++',         mode: 'ace/mode/c_cpp',      ext: 'cpp'   },
    109     { id: 2,  name: 'Java',        mode: 'ace/mode/java',       ext: 'java'  },
    110     { id: 3,  name: 'Python2.7',   mode: 'ace/mode/python',     ext: 'py'    },
    111     { id: 4,  name: 'Python3',     mode: 'ace/mode/python',     ext: 'py'    },
    112     { id: 5,  name: 'Perl',        mode: 'ace/mode/perl',       ext: 'pl'    },
    113     { id: 6,  name: 'Ruby',        mode: 'ace/mode/ruby',       ext: 'rb'    },
    114     { id: 7,  name: 'Clojure',     mode: 'ace/mode/clojure',    ext: 'clj'   },
    115     { id: 8,  name: 'Elixir',      mode: 'ace/mode/elixir',     ext: 'ex'    },
    116     { id: 9,  name: 'C#',          mode: 'ace/mode/csharp',     ext: 'cs'    },
    117     { id: 10, name: 'Erlang',      mode: 'ace/mode/erlang',     ext: 'erl'   },
    118     { id: 11, name: 'Scala',       mode: 'ace/mode/scala',      ext: 'scala' },
    119     { id: 12, name: 'Go',          mode: 'ace/mode/golang',     ext: 'go'    },
    120     { id: 13, name: 'Objective-C', mode: 'ace/mode/objectivec', ext: 'm'     },
    121     { id: 14, name: 'VB.Net',      mode: 'ace/mode/vbscript',   ext: 'vb'    },
    122     { id: 15, name: 'Swift3',      mode: 'ace/mode/objectivec', ext: 'swift' }
     107    { id: 0,     name: 'C',           mode: 'ace/mode/c_cpp',      ext: '.c'     },
     108    { id: 1,     name: 'C++',         mode: 'ace/mode/c_cpp',      ext: '.cpp'   },
     109    { id: 2,     name: 'Java',        mode: 'ace/mode/java',       ext: '.java'  },
     110    { id: 3,     name: 'Python2.7',   mode: 'ace/mode/python',     ext: '.py'    },
     111    { id: 4,     name: 'Python3',     mode: 'ace/mode/python',     ext: '.py'    },
     112    { id: 5,     name: 'Perl',        mode: 'ace/mode/perl',       ext: '.pl'    },
     113    { id: 6,     name: 'Ruby',        mode: 'ace/mode/ruby',       ext: '.rb'    },
     114    { id: 7,     name: 'Clojure',     mode: 'ace/mode/clojure',    ext: '.clj'   },
     115    { id: 8,     name: 'Elixir',      mode: 'ace/mode/elixir',     ext: '.ex'    },
     116    { id: 9,     name: 'C#',          mode: 'ace/mode/csharp',     ext: '.cs'    },
     117    { id: 10,    name: 'Erlang',      mode: 'ace/mode/erlang',     ext: '.erl'   },
     118    { id: 11,    name: 'Scala',       mode: 'ace/mode/scala',      ext: '.scala' },
     119    { id: 12,    name: 'Go',          mode: 'ace/mode/golang',     ext: '.go'    },
     120    { id: 13,    name: 'Objective-C', mode: 'ace/mode/objectivec', ext: '.m'     },
     121    { id: 14,    name: 'VB.Net',      mode: 'ace/mode/vbscript',   ext: '.vb'    },
     122    { id: 15,    name: 'Swift3',      mode: 'ace/mode/objectivec', ext: '.swift' },
     123    { id: 16,    name: 'Default',     mode: 'ace/mode/c_cpp',      ext: ''      }
    123124];
    124125
     
    155156var cdbx_editor_css = null;
    156157var cdbx_editor_js = null;
    157 var cdbx_curLangId = 0;
    158 var cdbx_curLangIdPref = 0;
     158var cdbx_defLangId = cdbx_languages.length - 1;
     159var cdbx_curLangId = cdbx_defLangId;
     160var cdbx_curLangIdPref = cdbx_defLangId;
    159161var cdbx_curEditorIdPref = 0;
    160162var cdbx_run_btn_status = 1;
  • code-editor-and-compiler/trunk/compilebin.php

    r1897955 r1900373  
    99 * Plugin Name:       Code Editor and Compiler
    1010 * Plugin URI:        https://www.compilebin.com
    11  * Description:       Execute code online.
     11 * Description:       Syntax highlighter and code compiler.
    1212 * Version:           1.3.1
    1313 * Author:            Compilebin
  • code-editor-and-compiler/trunk/readme.txt

    r1897955 r1900373  
    1313
    1414== Description ==
    15 This plugin acts as an interface to the online compiler api service on cloud provided by https://www.compilebin.com. It interacts with cloud service via rest APIs i.e, submit the code and get the output. Users need to signup and get an api key which is to be updated in the plugin to use the service. Plugin contains a link for signing up for the service. There is no security concern on the web server as the task of code execution is offloaded to the cloud service. The plugin uses the following open source libraries :
     15This is a syntax highlighter plugin which also acts as an interface to the online compiler api service on cloud provided by https://www.compilebin.com. It interacts with cloud service via rest APIs i.e, submit the code and get the output. Users need to signup and get an api key which is to be updated in the plugin to use the service. Plugin contains a link for signing up for the service. There is no security concern on the web server as the task of code execution is offloaded to the cloud service. The plugin uses the following open source libraries :
    16161) Code prettify for syntax highlighting
    17172) Ace code editor
Note: See TracChangeset for help on using the changeset viewer.