/
autosave-net.php
1682 lines (1476 loc) · 70 KB
/
autosave-net.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
Plugin Name: AutoSave Net
Plugin URI: http://wordquest.org/plugins/autosave-net/
Description: Auto-save safety net! Timed Backup of your Post Content while writing, with instant compare and restore content metabox.
Version: 1.3.4
Author: Tony Hayes
Author URI: http://dreamjester.net
GitHub Plugin URI: majick777/autosave-net
@fs_premium_only pro-functions.php
*/
if ( !function_exists( 'add_action' ) ) {
exit;
}
// === Development TODOs ===
// - better handling of visual/text editor view content ?
// - ability to compare to copy and pasted textarea Content ?
// - ability to compare to latest Wordpress AutoSave Content ?
// - ability to compare to earlier AutoSave Revisions Content ?
// - special option to set number of Revisions per post type ?
// === WordQuest Menus ===
// - Add WordQuest Submenu
// - WordQuest Submenu Icon Fix
// - Add WordQuest Sidebar Settings
// - Load WordQuest Admin Helper
// - Add Sidebar Floatbox
// === Plugin Setup ===
// - Plugin Options
// - Plugin Settings
// - Start Plugin Loader Instance
// - Define Plugin Constants
// - Define Version Constant
// === WordPress Autosave ===
// - Handle Wordpress AutoSave Options
// - Override AutoSave Time in Javascript
// - Dequeueue AutoSave Script
// - Limit Wordpress AutoSave Post Revisions
// === QuickSave Timer ===
// - Get Just Post Content Helper
// - Edit Screen Admin Notice
// - Display QuickSave Content Notice
// - Add Quicksave Metabox
// - Quicksave Metabox
// - QuickSave Save Forms
// - QuickSave Javascript
// === AJAX Actions ===
// - Quicksave via AJAX
// - Compare Saved Content via AJAX
// - Restore Saved Content via AJAX
// - Adjust Backup Timer via AJAX
// - Disable QuickSave for Post
// === Extra Scripts ===
// - DocReady Javascript
// - Smooth Scroll Jump Script
// ----------------------------
// Options / Filter Usage Notes
// ----------------------------
// use these filters to adjust autosave/revision limit on a conditional basis
// 'autosave_disable' (return 0 or 1)
// 'limit_post_revisions' (return empty or number)
// note: since AUTOSAVE_INTERVAL is a constant no filter has been made for it
// The default QuickSave Timer cycle is 60 seconds. To adjust use the filter:
// 'quicksave_timer' (return a value in seconds)
// By default Quicksave is active for all post types (including Custom Post Types.)
// To adjust the post types for which QuickSave is active use the filter:
// 'quicksave_post_types' (return an array of post types)
// By default Quicksave 'backup found' top admin notice is for post.php and edit.php
// For other post types which have their own edit screen, the notice is displayed
// in the Quicksave metabox, but you may want to move it to the top of screen.
// To adjust the screens for which Quicksave top admin notice is active use the filter:
// 'quicksave_notice_screens' (return an array of .php admin values)
// Quicksave metabox can be conditionally disabled by filter.
// 'quicksave_disabler' (return 1 to disable)
// -----------------------
// === WordQuest Menus ===
// -----------------------
// note: these actions must be added before loader is initiated
// ---------------------
// Add WordQuest Submenu
// ---------------------
add_filter( 'autosave_net_admin_menu_added', 'autosave_net_add_admin_menu', 10, 2 );
function autosave_net_add_admin_menu( $added, $args ) {
// --- filter menu capability early ---
$capability = apply_filters( 'wordquest_menu_capability', 'manage_options' );
// --- maybe add Wordquest top level menu ---
global $admin_page_hooks;
if ( empty( $admin_page_hooks['wordquest'] ) ) {
$icon = plugins_url( 'images/wordquest-icon.png', $args['file'] );
$position = apply_filters( 'wordquest_menu_position', '3' );
add_menu_page( 'WordQuest Alliance', 'WordQuest', $capability, 'wordquest', 'wqhelper_admin_page', $icon, $position );
}
// --- check if using parent menu ---
// (and parent menu capability)
if ( isset( $args['parentmenu']) && ( $args['parentmenu'] == 'wordquest' ) && current_user_can( $capability ) ) {
// --- add WordQuest Plugin Submenu ---
add_submenu_page( 'wordquest', $args['pagetitle'], $args['menutitle'], $args['capability'], $args['slug'], $args['namespace'] . '_settings_page' );
// --- add icons and styling fix to the plugin submenu :-) ---
add_action( 'admin_footer', 'autosave_net_wordquest_submenu_fix' );
return true;
}
return false;
}
// --------------------------
// WordQuest Submenu Icon Fix
// --------------------------
function autosave_net_wordquest_submenu_fix() {
$args = autosave_net_loader_instance()->args;
$icon_url = plugins_url( 'images/icon.png', $args['file'] );
if ( isset( $_REQUEST['page'] ) && ( $_REQUEST['page'] == $args['slug'] ) ) {$current = '1';} else {$current = '0';}
echo "<script>jQuery(document).ready(function() {if (typeof wordquestsubmenufix == 'function') {
wordquestsubmenufix('" . esc_js( $args['slug'] ) . "', '" . esc_url( $icon_url ) . "', '" . esc_js( $current ) . "');} });</script>";
}
// ------------------------------
// Add WordQuest Sidebar Settings
// ------------------------------
add_action( 'autosave_net_add_settings', 'autosave_net_add_settings' , 10, 1 );
function autosave_net_add_settings( $args ) {
if ( isset( $args['settings'] ) ) {
$adsboxoff = 'checked';
if ( file_exists($args['dir'] . '/updatechecker.php' ) ) {
$adsboxoff = '';
}
$sidebaroptions = array(
'installdate' => date( 'Y-m-d' ),
'donationboxoff' => '',
'subscribeboxoff' => '',
'reportboxoff' => '',
'adsboxoff' => $adsboxoff,
);
add_option( $args['settings'] . '_sidebar_options', $sidebaroptions );
}
}
// ---------------------------
// Load WordQuest Admin Helper
// ---------------------------
add_action( 'autosave_net_loader_helpers', 'autosave_net_load_wordquest_helper', 10, 1 );
function autosave_net_load_wordquest_helper( $args ) {
if ( is_admin() && ( version_compare( PHP_VERSION, '5.3.0') >= 0 ) ) {
$wqhelper = dirname( __FILE__ ) . '/wordquest.php';
if ( file_exists( $wqhelper ) ) {
include( $wqhelper );
global $wordquestplugins; $slug = $args['slug'];
$wordquestplugins[$slug] = $args;
}
}
}
// --------------------
// Add Sidebar Floatbox
// --------------------
add_action( 'autosave_net_admin_page_top', 'autosave_net_sidebar_floatbox' );
function autosave_net_sidebar_floatbox() {
$settings = autosave_net_loader_instance()->args;
$args = array( $settings['slug'], 'yes' );
$args = array( 'autosave-net', 'yes' );
if ( function_exists( 'wqhelper_sidebar_floatbox' ) ) {
wqhelper_sidebar_floatbox( $args );
echo wqhelper_sidebar_stickykitscript();
echo '<style>#floatdiv {float:right;}</style>';
echo '<script>jQuery("#floatdiv").stick_in_parent();
jQuery(document).ready(function() {
wrapwidth = jQuery("#pagewrap").width();
sidebarwidth = jQuery("#floatdiv").width();
newwidth = wrapwidth - sidebarwidth - 20;
jQuery("#wrapbox").css("width",newwidth+"px");
jQuery("#adminnoticebox").css("width",newwidth+"px");
});
</script>';
}
}
// ====================
// --- Plugin Setup ---
// ====================
// --------------
// Plugin Options
// --------------
// 1.3.4: updated options to use plugin loader
$options = array(
// --- Autosave Net Quicksave options ---
'quicksave_timer' => array(
'type' => 'numeric',
'default' => 60,
'min' => 10,
'max' => 10000,
'step' => 10,
'label' => __( 'QuickSave Interval Time', 'autosave-net' ),
'helper' => __( 'Global default for QuickSave Backups.', 'autosave-net'),
'section' => 'quicksave',
),
'quicksave_post_types' => array(
'type' => 'multicheck',
'default' => array( 'post', 'page' ),
'options' => 'POSTTYPES',
'label' => __( 'QuickSave Post Types', 'autosave-net' ),
'helper' => __( 'Post types to activate QuickSave for.', 'autosave-net' ),
'section' => 'quicksave',
),
// 1.3.4: removed plugin setting and made a filter
// 'quicksave_notice_screens' => array(
// 'type' => 'csv',
// 'default' => 'post.php, edit.php',
// 'label' => __( 'QuickSave Notice Screens','autosave-net' ),
// 'helper' => __( 'Admin screens to show QuickSave notices on.', 'autosave-net' ),
// 'section' => 'quicksave',
// ),
'quicksave_icons' => array(
'type' => 'radio',
'options' => array(
'dash' => __( 'Dashicons', 'autosave-net' ),
'colour' => __( 'Colour Icons', 'autosave-net' ),
),
'default' => 'dash',
'label' => __( 'QuickSave Icons', 'autosave-net' ),
'helper' => __( 'Icons to use for QuickSave controls.', 'autosave-net' ),
'section' => 'quicksave',
),
// --- WordPress Autosave options ---
'autosave_disable' => array(
'type' => 'checkbox',
'value' => '1',
'default' => '',
'label' => __( 'Disable WordPress AutoSave', 'autosave-net' ),
'helper' => __( 'Turns off WordPress AutoSave completely.', 'autosave-net' ),
'section' => 'autosave',
),
'autosave_time' => array(
'type' => 'numeric',
'default' => 60,
'min' => 10,
'max' => 3600,
'step' => 10,
'label' => __( 'AutoSave Interval Time', 'autosave-net' ),
'helper' => __( 'Time in seconds between WordPress AutoSaves', 'autosave-net' ),
'section' => 'autosave',
),
// --- WordPress Post Revisions ---
'autosave_revisions' => array(
'type' => 'numeric',
'default' => -1,
'min' => -1,
'max' => 999,
'step' => 1,
'label' => __( 'Limit AutoSave Post Revisions', 'autosave-net' ),
'helper' => __( 'AutoSave Revisions per post. -1 for no limit.', 'autosave-net' ),
'section' => 'revisions',
),
// TODO: special: number of revisions per post type ?
// --- section labels ---
'sections' => array(
'quicksave' => __( 'Content QuickSave Settings', 'autosave-net' ),
'autosave' => __( 'WordPress Autosave Settings', 'autosave-net' ),
'revisions' => __( 'WordPress Post Revisions', 'autosave-net' ),
),
);
// ---------------
// Plugin Settings
// ---------------
// 1.3.4: updated settings to use plugin loader
$slug = 'autosave-net';
$args = array(
// --- Plugin Info ---
'slug' => $slug,
'file' => __FILE__,
'version' => '0.0.1',
// --- Menus and Links ---
'title' => 'AutoSave Net',
'parentmenu' => 'wordquest',
'home' => 'http://wordquest.org/plugins/' . $slug . '/',
'support' => 'http://wordquest.org/quest-category/' . $slug . '/',
// 'share' => 'http://wordquest.org/plugins/' . $slug . '/#share',
'donate' => 'https://wordquest.org/contribute/?plugin=' . $slug,
'donatetext' => __( 'Support AutoSave Net' ),
'welcome' => '', // TODO
// --- Options ---
'namespace' => 'autosave_net',
'option' => 'autosave_net',
'options' => $options,
'settings' => 'fcs',
// --- WordPress.Org ---
'wporgslug' => 'autosave-net',
'textdomain' => 'autosave-net',
'wporg' => false,
// --- Freemius ---
'freemius_id' => '146',
'freemius_key' => 'pk_4c378ea656ccc7fb19bb6227eecca',
'hasplans' => false,
'hasaddons' => false,
'plan' => 'free',
);
// ----------------------------
// Start Plugin Loader Instance
// ----------------------------
require dirname( __FILE__ ) . '/loader.php';
new autosave_net_loader( $args );
// -----------------------
// Define Plugin Constants
// -----------------------
define( 'AUTOSAVENET_FILE', __FILE__ );
define( 'AUTOSAVENET_DIR', dirname( __FILE__ ) );
// -----------------------
// Define Version Constant
// -----------------------
add_action( 'plugins_loaded', 'autosave_net_set_version_constant', 11 );
function autosave_net_set_version_constant() {
$version = autosave_net_plugin_version();
if ( !defined( 'AUTOSAVENET_VERSION' ) ) {
define( 'AUTOSAVENET_VERSION', $version );
}
}
// --------------------------
// === WordPress AutoSave ===
// --------------------------
// ---------------------------------
// Handle Wordpress AutoSave Options
// ---------------------------------
add_action( 'plugins_loaded', 'autosave_net_wordpress_autosave' );
function autosave_net_wordpress_autosave() {
// 1.2.5: get filtered plugin options for wordpress autosave
$autosavedisable = autosave_net_get_setting( 'autosave_net_autosave_disable', true );
$autosavetime = (int)autosave_net_get_setting( 'autosave_time', true );
$autosaverevisions = autosave_net_get_setting( 'autosave_revisions', true );
if ( '1' == $autosavedisable ) {
// --- disable autosave by dequeueing script ---
add_action( 'admin_enqueue_scripts', 'autosave_net_dequeue_autosave', 11 );
} elseif ( ( $autosavetime ) && ( AUTOSAVE_INTERVAL != $autosavetime ) ) {
// --- override autosave interval time ---
// 1.3.4: override javascript variable instead as AUTOSAVE_INTERVAL is auto-defined
// define('AUTOSAVE_INTERVAL', $autosavetime);
add_action( 'admin_footer', 'autosave_net_override_autosave_interval', 999 );
}
// --- limit post revisions ---
// 1.3.4: simplify check to revision number filtering
if ( $autosaverevisions > -1 ) {
// 1.2.5: fix to incorrect function name call
add_filter( 'wp_revisions_to_keep', 'autosave_net_limit_post_revisions', 10, 2 );
}
}
// ------------------------------------
// Override AutoSave Time in Javascript
// ------------------------------------
function autosave_net_override_autosave_interval() {
$autosavetime = (int)autosave_net_get_setting( 'autosave_time', true );
echo "<script>jQuery(document).ready(function() {";
echo "if (typeof autosaveL10n == 'object') {";
echo "autosaveL10n.autosaveInterval = " . $autosavetime . ";";
echo "console.log('AutoSave Interval changed to " . $autosavetime . "'); console.log(autosaveL10n);";
echo "} });</script>";
}
// -------------------------
// Dequeueue AutoSave Script
// -------------------------
function autosave_net_dequeue_autosave() {
wp_dequeue_script( 'autosave' );
}
// ---------------------------------------
// Limit Wordpress AutoSave Post Revisions
// ---------------------------------------
function autosave_net_limit_post_revisions( $num, $post ) {
// 1.3.4: added recheck if post type supports revisions
if ( !post_type_supports( $post->post_type, 'revisions' ) ) {
$num = 0;
} else {
$num = autosave_net_get_setting( 'autosave_revisions' );
}
return $num;
}
// -----------------------
// === QuickSave Timer ===
// -----------------------
// ----------------------------
// Get Just Post Content Helper
// ----------------------------
function autosave_net_get_just_post_content( $postid ) {
global $wpdb;
// 1.3.4: use wpdb->prepare on query
$query = "SELECT post_content FROM " . $wpdb->prefix . "posts WHERE ID = %s";
$query = $wpdb->prepare( $query, $postid );
$postcontent = $wpdb->get_var( $query );
return $postcontent;
}
// -----------------------
// Translate Month Display
// -----------------------
function autosave_net_translate_month( $month ) {
// --- set months ---
$months = array(
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
);
// --- translate month ---
global $wp_locale;
foreach ( $months as $i => $fullmonth ) {
if ( $month == $fullmonth ) {
return $wp_locale->get_month( ( $i + 1 ) );
}
}
return $month;
}
// ------------------------
// Edit Screen Admin Notice
// ------------------------
function autosave_net_quicksave_notice() {
global $pagenow;
$checknotice = '';
// 1.3.4: remove plugin setting and make this a filter
// post.php and edit.php screens by default
// $postscreens = autosave_net_get_setting( 'quicksave_notice_screens', true );
$postscreens = array( 'post.php', 'edit.php' );
$postscreens = apply_filters( 'quicksave_notice_screens', $postscreens );
if ( is_array( $postscreens ) && ( count( $postscreens ) > 0 ) ) {
foreach ( $postscreens as $postscreen ) {
if ( $pagenow == $postscreen ) {
$checknotice = 'yes';
}
}
if ( 'yes' == $checknotice ) {
autosave_net_quicksave_check_notice( 'adminnotice' );
}
}
}
// --------------------------------
// Display QuickSave Content Notice
// --------------------------------
function autosave_net_quicksave_check_notice( $context ) {
global $post;
if ( !isset( $post ) || !is_object( $post ) ) {
return;
}
$postid = $post->ID;
$posttype = get_post_type( $postid );
$cpts = autosave_net_get_setting( 'quicksave_post_types', true );
if ( !is_array( $cpts ) ) {
return;
}
if ( !in_array( $posttype, $cpts ) ) {
return;
}
// --- Compare QuickSave Timestamp with Saved Post Content Timestamp ---
$backuptimestamp = get_post_meta( $postid, '_quicksavetime', true );
$modifiedtimestamp = get_post_modified_time( 'U', false, $postid, false );
if ( $backuptimestamp > $modifiedtimestamp ) {
// --- check for a content difference ---
$backupcontent = get_post_meta( $postid, '_quicksavecontent', true );
$savedcontent = autosave_net_get_just_post_content( $postid );
if ( $backupcontent != $savedcontent ) {
$backuptime = date( 'H:i:s', $backuptimestamp );
$modifiedtime = date( 'H:i:s', $modifiedtimestamp );
// --- bold emphasis on day/month/year differences ---
$backupyear = date( 'Y', $backuptimestamp );
$modifiedyear = date( 'Y', $modifiedtimestamp );
if ( $backupyear != $modifiedyear ) {
$backupyear = '<b>' . $backupyear . '</b>';
$modifiedyear = '<b>' . $modifiedyear . '</b>';
}
// 1.3.4: translate months using WP Locale
$backupmonth = autosave_net_translate_month( date( 'F', $backuptimestamp ) );
$modifiedmonth = autosave_net_translate_month( date( 'F', $modifiedtimestamp ) );
if ( $backupmonth != $modifiedmonth ) {
$backupmonth = '<b>' . $backupmonth . '</b>';
$modifiedmonth = '<b>' . $modifiedmonth . '</b>';
}
$backupday = date( 'jS', $backuptimestamp );
$modifiedday = date( 'jS', $modifiedtimestamp );
if ($backupday != $modifiedday) {
$backupday = '<b>' . $backupday . '</b>';
$modifiedday = '<b>' . $modifiedday . '</b>';
}
$backupdate = $backupday . ' ' . esc_html( __( 'of', 'autosave-net' ) ) . ' ' . $backupmonth . ' ' . $backupyear;
$backupdisplay = '<b>' . $backuptime . '</b> ' . __( 'on', 'autosave-net' ) . ' ' . $backupdate;
$modifieddate = $modifiedday . ' ' . esc_html( __( 'of', 'autosave-net' ) ) . ' ' . $modifiedmonth . ' ' . $modifiedyear;
$modifieddisplay = '<b>' . $modifiedtime . '</b> ' . esc_html( __( 'on', 'autosave-net' ) ) . ' ' . $modifieddate;
echo '<div class="error" style="padding:5px;line-height:20px;">';
echo esc_html( __( 'A more recent version of this post has been QuickSaved by AutoSave Net.', 'autosave-net' ) );
if ( 'adminnotice' == $context ) {
echo ' <a id="scrolltoquicksave" href="#quicksavemetabox">';
echo esc_html( __( 'Scroll down to the QuickSave metabox to compare versions.', 'autosave-net' ) );
echo '</a><br>';
} else {
$message .= "<br>";
}
echo esc_html( __( 'The QuickSave version was saved at', 'autosave-net' ) ) . ': ' . $backupdisplay . '<br>';
echo esc_html( __( 'and the actual post was last saved at', 'autosave-net' ) ) . ': ' . $modifieddisplay . '<br>';
echo '</div>';
// 1.2.5: moved smooth scroll jump script to footer
add_action( 'admin_footer', 'autosave_net_smooth_scroll_jump' );
}
}
}
// ---------------------
// Add Quicksave Metabox
// ---------------------
add_action( 'admin_init', 'autosave_net_quicksave_add_metabox' );
function autosave_net_quicksave_add_metabox() {
$cpts = autosave_net_get_setting( 'quicksave_post_types' );
// 1.3.1: fix to default array fallback
if ( !is_array( $cpts ) ) {
$cpts = array( 'post','page' );
}
foreach ( $cpts as $cpt ) {
add_meta_box( 'autosave_net_metabox', __( 'QuickSave Content Backup Timer', 'autosave-net' ), 'autosave_net_quicksave_metabox', $cpt, 'normal', 'low' );
}
// TODO: maybe use add_settings_error instead ?
add_action( 'admin_notices', 'autosave_net_quicksave_notice' );
}
// -----------------
// Quicksave Metabox
// -----------------
function autosave_net_quicksave_metabox() {
global $pagenow, $post;
$postid = $post->ID;
// --- check disable for post switch ---
$quicksavedisabled = get_post_meta( $postid, '_quicksavedisabled', true );
$quicksavedisabled = apply_filters( 'quicksave_disabler', $quicksavedisabled );
if ( !$quicksavedisabled ) {
$quicksavedisabled = '';
}
// --- if this is a new post, do nothing and tell user ---
if ( 'post-new.php' == $pagenow ) {
echo esc_html( __( 'QuickSave does not launch until you Publish - or Save a Draft and refresh.', 'autosave-net' ) );
return;
}
// Timer Variables
// ---------------
$timestamp = time();
// delete_post_meta( $postid, '_quicksavetime' );
$backuptime = get_post_meta( $postid, '_quicksavetime', true );
$latestcontent = '';
// Filterable Timer Value
// ----------------------
$quicksavetimer = absint( autosave_net_get_setting( 'quicksave_timer', true ) );
// --- a name hash scroll link ---
echo '<a name="quicksavemetabox"></a>';
// Resize Helper Wrapper
echo '<div id="quicksavewrapper">';
// display check message if NOT in the filtered quicksave post screens
// 1.3.4: remove plugin setting and make a filter
// $postscreens = autosave_net_get_setting( 'quicksave_notice_screens', true );
$postscreens = array( 'post.php', 'edit.php' );
$postscreens = apply_filters( 'quicksave_notice_screens', $postscreens );
$checknotice = '';
if ( is_array( $postscreens ) && ( count( $postscreens ) > 0 ) ) {
foreach ( $postscreens as $postscreen ) {
if ( $pagenow == $postscreen ) {
$checknotice = 'yes';
}
}
if ( 'yes' != $checknotice ) {
autosave_net_quicksave_check_notice( 'adminnotice' );
}
}
// QuickSave Info Box
// ------------------
// 1.2.0: fix to icon logic here
if ( file_exists( get_stylesheet_directory() . '/images/quicksave-icons.png' ) ) {
$iconsurl = get_stylesheet_directory_uri() . '/images/quicksave-icons.png';
} elseif ( file_exists( get_template_directory() . '/images/quicksave-icons.png' ) ) {
$iconsurl = get_template_directory_uri() . '/images/quicksave-icons.png';
} else {
$iconsurl = plugins_url( 'images/quicksave-icons.png', __FILE__ );
}
// else {$iconurl = admin_url('/images/menu.png'); $menuicon = 'yes';}
$menuicon = 'no';
echo '<div id="quicksaveinfobox">';
echo '<center><table><tr><td>';
echo '<div style="background-image:url(\'' . esc_url( $iconsurl ) . '\');';
if ( 'yes' == $menuicon ) {
echo 'width:28px;height:28px;background-position:-149px -1px;';
} else {
echo 'width:32px;height:32px;background-position:0px 0px;';
}
echo '" title="' . esc_attr( __( 'Hide QuickSave Info' ) ) . '" onclick="quicksave_show_hide(\'quicksaveinfobox\');quicksave_info(\'off\');">';
echo '</td><td width="10"></td><td>';
echo '<ul style="padding:0;list-style:none;display:inline-block;">';
echo '<li style="display:inline-block;">';
echo '<a href="https://wordquest.org/plugins/autosave-net/" title="AutoSave Net Content Backup Timer" target=_blank style="text-decoration:none;"><b>AutoSave Net</b></a>';
echo ' v' . AUTOSAVENET_VERSION;
echo ' ' . esc_html( __( 'by', 'autosave-net' ) );
echo ' <a href="https://wordquest.org" target=_blank style="text-decoration:none;">WordQuest</a></li>';
echo '<li style="display:inline-block;width:30px;"></li>';
echo '<li style="display:inline-block;font-size:9pt;"><a href="https://wordquest.org/contribute/?plugin=autosave-net" target=_blank style="text-decoration:none;">→ ' . esc_html( __('Contribute','autosave-net' ) ) . '</a></li>';
echo '<li style="display:inline-block;width:10px;"></li>';
echo '<li style="display:inline-block;font-size:9pt;"><a href="https://wordquest.org/plugins/" target=_blank style="text-decoration:none;">→ ' . esc_html( __( 'More Great Plugins', 'autosave-net' ) ) . '</a></li>';
echo '</ul>';
echo '</td></tr></table></center>';
echo '</div>';
// QuickSave Global Settings
// -------------------------
$settingsurl = admin_url( 'options-general.php' ) . '?page=autosave-net';
echo '<div id="quicksavesettings" style="display:none;"><center>';
if ( current_user_can( 'manage_options' ) ) {
echo '<a href="' . esc_url( $settingsurl ) . '" target="_blank">';
echo esc_html( __( 'Click here for Global QuickSave Settings on the AutoSave Net admin page.', 'autosave-net' ) );
echo '</a>.<br>';
} else {
echo esc_html( __( 'Contact your Site Administrator to adjust QuickSave Global Settings for AutoSave Net.', 'autosave-net' ) ) . '<br>';
}
echo '</center></div>';
// User Controls
// -------------
echo '<center><table><tr>';
echo '<td><div id="infobutton" style="display:none;margin-right:10px;background-image:url(\'' . esc_url( $iconsurl ) . '\');';
if ( 'yes' == $menuicon ) {
echo 'width:28px;height:28px; background-position:-149px -1px;';
} else {
echo 'width:32px;height:32px;background-position:0px 0px;';
}
echo '" title="' . esc_attr( __( 'Show QuickSave Info', 'autosave-net' ) ) . '" onclick="quicksave_show_hide(\'quicksaveinfobox\');quicksave_info(\'on\');"></td>';
// --- Plus/Minus Timer Adjustment ---
echo '<td><table cellpadding="0" cellspacing="0"><tr>';
echo '<td><input type="button" class="button-secondary" title="' . esc_attr( __( 'Decrement Timer Length', 'autosave-net' ) ) . '" value="-" style="font-weight:bold;" onclick="quicksave_decrement_timer();"></td>';
echo '<td><input type="text" id="quicksavetime" value="' . esc_attr( $quicksavetimer ) . '" style="width:50px;text-align:center;"></td>';
echo '<td><input type="button" class="button-secondary" title="' . esc_attr( __( 'Increment Timer Length', 'autosave-net' ) ) . '" value="+" style="font-weight:bold;" onclick="quicksave_increment_timer();"></td>';
echo '<td width="5"></td><td>' . esc_html( __( 'second save cycle', 'autosave-net' ) ) . '.</td>';
echo '</tr></table></td>';
// --- Readonly Timer Countdown ---
echo '<td width="20"></td>';
echo '<td>' . esc_html( __( 'QuickSaving in', 'autosave-net' ) ) . ':</td>';
echo '<td width="5"></td>';
echo '<td><input id="quicksavecountdown" type="text" style="width:30px;text-align:center;" value="' . esc_attr( $quicksavetimer ) . '" readonly></td>';
// --- QuickSave Tool Buttons ---
$colouricons = autosave_net_get_setting( 'quicksave_icons', true );
if ( $colouricons ) {
// 1.3.4: fix to incorrect quoting
$iconstyle = "background-image:url('" . esc_url( $iconsurl ) . "');";
$dashicons = '';
} else {
$iconstyle = '';
$dashicons = 'dashicons ';
}
if ( 'yes' == $quicksavedisabled ) {
$enable = '';
$disable = 'display:none;';
$pauser = 'display:none;';
} else {
$disable = '';
$enable = 'display:none;';
$pauser = '';
}
echo '<td width="20"></td>';
// dashicon play f522 "dashicons-controls-play", pause f523 "dashicons-controls-pause"
echo '<td><div id="quicksavepauser" title="' . esc_attr( __( 'Pause QuickSave Timer', 'autosave-net' ) ) . '" onclick="quicksave_timer_pause();"';
echo ' style="' . esc_attr( $pauser ) . 'width:32px;height:32px;background-position: -32px 0px;' . $iconstyle . '" class="' . esc_attr( $dashicons ) . 'dashicons-controls-pause"';
echo '></div><div id="quicksaveresumer" title="'.__('Resume QuickSave Timer','autosave-net').'" onclick="quicksave_timer_pause();"';
echo ' style="display:none;width:32px;height:32px;background-position: -64px 0px;' . $iconstyle . '" class="' . esc_attr( $dashicons );
if ( '' != $dashicons ) {echo ' dashicons-controls-play';}
echo '"></div></td>';
// dashicon reset f463 "dashicons dashicons-update"
echo '<td><div id="quicksavereset" title="' . esc_attr( __( 'Reset QuickSave Timer', 'autosave-net' ) ) . '" onclick="quicksave_timer_reset();"';
echo ' style="width:32px;height:32px;background-position: -96px 0px;' . $iconstyle . '" class="' . esc_attr( $dashicons );
if ( '' != $dashicons ) {echo ' dashicons-update';}
echo '"></div></td>';
// dashicon enable f147 "dashicons-yes", disable f335 "dashicons-no"
echo '<td><div id="quicksaveenabler" title="' . esc_attr( __( 'Enable QuickSave Timer for this Post', 'autosave-net' ) ) . '" onclick="quicksave_enable_disable();"';
echo ' style="' . $enable . 'width:32px;height:32px;background-position: -160px 0px;' . $iconstyle . '" class="' . esc_attr( $dashicons ) . 'dashicons-yes"';
echo '></div><div id="quicksavedisabler" title="'.__('Disable QuickSave Timer for this Post','autosave-net').'" onclick="quicksave_enable_disable();"';
echo ' style="' . $disable . 'width:32px;height:32px;background-position: -128px 0px;' . $iconstyle . '" class="' . esc_attr( $dashicons );
if ( '' != $dashicons ) {echo ' dashicons-no';}
echo '"></div></td>';
// dashicon save ? f119 "dashicons dashicons-welcome-write-blog"
echo '<td><div id="quicksavesavenow" title="' . esc_attr( __( 'QuickSave Now', 'autosave-net' ) ) . '" onclick="quicksave_manual_quicksave();"';
echo ' style="width:32px;height:32px;background-position: -192px 0px;' . $iconstyle . '" class="' . esc_attr( $dashicons );
if ( '' != $dashicons ) {echo ' dashicons-welcome-write-blog';}
echo '"></div></td>';
// dashicon settings f111 "dashicons dashicons-admin-generic"
echo '<td><div id="quicksaveoptions" title="' . esc_attr( __( 'QuickSave Settings', 'autosave-net' ) ) . '" onclick="quicksave_show_hide(\'quicksavesettings\');"';
echo ' style="width:32px;height:32px;background-position: -224px 0px;' . $iconstyle . '" class="' . esc_attr( $dashicons );
if ( '' != $dashicons ) {echo ' dashicons-admin-generic';}
echo '"></div></td>';
// end table
echo '</tr></table></center>';
// QuickSave Message Box
// ---------------------
echo '<div id="quicksavebox" style="display:none;text-align:center;border-radius:3px;padding:3px;">';
echo '<span id="quicksavemessage"> </span></div><br>';
// Display Pageload Backup Content
// -------------------------------
$timedisplay = '';
$datedisplay = '';
if ( '' != $backuptime ) {
if ( $timestamp > $backuptime ) {
$timedisplay = date( 'H:i:s', $backuptime );
$datedisplay = date( 'jS \o\f F Y', $backuptime );
$backupcontent = $latestcontent = get_post_meta( $postid, '_quicksavecontent', true );
if ( $backupcontent && ( '' != $backupcontent ) ) {
echo '<input type="button" class="button-secondary" style="font-weight:bold;" onclick="quicksave_show_hide(\'pageloadbackup\');" value="' . esc_attr( __( 'Pageload QuickSaved Content', 'autosave-net' ) ) . '">';
echo '<span style="margin-left:30px;">' . esc_html( __( 'QuickSave Time', 'autosave-net' ) ) . ':</span>';
echo '<span style="margin-left:30px;" id="pageloadtime"><b>' . $timedisplay . '</b> ' . esc_html( __( 'on', 'autosave-net' ) ) . $datedisplay . '</span><br>';
echo '<div id="pageloadbackup" style="display:none;">';
echo '<table style="width:100%;">';
echo '<tr><td colspan="7">';
echo '<textarea rows="10" cols="80" style="width:100%;" id="pageloadbackupcontent" readonly>' . $backupcontent . '</textarea>';
echo '</td></tr><tr><td width="30"></td><td align="center">';
echo '<input type="button" class="button-secondary" title="' . esc_attr( __( 'Compares QuickSave Backup on Pageload with Current Edited Content', 'autosave-net' ) ) . '" value="' . esc_attr( __( 'Compare with Current', 'autosave-net' ) ) . '" onclick="quicksave_compare_versions(\'pageload\',\'current\');">';
echo '</td><td width="30"></td><td align="center">';
echo '<input type="button" class="button-secondary" title="' . esc_attr( __( 'Compares Quicksave Backup on Pageload with Saved Database Content', 'autosave-net' ) ) . '" value="' . esc_attr( __( 'Compare with Database', 'autosave-net' ) ) . '" onclick="quicksave_compare_versions(\'pageload\',\'saved\');">';
echo '</td><td width="30"></td><td align="center">';
echo '<input type="button" class="button-secondary" title="' . esc_attr( __( 'Restores Quicksave Backup on Pageload to Content Editing Area', 'autosave-net' ) ) . '" value="' . esc_attr( __( 'Restore this QuickSave', 'autosave-net' ) ) . '" onclick="quicksave_restore_content(\'pageload\');">';
echo '</td></tr>';
echo '</table></div><br>';
}
}
}
// Display Latest QuickSave Content
// --------------------------------
echo '<input type="button" class="button-secondary" style="font-weight:bold;margin-left:15px;" onclick="quicksave_show_hide(\'latestquicksave\');" value="' . esc_attr( __( 'Latest QuickSaved Content', 'autosave-net' ) ) . '">';
echo '<span style="margin-left:30px;">' . esc_html( __( 'QuickSave Time', 'autosave-net' ) ) . ':</span>';
echo '<span style="margin-left:30px;" id="quicksavelatesttime">';
if ( ( '' != $timedisplay ) && ( '' != $datedisplay ) ) {
echo '<b>' . $timedisplay . '</b> ' . esc_html( __('on', 'autosave-net' ) ) . ' ' . $datedisplay;
} else {
echo esc_html( __( 'No QuickSave has happened yet...', 'autosave-net' ) );
}
echo '</span><br>';
echo '<div id="latestquicksave" style="display:none;">';
echo '<table style="width:100%;">';
echo '<tr><td colspan="7">';
echo '<textarea rows="10" cols="80" style="width:100%;" id="latestquicksavecontent" readonly>' . $latestcontent . '</textarea>';
echo '</td></tr><tr><td width="30"></td><td align="center">';
echo '<input type="button" class="button-secondary" title="' . esc_attr( __( 'Compares Latest QuickSave Backup with Current Edited Content', 'autosave-net' ) ) . '" value="' . esc_attr( __( 'Compare with Current', 'autosave-net' ) ) . '" onclick="quicksave_compare_versions(\'latest\',\'current\');">';
echo '</td><td width="30"></td><td align="center">';
echo '<input type="button" class="button-secondary" title="' . esc_attr( __( 'Compares Latest Quicksave Backup with Saved Database Content', 'autosave-net' ) ) . '" value="' . esc_attr( __( 'Compare with Database', 'autosave-net' ) ) . '" onclick="quicksave_compare_versions(\'latest\',\'saved\');">';
echo '</td><td width="30"></td><td align="center">';
echo '<input type="button" class="button-secondary" title="' . esc_attr( __( 'Restores Latest Quicksave Backup to Content Editing Area', 'autosave-net' ) ) . '" value="' . esc_attr( __( 'Restore this QuickSave', 'autosave-net' ) ) . '" onclick="quicksave_restore_content(\'latest\');">';
echo '</td></tr>';
echo '</table></div><br>';
// Hidden Backup Content Display
// -----------------------------
echo '<div id="contentbackupwrapper" style="display:none;">';
echo '<input type="button" class="button-secondary" style="font-weight:bold;margin-left:40px;" onclick="quicksave_show_hide(\'contentbackup\');" value="' . esc_attr( __( 'Content before Restore', 'autosave-net' ) ) . '">';
echo '<span style="margin-left:50px;">' . esc_html( __( 'Restore Time', 'autosave-net' ) ) . ':</span>';
echo '<span style="margin-left:30px;" id="contentbackuptime"></span><br>';
echo '<div id="contentbackup" style="display:none;">';
echo '<table style="width:100%;">';
echo '<tr><td colspan="7">';
echo '<textarea rows="10" cols="80" style="width:100%;" id="contentbackupcontent" readonly>' . $latestcontent . '</textarea>';
echo '</td></tr><tr><td width="30"></td><td align="center">';
echo '<input type="button" class="button-secondary" title="' . esc_attr( __( 'Compares Content Backup with Current Edited Content', 'autosave-net' ) ) . '" value="' . esc_attr( __( 'Compare with Current', 'autosave-net' ) ) . '" onclick="quicksave_compare_versions(\'backup\',\'current\');">';
echo '</td><td width="30"></td><td align="center">';
echo '<input type="button" class="button-secondary" title="' . esc_attr( __( 'Compares Content Backup with Saved Database Content', 'autosave-net' ) ) . '" value="' . esc_attr( __( 'Compare with Database', 'autosave-net' ) ) . '" onclick="quicksave_compare_versions(\'backup\',\'saved\');">';
echo '</td><td width="30"></td><td align="center">';
echo '<input type="button" class="button-secondary" title="' . esc_attr( __( 'Restores Content Backup to Content Editing Area', 'autosave-net' ) ) . '" value="' . esc_attr( __( 'Restore this Backup', 'autosave-net' ) ) . '" onclick="quicksave_restore_content(\'backup\');">';
echo '</td></tr>';
echo '</table></div><br></div>';
// --- hidden comparison iframe form target ---
echo '<div id="compareframewrapper" style="display:none;">';
echo '<br><center><b>' . esc_html( __( 'Content Comparison', 'autosave-net' ) ) . '</b></center><br>';
echo '<iframe name="compareframe" id="compareframe" src="javascript:void(0);" width="95%" height="200"></iframe>';
echo '</div>';
// --- hidden restored message ---
echo '<div id="restoredwrapper" style="display:none;background-color:#F0F000;text-align:center;">';
echo '<span id="restoredmessage"></span></div>';
// --- end quicksave wrapper ---
echo '</div>';
// --- enqueue Quicksave Forms ---
// put form in footer to not conflict with other forms
add_action( 'admin_footer','autosave_net_quicksave_save_forms' );
// --- enqueue QuickSave script ---
add_action( 'admin_footer','autosave_net_quicksave_save_javascript' );
}
// --------------------
// QuickSave Save Forms
// --------------------
function autosave_net_quicksave_save_forms() {
global $post;
$postid = $post->ID;
$quicksavetimer = absint( apply_filters( 'quicksave_timer', get_option( 'quicksave_timer' ) ) );
$userid = get_current_user_id();
// --- quicksave form ---
echo '<form id="quicksaveform" name="quicksaveform" target="quicksaveframe" action="admin-ajax.php?action=do_quick_save" method="post">';
echo '<input type="hidden" id="quicksaveid" name="quicksaveid" value="' . esc_attr( $postid ) . '">';
echo '<input type="hidden" id="quicksaveuserid" name="quicksaveuserid" value="' . esc_attr( $userid ) . '">';
echo '<textarea style="display:none;" id="quicksavecontent" name="quicksavecontent"></textarea>';
echo '<input type="hidden" id="quicksavetimer" name="quicksavetimer" value="' . esc_attr( $quicksavetimer ) . '">';
echo '<input type="hidden" id="quicksaveusertimer" name="quicksaveusertimer" value="' . esc_attr( $quicksavetimer ) . '">';
echo '<input type="hidden" id="quicksavemanual" name="quicksavemanual" value="">';
echo '<input type="hidden" id="quicksavepause" name="quicksavepause" value="">';
echo '</form>';
// - hidden iframe form target -
echo '<iframe style="display:none;" name="quicksaveframe" id="quicksaveframe" src="javascript:void(0);"></iframe>';
// --- compare form ---
echo '<form id="compareform" name="compareform" target="compareframe" action="admin-ajax.php?action=compare_quick_saves" method="post">';
echo '<input type="hidden" id="comparepostid" name="comparepostid" value="' . esc_attr( $postid ) . '">';
echo '<input type="hidden" id="compareuserid" name="compareuserid" value="' . esc_attr( $userid ) . '">';
echo '<textarea style="display:none;" id="savedcontent" name="savedcontent"></textarea>';
echo '<textarea style="display:none;" id="currentcontent" name="currentcontent"></textarea>';
echo '<input type="hidden" id="savedtype" name="savedtype" value="">';
echo '<input type="hidden" id="contenttype" name="contenttype" value="">';
echo '</form>';
// --- backup time form ---
echo '<form id="backuptimeform" name="backuptimeform" target="backuptimeframe" action="admin-ajax.php?action=quicksave_update_backup_time" method="post">';
echo '<input type="hidden" id="backupsource" name="backupsource" value="' . esc_attr( $postid ) . '">';
echo '</form>';
echo '<iframe style="display:none;" name="backuptimeframe" id="backuptimeframe" src="javascript:void(0);"></iframe>';
// 1.2.5: fix to missing meta value for post disable
$quicksavedisabled = get_post_meta( $postid, '_quicksavedisabled', true );
$quicksavedisabled = apply_filters( 'quicksave_disabler', $quicksavedisabled, $postid );
if ( !$quicksavedisabled ) {
$quicksavedisabled = '';
}
// --- disable form ---
echo '<form id="quicksavedisableform" name="quicksavedisableform" target="quicksavedisableframe" action="admin-ajax.php?action=quicksave_enable_disable" method="post">';
echo '<input type="hidden" id="quicksavedisablepostid" name="quicksavedisablepostid" value="' . esc_attr( $postid ) . '">';
echo '<input type="hidden" id="quicksavedisableuserid" name="quicksavedisableuserid" value="' . esc_attr( $userid ) . '">';
echo '<input type="hidden" id="quicksavedisable" name="quicksavedisable" value="' . esc_attr( $quicksavedisabled ) . '">';
echo '</form>';
// - hidden iframe form target -
echo '<iframe style="display:none;" name="quicksavedisableframe" id="quicksavedisableframe" src="javascript:void(0);"></iframe>';
}
// --------------------
// QuickSave Javascript
// --------------------
function autosave_net_quicksave_save_javascript() {
// DocReady Javascript
// -------------------
echo "<script>";
echo autosave_net_docready_javascript();
echo "</script>";
// QuickSave Javascript
// -------------------
// 1.3.4: fix to metabox ID and style height in quicksave_wrapper_resize
echo "<script>
var thepostcontent; var quicksavetimer; var quicksavecycle;
var quicksavedisabled = document.getElementById('quicksavedisable').value;
function quicksave_wrapper_resize() {
newheight = document.getElementById('quicksavewrapper').scrollHeight;
document.getElementById('autosave_net_metabox').style.height = newheight + 50 + 'px';
}
function quicksave_info(onoff) {
if (onoff == 'on') {document.getElementById('infobutton').style.display = 'none';}
if (onoff == 'off') {document.getElementById('infobutton').style.display = '';}
}
function quicksave_show_hide(divid) {
if (document.getElementById(divid).style.display == 'none') {
document.getElementById(divid).style.display = '';
}
else {document.getElementById(divid).style.display = 'none';}
quicksave_wrapper_resize();
}
function quicksave_increment_timer() {
var timerinput = document.getElementById('quicksavetime');
var quicksavetimer = document.getElementById('quicksavetimer').value;
var textint = parseInt(timerinput.value);
if (isNaN(textint)) {timerinput.value = quicksavetimer;}
else {timerinput.value++;}
}
function quicksave_decrement_timer() {
var timerinput = document.getElementById('quicksavetime');
var quicksavetimer = document.getElementById('quicksavetimer').value;
var textint = parseInt(timerinput.value);
if (isNaN(textint)) {timerinput.value = quicksavetimer;}
else {
/* five second maximum */
if (timerinput.value > 5) {timerinput.value--;}
if (timerinput.value < 6) {timerinput.value = 5;}
}
}
function quicksave_timer_pause() {
if (document.getElementById('quicksavepause').value == 'yes') {
document.getElementById('quicksavepause').value = '';
document.getElementById('quicksaveresumer').style.display = 'none';
document.getElementById('quicksavepauser').style.display = '';
} else {
document.getElementById('quicksavepause').value = 'yes';
document.getElementById('quicksavepauser').style.display = 'none';
document.getElementById('quicksaveresumer').style.display = '';
}
}