Last active
March 20, 2017 19:51
-
-
Save smichaelsen/51dcb8ec0269da7a4215545d225382b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var loadScript = function (url, callback) { | |
// Adding the script tag to the head as suggested before | |
var head = document.getElementsByTagName('head')[0]; | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = url; | |
// Then bind the event to the callback function. | |
// There are several events for cross browser compatibility. | |
if (callback) { | |
script.onreadystatechange = callback; | |
script.onload = callback; | |
} | |
// Fire the loading | |
head.appendChild(script); | |
}; | |
var loadBootstrapStylesheet = function () { | |
var u = 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'; | |
var l = document.createElement('link'); | |
l.rel = 'stylesheet'; | |
l.href = u; | |
document.body.appendChild(l); | |
}; | |
loadScript('https://code.jquery.com/jquery-3.2.0.min.js', function () { | |
loadScript('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js'); | |
(function ($) { | |
jQuery(function () { | |
xlisterForm = $( | |
'<form class="container">' + | |
'<div class="row">' + | |
'<h1 class="col-lg-12">xlister</h1>' + | |
'<fieldset class="col-lg-6">' + | |
'<legend style="color:green">Extension Lists</legend>' + | |
'<div class="checkbox">' + | |
'<label>' + | |
'<input type="checkbox" checked value="templavoila,tt_news,static_info_tables,realurl,phpmyadmin,powermail,automaketemplate,ve_guestbook,sr_feuser_register,tt_address,transit_art,direct_mail,t3jquery,div2007,cal,gridelements,irfaq,jfmulticontent,sr_freecap,news"/>' + | |
'<b>All-Time Top 20 TER-Extensions</b> (templavoila, tt_news, static_info_tables, realurl, ...)' + | |
'</label>' + | |
'</div>' + | |
'<div class="checkbox">' + | |
'<label>' + | |
'<input type="checkbox" checked value="flux, fluidcontent, fluidpages, vhs"/>' + | |
'<b>FluidTYPO3 Extensions</b> (flux, fluidcontent, fluidpages, vhs)' + | |
'</label>' + | |
'</div>' + | |
'</fieldset>' + | |
'<fieldset class="col-lg-6">' + | |
'<legend style="color:green">Custom extension input</legend>' + | |
'<div class="form-group">' + | |
'<label>' + | |
'And these (one extkey per line)' + | |
'<textarea class="form-control"></textarea>' + | |
'</label>' + | |
'</div>' + | |
'</fieldset>' + | |
'<button type="submit" class="btn btn-primary">Start</button>' + | |
'</div>' + | |
'<div class="row">' + | |
'<div class="col-lg-6">' + | |
'<h2>Installed extensions:</h2>' + | |
'<ul data-found-result-list></ul>' + | |
'</div>' + | |
'<div class="col-lg-6">' + | |
'<h2>Not installed extensions:</h2>' + | |
'<ul data-not-found-result-list></ul>' + | |
'</div>' + | |
'</div>' + | |
'</form>' | |
); | |
container = $('<div />').css({ | |
backgroundColor: 'rgba(15, 15, 15, 0.9)', | |
color: 'green', | |
padding: '20px', | |
position: 'fixed', | |
left: '2%', | |
right: '2%', | |
top: '2%', | |
bottom: '2%', | |
zIndex: 9000, | |
overflow: 'scroll' | |
}).append(xlisterForm); | |
container.appendTo('body'); | |
xlisterForm.on('submit', function (e) { | |
e.preventDefault(); | |
var extKeysToCheck = []; | |
xlisterForm.find('input[type="checkbox"]').filter(':checked').each(function () { | |
extKeysToCheck = extKeysToCheck.concat($(this).val().split(',')); | |
}); | |
if (xlisterForm.find('textarea').val()) { | |
extKeysToCheck = extKeysToCheck.concat(xlisterForm.find('textarea').val().split("\n")); | |
} | |
extKeysToCheck = $.uniqueSort(extKeysToCheck); | |
var extkeyResults = {}; | |
var baseUrl = window.location.protocol + '//' + window.location.hostname; | |
var foundResultList = xlisterForm.find('[data-found-result-list]').html(''); | |
var notFoundResultList = xlisterForm.find('[data-not-found-result-list]').html(''); | |
$(extKeysToCheck).each(function () { | |
var extkey = this; | |
if (extkey != '') { | |
$.ajax({ | |
url: baseUrl + '/typo3conf/ext/' + extkey + '/ext_emconf.php', | |
method: 'head', | |
complete: function (response) { | |
var found = response.status == 200; | |
extkeyResults[extkey] = found; | |
var resultItem = $('<li/>').text(extkey); | |
if (found) { | |
foundResultList.append(resultItem); | |
} else { | |
notFoundResultList.append(resultItem); | |
} | |
} | |
}) | |
} | |
}); | |
}); | |
}); | |
})(jQuery); | |
}); | |
loadBootstrapStylesheet(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment