PluginProbe ʕ •ᴥ•ʔ
10Web Booster – Website speed optimization, Cache & Page Speed optimizer / trunk
10Web Booster – Website speed optimization, Cache & Page Speed optimizer vtrunk
2.33.0 2.30.5 2.30.7 2.30.9 2.31.10 2.31.8 2.32.11 2.32.21 2.32.3 2.32.4 2.32.7 2.6.31 2.6.40 2.6.42 2.6.7 2.7.37 2.7.44 2.7.47 2.8.18 2.8.19 2.8.32 2.8.34 2.8.35 2.9.23 2.9.24 2.9.25 2.9.27 v2.27.4 trunk 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.17 2.0.18 2.0.21 2.0.22 2.0.25 2.0.26 2.0.27 2.0.3 2.0.7 2.0.9 2.10.46 2.10.65 2.10.66 2.10.68 2.11.41 2.11.42 2.11.43 2.12.15 2.12.21 2.12.22 2.12.23 2.12.26 2.13.37 2.13.40 2.13.41 2.13.42 2.13.44 2.13.45 2.13.47 2.14.49 2.14.50 2.15.18 2.17.21 2.17.23 2.18.17 2.19.44 2.19.45 2.19.46 2.19.49 2.2.12 2.2.15 2.2.16 2.2.18 2.2.8 2.20.31 2.20.32 2.20.33 2.21.11 2.21.12 2.21.16 2.21.25 2.22.32 2.23.13 2.23.15 2.23.16 2.23.18 2.24.12 2.24.14 2.24.18 2.25.14 2.26.6 2.28.10 2.28.13 2.28.14 2.28.7 2.29.1 2.29.2 2.29.3 2.3.0 2.3.1 2.3.2 2.3.3 2.30.18
tenweb-speed-optimizer / assets / js / gutenbergComponents / ScoreReanalyzing.js
tenweb-speed-optimizer / assets / js / gutenbergComponents Last commit date
ScoreReanalyzing.js 3 years ago notOptimized.js 3 years ago optimized.js 3 years ago optimizing.js 3 years ago score.js 3 years ago set_scoreData.js 3 years ago
ScoreReanalyzing.js
117 lines
1 import {useState} from "react";
2 const { __ } = wp.i18n;
3
4 export const ScoreReanalyzing = ({post_id, score_data}) => {
5 let reanalyze_button_status = false, reanalyze_button_status_current = false, reanalyze_button_status_previous = false;
6 if( score_data ) {
7 if (score_data['current_score'] && score_data['current_score']['status']
8 && score_data['current_score']['status'] == 'inprogress' ) {
9 reanalyze_button_status = true;
10 reanalyze_button_status_current = true;
11 }
12 if (score_data['previous_score'] && score_data['previous_score']['status']
13 && score_data['previous_score']['status'] == 'inprogress' ) {
14 reanalyze_button_status = true;
15 reanalyze_button_status_previous = true;
16 }
17 }
18
19 let no_old_scores = '', no_new_scores = '', reanalyze_score_for = 'new';
20 let score_check_link_before = '', score_check_link_after ='', score_check_button ='';
21 if ( !score_data || !score_data['previous_score'] || reanalyze_button_status_previous ) {
22 no_old_scores = 'two-no-scores';
23 reanalyze_score_for = 'old';
24 }
25 if ( !score_data || !score_data['current_score'] || reanalyze_button_status_current ) {
26 no_new_scores = 'two-no-scores';
27 }
28 if ( no_old_scores != '' && no_new_scores != '' ) {
29 reanalyze_score_for = 'both';
30 }
31
32
33 const [isReanalyzing, setIsReanalyzing] = useState(reanalyze_button_status);
34 const [isReanalyzeButton, setIsReanalyzeButton] = useState(false);
35 const [new_no_new_scores, setno_new_scores] = useState(no_new_scores);
36
37 const reanalyze = (post_id,ReanalyzeButton) => {
38 if ( !isReanalyzing ) {
39 setIsReanalyzing(true);
40 if (ReanalyzeButton == 'button') {
41 setIsReanalyzeButton(true);
42 setno_new_scores('two-no-scores');
43 }
44
45 const url = two_speed.ajax_url;
46 var params = new FormData();
47
48 params.append('action', 'two_recount_score');
49 params.append('post_id', post_id);
50 params.append('nonce', two_speed.nonce);
51 params.append('initiator', 'gutenberg');
52 params.append('reanalyze_score_for', reanalyze_score_for);
53
54 fetch(url, {
55 method: "POST",
56 body: params,
57 }
58 )
59 .then(response => response.json())
60 .then(data => {
61 console.log(data)
62 })
63 .catch((err) => console.log(err));
64 }
65 }
66
67 if ( isReanalyzing ) {
68 score_check_button = <div className="two-gutenberg-reanalyze_container two_reanalyze_loading">
69 <a href="#" className="two_reanalyze_button">{__("Reanalyzing...", "tenweb-speed-optimizer")}</a>
70 <p className="two-description">{__("Reload in 2 minutes to see the new score","tenweb-speed-optimizer")}</p>
71 </div>;
72 if ( isReanalyzeButton ) {
73 score_check_link_after = <span className="two-page-speed two-optimizing"></span>;
74 if ( reanalyze_score_for == 'both') {
75 score_check_link_before = <span className="two-page-speed two-optimizing"></span>;
76 }
77 }
78 else {
79 if ( reanalyze_score_for == 'both') {
80 score_check_link_before = <span className="two-page-speed two-optimizing"></span>;
81 score_check_link_after = <span className="two-page-speed two-optimizing"></span>;
82 } else if (reanalyze_score_for == 'old'){
83 score_check_link_before = <span className="two-page-speed two-optimizing"></span>;
84 } else if (reanalyze_score_for == 'new') {
85 score_check_link_after = <span className="two-page-speed two-optimizing"></span>;
86 }
87 }
88 } else {
89 score_check_button = <div className="two-gutenberg-reanalyze_container">
90 <a onClick={() => reanalyze(post_id,'button')}
91 className="two_reanalyze_button">{__("Reanalyze", "tenweb-speed-optimizer")}
92 </a>
93 </div>;
94 let link = <a onClick={() => reanalyze(post_id,'')} data-post_id={post_id}
95 target="_blank" className="two_reanalyze_link"></a>;
96 if ( no_old_scores != '' && no_new_scores != '') {
97 score_check_link_before = link;
98 score_check_link_after = link;
99 } else if (no_old_scores != ''){
100 score_check_link_before = link;
101 score_check_link_after = '';
102
103 } else if (no_new_scores != '') {
104 score_check_link_before = '';
105 score_check_link_after = link;
106 }
107 }
108
109 return {
110 'score_check_button': score_check_button,
111 'score_check_link_before': score_check_link_before,
112 'score_check_link_after': score_check_link_after,
113 'no_new_scores': new_no_new_scores,
114 'no_old_scores': no_old_scores,
115 'reanalyzingStatus': isReanalyzing,
116 }
117 }