We don't use any info from ynhpanel.json

This commit is contained in:
Alexandre Aubin 2019-02-21 19:29:06 +01:00
parent c05e5ea7eb
commit a80b4bdff1

View file

@ -242,47 +242,32 @@ domReady(function(){
document.body.insertBefore(overlay, null); document.body.insertBefore(overlay, null);
// Add portal stylesheet
var portalStyle = document.createElement("link");
portalStyle.setAttribute("rel", "stylesheet");
portalStyle.setAttribute("type", "text/css");
portalStyle.setAttribute("href", '/ynhpanel.css');
document.getElementsByTagName("head")[0].insertBefore(portalStyle, null);
// Get user's app // Bind YNH Button
var r = new XMLHttpRequest(); window.addEvent(portal, 'click', function(e){
r.open("GET", "/ynhpanel.json", true); // Prevent default click
r.onreadystatechange = function () { window.eventPreventDefault(e);
// Die if error // Toggle overlay on YNHPortal button click
if (r.readyState != 4 || r.status != 200) return; Element.toggleClass(overlay, 'visible');
Element.toggleClass(portal, 'visible');
Element.toggleClass(document.querySelector('html'), 'ynh-panel-active');
Element.toggleClass(overlay, 'ynh-active');
// Response is JSON if(overlay.classList.contains('ynh-active')) {
response = JSON.parse(r.responseText); meta_viewport.setAttribute('content', meta_viewport_content);
Element.addClass(overlay, 'ynh-fadeIn');
Element.removeClass(overlay, 'ynh-fadeOut');
// Add portal stylesheet }else {
var portalStyle = document.createElement("link"); meta_viewport.setAttribute('content', "width=device-width");
portalStyle.setAttribute("rel", "stylesheet"); Element.removeClass(overlay, 'ynh-fadeIn');
portalStyle.setAttribute("type", "text/css"); Element.addClass(overlay, 'ynh-fadeOut');
portalStyle.setAttribute("href", '/ynhpanel.css'); }
document.getElementsByTagName("head")[0].insertBefore(portalStyle, null); });
// Bind YNH Button
window.addEvent(portal, 'click', function(e){
// Prevent default click
window.eventPreventDefault(e);
// Toggle overlay on YNHPortal button click
Element.toggleClass(overlay, 'visible');
Element.toggleClass(portal, 'visible');
Element.toggleClass(document.querySelector('html'), 'ynh-panel-active');
Element.toggleClass(overlay, 'ynh-active');
if(overlay.classList.contains('ynh-active')) {
meta_viewport.setAttribute('content', meta_viewport_content);
Element.addClass(overlay, 'ynh-fadeIn');
Element.removeClass(overlay, 'ynh-fadeOut');
}else {
meta_viewport.setAttribute('content', "width=device-width");
Element.removeClass(overlay, 'ynh-fadeIn');
Element.addClass(overlay, 'ynh-fadeOut');
}
});
};
r.send();
}); });