1// Copyright 1999-2026. WebPros International GmbH. All rights reserved. 2 3PleskExt.WpToolkit.addSiteServices = function(urls) { 4 var locale = Jsw.Locale.getSection('list.sites.services'); 5 6 // update grid layout for adding extra items 7 var updateGridLayout = function(element, count) { 8 var grid = element.down('.b-grid'); 9 if (grid.className === 'b-grid') { 10 setTimeout(function () { 11 var items = grid.getElementsByTagName('li'); 12 if (!items) { 13 return; 14 } 15 var itemsLengh = 0; 16 for (var i = 0; i < items.length; i++) { 17 items[i].className.split(' ').each(function(className){ 18 if (className.match(/b-grid-item-[^\s'"]+/)) { 19 var parts = className.split('b-grid-item-'); 20 itemsLengh += parseInt(parts[1]); 21 } else { 22 itemsLengh++; 23 } 24 }); 25 } 26 grid.addClassName('b-grid-' + itemsLengh); 27 }); 28 return; 29 } 30 grid.className.split(' ').each(function(className){ 31 if (className.match(/b-grid-[^\s'"]+/)) { 32 var parts = className.split('-'); 33 parts[parts.length - 1] = parseInt(parts[parts.length - 1]) + count; 34 grid.addClassName(parts.join('-')); 35 grid.removeClassName(className); 36 } 37 }); 38 }; 39 40 // start WordPress installation on selected domain 41 var onClickInstall = function (element) { 42 var itemId = getListItem(element).id; 43 var domainId = itemId.split(':')[1]; 44 var buttonWrapper = element.down('.js-wp-install'); 45 46 if (buttonWrapper.hasClassName('disabled')) { 47 return; 48 } 49 50 buttonWrapper.addClassName('disabled'); 51 buttonWrapper.update('<span class="ajax-loading">' + locale.lmsg('loading') + '</span>'); 52 53 Jsw.redirect(urls.install, { 54 domain: domainId, 55 returnUrl: urls.return + '/id/' + domainId 56 }); 57 }; 58 59 // get list item to which this service belongs 60 var getListItem = function (element) { 61 return element.up('.active-list-item'); 62 }; 63 64 var ce = Jsw.createElement; 65 var body = $('content-body'); 66 67 // insert quick start block 68 var isQuickStartBlockInserted = false; 69 var insertQuickStartBlock = function() { 70 if (isQuickStartBlockInserted) { 71 return; 72 } 73 74 body.select('.caption-services-quick-start').each(function(quickStart){ 75 updateGridLayout(quickStart, 1); 76 77 var newItem = ce('li.b-grid-item', 78 ce('.b-grid-item-wrap', 79 ce('.quick-start-block', [ 80 ce('.quick-start-name', locale.lmsg('quickStartTitle')), 81 ce('.quick-start-description', locale.lmsg('quickStartDesc')), 82 ce('.quick-start-actions', 83 ce('a.btn', {class: 'js-wp-install', onclick: onClickInstall.bind(this, quickStart)}, locale.lmsg('quickStartAction')) 84 ) 85 ]) 86 ) 87 ); 88 Jsw.render(quickStart.down('.b-grid-list'), newItem, 'top'); 89 isQuickStartBlockInserted = true; 90 }) 91 }; 92 93 insertQuickStartBlock(); 94 if (!isQuickStartBlockInserted) { 95 setTimeout(insertQuickStartBlock, 500); 96 } 97 98 // insert quick access block (for plesk version >= 18.0 ) 99 var isQuickAccessBlockInserted = false; 100 var insertQuickAccessBlock = function() { 101 if (isQuickAccessBlockInserted) { 102 return; 103 } 104 105 // start WordPress installation on selected domain 106 var onClickInstall = function (element) { 107 var itemId = getListItem(element).id; 108 var domainId = itemId.split(':')[1]; 109 110 Jsw.redirect(urls.install, { 111 domain: domainId, 112 returnUrl: urls.return + '/id/' + domainId, 113 }); 114 }; 115 116 body.select('.caption-services').each(function (services) { 117 if (getListItem(services).down('.caption-services-apps-ext-WordPress')) {
118 // this domain already has installed WordPress instances 119 return; 120 } 121 122 var toolsList = services.down('.tools-list'); 123 if (!toolsList) { 124 return; 125 } 126 127 var newItem = ce('li.tools-item', 128 ce('a.tool-block', { href: urls.list, 'data-identity': 'buttonWordPress' }, 129 [ 130 ce('span.tool-icon', 131 ce('img', { src: urls.base + '/images/wordpresses.png', alt: 'WordPress' }) 132 ), 133 ce('span.tool-name', locale.lmsg('serviceName')), 134 ce('div.caption-service-toolbar', 135 ce('div.caption-service-item.item-visible', 136 ce('a', { href: '#', class: 'js-wp-install', onclick: onClickInstall.bind(this, services) }, locale.lmsg('serviceAction')) 137 ) 138 ), 139 ] 140 ) 141 ); 142 Jsw.render(toolsList, newItem, 'bottom'); 143 isQuickAccessBlockInserted = true; 144 }); 145 }; 146 147 insertQuickAccessBlock(); 148 if (!isQuickAccessBlockInserted) { 149 setTimeout(insertQuickAccessBlock, 500); 150 } 151 152 // insert service block 153 var isServiceBlockInserted = false; 154 var insertServiceBlock = function() { 155 if (isServiceBlockInserted) { 156 return; 157 } 158 159 body.select('.caption-services-custom').each(function(services) { 160 if (getListItem(services).down('.caption-services-apps-ext-WordPress')) { 161 var quickStartBlock = services.parentNode.querySelector('.caption-services-quick-start'); 162 if (quickStartBlock) { 163 quickStartBlock.remove(); 164 } 165 // this domain already has installed WordPress instances 166 return; 167 } 168 169 updateGridLayout(services, 2); 170 171 var newItem = ce('li.b-grid-item.b-grid-item-2', 172 ce('.b-grid-item-wrap', 173 ce('.caption-service-block', [ 174 ce('span.caption-service-title', [ 175 ce('i.caption-service-icon', [ 176 ce('a', {href: '#'}, 177 ce('img', {src: urls.base + '/images/wordpresses.png'}) 178 ) 179 ]), 180 ce('span.caption-service-name', 181 ce('a', {href: urls.list}, locale.lmsg('serviceName')) 182 ) 183 ]), 184 ce('.caption-service-toolbar', 185 ce('.caption-service-item.item-visible', 186 ce('a.btn', {class: 'js-wp-install', onclick: onClickInstall.bind(this, services)}, locale.lmsg('serviceAction')) 187 ) 188 ) 189 ]) 190 ) 191 ); 192 Jsw.render(services .down('.b-grid-list'), newItem, 'bottom'); 193 isServiceBlockInserted = true; 194 }); 195 }; 196 197 insertServiceBlock(); 198 if (!isServiceBlockInserted) { 199 setTimeout(insertServiceBlock, 500); 200 } 201};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.