class Appender{
constructor(bigScreenParent, smallScreenParent, child, media){
this._bigScreenParent = bigScreenParent
this._smallScreenParent = smallScreenParent
this._child = child
this._media = media
}
get bigScreenParent(){
return this._bigScreenParent
}
get smallScreenParent(){
return this._smallScreenParent
}
get child(){
return this._child
}
get media(){
return this._media
}
addChild(){
if (this._media.matches){
this._smallScreenParent.insertAdjacentElement('afterbegin', this._child)
}else this.bigScreenParent.insertAdjacentElement('afterbegin', this._child)
}
}
let bigScreenParent = document.getElementById('sidebar')
let smallScreenParent = document.getElementById('main')
let child = document.getElementById('sidebarBlurb')
let media = window.matchMedia("(max-width: 1280px)")
let prependThis = new Appender(bigScreenParent, smallScreenParent, child, media)
window.onload = prependThis.addChild()
window.matchMedia('(max-width: 1280px)').addEventListener('change', () => prependThis.addChild())