// -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- // // ----------------------------- BOX SCRIPTS -------------------------------- // // -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- // var box = { set: {}, show: {}, hide: {}, global: {}, button: {}, slider: {}, adjust: {}, } box.global.previousKey = undefined; box.global.currentKey = undefined; box.global.transformedBoxes = []; box.global.keys = []; box.global.nextBoxToShow = undefined; box.global.symmetricHeteroTreatment = undefined; box.global.asymmetricHeteroTreatment = undefined; box.global.homoTreatment = undefined; box.global.ourGroupHetero = undefined; box.global.theirGroupHetero = undefined; box.set.treatment = function(myData) { var myTreat = myData.treatment; var sum = myTreat.reduce((a,b) => a + b, 0); box.global.homoTreatment = false; box.global.symmetricHeteroTreatment = false; box.global.asymmetricHeteroTreatment = false; box.global.ourGroupHetero = false; box.global.theirGroupHetero = false; if(sum === 0) { box.global.homoTreatment = true; } if(sum === 1) { box.global.asymmetricHeteroTreatment = true; box.global.ourGroupHetero = icon.globalVariable.ourFollowersAreHetero; box.global.theirGroupHetero = icon.globalVariable.theirFollowersAreHetero; } if(sum === 2) { box.global.symmetricHeteroTreatment = true; box.global.ourGroupHetero = true; box.global.theirGroupHetero = true; } } box.set.wrapHeight = function(id) { var key = id.split('-')[1]; box.global.keys.push(key); box.global.currentKey = box.global.keys[box.global.keys.length - 1]; if(box.global.keys.length === 1) { box.global.previousKey = box.global.keys[box.global.keys.length - 1]; } else { box.global.previousKey = box.global.keys[box.global.keys.length - 2]; } id = '#' + id; var height = $(id).height(); // console.log('height: ' + height); if(height === undefined) { height = '0px'; } else { height = height + 'px'; } // console.log('we are inside wrapHeight'); // console.log(height); var boxbox = '#boxbox-' + key; // console.log(key); // console.log(boxbox); $(boxbox).css({'height' : height}); if(box.global.previousKey != box.global.currentKey) { // console.log('do we get in here somehow?'); var prevBoxbox = '#boxbox-' + box.global.previousKey; $(prevBoxbox).css({'height' : '0'}); } if(box.global.keys.length > 2) { box.global.keys = box.global.keys.slice(Math.max(box.global.keys.length - 2, 1)); } // console.log(box.global.keys); } box.set.wrapHeight2 = function(id) { var key = id.split('-')[1]; box.global.keys.push(key); box.global.currentKey = box.global.keys[box.global.keys.length - 1]; if(box.global.keys.length === 1) { box.global.previousKey = box.global.keys[box.global.keys.length - 1]; } else { box.global.previousKey = box.global.keys[box.global.keys.length - 2]; } id = '#' + id; var height = $(id).height(); // console.log('height: ' + height); if(height === undefined) { height = '0px'; } else { height = height + 'px'; } // console.log('we are inside wrapHeight'); // console.log(height); var boxbox = '#boxbox-' + key; // console.log(key); // console.log(boxbox); $(boxbox).css({'height' : height, 'margin-top':'20px', 'margin-bottom':'20px'}); if(box.global.previousKey != box.global.currentKey) { // console.log('do we get in here somehow?'); var prevBoxbox = '#boxbox-' + box.global.previousKey; $(prevBoxbox).css({'height' : '0'}); } if(box.global.keys.length > 2) { box.global.keys = box.global.keys.slice(Math.max(box.global.keys.length - 2, 1)); } // console.log(box.global.keys); } box.move = function(id) { var myDiv = '#boxwrap-' + id.split('-')[1] + '-' + id.split('-')[2]; // console.log(myDiv); var myPlace = '#boxbox-' + id.split('-')[1]; // console.log(myPlace); $(myDiv).appendTo(myPlace); } box.store = function(id) { var myDiv = '#boxwrap-' + id.split('-')[1] + '-' + id.split('-')[2]; $(myDiv).appendTo('.reviewBox'); } // need to be used before the transition is made as it is added to the end of the div box.addSpace = function(id) { var key = id.split('-')[1]; var myBox = '#boxbox-' + key; // console.log('space is being added to ' + myBox); $('
').appendTo(myBox); } box.show = function(id, addSpaceAbove) { var id1, id2, id3; // console.log('asdasdasdasda: ' + id); id1 = id.split(':')[0]; id2 = id.split(':')[1]; if(id2 != undefined) { id3 = id1.split('box-')[1]; } // console.log('id: ' + id); // console.log('id1: ' + id1); // console.log('id2: ' + id2); // console.log('id3: ' + id3); if(id2 === 'wait') { // if this is not undefined then showresult that is called by the wheel // will also activate showing the new box // and as it shows it, it should make the below global undefined again box.global.nextBoxToShow = id3; } else { if(addSpaceAbove) { box.addSpace(id); } box.global.nextBoxToShow = undefined; box.move(id); // console.log('calling wrapHeight'); box.set.wrapHeight(id); id = '#' + id; $(id).css({'transform':'scale(1)'}); // ADD MOVE IFRAME TO THIS DIV METHOD HERE } } box.show2 = function(id, addSpaceAbove) { var id1, id2, id3; // console.log('asdasdasdasda: ' + id); id1 = id.split(':')[0]; id2 = id.split(':')[1]; if(id2 != undefined) { id3 = id1.split('box-')[1]; } // console.log('id: ' + id); // console.log('id1: ' + id1); // console.log('id2: ' + id2); // console.log('id3: ' + id3); if(id2 === 'wait') { // if this is not undefined then showresult that is called by the wheel // will also activate showing the new box // and as it shows it, it should make the below global undefined again box.global.nextBoxToShow = id3; } else { if(addSpaceAbove) { box.addSpace(id); } box.global.nextBoxToShow = undefined; box.move(id); // console.log('calling wrapHeight'); box.set.wrapHeight2(id); id = '#' + id; $(id).css({'transform':'scale(1)'}); // ADD MOVE IFRAME TO THIS DIV METHOD HERE } } box.transform = function(idCore, id) { var cT, cTCA; box.global.transformedBoxes.push(id); // console.log(box.global.transformedBoxes); box.button.hide(idCore); $(id).css({'position':'relative', 'background':'transparent', 'border-width':'0px', 'box-shadow':'0px 0px black', 'margin-top':'-30px'}); cT = $(id).children('div:first'); // console.log(cT); $(cT).css({'font-size':'20px'}); cTCA = $(id).children('div:first').children(); // console.log(cTCA); for(var f = 0; f < cTCA.length; f++) { $(cTCA[f]).css({'margin-bottom':'-5px'}); } box.global.transformedBoxesStorage = box.global.transformedBoxes; } box.transform2 = function(idCore, id , marginTop) { var cT, cTCA; box.global.transformedBoxes.push(id); // console.log(box.global.transformedBoxes); // console.log(marginTop); mt = marginTop + 'px'; box.button.hide(idCore); $(id).css({'transition':'0.15s', 'border-width':'0px', 'box-shadow':'0px 0px 0px 0px black'}); setTimeout(()=>{ $(id).css({'transition':'0.25s', 'background':'transparent', 'border-width':'0px', 'box-shadow':'0px 0px 0px 0px black'}); setTimeout(()=>{ // $(id).css({'transition':'1s', 'position':'relative', 'margin-top':mt}); $(id).css({'transition':'1s', 'margin-top':mt}); }, 150) },150) cT = $(id).children('div:first'); // console.log(cT); $(cT).css({'font-size':'20px'}); cTCA = $(id).children('div:first').children(); // console.log(cTCA); for(var f = 0; f < cTCA.length; f++) { $(cTCA[f]).css({'margin-bottom':'-5px'}); } box.global.transformedBoxesStorage = box.global.transformedBoxes; } box.global.transformedKey = undefined; box.flush = function() { if(box.global.transformedBoxes.length > 0) { box.global.transformedKey = (box.global.transformedBoxes[0]).split('-')[1]; var id, cT, cTCA; id = box.global.transformedBoxes.pop(); $(id).css({'transition':'1s', 'transform':'scale(0)', 'margin-bottom':'-200px'}); setTimeout(()=>{ $(id).css({'transition':'0.5s', 'transition-delay':'2s', 'position':'absolute', 'background':'rgb(255, 254, 172)', 'border-width':'4px', 'box-shadow':'0px 2px 5px 1px black', 'margin-top':'0px', 'margin-bottom':'0px'}); }, 2000) // text div of the div in question cT = $(id).children('div:first'); $(cT).css({'transition':'1s', 'font-size':'25px'}); // subtext divs of the text div of the div in question cTCA = $(id).children('div:first').children(); for(var f = 0; f < cTCA.length; f++) { $(cTCA[f]).css({'transition':'1s', 'margin-bottom':'1rem'}); } // show the button again setTimeout(()=>{ $($($(id).children()[1]).children()).css({'transform':'scale(1)'}); }, 2000) setTimeout(()=>box.flush(), 100); } else { console.log(box.global.transformedKey); var boxWrap = '#boxbox-' + box.global.transformedKey; console.log(boxWrap); $($(boxWrap).children()).remove('br') } } box.hide = function(id, transform, moveToReviewBox) { var idCore = id.split('box-')[1]; id = '#' + id; if(transform === 1) { box.transform(idCore, id); } else if(transform === 0) { $(id).css({'transform':'scale(0)'}); } else { // console.log('asdaslkdjalskdjalksjdlaksjdlaksdjalksdja'); box.transform2(idCore, id, transform); } if(moveToReviewBox) { setTimeout(()=>{ box.store(id); $(id).css({'transform':'scale(1)'}); }, 850); } } box.transition = function(id1, id2, transform, addSpaceBetween, hideButton, delay) { delay = delay === undefined ? 750 : delay; if(hideButton) { box.button.hide(id2); } $('#debugInfoBoxText').html(id2); id1 = 'box-' + id1; id2 = 'box-' + id2; box.hide(id1, transform); setTimeout(()=>{ box.show(id2, addSpaceBetween); }, delay); } // transition2 calls show2 which calls wrapheight2 everything is the same except wrapheight2 // in wrapheight2 everything is the same except boxbox margin top and bottom are reset to 20 20 // we are going to use this when we are making the info box dissapear between contest hs calculator sections // and we additionally need to also make the boxbox mt and mb 0 0. So when we show a new infobox we need // to reset the mt and mb to 20 20 and to to that we are using transition2 that is the only difference // a super lazy short copy past solution box.transition2 = function(id1, id2, transform, addSpaceBetween, hideButton, delay) { delay = delay === undefined ? 750 : delay; if(hideButton) { box.button.hide(id2); } id1 = 'box-' + id1; id2 = 'box-' + id2; box.hide(id1, transform); setTimeout(()=>{ box.show2(id2, addSpaceBetween); }, delay); } box.button.hide = function(id) { id = '#btn-' + id; $(id).css({'transform':'scale(0) rotate(1turn)'}); } box.button.show = function(id, size) { size = size === undefined ? 1 : size; var string = 'scale(' + size + ') rotate(0turn)' id = '#btn-' + id; $(id).css({'transform':string}); } box.button.show2 = function(id, size) { size = size === undefined ? 1 : size; var string = 'scale(' + size + ') rotate(1turn)' var temp = id; id = '#btn-' + id; $(id).css({'transition':'0.75s', 'transform':string}); setTimeout(()=>{ tool.active.sparkle = true; tool.sparkle(temp); }, 1000) } box.global.stopWiggle = true; box.button.point = function() { $('.buttonIndicator').css({'transition':'1s', 'opacity':'1'}); box.global.stopWiggle = false; box.button.wiggle(1); } box.button.wiggle = function(state) { if(!box.global.stopWiggle) { if(state === 0) { $('.buttonIndicator').css({'transition':'0.8s', 'top':'-70px'}); setTimeout(()=>box.button.wiggle(1), 700) } if(state === 1) { $('.buttonIndicator').css({'transition':'1s', 'top':'-60px'}); setTimeout(()=>box.button.wiggle(0), 700) } } else { $('.buttonIndicator').css({'transition':'1s', 'opacity':'0', 'transform':'scale(0)'}); } } box.slider.point = function() { $('.buttonIndicator2').css({'transition':'1s', 'opacity':'1'}); box.global.stopWiggle = false; box.slider.wiggle(1); } box.slider.wiggle = function(state) { if(!box.global.stopWiggle) { if(state === 0) { $('.buttonIndicator2').css({'transition':'0.7s', 'left':'220px'}); setTimeout(()=>box.slider.wiggle(1), 700) } if(state === 1) { $('.buttonIndicator2').css({'transition':'0.7s', 'left':'230px'}); setTimeout(()=>box.slider.wiggle(0), 700) } } else { $('.buttonIndicator2').css({'transition':'0.3s', 'opacity':'0', 'transform':'scale(0)'}); } }