edit-content.html.php 26 KB

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