PluginProbe
Hostinger Tools / 1.9.5
Hostinger Tools v1.9.5
3.0.77 3.0.76 3.0.75 3.0.74 3.0.73 3.0.72 3.0.71 3.0.70 3.0.69 3.0.68 3.0.67 3.0.66 1.8.1 1.8.2 1.8.3 1.9.1 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.4 All 108 releases
hostinger / src / js / main.js

main.js in Hostinger Tools 1.9.5, at src/js/main.js

207 lines 6.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import './autocomplete_steps';
2 import './videos'
3
4 ( function ( $ ) {
5 $( document ).on( 'ready', function () {
6 const openClass = 'open';
7 const completedClass = 'completed';
8 const homeTab = $( '.hostinger.hsr-onboarding' );
9 const learnTab = $( '.hsr-learn-more' );
10 const aiAssistantTab = $( '.hsr-ai-assistant-tab' );
11 aiAssistantTab.hide();
12 learnTab.hide();
13 let selectedTab = 'Home';
14 const stepsTitle = $( '.hsr-onboarding-step--title' )
15 const gotItBtn = $( '.hsr-got-it-btn' );
16 const publishBtn = $( '.hsr-publish-btn' );
17 const closeBtn = $( '.hsr-close-btn' );
18 const navigationItem = $( '.hsr-list__item' );
19 const knowledgeCard = $( '#card-knowledge' );
20 const helpCard = $( '#card-help' );
21
22 gotItBtn.on( 'click', function ( e ) {
23 e.preventDefault();
24 const element = $( this );
25 const step = $( this ).data( 'step' );
26 let remaining_tasks = $( '.hsr-onboarding-steps' ).data( 'remaining-tasks' );
27
28 $.ajax( {
29 type: 'post',
30 dataType: 'json',
31 url: ajaxurl,
32 data: {
33 action: 'hostinger_complete_onboarding_step',
34 step: step,
35 },
36 success: function () {
37 element.closest( '.hsr-onboarding-step--content' ).slideUp()
38 element.parents( '.hsr-onboarding-step' )
39 .find( '.hsr-onboarding-step--status' )
40 .addClass( completedClass )
41
42 if ( remaining_tasks > 0 ) {
43 remaining_tasks = remaining_tasks - 1;
44 $( '.hsr-onboarding-steps' ).data( 'remaining-tasks', remaining_tasks )
45
46 if ( remaining_tasks === 0 ) {
47 $( '.hsr-publish-btn' ).addClass( completedClass );
48 }
49
50 }
51 },
52 } )
53 } )
54
55 stepsTitle.on( 'click', function () {
56 $( this ).find( '.hsr-onboarding-step--expand' ).toggleClass( openClass );
57 $( this ).parent().find( '.hsr-onboarding-step--content' ).slideToggle( 200 );
58 } )
59
60 publishBtn.on( 'click', function ( e ) {
61 e.preventDefault();
62 $( '.hsr-modal' ).addClass( 'open' );
63 $( 'body' ).addClass( 'modal-open' );
64 $.ajax( {
65 type: 'post',
66 dataType: 'json',
67 url: ajaxurl,
68 data: {
69 action: 'hostinger_publish_website',
70 maintenance: 0,
71 },
72 success: function ( result ) {
73 const previewBtn = $( '.hsr-preview-btn' );
74 $( '.hsr-circular' ).addClass( 'hsr-hide' )
75 $( '.hsr-success-circular' ).addClass( 'hsr-show' )
76 $( '.hsr-publish-modal--footer' ).addClass( 'show' )
77 $( '.hsr-publish-modal--body h3' ).text( result.data.title );
78 $( '.hsr-publish-modal--body__description' ).text( result.data.description );
79 $( '.hsr-publish-btn' ).addClass( 'hsr-preview' )
80 previewBtn.addClass( 'hsr-preview' )
81 previewBtn.text( result.data.content.btn.text )
82 $( '.hsr-onboarding__title' ).text( result.data.content.title );
83 $( '.hsr-onboarding__description' ).text( result.data.content.description );
84 },
85 } )
86 } )
87
88 closeBtn.on( 'click', function () {
89 $( '.hsr-modal' ).removeClass( 'open' );
90 $( 'body' ).removeClass( 'modal-open' );
91 } )
92 navigationItem.click( function () {
93 var clickedItem = $( this );
94 $( '.hsr-list__item' ).removeClass( 'hsr-active' );
95 clickedItem.addClass( 'hsr-active' );
96 selectedTab = clickedItem.data( 'name' );
97 if ( selectedTab === 'home' ) {
98 homeTab.show();
99 aiAssistantTab.hide();
100 learnTab.hide();
101 } else if ( selectedTab === 'learn' ) {
102 homeTab.hide();
103 aiAssistantTab.hide();
104 learnTab.show();
105 } else if ( selectedTab === 'ai-assistant' ) {
106 homeTab.hide();
107 learnTab.hide();
108 aiAssistantTab.show();
109 }
110
111 add_admin_menu_class();
112 } );
113
114 if ( window.location.hash === "#ai-assistant" ) {
115 $( '.hsr-list__item' ).removeClass( 'hsr-active' );
116 $( '.hsr-list__item.hts-ai-assistant-tab' ).addClass( 'hsr-active' );
117 homeTab.hide();
118 learnTab.hide();
119 aiAssistantTab.show();
120 }
121
122 if ( window.location.hash === "#home" ) {
123 $( '.hsr-list__item' ).removeClass( 'hsr-active' );
124 $( '.hsr-list__item.hts-home-tab' ).addClass( 'hsr-active' );
125 homeTab.show();
126 aiAssistantTab.hide();
127 learnTab.hide();
128 }
129
130 if ( window.location.hash === "#learn" ) {
131 $( '.hsr-list__item' ).removeClass( 'hsr-active' );
132 $( '.hsr-list__item.hts-learn-tab' ).addClass( 'hsr-active' );
133 homeTab.hide();
134 aiAssistantTab.hide();
135 learnTab.show();
136 }
137
138 helpCard.click( function () {
139 window.open( 'https://hostinger.com/cpanel-login?r=jump-to/new-panel/section/help', '_blank' );
140 } );
141 knowledgeCard.click( function () {
142 window.open( 'https://support.hostinger.com/en/?q=WordPress', '_blank' );
143 } );
144
145 document.querySelectorAll( '.hsr-playlist-item' ).forEach( function ( item ) {
146 const firstItem = document.querySelector( '.hsr-playlist-item:first-child' );
147 firstItem.classList.add( 'hsr-active-video' );
148 firstItem.querySelector( '.hsr-playlist-item-arrow' ).style.visibility = 'visible';
149 item.addEventListener( 'click', function () {
150 document.querySelectorAll( '.hsr-playlist-item.hsr-active-video' ).forEach( function ( selectedItem ) {
151 selectedItem.classList.remove( 'hsr-active-video' );
152 selectedItem.querySelector( '.hsr-playlist-item-arrow' ).style.visibility = 'hidden';
153 } );
154 this.classList.add( 'hsr-active-video' );
155 this.querySelector( '.hsr-playlist-item-arrow' ).style.visibility = 'visible';
156 } );
157 } );
158
159 function add_admin_menu_class () {
160 const tabSelectors = [
161 '.hsr-list__item.hts-home-tab',
162 '.hsr-list__item.hts-learn-tab',
163 '.hsr-list__item.hts-ai-assistant-tab',
164 '.hsr-list__item.hts-ai-website-tab'
165 ];
166
167 const hostingerSubMenu = document.querySelectorAll( '#toplevel_page_hostinger .wp-submenu li' );
168 if ( hostingerSubMenu ) {
169 hostingerSubMenu.forEach( item => {
170 item.classList.remove( 'current' );
171 } );
172
173 tabSelectors.forEach( ( selector, index ) => {
174 const tab = document.querySelector( selector );
175 if ( tab && tab.classList.contains( 'hsr-active' ) ) {
176 if ( typeof hostingerSubMenu[ index + 1 ] !== "undefined" ) {
177 hostingerSubMenu[ index + 1 ].classList.add( 'current' );
178 }
179 }
180 } );
181 }
182
183 }
184
185 add_admin_menu_class();
186
187 // Copy nameservers to clipboard
188 $(document).ready(function() {
189 $('.hts-nameservers svg').click(function() {
190 let textToCopy = $(this).closest('div').find('b').text();
191 copyTextToClipboard(textToCopy);
192 });
193 });
194
195 function copyTextToClipboard(text) {
196 let textArea = document.createElement('textarea');
197 textArea.value = text;
198 document.body.appendChild(textArea);
199 textArea.select();
200 document.execCommand('copy');
201 document.body.removeChild(textArea);
202 }
203
204 } );
205
206 } )( jQuery );
207