clean this mess up and make it typescript window.addEventListener("message", (event)=>{…
- User
clean this mess up and make it typescript window.addEventListener("message", (event)=>{ if(event.data.imageProps) ImagePopup.showWithProps(event.data.imageProps); });
window.ImagePopup = { sendToParent: false, element: null, dims: {},
showWithProps: function ( props // url, geometry, etc with loose json format ) { var self = this;
codeif(this.sendToParent) { window.top.postMessage({imageProps: props},'*'); return; } if(window.opener) { window.opener.postMessage({imageProps: props},'*'); return; } var style = { position: 'fixed', zIndex: '999999999999' }; let creatingAnew = !this.element; if(creatingAnew) { this.element = document.createElement('IMG'); this.element.src = props.url; this.element.onclick= () => { this.element.parentNode.removeChild(this.element); this.element = null; this.dims = {}; } } if(props.url) { this.element.src = props.url; }if(props.dims) { var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
codevar height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; // transition = 'transform ' + animDuration + 's ease-in-out' if(props.dims.x) { style.left = (typeof (props.dims.x) == 'number') ? Math.round(props.dims.x*width) + 'px': props.dims.x; this.dims.x = props.dims.x; } else { style.left = '0'; } if(props.dims.y) { style.top = (typeof (props.dims.y) == 'number') ? Math.round(props.dims.y*height) + 'px' : props.dims.y; this.dims.y = props.dims.y; } else { style.top = '0'; } if(props.dims.w) { style.width = (typeof (props.dims.w) == 'number') ? Math.round(props.dims.w*width) + 'px': props.dims.w; this.dims.w = props.dims.w; } if(props.dims.h) { style.height = (typeof (props.dims.h) == 'number') ? Math.round(props.dims.h * height) + 'px' : props.dims.h; this.dims.h = props.dims.h; } - Assistant
- User
continue
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.