This repository has been archived by the owner on May 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
MegaApuTurkUltra
committed
Mar 11, 2015
1 parent
e474ac3
commit fb72413
Showing
4 changed files
with
122 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
msuParts["projectStuff"] = function (ScratchUserscript) { | ||
var settingsDlg = $("<div></div>"); | ||
|
||
ScratchUserscript.registerPart("Project Stuff", "Adds phosphorus and scratchblocks2 buttons to projects.", settingsDlg); | ||
|
||
var settings = { | ||
phosphorus: true, | ||
sb2: true, | ||
diff: true | ||
}; | ||
var labels = { | ||
phosphorus: "Enable phosphorus button", | ||
sb2: "Enable scratchblocks2 generator button", | ||
diff: "Enable scratchblocks2 diff button" | ||
}; | ||
settings = ScratchUserscript.readSetting("projectStuff", "settings", settings); | ||
|
||
updateChanges = function(){ | ||
for(x in settings){ | ||
if($("#msu-ps"+x+"btn").is(":checked")){ | ||
settings[x] = true; | ||
} else { | ||
settings[x] = false; | ||
} | ||
} | ||
ScratchUserscript.writeSetting("projectStuff", "settings", settings); | ||
}; | ||
|
||
settingsDlg.append("<br/>"); | ||
|
||
for(x in settings){ | ||
settingsDlg.append("<input type='checkbox' id='msu-ps"+x+"btn' /> \ | ||
<label for='msu-ps"+x+"btn' \ | ||
style='display: inline;margin-right:1em;'>\ | ||
"+labels[x]+"</label><br/>"); | ||
if(settings[x]) $("#msu-ps"+x+"btn").attr("checked", "checked"); | ||
} | ||
|
||
settingsDlg.find("input").bind("change", updateChanges); | ||
|
||
var isEnabled = ScratchUserscript.isPartEnabled("projectStuff"); | ||
|
||
if (isEnabled && ScratchUserscript.getPageType().type == "project") { | ||
if(settings.phosphorus){ | ||
var phosButton = $('<div id="msu-ps-phosphorus" class="action tooltip bottom isflash">'+ | ||
'<span class="hovertext" id="msu-ps-phosphorus-tool"><span class="arrow"></span>Switch to phosphorus</span>'+ | ||
'<span>Player type</span></div>'); | ||
$(".active").append(phosButton); | ||
$("#msu-ps-phosphorus").click(function(){ | ||
if($(this).hasClass('isflash')){ | ||
$(this).removeClass('isflash'); | ||
$(".buttons").hide(); | ||
$(".player").hide(); | ||
|
||
var iframe = document.createElement('iframe'); | ||
iframe.setAttribute('allowfullscreen', true); | ||
iframe.setAttribute('allowtransparency', true); | ||
iframe.src = 'http://phosphorus.github.io/embed.html?id=' + Scratch.INIT_DATA.PROJECT.model.id + '&auto-start=true&light-content=false'; | ||
iframe.width = 482; | ||
iframe.height = 393; | ||
iframe.style.border = '0'; | ||
iframe.className = 'phosphorus'; | ||
var first = document.getElementsByClassName('player')[0]; | ||
first.parentNode.insertBefore(iframe, first); | ||
|
||
$("#msu-ps-phosphorus-tool").html("<span class='arrow'></span>Switch to flash"); | ||
} else { | ||
$(this).addClass('isflash'); | ||
$(".buttons").show(); | ||
$(".player").show(); | ||
$(".msu-phosphorus-script, .phosphorus").remove(); | ||
$("#msu-ps-phosphorus-tool").htmk("<span class='arrow'></span>Switch to phosphorus"); | ||
} | ||
}); | ||
} | ||
if(settings.sb2){ | ||
var btn = $('<div id="msu-ps-sb2" class="action tooltip bottom isflash">'+ | ||
'<span class="hovertext"><span class="arrow"></span>Generate scratchblocks2 code</span>'+ | ||
'<span>Generate code</span></div>'); | ||
$(".active").append(btn); | ||
$("#msu-ps-sb2").click(function(){ | ||
window.open('http://scratchblocks.github.io/generator/#project='+Scratch.INIT_DATA.PROJECT.model.id, "_blank"); | ||
}); | ||
} | ||
if(settings.diff){ | ||
var btn = $('<div id="msu-ps-diff" class="action tooltip bottom isflash">'+ | ||
'<span class="hovertext"><span class="arrow"></span>Generate scratchblocks2 diff</span>'+ | ||
'<span>Generate diff</span></div>'); | ||
$(".active").append(btn); | ||
$("#msu-ps-diff").click(function(){ | ||
var diff2 = prompt("Other project ID?"); | ||
if(diff2 == null || diff2 == "") return; | ||
window.open('http://scratchblocks.github.io/diff/#'+Scratch.INIT_DATA.PROJECT.model.id+"+"+diff2, "_blank"); | ||
}); | ||
} | ||
} | ||
}; |
This file contains 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
This file contains 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