Changeset 1904276
- Timestamp:
- 07/05/2018 04:05:49 AM (8 years ago)
- Location:
- code-editor-and-compiler/trunk
- Files:
-
- 8 edited
-
admin/compilebin-admin.php (modified) (5 diffs)
-
admin/js/editor-handler.js (modified) (6 diffs)
-
common/css/editor-style.css (modified) (1 diff)
-
common/js/include.js (modified) (2 diffs)
-
compilebin.php (modified) (1 diff)
-
public/compilebin-public.php (modified) (1 diff)
-
public/js/editor-handler-public.js (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
code-editor-and-compiler/trunk/admin/compilebin-admin.php
r1902882 r1904276 7 7 public function __construct() { 8 8 $this->plugin_name = "code-editor-and-compiler"; 9 $this->plugin_version = "1.3. 6";9 $this->plugin_version = "1.3.7"; 10 10 add_action('admin_notices', array($this, 'plugin_activation')); 11 11 add_action('deactivated_plugin', array($this, 'plugin_deactivation')); … … 265 265 echo $theme_type; 266 266 wp_die(); 267 } 268 269 public function saveLinenumPreferenceInternal() { 270 $linenum = $_POST['linenum_status']; 271 delete_option('linenum_status'); 272 delete_transient('linenum_status'); 273 $status = add_option('linenum_status', $linenum, '', 'no'); 274 return $status; 275 } 276 277 private function saveLinenumPreference() { 278 $status = saveLinenumPreferenceInternal(); 279 if ($status) { 280 echo "Line number preference saved successfully."; 281 } else { 282 echo "Error setting line number preference. Please try again."; 283 } 284 wp_die(); 285 } 286 287 private function getLinenumPreferenceInternal() { 288 $linenum_status = null; 289 if (false === ($linenum_status = get_transient('linenum_status'))) { 290 $linenum_status = get_option('linenum_status'); 291 set_transient('linenum_status', $linenum_status, YEAR_IN_SECONDS); 292 } 293 return $linenum_status; 294 } 295 296 public function getLinenumPreference() { 297 $linenum_status = $this->getLinenumPreferenceInternal(); 298 echo $linenum_status; 299 wp_die(); 267 300 } 268 301 … … 272 305 'editorPref' => $this->getEditorPreferenceInternal(), 273 306 'langPref' => $this->getLangPreferenceInternal(), 274 'themePref' => $this->getThemePreferenceInternal() 307 'themePref' => $this->getThemePreferenceInternal(), 308 'linenumStatus' => $this->getLinenumPreferenceInternal() 275 309 ); 276 310 echo json_encode($settingObj); … … 283 317 $statusLangPref = $this->saveLangPreferenceInternal(); 284 318 $statusThemePref = $this->saveThemePreferenceInternal(); 285 if (!$statusRunBtn || !$statusEditorPref || !$statusLangPref || !$statusThemePref) { 319 $statusLinenumPref = $this->saveLinenumPreferenceInternal(); 320 if (!$statusRunBtn || !$statusEditorPref || !$statusLangPref || !$statusThemePref || !$statusLinenumPref) { 286 321 echo "<b>Error saving your preferences. Please try again.</b><br><br>"; 287 322 } else { … … 294 329 $settingObj = array ( 295 330 'runBtnStatus' => $this->getRunBtnStatusInternal(), 296 'themePref' => $this->getThemePreferenceInternal() 331 'themePref' => $this->getThemePreferenceInternal(), 332 'linenumStatus' => $this->getLinenumPreferenceInternal() 297 333 ); 298 334 echo json_encode($settingObj); -
code-editor-and-compiler/trunk/admin/js/editor-handler.js
r1902882 r1904276 325 325 cdbx_run_btn_status = parseInt(setObj.runBtnStatus); 326 326 } 327 if (setObj.linenumStatus.length > 0) { 328 cdbx_linenum_status = parseInt(setObj.linenumStatus); 329 } 327 330 if (setObj.editorPref.length > 0) { 328 331 if (setObj.editorPref == CDBX_EDITOR_WEBDESIGN) { … … 807 810 editor_type: $(CDBX_PREF_EDITOR).find('option:selected').val(), 808 811 lang: $(CDBX_PREF_LANG).find('option:selected').val(), 809 theme: $(CDBX_PREF_THEME).find('option:selected').val() 812 theme: $(CDBX_PREF_THEME).find('option:selected').val(), 813 linenum_status: $(CDBX_LINENUM_STATUS).is(":checked") ? 1 : 0 810 814 }; 811 815 … … 841 845 cdbx_setTheme(); 842 846 cdbx_run_btn_status = cdbx_json.run_btn_status; 847 cdbx_linenum_status = cdbx_json.linenum_status; 843 848 cdbx_updateDOM(); 844 849 }, … … 859 864 '<div id="cdbx-global-setting-save-msg" style="color:#000080"></div>' + 860 865 '<input type="checkbox" id="cdbx-run-btn-status"> <span class="cdbx-label-text">Disable code execution</span>    <span class="cdbx-info-text-1">Syntax highlighter mode only. Run button will not be visible in code snippets.</span><br><br>' + 866 '<input type="checkbox" id="cdbx-linenum-status"> <span class="cdbx-label-text">Show line numbers</span>    <span class="cdbx-info-text-1">Display line numbers in syntax highlighted code.</span><br><br>' + 861 867 '<span class="cdbx-label-text">Preferred Editor</span> <select name="cdbx-pref-editor" id="cdbx-pref-editor" style=""></select>    <span class="cdbx-info-text-1">Default code editor.</span><br><br>' + 862 868 '<span class="cdbx-label-text">Preferred Language</span> <select name="cdbx-pref-lang" id="cdbx-pref-lang" style=""></select>    <span class="cdbx-info-text-1">Default programming language.</span><br><br>' + … … 890 896 // enable the checkbox to hide run button 891 897 $(CDBX_RUN_BTN_STATUS).prop('checked', true); 898 } 899 900 if (cdbx_linenum_status) { 901 // enable the checkbox to hide run button 902 $(CDBX_LINENUM_STATUS).prop('checked', true); 892 903 } 893 904 … … 956 967 if (setObj.runBtnStatus.length > 0) { 957 968 cdbx_run_btn_status = parseInt(setObj.runBtnStatus); 969 } 970 if (setObj.linenumStatus.length > 0) { 971 cdbx_linenum_status = parseInt(setObj.linenumStatus); 958 972 } 959 973 if (setObj.editorPref.length > 0) { -
code-editor-and-compiler/trunk/common/css/editor-style.css
r1900373 r1904276 207 207 font-size: 1.1em; 208 208 } 209 210 pre { 211 counter-reset: line; 212 } 213 214 cdbx-code { 215 counter-increment: line; 216 } 217 218 cdbx-code::before { 219 content: counter(line); 220 display: inline-block; 221 text-align: right; 222 min-width: 3.5em; 223 border-right: 1px solid #ddd; 224 padding: 0 .5em; 225 margin-right: .5em; 226 margin-left: -0.8em; 227 color: #888; 228 /*background-color: #F8F8FF; */ 229 -webkit-user-select: none; 230 } -
code-editor-and-compiler/trunk/common/js/include.js
r1901884 r1904276 42 42 var CDBX_API_KEY_SAVE_MSG = '#cdbx-api-key-save-msg'; 43 43 var CDBX_RUN_BTN_STATUS = '#cdbx-run-btn-status'; 44 var CDBX_LINENUM_STATUS = '#cdbx-linenum-status'; 44 45 var CDBX_SAVE_GLOBAL_SETTING = '#cdbx-save-global-setting'; 45 46 var CDBX_GLOBAL_SETTING_SAVE_MSG = '#cdbx-global-setting-save-msg'; … … 163 164 var cdbx_curEditorIdPref = 0; 164 165 var cdbx_run_btn_status = 1; 166 var cdbx_linenum_status = 1; 165 167 var cdbx_curThemePrefId = CDBX_THEME_XCODE; 166 168 var cdbx_curThemeId = CDBX_THEME_XCODE; -
code-editor-and-compiler/trunk/compilebin.php
r1902882 r1904276 10 10 * Plugin URI: https://www.compilebin.com 11 11 * Description: Syntax highlighter and code compiler. 12 * Version: 1.3. 612 * Version: 1.3.7 13 13 * Author: Compilebin 14 14 * Author URI: https://www.compilebin.com -
code-editor-and-compiler/trunk/public/compilebin-public.php
r1902882 r1904276 7 7 public function __construct() { 8 8 $this->plugin_name = "code-editor-and-compiler"; 9 $this->plugin_version = "1.3. 6";9 $this->plugin_version = "1.3.7"; 10 10 add_action('wp_enqueue_scripts', array(&$this, 'enqueueScripts')); 11 11 add_action('wp_enqueue_scripts', array(&$this, 'enqueueStyles')); -
code-editor-and-compiler/trunk/public/js/editor-handler-public.js
r1901556 r1904276 19 19 var cdbx_preProcess = function() { 20 20 var cdbx_preElems = document.getElementsByTagName("PRE"); 21 22 for (var i = 0; i < cdbx_preElems.length; i++)23 if (cdbx_isCrayonHighlighterPresent(cdbx_preElems[i])) {24 cdbx_preElems[i].classList.add('prettyprint');25 cdbx_preElems[i].setAttribute("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;");21 for (var i = 0; i < cdbx_preElems.length; i++) { 22 if (cdbx_isCrayonHighlighterPresent(cdbx_preElems[i])) { 23 cdbx_preElems[i].classList.add('prettyprint'); 24 cdbx_preElems[i].setAttribute("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;"); 25 } 26 26 } 27 27 }; 28 28 29 29 cdbx_preProcess(); 30 31 var cdbx_showLineNums = function () { 32 var cdbx_preElems = document.getElementsByTagName("PRE"); 33 for (var i = 0; i < cdbx_preElems.length; i++) { 34 var preContent = cdbx_preElems[i].innerHTML; 35 var codeLine = new Array(); 36 var newContent = ''; 37 codeLine = preContent.split('\n'); 38 for (var j = 0; j < codeLine.length; j++) { 39 newContent = newContent + '<cdbx-code>' + codeLine[j] + '</cdbx-code>'; 40 if (j != codeLine.length) { 41 newContent += '\n'; 42 } 43 } 44 cdbx_preElems[i].innerHTML = newContent; 45 } 46 }; 30 47 31 48 $.ajax({ … … 51 68 default : break; 52 69 } 53 } 70 } 71 if (setObj.linenumStatus.length == 0) { 72 // linenum status not found, display line numbers by default 73 cdbx_showLineNums(); 74 } else { 75 if (parseInt(setObj.linenumStatus) == 1) { 76 cdbx_showLineNums(); 77 } 78 } 79 54 80 } 55 81 }); … … 255 281 var code = document.getElementById(codeElem).innerHTML; 256 282 $(CDBX_HIDDEN_CONTENT).html(code); 257 varcode = $(CDBX_HIDDEN_CONTENT).text();283 code = $(CDBX_HIDDEN_CONTENT).text(); 258 284 cdbx_curLangId = elem.dataset.lang; 259 285 cdbx_progName = elem.dataset.filename; -
code-editor-and-compiler/trunk/readme.txt
r1902882 r1904276 5 5 Requires at least: 3.1 6 6 Tested up to: 4.9.4 7 Stable tag: 1.3. 67 Stable tag: 1.3.7 8 8 Requires PHP: 5.2.4 9 9 License: GPLv2 or later … … 35 35 36 36 == Changelog == 37 1.3.7 38 Introduced support for displaying line numbers in syntax highlighted code 39 37 40 1.3.6 38 41 Fixed display issue in firefox
Note: See TracChangeset
for help on using the changeset viewer.