Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion 1LLL.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ <h2>Algorithm Credits</h2>


<div class=column_right>
<img src="https://www.cubing.net/api/visualcube/?fmt=svg&size=300&view=plan&bg=black&alg=x2" id="visualcube" title="Click to switch between flat and 3D view"/>
<twisty-player id="case-display" title="Click to switch between flat and 3D view"
data-experimental-drag-input="none"
data-background="none"
data-control-panel="none"
hint-facelets="none"
></twisty-player>
<p style="font-size: small;">Click the above cube to switch between flat and 3D view</p>

<div style="overflow-y: scroll; height:150px;">
Expand Down
7 changes: 6 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ <h2>Algorithm Credits</h2>


<div class=column_right>
<img src="https://www.cubing.net/api/visualcube/?fmt=svg&size=300&view=plan&bg=black&alg=x2" id="visualcube" title="Click to switch between flat and 3D view"/>
<twisty-player id="case-display" title="Click to switch between flat and 3D view"
data-experimental-drag-input="none"
data-background="none"
data-control-panel="none"
hint-facelets="none"
></twisty-player>
<p style="font-size: small;">Click the above cube to switch between flat and 3D view</p>

<div style="overflow-y: scroll; height:150px;">
Expand Down
31 changes: 19 additions & 12 deletions js/RubiksCube.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ var shouldRecalculateStatistics = true;

createAlgsetPicker();

const cubingTwistyPromise = import("https://cdn.cubing.net/js/cubing/twisty")

window.onbeforeunload = function () {
window.scrollTo(0, 0);
}
Expand Down Expand Up @@ -119,7 +121,7 @@ useCustomColourScheme.addEventListener("click", function(){
localStorage.setItem("useCustomColourScheme", this.checked);

var algTest = algorithmHistory[historyIndex];
updateVisualCube(algTest ? algTest.preorientation+algTest.scramble : "");
updateVisualCube(algTest ? algTest.preorientation + " " + algTest.scramble : "");

drawCube(cube.cubestate);
});
Expand All @@ -140,7 +142,7 @@ for (var i = 0; i < customColours.length; i++) {
localStorage.setItem(this.id, this.value);

var algTest = algorithmHistory[historyIndex];
updateVisualCube(algTest ? algTest.preorientation+algTest.scramble : "");
updateVisualCube(algTest ? algTest.preorientation + " " + algTest.scramble : "");

drawCube(cube.cubestate);
});
Expand All @@ -157,7 +159,7 @@ resetCustomColourScheme.addEventListener("click", function(){
}

var algTest = algorithmHistory[historyIndex];
updateVisualCube(algTest ? algTest.preorientation+algTest.scramble : "");
updateVisualCube(algTest ? algTest.preorientation + " " + algTest.scramble : "");

drawCube(cube.cubestate);
}
Expand Down Expand Up @@ -185,13 +187,13 @@ hideTimer.addEventListener("click", function(){

});

var visualCube = document.getElementById("visualcube");
visualCube.addEventListener("click", function(){
var caseDisplay = document.getElementById("case-display");
caseDisplay.addEventListener("click", function(){
var currentView = localStorage.getItem("visualCubeView")
var newView = currentView == ""? "plan": "";
localStorage.setItem("visualCubeView", newView);
var algTest = algorithmHistory[historyIndex];
updateVisualCube(algTest ? algTest.preorientation+algTest.scramble : "");
updateVisualCube(algTest ? algTest.preorientation + " " + algTest.scramble : "");
});


Expand Down Expand Up @@ -692,8 +694,8 @@ function generateOrientation(){

var rand1 = Math.floor(Math.random()*6);
var rand2 = Math.floor(Math.random()*4);
var randomPart = firstRotation[rand1] + secondRotation[rand2];
if (randomPart == "x2z2"){
var randomPart = firstRotation[rand1] + " " + secondRotation[rand2];
if (randomPart == "x2 z2"){
randomPart = "y2";
}
var fullOrientation = cn1 + randomPart; // Preorientation to perform starting from white top green front
Expand All @@ -712,8 +714,8 @@ function generateOrientation(){
var rand2 = Math.floor(Math.random()*4);

//console.log(cn1 + cn2.repeat(rand1) + cn3.repeat(rand2));
var randomPart = cn2.repeat(rand1) + cn3.repeat(rand2); // Random part of the orientation
var fullOrientation = cn1 + randomPart; // Preorientation to perform starting from white top green front
var randomPart = new Array(rand1).fill(cn2).join(" ") + " " + new Array(rand2).fill(cn3).join(" "); // Random part of the orientation
var fullOrientation = cn1 + " " + randomPart; // Preorientation to perform starting from white top green front
return [fullOrientation, randomPart];
}

Expand Down Expand Up @@ -799,7 +801,7 @@ function testAlg(algTest, addToHistory=true){
doAlg(algTest.scramble);
drawCube(cube.cubestate)

updateVisualCube(algTest.preorientation + algTest.scramble);
updateVisualCube(algTest.preorientation + " " + algTest.scramble);

if (addToHistory){
algorithmHistory.push(algTest);
Expand Down Expand Up @@ -948,7 +950,12 @@ function updateVisualCube(algorithm){
stripLeadingHashtag(customColourF.value);
}

document.getElementById("visualcube").src = imgsrc;
console.log("x2 " + algorithm)
console.log(document.getElementById("case-display"))
cubingTwistyPromise.then(() => {
document.getElementById("case-display").alg = "x2 " + algorithm;
document.getElementById("case-display").visualization = (view === "plan" ? "experimental-2D-LL" : "3D");
})
}

function displayAlgorithm(algTest, reTest=true){
Expand Down