Skip to content
This repository has been archived by the owner on May 30, 2021. It is now read-only.

Commit

Permalink
No project Top Bar & Phosphorus Loading
Browse files Browse the repository at this point in the history
Featured projects now automatically load with Phosphorus if iFrame page yields 404 (unshared and deleted projects).
Project's top bar is now hidden as to leave more room for the project.

PS: The css and height attribute changes are there to work around a glitch that cuts off the bottom of the iFrame.
PS²: This is a merge from the PR I made to GRA0007's originals folder.
  • Loading branch information
Felizolinha committed Jan 27, 2015
1 parent 3b10e00 commit f9a0c88
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions parts/profileenhancer.part.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,27 @@ msuParts["profileEnhancer"] = function (ScratchUserscript) {
if (settings.liveProject) {
//Make project live
$("#featured-project").remove();
var projID = unsafeWindow.Scratch.INIT_DATA.PROFILE.featuredProject.id;
$(".stage").append("<iframe allowtransparency='true' width='282' height='210' src='http://scratch.mit.edu/projects/embed/" + projID + "/?autostart=true' frameborder='0' allowfullscreen=''></iframe>");
var $projName = $('.project-name'),
projID = unsafeWindow.Scratch.INIT_DATA.PROFILE.featuredProject.id;

$projName.html($projName.html().trim()); //Make sure no whitespaces interefere with centering
$('.player .title').css('text-align', 'center');

$( ".stage" ).append( "<div style='overflow: hidden; height: 216px;' id='applet'><iframe style='margin-top: -25px;' allowtransparency='true' width='282' height='237' frameborder='0' allowfullscreen=''></iframe></div>" );

$('.stage iframe').load(function(){
var is404 = $(this).contents().find('#page-404').length > 0;
if(is404) {
$('.stage div').css('height', '211px');
$(this).css('margin-top', '-14px');
$(this).attr('height', '239');
$(this).attr('src', 'http://phosphorus.github.io/app.html?id=' + projID);
}
else if($(this).attr('src').indexOf('http://scratch.mit.edu/projects/embed/') > -1) {
setTimeout(function(){$('.stage iframe').attr('height', '238');}, 200);
}
});
$('.stage iframe').attr("src", "http://scratch.mit.edu/projects/embed/" + projID + "/?autostart=true");
}
}
};
};

0 comments on commit f9a0c88

Please sign in to comment.