HEX
Server: Apache/2
System: Linux saturn 4.18.0-477.15.1.lve.2.el8.x86_64 #1 SMP Wed Aug 2 10:43:45 UTC 2023 x86_64
User: centuryt (1072)
PHP: 7.4.33
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/centuryt/public_html/wp-content/themes/woostify/assets/js/admin/install-demo.js
/**
 * Install Demo
 *
 * @package woostify
 */

/* global woostify_install_demo */

'use strict';

// Activate plugin.
var activatePlugin = function( url, redirect ) {
	if ( 'undefined' === typeof( url ) || ! url ) {
		return;
	}

	var request = new Request(
		url,
		{
			method: 'GET',
			credentials: 'same-origin',
			headers: new Headers(
				{
					'Content-Type': 'text/xml'
				}
			)
		}
	);

	fetch( request )
		.then(
			function( data ) {
				location.reload();
			}
		).catch(
			function( error ) {
				console.log( error );
			}
		);
}

// Download and Install plugin.
var installPlugin = function() {
	var installBtn = document.querySelector( '.woostify-install-demo' );
	if ( ! installBtn ) {
		return;
	}

	installBtn.onclick = function( e ) {
		e.preventDefault();

		var t        = this,
			url      = t.getAttribute( 'href' ),
			slug     = t.getAttribute( 'data-slug' ),
			redirect = t.getAttribute( 'data-redirect' );

		t.innerHTML = woostify_install_demo.installing;

		t.classList.add( 'updating-message' );
		wp.updates.installPlugin(
			{
				slug: slug,
				success: function () {
					t.innerHTML = woostify_install_demo.activating + '...';
					activatePlugin( url, redirect );
				}
			}
		);
	}
}

// Activate plugin manual.
var handleActivate = function() {
	var activeButton = document.querySelector( '.woostify-active-now' );
	if ( ! activeButton ) {
		return;
	}

	activeButton.onclick = function( e ) {
		e.preventDefault();

		var t        = this,
			url      = t.getAttribute( 'href' ),
			redirect = t.getAttribute( 'data-redirect' );

		t.classList.add( 'updating-message' );
		t.innerHTML = woostify_install_demo.activating + '...';

		activatePlugin( url, redirect );
	}
}

document.addEventListener(
	'DOMContentLoaded',
	function() {
		installPlugin();
		handleActivate();
	}
);