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 / optimized.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
optimized.js
90 lines
1 import {Score} from "./score";
2 import {useEffect,useState} from "react";
3 import {set_scoreData} from "./set_scoreData";
4 import {ScoreReanalyzing} from "./ScoreReanalyzing";
5 import {Optimizing} from "./optimizing";
6 const { __ } = wp.i18n;
7
8 export const Optimized = ({metas, post_id}) => {
9 let score_data = set_scoreData( {post_id, metas} );
10 let scoreReanalyzingValues = ScoreReanalyzing( {post_id, score_data} );
11 useEffect(() => {
12 const elements = document.getElementsByClassName('two-score-circle');
13 for (let i = 0; i < elements.length; i++) {
14 two_draw_score_circle(elements[i]);
15 }
16 }, [score_data]);
17 const [isLoading, setIsLoading] = useState(false);
18 const optimize = (post_id) => {
19 setIsLoading(true);
20 fetch(two_speed.ajax_url + '?action=two_optimize_page&post_id=' + post_id + '&nonce=' + two_speed.nonce + '&initiator=gutenberg')
21 .then(_res => {
22 });
23 }
24 let date = 0;
25 if ( score_data && score_data['current_score'] ) {
26 if( (post_id in two_speed.critical_pages) && two_speed.critical_pages[post_id]['critical_date'] ) {
27 date = two_speed.critical_pages[post_id]['critical_date'];
28 } else if( score_data['current_score']['date'] ) {
29 date = Date.parse(score_data['current_score']['date']);
30 }
31 }
32 let modified_date='',re_optimize = false;
33 modified_date = Date.parse(wp.data.select('core/editor').getEditedPostAttribute('modified') + 'Z')/1000;
34 if ( modified_date > date && date != 0 ) {
35 re_optimize = true;
36 }
37
38 let re_opt_button = <div className="two-score-container-reoptimize">
39 <a onClick={() => optimize(post_id)}
40 data-initiator="gutenberg"
41 className="two-button-green ">{__('Re-optimize', 'tenweb-speed-optimizer')}</a>
42 </div>;
43 if ( scoreReanalyzingValues.reanalyzingStatus ) {
44 re_opt_button = <div className="two-score-container-reoptimize">
45 <a href='#'
46 className="two-button-green two-deactivated-button">{__('Re-optimize', 'tenweb-speed-optimizer')}</a>
47 </div>;
48 }
49 const title = wp.data.select("core/editor").getEditedPostAttribute( 'title' );
50
51 if ( isLoading ) {
52 let optimizingTitle = 'Re-optimizing...';
53 return <Optimizing title={optimizingTitle} />;
54 } else {
55 return (
56 <div className="two-score-section two-score-section-gutenberg">
57 <p className="two-gutenberg-container-title">
58 <span><b>{title}</b></span>{__(' page is successfully optimized', 'tenweb-speed-optimizer')}</p>
59 <div className="two-score-container-both">
60 <div className="two-score-container-old">
61 <div className="two-score-header">{__('Before optimization', 'tenweb-speed-optimizer')}</div>
62 <div className={"two-old-scores " + scoreReanalyzingValues.no_old_scores}>
63 <Score score={ score_data && score_data.previous_score && score_data.previous_score.mobile_score}
64 tti={score_data && score_data.previous_score && score_data.previous_score.mobile_tti}
65 device='Mobile'/>
66 <Score score={score_data && score_data.previous_score && score_data.previous_score.desktop_score}
67 tti={score_data && score_data.previous_score && score_data.previous_score.desktop_tti}
68 device='Desktop'/>
69 {scoreReanalyzingValues.score_check_link_before}
70 </div>
71 </div>
72 <div className="two-score-container-new">
73 <div className="two-score-header">{__('After optimization', 'tenweb-speed-optimizer')}</div>
74 <div className={"two-new-scores " + scoreReanalyzingValues.no_new_scores}>
75 <Score score={score_data && score_data.current_score && score_data.current_score.mobile_score}
76 tti={score_data && score_data.current_score && score_data.current_score.mobile_tti}
77 device='Mobile'/>
78 <Score score={score_data && score_data.current_score && score_data.current_score.desktop_score}
79 tti={score_data && score_data.current_score && score_data.current_score.desktop_tti}
80 device='Desktop'/>
81 {scoreReanalyzingValues.score_check_link_after}
82 </div>
83 </div>
84 </div>
85 {scoreReanalyzingValues.score_check_button}
86 {re_optimize && re_opt_button}
87 </div>
88 );
89 }
90 }