Skip to content

Commit

Permalink
Poet Buttons are functional
Browse files Browse the repository at this point in the history
  • Loading branch information
jtallison committed Jul 14, 2019
1 parent 3ca920d commit bd68e6e
Show file tree
Hide file tree
Showing 4 changed files with 413 additions and 284 deletions.
37 changes: 37 additions & 0 deletions diamondsCluster/diamondsCluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,43 @@ if (cluster.isMaster) {
});
});

socket.on('start', function(data) {
console.log("start: ", data);
socket.broadcast.emit('start', data);
});

socket.on('excite', function(data) {
console.log("excite: ", data);
socket.broadcast.emit('excite', data);
});

socket.on('echo', function(data) {
console.log("echo: ", data.phrase);
socket.broadcast.emit('echo', data);
});

socket.on('kill', function(data) {
console.log("kill: ", data);
socket.broadcast.emit('kill', data);
});

socket.on('volta', function(data) {
console.log("volta: ", data);
socket.broadcast.emit('volta', data);
});

socket.on('end', function(data) {
console.log("end: ", data);
socket.broadcast.emit('end', data);
});











Expand Down
52 changes: 36 additions & 16 deletions diamondsCluster/public/audience/index-proto.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ <h1 onclick="Tone.startMobile();document.getElementsByClassName('welcomeText')[0
}
user.sessionName = localStorage.getItem('sessionName') || 'default';

let generatedTexts = [];

var colors = new Array(
[62, 35, 255], [60, 255, 60], [255, 35, 98], [45, 175, 230], [255, 0, 255], [255, 128, 0]);

Expand Down Expand Up @@ -275,22 +277,6 @@ <h1 onclick="Tone.startMobile();document.getElementsByClassName('welcomeText')[0
socket.on('setSection', function(data) {
// console.log(data);
console.log("the section is now: " + data.title);

// if (data.sect == "15") {
// Tone.startMobile();
// causeSound.playBrought();
// }

// if(data.title !== undefined){
// var otherClasses = document.querySelectorAll('.sec');

// for (var i = 0; i < otherClasses.length; i++) {
// otherClasses[i].style.display = 'none';
// }

// document.getElementsByClassName("s"+data.sect)[0].style.display = 'block';
// }

});


Expand All @@ -301,6 +287,7 @@ <h1 onclick="Tone.startMobile();document.getElementsByClassName('welcomeText')[0
console.log("itemback:", data.phrase);
var elements = document.getElementsByClassName("gentext")[0];
elements.innerHTML = data.phrase;
generatedTexts.push(data.phrase);
// elements[0].className += " clicked";
});

Expand All @@ -310,6 +297,39 @@ <h1 onclick="Tone.startMobile();document.getElementsByClassName('welcomeText')[0
dSound.audienceEnable(data);
});


socket.on('start', function(data) {
console.log("Start: ", data);
dSound.speak("So it begins...");
});

socket.on('excite', function(data) {
if (generatedTexts.length > 0) {
dSound.speak(generatedTexts[generatedTexts.length - 1]);
}
});

socket.on('echo', function(data) {
console.log("Echo: ", data.phrase);
dSound.speak(data.phrase);
});

socket.on('kill', function(data) {
console.log("Kill: ", data);
dSound.speak('die');
});

socket.on('volta', function(data) {
console.log("Volta: ", data);
dSound.speak('Umm, volta, yeah.');
});

socket.on('end', function(data) {
console.log("End: ", data);
dSound.speak('Thank you.');
});


socket.on('playChord', function(data) {
dSound.playChord(data.notes, data.duration);
});
Expand Down
63 changes: 51 additions & 12 deletions diamondsCluster/public/poet/index-proto.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

<body>
<div class="buttons">
<button onclick="socket.emit('triggerBeginning')">Start</button>
<button onclick="socket.emit('triggerExcite')">Excite</button>
<button onclick="socket.emit('triggerEcho')">Echo</button>
<button onclick="socket.emit('triggerKill')">Kill</button>
<button onclick="socket.emit('triggerVolta')">Volta</button>
<button onclick="socket.emit('triggerEnd')">End</button>
<button onclick="socket.emit('start')">Start</button>
<button onclick="socket.emit('excite')">Excite</button>
<button onclick="echo()">Echo</button>
<button onclick="socket.emit('kill')">Kill</button>
<button onclick="socket.emit('volta')">Volta</button>
<button onclick="socket.emit('end')">End</button>
</div>
<div class="generatedText stuff"></div>
<div class="gentextbuttons">
Expand All @@ -34,9 +34,12 @@
<script type="text/javascript">
let user = {
'name': 'a_user',
'id': 1000
'id': 1000,
'color': getRandomColor()
}
user.sessionName = localStorage.getItem('sessionName') || 'default';
// let myColor = getRandomColor();
// let myLocation = [0.5, 0.5]; // Default centered

// var socket = io.connect('130.39.92.112:8000/');
var socket = io.connect(window.location.origin, {
Expand All @@ -49,21 +52,47 @@
var pACount = 0;
var pALimit = 10;

socket.emit('addme', {
name: "controller"
});

function registerWithServer() {
socket.emit('addme', {
name: "controller",
sessionName: user.sessionName,
corpus: user.corpus,
color: user.color
});
}
registerWithServer();

// **********************************************************
// Only for the Overlay/intro page

socket.on('chat', function(data) {
console.log(data);
console.log("chat: " + data);
if (data.corpus) {
user.corpus = data.corpus;
}
});

socket.on('setSection', function(data) {
console.log("The section is now: " + data.title);
});

function echo() {
if (generatedTexts.length > 0) {
socket.emit('echo', {
"phrase": currentPhrase
});
}
};






function nexPhraseClick() {
document.getElementsByClassName('generatedText')[0].innerHTML = pArray[pACount];
currentPhrase = pArray[pACount];
document.getElementsByClassName('generatedText')[0].innerHTML = currentPhrase;

console.log("pACount", pACount);
if (pACount < pArray.length) {
Expand All @@ -84,6 +113,7 @@
pArray.pop();
console.log("else", pArray.length);
}
generatedTexts.push(data.phrase); // Keeping track of all phrases received.
// pArray[pACount] = data.phrase;

// currentPhrase = data.phrase;
Expand Down Expand Up @@ -170,6 +200,15 @@
// }

// };

function getRandomColor() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
</script>

</body>
Expand Down
Loading

0 comments on commit bd68e6e

Please sign in to comment.