edit-content.html.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. <?php if (!defined('HTMLY')) die('HTMLy'); ?>
  2. <?php
  3. if (isset($p->file)) {
  4. $file_path = pathinfo($p->file);
  5. } else {
  6. $file_path = pathinfo($oldfile);
  7. }
  8. $filename = $file_path['dirname'] . '/' . $file_path['basename'];
  9. $desc = get_category_info(null);
  10. $content = file_get_contents($filename);
  11. $oldtitle = get_content_tag('t', $content, 'Untitled');
  12. $olddescription = get_content_tag('d', $content);
  13. $oldtag = get_content_tag('tag', $content);
  14. $oldcontent = remove_html_comments($content);
  15. $oldimage = get_content_tag('image', $content);
  16. $oldaudio = get_content_tag('audio', $content);
  17. $oldvideo = get_content_tag('video', $content);
  18. $oldlink = get_content_tag('link', $content);
  19. $oldquote = get_content_tag('quote', $content);
  20. $dir = $file_path['dirname'];
  21. $isdraft = explode('/', $dir);
  22. $oldurl = explode('_', $file_path['basename']);
  23. if (empty($oldtag)) {
  24. $oldtag = $oldurl[1];
  25. }
  26. $oldmd = str_replace('.md', '', $oldurl[2]);
  27. if (isset($_GET['destination'])) {
  28. $destination = _h($_GET['destination']);
  29. } else {
  30. $destination = 'admin';
  31. }
  32. $cat = explode('/', $dir);
  33. $category = $cat[3];
  34. $dt = $oldurl[0];
  35. $t = str_replace('-', '', $dt);
  36. $time = new DateTime($t);
  37. $timestamp = $time->format("Y-m-d H:i:s");
  38. // The post date
  39. $postdate = strtotime($timestamp);
  40. // The post URL
  41. if (permalink_type() == 'default') {
  42. $delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destination=' . $destination;
  43. } else {
  44. // The post URL
  45. $delete = site_url() . permalink_type() . '/' . $oldmd . '/delete?destination=' . $destination;
  46. }
  47. $tags = tag_cloud(true);
  48. $tagslang = "content/data/tags.lang";
  49. if (file_exists($tagslang)) {
  50. $ptags = unserialize(file_get_contents($tagslang));
  51. $tkey = array_keys($tags);
  52. if (!empty($ptags)) {
  53. $newlang = array_intersect_key($ptags, array_flip($tkey));
  54. } else {
  55. $newlang = array_combine($tkey, $tkey);
  56. }
  57. $tmp = serialize($newlang);
  58. file_put_contents($tagslang, print_r($tmp, true), LOCK_EX);
  59. }
  60. $images = image_gallery(null, 1, 40);
  61. $fields = array();
  62. $field_file = 'content/data/field/post.json';
  63. if (file_exists($field_file)) {
  64. $fields = json_decode(file_get_contents($field_file, true));
  65. }
  66. ?>
  67. <link rel="stylesheet" type="text/css" href="<?php echo site_url() ?>system/admin/editor/css/editor.css"/>
  68. <script src="<?php echo site_url() ?>system/resources/js/jquery.min.js"></script>
  69. <script src="<?php echo site_url() ?>system/resources/js/jquery-ui.min.js"></script>
  70. <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Converter.js"></script>
  71. <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Sanitizer.js"></script>
  72. <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script>
  73. <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Extra.js"></script>
  74. <link rel="stylesheet" href="<?php echo site_url() ?>system/resources/css/jquery-ui.css">
  75. <script>
  76. $( function() {
  77. // Decode HTML entities
  78. function decodeHtml(html) {
  79. var txt = document.createElement("textarea");
  80. txt.innerHTML = html;
  81. return txt.value;
  82. }
  83. var availableTags = [
  84. <?php foreach ($tags as $tag => $count):?>
  85. "<?php echo tag_i18n($tag) ?>",
  86. <?php endforeach;?>
  87. ].map(decodeHtml); // Decoding all tags
  88. function split( val ) {
  89. return val.split( /,\s*/ );
  90. }
  91. function extractLast( term ) {
  92. return split( term ).pop();
  93. }
  94. $( "#pTag" )
  95. // don't navigate away from the field on tab when selecting an item
  96. .on( "keydown", function( event ) {
  97. if ( event.keyCode === 9 && // 9 = tab
  98. $( this ).autocomplete( "instance" ).menu.active ) {
  99. event.preventDefault();
  100. }
  101. })
  102. .autocomplete({
  103. minLength: 0,
  104. source: function( request, response ) {
  105. // delegate back to autocomplete, but extract the last term
  106. response( $.ui.autocomplete.filter(
  107. availableTags, extractLast( request.term ) ) );
  108. },
  109. focus: function() {
  110. // prevent value inserted on focus
  111. return false;
  112. },
  113. select: function( event, ui ) {
  114. var terms = split( this.value );
  115. // remove the current input
  116. terms.pop();
  117. // add the selected item
  118. terms.push( ui.item.value );
  119. // add placeholder to get the comma-and-space at the end
  120. terms.push( "" );
  121. this.value = terms.join( ", " );
  122. return false;
  123. }
  124. });
  125. } );
  126. </script>
  127. <?php if (isset($error)) { ?>
  128. <div class="error-message"><?php echo $error ?></div>
  129. <?php } ?>
  130. <div class="notice error" id="response-error"></div>
  131. <div class="notice" id="response"></div>
  132. <div class="row">
  133. <div class="hide-button" style="margin-bottom:1em;width:100%;text-align:right;"><button type="button" title="<?php echo i18n('Focus_mode');?>" id="hideButton" class="note-btn btn btn-sm <?php echo ((config('admin.theme') === 'light' || is_null(config('admin.theme'))) ? "btn-light" : "btn-dark");?>" style="width:38px;height:38px;font-size:18px;" ><i class="fa fa-eye" aria-hidden="true"></i></button></div>
  134. <div class="wmd-panel" style="width:100%;">
  135. <form method="POST">
  136. <div id="post-settings" class="row">
  137. <div class="col-sm-6">
  138. <label for="pTitle"><?php echo i18n('Title');?> <span class="required">*</span></label>
  139. <input autofocus type="text" id="pTitle" name="title" class="form-control text <?php if (isset($postTitle)) { if (empty($postTitle)) { echo 'error';} } ?>" value="<?php echo $oldtitle ?>"/>
  140. <br>
  141. <label for="pCategory"><?php echo i18n('Category');?> <span class="required">*</span></label>
  142. <select id="pCategory" class="form-control" name="category">
  143. <?php foreach ($desc as $d):?>
  144. <option value="<?php echo $d->slug;?>" <?php if($category === $d->slug) { echo 'selected="selected"';} ?>><?php echo $d->title;?></option>
  145. <?php endforeach;?>
  146. </select>
  147. <br>
  148. <label for="pTag"><?php echo i18n('Tags');?> <span class="required">*</span></label>
  149. <input type="text" id="pTag" name="tag" class="form-control text <?php if (isset($postTag)) { if (empty($postTag)) { echo 'error'; } } ?>" value="<?php echo $oldtag ?>" placeholder="<?php echo i18n('Comma_separated_values');?>"/>
  150. <br>
  151. <label for="pMeta"><?php echo i18n('Meta_description');?> (<?php echo i18n('optional');?>)</label>
  152. <textarea id="pMeta" class="form-control" name="description" rows="3" cols="20" placeholder="<?php echo i18n('If_left_empty_we_will_excerpt_it_from_the_content_below');?>"><?php if (isset($p->description)) { echo $p->description; } else { echo $olddescription;} ?></textarea>
  153. <br>
  154. </div>
  155. <div class="col-sm-6">
  156. <div class="form-row">
  157. <div class="col">
  158. <label for="pDate"><?php echo i18n('Date');?></label>
  159. <input type="date" id="pDate" name="date" class="form-control text" value="<?php echo date('Y-m-d', $postdate); ?>">
  160. </div>
  161. <div class="col">
  162. <label for="pTime"><?php echo i18n('Time');?></label>
  163. <input step="1" type="time" id="pTime" name="time" class="form-control text" value="<?php echo $time->format('H:i:s'); ?>">
  164. </div>
  165. <small style="margin-top:10px;"><em><?php echo i18n('Scheduled_tips');?></em></small>
  166. </div>
  167. <br>
  168. <label for="pURL"><?php echo i18n('Slug');?> (<?php echo i18n('optional');?>)</label>
  169. <input type="text" id="pURL" name="url" class="form-control text" value="<?php echo $oldmd ?>" placeholder="<?php echo i18n('If_the_url_is_left_empty_we_will_use_the_post_title');?>"/>
  170. <br>
  171. <?php if ($type == 'is_audio'):?>
  172. <label for="pAudio"><?php echo i18n('Featured_Audio');?> <span class="required">*</span> (e.g Soundcloud)</label>
  173. <textarea rows="2" cols="20" class="media-uploader form-control text <?php if (isset($postAudio)) { if (empty($postAudio)) { echo 'error';} } ?>" id="pAudio" name="audio"><?php echo $oldaudio; ?></textarea>
  174. <input type="hidden" name="is_audio" value="is_audio">
  175. <br>
  176. <?php endif;?>
  177. <?php if ($type == 'is_video'):?>
  178. <label for="pVideo"><?php echo i18n('Featured_Video');?> <span class="required">*</span> (e.g Youtube)</label>
  179. <textarea rows="2" cols="20" class="media-uploader form-control text <?php if (isset($postVideo)) { if (empty($postVideo)) { echo 'error';} } ?>" id="pVideo" name="video"><?php echo $oldvideo ?></textarea>
  180. <input type="hidden" name="is_video" value="is_video">
  181. <br>
  182. <?php endif;?>
  183. <?php if ($type == 'is_image'):?>
  184. <style>.imgPrev img {width:50%;} </style>
  185. <label for="pImage"><?php echo i18n('Featured_Image');?> <span class="required">*</span></label>
  186. <br>
  187. <label class="btn btn-primary btn-sm" id="insertButton"><?php echo i18n('Insert_Image');?></label>
  188. <br>
  189. <div class="imgPrev"><img id="imgFile" src="<?php echo $oldimage; ?>"/></div>
  190. <br>
  191. <input type="text" class="media-uploader form-control text <?php if (isset($postImage)) { if (empty($postImage)) { echo 'error';}} ?>" id="pImage" name="image" readonly value="<?php echo $oldimage; ?>">
  192. <input type="hidden" name="is_image" value="is_image">
  193. <br>
  194. <?php endif;?>
  195. <?php if ($type == 'is_quote'):?>
  196. <label for="pQuote"><?php echo i18n('Featured_Quote');?> <span class="required">*</span></label>
  197. <textarea rows="3" cols="20" class="form-control text <?php if (isset($postQuote)) { if (empty($postQuote)) { echo 'error';} } ?>" id="pQuote" name="quote"><?php echo $oldquote ?></textarea>
  198. <input type="hidden" name="is_quote" value="is_quote">
  199. <br>
  200. <?php endif;?>
  201. <?php if ($type == 'is_link'):?>
  202. <label for="pLink"><?php echo i18n('Featured_Link');?> <span class="required">*</span></label>
  203. <textarea rows="2" cols="20" class="form-control text <?php if (isset($postLink)) { if (empty($postLink)) { echo 'error';} } ?>" id="pLink" name="link"><?php echo $oldlink ?></textarea>
  204. <input type="hidden" name="is_link" value="is_link">
  205. <br>
  206. <?php endif;?>
  207. <?php if ($type == 'is_post'):?>
  208. <input type="hidden" name="is_post" value="is_post">
  209. <?php endif;?>
  210. <input id="oldfile" type="hidden" name="oldfile" class="text" value="<?php echo $filename; ?>"/>
  211. <input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">
  212. </div>
  213. </div>
  214. <div class="row">
  215. <div class="col-sm-12" style="text-align:right;">
  216. <button class="note-btn btn btn-sm <?php echo ((config('admin.theme') === 'light' || is_null(config('admin.theme'))) ? "btn-light" : "btn-dark");?>" style="width:38px;height:38px;font-size:18px;" type="button" title="Toggle <?php echo i18n('Preview');?>" id="preview-toggle" class="btn btn-secondary btn-xs"><i class="fa fa-columns" aria-hidden="true"></i></button>
  217. </div>
  218. </div>
  219. <div class="row">
  220. <div class="col-sm-6" id="editor-col">
  221. <div>
  222. <input type="hidden" id="pType" name="posttype" value="<?php echo $type; ?>">
  223. <label for="wmd-input"><?php echo i18n('Content');?> <span class="required">*</span></label>
  224. <div id="wmd-button-bar" class="wmd-button-bar"></div>
  225. <textarea id="wmd-input" class="form-control wmd-input <?php if (isset($postContent)) { if (empty($postContent)) { echo 'error'; } } ?>" name="content" cols="20" rows="15"><?php echo $oldcontent ?></textarea>
  226. <br>
  227. <?php if(!empty($fields)):?>
  228. <details id="custom-fields" >
  229. <summary id="custom-fields-click" style="padding:10px; margin-bottom:10px; <?php echo ((config('admin.theme') === 'light' || is_null(config('admin.theme'))) ? "background-color: #E4EBF1;" : "background-color: rgba(255,255,255,.1);");?>"><strong><?php echo i18n('custom_fields');?></strong></summary>
  230. <div class="row">
  231. <div class="col">
  232. <?php foreach ($fields as $fld):?>
  233. <?php if ($fld->type == 'text'):?>
  234. <label><?php echo $fld->label;?></label>
  235. <input type="<?php echo $fld->type;?>" placeholder="<?php echo $fld->info;?>" class="form-control text" id="<?php echo $fld->name;?>" name="<?php echo $fld->name;?>" value="<?php echo get_field($fld->name, $content);?>"/>
  236. <br>
  237. <?php elseif ($fld->type == 'textarea'):?>
  238. <label><?php echo $fld->label;?></label>
  239. <textarea class="form-control text" id="<?php echo $fld->name;?>" rows="3" placeholder="<?php echo $fld->info;?>" name="<?php echo $fld->name;?>"><?php echo get_field($fld->name, $content);?></textarea>
  240. <br>
  241. <?php elseif ($fld->type == 'checkbox'):?>
  242. <input type="<?php echo $fld->type;?>" id="<?php echo $fld->name;?>" name="<?php echo $fld->name;?>" <?php echo get_field($fld->name, $content);?>>
  243. <label for="<?php echo $fld->name;?>"><?php echo $fld->label;?></label>
  244. <span class="d-block mt-1"><small><em><?php echo $fld->info;?></em></small></span>
  245. <br>
  246. <?php elseif ($fld->type == 'select'):?>
  247. <label for="<?php echo $fld->name;?>"><?php echo $fld->label;?></label>
  248. <select id="<?php echo $fld->name;?>" class="form-control" name="<?php echo $fld->name;?>">
  249. <?php foreach ($fld->options as $val):?>
  250. <option value="<?php echo $val;?>" <?php if (get_field($fld->name, $content) === $val) { echo 'selected="selected"';} ?>><?php echo $val;?></option>
  251. <?php endforeach;?>
  252. </select>
  253. <span class="d-block mt-1"><small><em><?php echo $fld->info;?></em></small></span>
  254. <br>
  255. <?php endif;?>
  256. <?php endforeach;?>
  257. </div>
  258. </div>
  259. </details>
  260. <br>
  261. <script>if(localStorage.getItem("custom-fields-state")==="open"){document.getElementById("custom-fields").setAttribute("open","")}document.getElementById("custom-fields-click").addEventListener("click",()=>{if(document.getElementById("custom-fields").open){localStorage.setItem("custom-fields-state",'close')}else{localStorage.setItem("custom-fields-state",'open')}})</script>
  262. <?php endif;?>
  263. <?php if ($isdraft[4] == 'draft') { ?>
  264. <input type="submit" name="publishdraft" class="btn btn-primary submit" value="<?php echo i18n('Publish_draft');?>"/> <input type="submit" name="updatedraft" class="btn btn-primary draft" value="<?php echo i18n('Update_draft');?>"/> <a class="btn btn-danger" href="<?php echo $delete ?>"><?php echo i18n('Delete');?></a>
  265. <?php } else { ?>
  266. <input type="submit" name="updatepost" class="btn btn-primary submit" value="<?php echo i18n('Update_post');?>"/> <input type="submit" name="revertpost" class="btn btn-primary revert" value="<?php echo i18n('Revert_to_draft');?>"/> <a class="btn btn-danger" href="<?php echo $delete ?>"><?php echo i18n('Delete');?></a>
  267. <?php }?>
  268. <br>
  269. </div>
  270. </div>
  271. <div class="col-sm-6" id="preview-col">
  272. <label><?php echo i18n('Preview');?></label>
  273. <br>
  274. <div id="wmd-preview" class="wmd-panel wmd-preview <?php if (config('admin.theme') === 'dark'){echo "card";}?>" style="width:100%;overflow:auto;"></div>
  275. </div>
  276. </div>
  277. </form>
  278. </div>
  279. <style>
  280. .wmd-prompt-background {z-index:10!important;}
  281. #wmd-preview img {max-width:100%;}
  282. </style>
  283. <div class="modal fade" id="insertImageDialog" tabindex="-1" role="dialog" aria-labelledby="insertImageDialogTitle" aria-hidden="true">
  284. <div class="modal-dialog modal-xl" role="document">
  285. <div class="modal-content">
  286. <div class="modal-header">
  287. <p class="modal-title" id="insertImageDialogTitle"><?php echo i18n('Insert_Image');?></p>
  288. <button type="button" class="close" id="insertImageDialogClose" data-dismiss="modal" aria-label="Close">
  289. <span aria-hidden="true">&times;</span>
  290. </button>
  291. </div>
  292. <div class="modal-body">
  293. <div class="row">
  294. <div class="col-9">
  295. <div class="form-group">
  296. <div class="row-fluid img-container" id="gallery-1">
  297. <?php echo $images;?>
  298. </div>
  299. </div>
  300. </div>
  301. <div class="col">
  302. <div class="form-group">
  303. <label for="insertImageDialogURL">URL</label>
  304. <textarea class="form-control" id="insertImageDialogURL" rows="5" placeholder="<?php echo i18n('Enter_image_URL');?>" ></textarea>
  305. </div>
  306. <hr>
  307. <div class="form-group">
  308. <label for="insertImageDialogFile"><?php echo i18n('Upload');?></label>
  309. <input type="file" class="form-control-file" name="file" id="insertImageDialogFile" accept="image/png,image/jpeg,image/gif, image/webp" style="display:none;" />
  310. <button id="dropZoneIIDF" class="vs-dropzone" type="button">Drag &amp; Drop image here, or click to browse</button>
  311. </div>
  312. <hr>
  313. <div class="form-group">
  314. <button type="button" class="btn btn-primary" id="insertImageDialogInsert"><?php echo i18n('Insert_Image');?></button>
  315. <button type="button" class="btn btn-secondary" id="insertImageDialogCancel" data-dismiss="modal"><?php echo i18n('Cancel');?></button>
  316. </div>
  317. </div>
  318. </div>
  319. </div>
  320. </div>
  321. </div>
  322. </div>
  323. <?php if ($type == 'is_image'):?>
  324. <div class="modal fade" id="insertMediaDialog" tabindex="-1" role="dialog" aria-labelledby="insertMediaDialogTitle" aria-hidden="true">
  325. <div class="modal-dialog modal-xl" role="document">
  326. <div class="modal-content">
  327. <div class="modal-header">
  328. <p class="modal-title" id="insertMediaDialogTitle"><?php echo i18n('Insert_Image');?></p>
  329. <button type="button" class="close" id="insertMediaDialogClose" data-dismiss="modal" aria-label="Close">
  330. <span aria-hidden="true">&times;</span>
  331. </button>
  332. </div>
  333. <div class="modal-body">
  334. <div class="row">
  335. <div class="col-9">
  336. <div class="form-group">
  337. <div class="row-fluid img-container" id="gallery-2">
  338. <?php echo $images;?>
  339. </div>
  340. </div>
  341. </div>
  342. <div class="col">
  343. <div class="form-group">
  344. <label for="insertMediaDialogURL">URL</label>
  345. <textarea class="form-control" id="insertMediaDialogURL" rows="5" placeholder="<?php echo i18n('Enter_image_URL');?>"></textarea>
  346. </div>
  347. <hr>
  348. <div class="form-group">
  349. <label for="insertMediaDialogFile"><?php echo i18n('Upload');?></label>
  350. <input type="file" class="form-control-file" name="file" id="insertMediaDialogFile" accept="image/png,image/jpeg,image/gif, image/webp" style="display:none;" />
  351. <button id="dropZoneIMDF" class="vs-dropzone" type="button">Drag &amp; Drop image here, or click to browse</button>
  352. </div>
  353. <hr>
  354. <div class="form-group">
  355. <button type="button" class="btn btn-primary" id="insertMediaDialogInsert"><?php echo i18n('Insert_Image');?></button>
  356. <button type="button" class="btn btn-secondary" id="insertMediaDialogCancel" data-dismiss="modal"><?php echo i18n('Cancel');?></button>
  357. </div>
  358. </div>
  359. </div>
  360. </div>
  361. </div>
  362. </div>
  363. </div>
  364. <?php endif;?>
  365. </div>
  366. <!-- Declare the base path. Important -->
  367. <script type="text/javascript">
  368. var base_path = '<?php echo site_url() ?>';
  369. var initial_image = <?php echo json_encode($images); ?>;
  370. var parent_page = '';
  371. var addEdit = 'edit';
  372. var saveInterval = 60000;
  373. const field = [<?php foreach ($fields as $f){ echo '"' . $f->name . '", ';}?>];
  374. </script>
  375. <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/editor.js"></script>
  376. <script type="text/javascript" src="<?php echo site_url() ?>system/resources/js/media.uploader.js"></script>
  377. <script>
  378. function loadImages(page) {
  379. $.ajax({
  380. url: '<?php echo site_url();?>admin/gallery',
  381. type: 'POST',
  382. data: { page: page },
  383. dataType: 'json',
  384. success: function(response) {
  385. $('#gallery-1').html(response.images);
  386. $('#gallery-2').html(response.images);
  387. }
  388. });
  389. }
  390. $('.img-container').on("click", ".the-img", function(e) {
  391. $('#insertMediaDialogURL').val($(e.target).attr('src'));
  392. $('#insertImageDialogURL').val($(e.target).attr('src'));
  393. });
  394. </script>
  395. <script>
  396. function toggleDivs() {
  397. var div1 = document.getElementById('post-settings');
  398. if (div1.style.display === 'none') {
  399. div1.style.display = '';
  400. document.body.classList.add("sidebar-mini");
  401. document.body.classList.remove("sidebar-collapse");
  402. } else {
  403. div1.style.display = 'none';
  404. document.body.classList.remove("sidebar-mini");
  405. document.body.classList.add("sidebar-collapse");
  406. }
  407. }
  408. document.getElementById('hideButton').addEventListener('click', toggleDivs);
  409. </script>
  410. <?php if (config('autosave.enable') == 'true' ):?>
  411. <?php if ($isdraft[4] == 'draft') : ?>
  412. <script src="<?php echo site_url();?>system/resources/js/save_draft.js?v=1"></script>
  413. <?php endif;?>
  414. <?php endif;?>
  415. <script>
  416. if (localStorage.getItem("preview-state") === "open") {
  417. document.getElementById("editor-col").classList.remove('col-sm-12');
  418. document.getElementById("editor-col").classList.add('col-sm-6');
  419. document.getElementById("preview-col").style.display = '';
  420. } else if (localStorage.getItem("preview-state") === "close") {
  421. document.getElementById("editor-col").classList.remove('col-sm-6');
  422. document.getElementById("editor-col").classList.add('col-sm-12');
  423. document.getElementById("preview-col").style.display = 'none';
  424. }
  425. document.getElementById("preview-toggle").addEventListener("click", () => {
  426. if (document.getElementById("editor-col").className.includes("col-sm-6")) {
  427. document.getElementById("editor-col").classList.remove('col-sm-6');
  428. document.getElementById("editor-col").classList.add('col-sm-12');
  429. document.getElementById("preview-col").style.display = 'none';
  430. localStorage.setItem("preview-state", 'close');
  431. } else {
  432. document.getElementById("editor-col").classList.remove('col-sm-12');
  433. document.getElementById("editor-col").classList.add('col-sm-6');
  434. document.getElementById("preview-col").style.display = '';
  435. localStorage.setItem("preview-state", 'open');
  436. }
  437. })
  438. </script>