MCPcopy Create free account
hub / github.com/JustinBeckwith/cloudcats / processMessage

Function processMessage

web/public/script.js:59–102  ·  view source on GitHub ↗
(m)

Source from the content-addressed store, hash-verified

57}
58
59function processMessage(m) {
60 if (m.type === FIN) {
61 let winner;
62 console.log('we are DONE');
63 if (cats > dogs) {
64 winner = 'CATS';
65 } else if (dogs > cats) {
66 winner = 'DOGS';
67 } else {
68 winner = 'tie';
69 }
70
71 showDialog({
72 winner,
73 dogs,
74 cats,
75 other
76 });
77 } else {
78 const pic = document.createElement('div');
79 pic.style.backgroundImage = 'url(' + m.url + ')';
80 switch (m.type) {
81 case DOG:
82 dogs++;
83 dogDiv.insertBefore(pic, dogDiv.firstChild);
84 break;
85 case CAT:
86 cats++;
87 catDiv.insertBefore(pic, catDiv.firstChild);
88 break;
89 case BOTH:
90 cats++;
91 dogs++;
92 dogDiv.insertBefore(pic, dogDiv.firstChild);
93 catDiv.insertBefore(pic, catDiv.firstChild);
94 break;
95 case NEITHER:
96 other++;
97 break;
98 default:
99 break;
100 }
101 }
102}
103
104setInterval(() => {
105 if (queue.length > 0) {

Callers 1

script.jsFile · 0.85

Calls 1

showDialogFunction · 0.85

Tested by

no test coverage detected