Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
steve-image-carosel-test-page [2023/01/30 00:08] steve.wangsteve-image-carosel-test-page [2023/02/09 23:35] (current) steve.wang
Line 1: Line 1:
 ====== Designing Service: Using Research & Empathy to Assist Society 服務設計:透過研究與同理心創造包容性社會 ====== ====== Designing Service: Using Research & Empathy to Assist Society 服務設計:透過研究與同理心創造包容性社會 ======
-=== design and change for assistance and pressure alleviation of the elderlystressed, and general public ===+===Design and Change for Assistance and Pressure Alleviation of the ElderlyStressed, and General Public 計畫如何做出改變來協助年長者及社會大眾紓解壓力===
  
 +<html>
 +<style>
 +    body {
 +        stylemargin: 0;
 +        stylepadding: 0;
 +        style/*font: 75%/120% sans-serif;*/
 +    }
  
-=== Some Website Highlights 一些網頁精彩高光 ===+.imageCarosel{ 
 +        overflow:hidden; 
 +        border-width:2px; 
 +        border-style:solid; 
 +        border-color:black; 
 +        background-color:grey; 
 +}
  
-<html>+.mainImg{ 
 +        position:absolute; 
 +        transition-property:left; 
 +        transition-duration: 0.5s; 
 +        transition-delay: 100ms; 
 +        cursor:ew-resize; 
 +}
  
-<head> +.left
-    <title>Interactive buttons test</title> +        z-Index:2
-    <style> +        line-height: 34px
- .buttons+        display: inline-block; 
-      widthauto+        white-space: nowrap; 
-      height: 400px+          -webkit-transform: scaleX(-1); 
-    } +            transform: scaleX(-1); 
-    </style> +        opacity:0.5; 
-    <!--<link rel="icon" type="image/x-icon" href="./favicon.ico">--> +          color: grey; 
-    <link rel="shortcut icon" href="#"> +          background-color:transparent; 
-</head>+          border:none; 
 +        }
  
-<body> +.left:hover{ 
-    <script src="https://cdnjs.cloudflare.com/ajax/libs/svg.js/3.1.2/svg.min.js"></script> +        opacity:0.9; 
-    <script> +}
-const destressingCanvas = SVG().addTo('body').size(400, 400) +
-destressingCanvas.node.id = "button1" +
-destressingCanvas.node.classList.add('buttons')  +
-const elderlyCanvas = SVG().addTo('body').size(400, 400) +
-elderlyCanvas.node.id = "button2" +
-elderlyCanvas.node.classList.add('buttons')  +
-const microCanvas = SVG().addTo('body').size(400, 400) +
-microCanvas.node.id = "button3" +
-microCanvas.node.classList.add('buttons')  +
-const hydraCanvas = SVG().addTo('body').size(400, 400) +
-hydraCanvas.node.id = "button4" +
-hydraCanvas.node.classList.add('buttons')  +
-const visualCanvas = SVG().addTo('body').size(400, 400) +
-visualCanvas.node.id = "button5" +
-visualCanvas.node.classList.add('buttons')  +
-const simulationCanvas = SVG().addTo('body').size(400, 400) +
-simulationCanvas.node.id = "button6" +
-simulationCanvas.node.classList.add('buttons')  +
-const studentsCanvas = SVG().addTo('body').size(400, 400) +
-studentsCanvas.node.id = "button7" +
-studentsCanvas.node.classList.add('buttons')  +
-const impressionCanvas = SVG().addTo('body').size(400, 400) +
-impressionCanvas.node.id = "button8" +
-//put them in a HTML class +
-impressionCanvas.node.classList.add('buttons'+
  
  
 +.right{
 +        z-Index:2;
 +        line-height: 34px;
 +        display: inline-block;
 +        opacity:0.5;
 +        color: grey;
 +        background-color:transparent;
 +          border:none;
 +}
  
-let allSvgs = []+.right:hover{ 
 +        opacity:0.9; 
 +
 +.arrow{ 
 +        z-Index:3; 
 +        line-height: 34px; 
 +        position:absolute; 
 +        top:50%; 
 +        opacity:0.2; 
 +        color: grey; 
 +
 +/* Make text go to the middle: 
 + * https://stackoverflow.com/a/14061404/19515980 
 + * 
 + * */ 
 +/* 
 + * .moveLeft{ 
 +     transition:4s; 
 +         transform:translateX(-3000) 
 +         } 
 + * 
 +         .moveRight{ 
 +             transition:4s; 
 +                 transform:translateX(3000) 
 +                 } 
 +                 */
  
-let allSvgsObj = {} 
  
-//some notes: create a bunch of SVG canvas, and stuff different butotns in one by one. +</style> 
-//Make a function that activates buttons +<script>
-//+
  
 +//setup:
  
-function checkIfSVGjsElement(item) { +class Point { 
-    try +  constructor(x, y) { 
-        item.dmove(00+    this.x = x; 
-        return true +    this.y = y; 
-    } catch +  } 
-        return false+  move(xDistance, yDistance) 
 +    return new Point(this.x + xDistance, this.y + yDistance); 
 +  } 
 +  moveByAngle(angledistance{ 
 +    let r = (angle * Math.PI) / 180; 
 +    return new Point( 
 +      this.x + distance * Math.sin(r), 
 +      this.y + distance * Math.cos(r) 
 +    ); 
 +  } 
 +  distance(point2) 
 +    let point1 = new Point(this.x, this.y) 
 +    let a = point1.x - point2.x 
 +    let b = point1.y - point2.y 
 +    if (a < 0) { 
 +      a = a - (a * 2)
     }     }
 +    if (b < 0) {
 +      b = b - (b * 2)
 +    }
 +    let toSquare = (b ** 2) + (a ** 2)
 +    return Math.sqrt(toSquare)
 +  }
 } }
  
 +// A safer version of splice
  
-function getAllShapes(svgArraycanvas) { +function safeSplice(inputArrayamountToRemove,indexToRemove,replaceWith) { 
-    let newSvgArray = [] +  let array1 = inputArray.slice(0, indexToRemove ) 
-    //console.log("svgArray") +if (replaceWith!=undefined){ 
-    //console.log(svgArray+array1.push(replaceWith)} 
-    if (svgArray == undefined) { +  let array2 = inputArray.slice(indexToRemove + amountToRemove, inputArray.length) 
-        //console.log("destressingButton.children: "+  return array1.concat(array2) 
-        //console.log(destressingButton.children()[0]+
-        console.log(canvas.children()[0].children()) +/* 
-        //getAllShapes(destressingButton.children()[0].children()) +let info=[
-        //getAllShapes(destressingButton.children()[1].children()) +    imageSrc:'./what is this.png', 
-        canvas.children().forEach(=> { +    portraitSrc:'./measure-portrait.PNG', 
-            getAllShapes(e.children()) +    href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=about-space_invaders', 
-        }) +    description:'hi,hi,hi', 
-    } else +},{ 
-        svgArray.forEach(=> { +    imageSrc:'./steve-color-scrolling.png', 
-            if (x.type == 'g'{ +    portraitSrc:'./homework-portrait.PNG', 
-                x.children().forEach(=> { +    href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=my_planet', 
-                    console.log(y+    description:'hio,hio,hio', 
-                    newSvgArray.push(y+},{ 
-                }) +    imageSrc:'./steve-drawing-fractals.png', 
-            } else if (x.type != 'defs&& x.type.includes('sodipodi') == false && checkIfSVGjsElement(x)) { +    portraitSrc:'./circuits-portrait.jpg', 
-                //remove the css color, and replace it with the .fill() color in SVG.js +    href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=agriculture', 
-                console.log(x+    description:'hiv,hiv,hiv', 
-                x.fill(x.node.style.fill+}] 
-                x.node.style = null; +*/ 
-                //console.log("here"+ 
-                //console.log(x+let info=[{ 
-                allSvgs.push(x)+    imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-students.jpg', 
 +    portraitSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-portrait-students.jpg', 
 +    href:'https://renickbell.net/ed/2022service/doku.php?id=about-students', 
 +    description:'about our students', 
 +},{ 
 +    imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-arduino.jpg', 
 +    portraitSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-portrait-arduino.jpg', 
 +    href:'https://renickbell.net/ed/2022service/doku.php?id=arduino', 
 +    description:'arduino', 
 +},{ 
 +    imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-simulation.jpg', 
 +    portraitSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-portrait-simulation.jpg', 
 +    href:'https://renickbell.net/ed/2022service/doku.php?id=partner-simulation', 
 +    description:'simulation of elderly experience', 
 +},{ 
 +    imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-hydra.jpg', 
 +    portraitSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-portrait-hydra.jpg', 
 +    href:'https://renickbell.net/ed/2022service/doku.php?id=hydra-practice', 
 +    description:'hydra', 
 +},{ 
 +    imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-visual.jpg', 
 +    portraitSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-portrait-visual.jpg', 
 +    href:'https://renickbell.net/ed/2022service/doku.php?id=art-museum', 
 +    description:'visual cues', 
 +}] 
 + 
 + 
 +let carosels=[] 
 + 
 +let browserZoomLevel; 
 + 
 +//Make imagecaorsel class and to move use assign element to css class and use transition, transform translate. 
 +class ImageCarosel{ 
 +    constructor (sizePoint,info,domLocation,caroselLocation){ 
 +        this.domLocation=domLocation 
 +        this.type=domLocation 
 +        if (sizePoint=='auto'){ 
 +            sizePoint=new Point(window.innerWidth-10,window.innerHeight-10) 
 +        
 +        if (domLocation=='main'){ 
 +            this.carosel=document.createElement('div'
 +            this.carosel.style.position='relative' 
 +            this.carosel.style.left='0px' 
 +            this.carosel.style.top='0px' 
 +            this.carosel.style.width=sizePoint.x+'px' 
 +            this.carosel.style.height=sizePoint.y+'px' 
 +     this.caroselLocation=new Point(0,0
 +        
 +        else if (domLocation=='doku'){ 
 +            //document.getElementById('dokuwiki__content').appendChild(this.carosel) 
 +            document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public_計畫如何做出改變來協助年長者及社會大眾紓解壓力').appendChild(this.carosel
 +        
 +        else{ 
 +            this.carosel=document.createElement('div'
 +            this.carosel.style.left=caroselLocation.x 
 +            this.carosel.style.top=caroselLocation.y 
 +            this.carosel.style.width=sizePoint.x 
 +            this.carosel.style.height=sizePoint.y 
 +     this.caroselLocation=caroselLocation 
 +        } 
 +        this.carosel.className='imageCarosel' 
 +        this.carosel.ondragstart=(()=>{return false}) 
 +        this.carosel.ondrop=(()=>{return false}
 +        if (domLocation=='body' || domLocation==undefined || domLocation=='main'){ 
 +            document.body.appendChild(this.carosel) 
 +        } 
 +        else if (domLocation=='doku'){ 
 +            //document.getElementById('dokuwiki__content').appendChild(this.carosel) 
 +            document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public_計畫如何做出改變來協助年長者及社會大眾紓解壓力').appendChild(this.carosel) 
 +
 +        else{ 
 +            document.getElementById(domLocation).appendChild(this.carosel) 
 +        } 
 +        this.info=info 
 +        this.currentImage=0 
 +        this.mainImg1=document.createElement('img'
 +        this.mainImg1.src=info[0].imageSrc 
 +        if (deviceOrientation=='landscape')
 +            this.mainImg1.href=this.info[1].href 
 +        
 +        else{ 
 +            this.mainImg1.href=this.info[1].portraitSrc 
 +        } 
 +        this.mainImg1.className='mainImg' 
 +        this.mainImg2=document.createElement('img'
 +        this.mainImg2.href=this.info[0].href 
 +        if (deviceOrientation=='landscape')
 +            this.mainImg2.src=info[1].imageSrc 
 +        } 
 +        else{ 
 +            this.mainImg2.src=this.info[0].portraitSrc 
 +        } 
 +        this.mainImg2.className='mainImg' 
 +        if (domLocation=='main' || domLocation=='doku')
 +            this.mainImg1.style.width='100%' 
 +            this.mainImg1.style.height='auto' 
 +            this.mainImg2.style.width='100%' 
 +            this.mainImg2.style.height='auto' 
 +        } 
 +        this.carosel.appendChild(this.mainImg1
 +        this.carosel.appendChild(this.mainImg2) 
 +        this.mainImg1.style.position='absolute' 
 +        this.mainImg2.style.position='absolute' 
 +        this.centeredImg=this.mainImg2 
 +        this.caroselSize=sizePoint 
 +        setTimeout(()=>{ 
 +            this.correctCenteredImgPosition=new Point(this.carosel.style.left.slice(0,this.carosel.style.left.length-2),this.carosel.style.top.slice(0,this.carosel.style.left.length-2)) 
 +        },100) 
 +        this.imageCaroselNumber=carosels.length 
 +        this.queue=[] 
 +    } 
 +    createArrows()
 +        /* 
 +        this.left=document.createElement('button'
 +        this.left.className='left' 
 +        this.left.onclick= (()=>{this.switchLeft()}) 
 +        this.left.style.position='absolute' 
 +        this.left.style.left='0%' 
 +        this.left.style.top='50%' 
 +        this.left.textContent='⇦' 
 +        this.left.style.width=browserZoomLevel/2+'px' 
 +        this.left.style.height=browserZoomLevel/2+'px' 
 +        this.left.style.fontSize=browserZoomLevel/2+'px' 
 +        */ 
 +        this.right=document.createElement('button') 
 +        this.right.className='right' 
 +        //this.right.onclick=(()=>{this.sequenceActions(this.quickRight)}) 
 +        //this.right.onclick=(()=>{this.quickRight()}) 
 +        this.right.onclick=(()=>{this.sequenceActions('quickRight')}
 +        this.right.style.position='absolute' 
 +        this.right.style.right='0%' 
 +        this.right.style.top='50%' 
 +        let arrowSizes=browserZoomLevel/
 +        if (arrowSizes<84 && deviceOrientation=='landscape'){ 
 +            arrowSizes=84 
 +        } 
 +        else if (arrowSizes>100 && deviceOrientation=='landscape'){ 
 +            arrowSizes=100 
 +        } 
 +        else if (deviceOrientation=='portrait'){ 
 +            console.log('acknowledged'
 +            arrowSizes=browserZoomLevel/
 +        } 
 +        this.right.style.width=arrowSizes+'px' 
 +        this.right.style.height=arrowSizes+'px' 
 +        this.right.style.fontSize=arrowSizes+'px' 
 +        this.right.textContent='⇨' 
 +        this.left=this.right.cloneNode(true) 
 +        //this.left.onclick=(()=>{this.quickLeft()}) 
 +        //this.left.onclick= (()=>{this.sequenceActions(this.quickLeft)}) 
 +        this.left.onclick=(()=>{this.sequenceActions('quickLeft')}) 
 +        this.left.style.position='absolute' 
 +        this.left.style.left='0%' 
 +        this.left.style.top='50%' 
 +        this.left.className='left' 
 +        /
 +        this.mainImg1.style.position='absolute' 
 +        this.mainImg2.style.position='absolute' 
 +        let arrowSizes=browserZoomLevel/
 +        this.mainImg1.style.width=this.mainImg1.getBoundingClientRect().width-arrowSizes-100+'px' 
 +        this.mainImg1.style.height=this.mainImg1.getBoundingClientRect().height-arrowSizes-100+'px' 
 +        this.mainImg2.style.width=this.mainImg2.getBoundingClientRect().width-arrowSizes-100+'px' 
 +        this.mainImg2.style.height=this.mainImg2.getBoundingClientRect().height-arrowSizes-100+'px' 
 +        this.mainImg1.style.left=this.mainImg1.getBoundingClientRect().x+arrowSizes+'px' 
 +        this.mainImg2.style.left=this.mainImg1.getBoundingClientRect().x+arrowSizes+'px' 
 +        this.mainImg1.style.position='auto' 
 +        this.mainImg2.style.position='auto' 
 +        */ 
 +        this.correctCenteredImgPosition=new Point(this.centeredImg.getBoundingClientRect().x,this.centeredImg.getBoundingClientRect().y
 +        this.carosel.insertBefore(this.right,this.mainImg2) 
 +        this.carosel.insertBefore(this.left,this.mainImg1) 
 +    } 
 +    checkForNormalMovements (){ 
 +        if (this.queue.includes('switchRight') ||this.queue.includes('switchLeft')){ 
 +            return true 
 +        } 
 +        else { 
 +            return false 
 +        } 
 +    } 
 +    sequenceActions (action){ 
 +        let beforeLength=this.queue.length 
 +        console.log(action
 +        if (action=='quickLeft' && this.queue.length>0 && this.checkForNormalMovements()==true || action=='quickRight' && this.queue.length>0 && this.checkForNormalMovements()==true){ 
 +            this.cutQueue(action) 
 +        } 
 +        else{ 
 +            this.queue.push(action) 
 +        } 
 +        if (this.queue.length==1 ){ 
 +            sequencingSwitchingImages(this.imageCaroselNumber) 
 +        } 
 +    } 
 +    cutQueue (action){ 
 +        this.queue.forEach((x,i)=>{ 
 +            if (x!='quickRight'&& x!='quickLeft'){ 
 +                this.queue=[...safeSplice(this.queue,this.queue.length-i-1,i),action,...safeSplice(this.queue,i,0)] 
 +            console.log('trying',this.queue)
             }             }
         })         })
     }     }
-    if (newSvgArray.length > 0) { +    quickRight (){ 
-        getAllShapes(newSvgArray)+        console.log('quick right'
 +        this.currentImage-=1 
 +        if (this.currentImage<0){ 
 +            this.currentImage=this.info.length-1 
 +        } 
 +        if (this.centeredImg==this.mainImg1){ 
 +            this.changeContent(this.mainImg2) 
 +            setTimeout(()=>
 +                this.mainImg2.style.transitionProperty='none' 
 +                this.mainImg2.style.left=this.correctCenteredImgPosition.x-this.mainImg2.getBoundingClientRect().width+'px' 
 +                this.centeredImg.style.left=this.carosel.getBoundingClientRect().right+this.centeredImg.getBoundingClientRect().width+'px' 
 +                this.mainImg2.style.transitionProperty='left' 
 +                this.mainImg2.style.left=this.correctCenteredImgPosition.x+'px' 
 +                this.centeredImg=this.mainImg2 
 +            },100) 
 +        } 
 +        else{ 
 +            this.changeContent(this.mainImg1) 
 +            setTimeout(()=>
 +                this.mainImg1.style.transitionProperty='none' 
 +                this.mainImg1.style.left=this.correctCenteredImgPosition.x-this.mainImg1.getBoundingClientRect().width+'px' 
 +            this.centeredImg.style.left=this.carosel.getBoundingClientRect().right+this.centeredImg.getBoundingClientRect().width+'px' 
 +                this.mainImg1.style.transitionProperty='left' 
 +                this.mainImg1.style.left=this.correctCenteredImgPosition.x+'px' 
 +                this.centeredImg=this.mainImg1 
 +            },100) 
 +        
 +        return new Promise((resolve,reject)=>
 +            setTimeout(()=>
 +                resolve(true) 
 +            },10*35) 
 +        })
     }     }
-} +    quickLeft (){ 
- +        console.log('quick left') 
-//from https://stackoverflow.com/questions/14446447/how-to-read-a-local-text-file-in-the-browser +        this.currentImage-=1 
-//reads a text file +        if (this.currentImage<0){ 
-function readTextFile(file) { +            this.currentImage=this.info.length-1 
-    let rawFile new XMLHttpRequest(); +        } 
-    rawFile.open("GET"filefalse); +        if (this.centeredImg==this.mainImg1){ 
-    let allText; +            this.changeContent(this.mainImg2) 
-    rawFile.onreadystatechange function() { +            this.mainImg2.style.transitionProperty='none' 
-        if (rawFile.readyState === 4) { +            this.mainImg2.style.left=this.correctCenteredImgPosition.x+this.mainImg2.getBoundingClientRect().width+'px' 
-            if (rawFile.status === 200 || rawFile.status == 0) { +            this.centeredImg.style.left=this.correctCenteredImgPosition.x-this.centeredImg.getBoundingClientRect().width+'px' 
-                allText rawFile.responseText; +            this.mainImg2.style.transitionProperty='left' 
-                //console.log(allText);+            this.mainImg2.style.left=this.correctCenteredImgPosition.x+'px' 
 +            this.centeredImg=this.mainImg2 
 +        } 
 +        else{ 
 +            this.changeContent(this.mainImg1) 
 +            this.mainImg1.style.transitionProperty='none' 
 +            this.mainImg1.style.left=this.correctCenteredImgPosition.x+this.mainImg1.getBoundingClientRect().width+'px' 
 +            this.centeredImg.style.left=this.correctCenteredImgPosition.x-this.centeredImg.getBoundingClientRect().width+'px' 
 +            this.mainImg1.style.transitionProperty='left' 
 +            this.mainImg1.style.left=this.correctCenteredImgPosition.x+'px' 
 +            this.centeredImg=this.mainImg1 
 +        } 
 +        return new Promise((resolve,reject)=>
 +            setTimeout(()=>
 +                resolve(true) 
 +            },10*35) 
 +        }
 +    } 
 +    switchRight (){ 
 +        console.log('switch right'
 +        this.currentImage-=
 +        if (this.currentImage<0){ 
 +            this.currentImage=this.info.length-1 
 +        } 
 +        if (this.centeredImg==this.mainImg1){ 
 +            this.changeContent(this.mainImg2) 
 +            setTimeout(()=>{ 
 +                this.mainImg2.style.transitionProperty='none' 
 +                this.mainImg2.style.left=this.correctCenteredImgPosition.x-this.mainImg2.getBoundingClientRect().width+'px' 
 +                this.centeredImg.style.left=this.carosel.getBoundingClientRect().right+this.centeredImg.getBoundingClientRect().width+'px' 
 +                this.mainImg2.style.transitionProperty='left' 
 +                this.mainImg2.style.left=this.correctCenteredImgPosition.x+'px' 
 +                this.centeredImg=this.mainImg2 
 +            },100) 
 +        } 
 +        else{ 
 +            this.changeContent(this.mainImg1) 
 +            setTimeout(()=>
 +                this.mainImg1.style.transitionProperty='none' 
 +                this.mainImg1.style.left=this.correctCenteredImgPosition.x-this.mainImg1.getBoundingClientRect().width+'px' 
 +            this.centeredImg.style.left=this.carosel.getBoundingClientRect().right+this.centeredImg.getBoundingClientRect().width+'px' 
 +                this.mainImg1.style.transitionProperty='left' 
 +                this.mainImg1.style.left=this.correctCenteredImgPosition.x+'px' 
 +                this.centeredImg=this.mainImg1 
 +            },100) 
 +        } 
 +        return new Promise((resolve,reject)=>
 +            setTimeout(()=>
 +                resolve(true) 
 +            },10*35) 
 +        }) 
 +    } 
 +    handleClicks (e){ 
 +        console.log(e.target,this.centeredImg) 
 +        if (e.target==this.centeredImg){ 
 +            window.open(this.centeredImg.href) 
 +        } 
 +    } 
 +    autoScroller (){ 
 +        this.scrollInterval=setInterval(()=>
 +            if (this.queue.length==0 && imageAutoSwitchCooldown==false){ 
 +                imageAutoSwitchCooldown=true 
 +                resetImageSwitchCooldown() 
 +                this.sequenceActions('switchRight')
             }             }
 +        },8000)
 +    }
 +    imageJumpAnimationRight (amount){
 +        this.currentImage-=amount
 +        if (this.currentImage<0){
 +            this.currentImage=this.info.length+this.currentImage
         }         }
 +        this.centeredImg.style.left=this.carosel.getBoundingClientRect().right*3+'px'
 +        let jumpInterval=setInterval(()=>{
 +            this.centeredImg.style.left=this.correctCenteredImgPosition.x+'px'
 +        },amount/0.3)
 +        setTimeout(()=>{
 +            clearInterval(jumpInterval)
 +            this.changeContent(this.centeredImg)
 +        },amount/0.6)
 +    }
 +    textDesciption (){
 +        this.infoText=document.createElement('div')
 +        this.infoText.style.backgroundColor='grey'
 +        this.infoText.style.textAlign = "right";
 +        this.infoText.style.font='25px'
 +        this.infoText.style.color='black'
 +        this.infoText.style.wordWrap='break-word'
 +        //https://stackoverflow.com/a/23842462/19515980
 +        this.infoText.style.overflow='auto'
 +        this.mainImg1.style.height=this.carosel.getBoundingClientRect().height-100+'px'
 +        this.mainImg2.style.height=this.carosel.getBoundingClientRect().height-100+'px'
 +        this.infoText.textContent='wgwgwegwegwegweg .'
 +        this.infoText.style.position='absolute'
 +        this.infoText.style.top=this.carosel.getBoundingClientRect().height-100+'px'
 +        this.infoText.style.left='0px'
 +        this.infoText.style.width=this.carosel.getBoundingClientRect().width-3+'px'
 +        this.infoText.style.height='100px';
 +        this.carosel.appendChild(this.infoText)
 +    }
 +    changeContent (toChangeTo){
 +            toChangeTo.href=this.info[this.currentImage].href
 +            if (deviceOrientation=='landscape'){
 +                toChangeTo.src=this.info[this.currentImage].imageSrc
 +            }
 +            else{
 +                toChangeTo.src=this.info[this.currentImage].portraitSrc
 +            }
 +        }
 +     addSpaceAbove (amount){
 +         for (let i = 0; i < amount; i++) {
 +             this.carosel.parentElement.insertBefore(document.createElement('br'),this.carosel)
 +         }
     }     }
-    rawFile.send(null); 
-    return allText; 
 } }
  
-//Change files to the format that we can use +function loadImg (){ 
-function readFile(input) { +    let imageElemForLoadingnew Image() 
-    let file input.files[0]; +    if (deviceOrientation == portrait'){ 
-    //console.log('"file" in readFile function') +        info.forEach(x=>
-    //console.log(file)+            imageElemForLoading.src=x.portraitSrc 
 +        }
 +    
 +    else{ 
 +        info.forEach(x=>{ 
 +            imageElemForLoading.src=x.imageSrc 
 +        }) 
 +    } 
 +}
  
-    let reader = new FileReader(); 
  
-    reader.readAsText(file);+function manuallyMoveHtmlToRight (elem,startX,moveBy,times,counter){ 
 +    if (counter==undefined){ 
 +        counter=1} 
 +    elem.style.left=startX+moveBy*counter+'px' 
 +    if (counter<times){ 
 +        setTimeout(()=>
 +            manuallyMoveHtmlToRight(elem,startX,moveBy,times,counter+1)},14)
 +}
  
-    reader.onload = function() { 
-        //console.log(reader.result); 
-    }; 
  
-    reader.onerror = function() { +function manuallyMoveHtmlToLeft (elem,startX,moveBy,times,counter){ 
-        //console.log(reader.error); +    if (counter==undefined){ 
-    }; +        counter=1
-    return reader+    elem.style.left=startX-moveBy*counter+'px' 
 +    if (counter<times){ 
 +        setTimeout(()=>
 +            manuallyMoveHtmlToLeft(elem,startX,moveBy,times,counter+1)},14)}
 } }
  
-//code from Chat-GPT, https://chat.openai.com/chat/8884aedb-3f4d-4e14-87bf-d9cfe3223d90 +/* 
-function removeCamelCase(str) { +async function sequencingSwitchingImages (imageCaroselNumber){ 
-    // Split the string into an array of words +   await carosels[imageCaroselNumber][carosels[imageCaroselNumber][queue][0]]() 
-    let words str.split(/(?=[A-Z])/); +   carosels[imageCaroselNumber][queue]=safeSplice(carosels[imageCaroselNumber][queue],1,0
- +    if (carosels[imageCaroselNumber][queue].length>0)
-    // Remove the first word and join the remaining words with a space +        sequencingSwitchingImages(imageCaroselNumber
-    let result = words.slice(1).join(" ").toLowerCase()+    }
- +
-    return result;+
 } }
  
-//put svgs into an object and use their ids as their keys +async function sequencingSwitchingImages (imageCaroselNumber){ 
-function putSvgsInObject(svgArray, object, camelCase) { +   let currentImageCarosel=carosels[imageCaroselNumber] 
-    if (camelCase{ +   await currentImageCarosel[currentImageCarosel.queue[0]]() 
-        svgArray.forEach(=> object[removeCamelCase(e.node.id)] = e+   //document.getElementById('console_output').innerHTML+='<br><br>'+currentImageCarosel.queue[0] 
-    } else +   currentImageCarosel.queue=safeSplice(currentImageCarosel.queue,1,0
-        svgArray.forEach(e => object[e.node.id] = e)+    if (currentImageCarosel.queue.length>0)
 +        sequencingSwitchingImages(imageCaroselNumber)
     }     }
 } }
  
-function printObject(obj) { +*/ 
-    for (const [key, valueof Object.entries(obj)) { + 
-        console.log(`${key}: ${value}`)+let imageAutoSwitchCooldown=false 
 +async function sequencingSwitchingImages (imageCaroselNumber){ 
 +   imageAutoSwitchCooldown=true 
 +   let currentImageCarosel=carosels[imageCaroselNumber] 
 +   await currentImageCarosel[currentImageCarosel.queue[0]]() 
 +   currentImageCarosel.queue=safeSplice(currentImageCarosel.queue,1,0) 
 +    if (currentImageCarosel.queue.length>0){ 
 +        sequencingSwitchingImages(imageCaroselNumber) 
 +        resetImageSwitchCooldown(currentImageCarosel)
     }     }
 } }
  
-function changeCursor(style) { +function resetImageSwitchCooldown (currentImageCarosel){ 
-    document.getElementsByTagName("body")[0].style.cursor style+    setTimeout(()=>{ 
 +        if (currentImageCarosel.queue.length==0){ 
 +            imageAutoSwitchCooldown=false 
 +        } 
 +        else { 
 +            setTimeout(()=>
 +                resetImageSwitchCooldown(currentImageCarosel) 
 +            },5000) 
 +        } 
 +    },3000)
 } }
  
- +let higs;  
-function displaySvgs(canvas, ...files) { +window.addEventListener("load", function(e){ 
-    //let svgXml = readTextFile(file) +     browserZoomLevel = Math.round(window.devicePixelRatio * 100); 
-    files.forEach(e => { +if (window.innerWidth<window.innerHeight){ 
-        canvas.svg(readTextFile(e)) +    console.log('portrait mode'
-    }) +    deviceOrientation='portrait'
-    //console.log(svgXml) +
-    //console.log(reader.result+
-    //destressingButton.svg(reader.result) +
-    //destressingButton.svg(svgXml) +
-    getAllShapes(undefined, canvas) +
-    putSvgsInObject(allSvgs, allSvgsObj+
-    console.log(allSvgsObj+
-    console.log(allSvgs)+
 } }
 +else{
 +    console.log('landscape mode')
 +    deviceOrientation='landscape'
 +}
 +loadImg()
 +console.log('loaded')
 +//higs=new ImageCarosel(new Point(1920,1000),info,'main')
 +//hhigs=new ImageCarosel('auto',info,'main')
 +higs=new ImageCarosel('doku',info,'main')
 +higs.createArrows()
 +carosels.push(higs)
 +//higs.sequenceActions(higs.quickRight)
 +higs.quickRight()
 +//higs.autoScroller()
 +/*
 +    setTimeout(()=>{
 +        if (deviceOrientation=='landscape'){
 +            higs.carosel.style.height=window.innerHeight+'px';
 +            higs.carosel.style.width=window.innerWidth-100+'px';      
 +            document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public_計畫如何做出改變來協助年長者及社會大眾紓解壓力').appendChild(higs.carosel)
 +            higs.caroselLocation=new Point(0,300)
 +        }
 +        else{
 +            higs.carosel.style.height=window.innerHeight+'px';
 +            higs.carosel.style.width=window.innerWidth+'px';      
 +            document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public_計畫如何做出改變來協助年長者及社會大眾紓解壓力').appendChild(higs.carosel)
 +            higs.caroselLocation=new Point(100,300)
 +        }
 +    },1000)
 +    */
 +    setTimeout(()=>{
 +           //higs.carosel.style.width=document.getElementsByClassName('permalink')[0].getBoundingClientRect().right-higs.carosel.getBoundingClientRect().x+'px';      
 +      higs.carosel.style.width='80%'
 +           // higs.carosel.style.width='1600px'
 +            //higs.carosel.style.height='400px'
 +            document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public_計畫如何做出改變來協助年長者及社會大眾紓解壓力').appendChild(higs.carosel)
 +            higs.caroselLocation=new Point(0,900)
 +            setTimeout(()=>{
 +                higs.addSpaceAbove(2)
 +                //higs.carosel.style.height=higs.mainImg1.getBoundingClientRect().height+'px';
 +           // higs.carosel.style.height='800px'
 +                higs.carosel.style.height=higs.mainImg1.getBoundingClientRect().height+'px'
 +            },100)
 +    },300)
 +})
  
 +function getDeviceType () {
 +  const ua = navigator.userAgent;
 +  if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(ua)) {
 +    return "tablet";
 +  }
 +  if (
 +    /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(
 +      ua
 +    )
 +  ) {
 +    return "mobile";
 +  }
 +  return "desktop";
 +};
  
 +let deviceType=getDeviceType()
  
-//if (document.readyState === 'complete') { +document.addEventListener("click", e => { 
-//console.log("hi9"+    if (e.target.href!=undefined && e.target.className=='mainImg'){ 
-//} +        window.open(e.target.href
- +    } 
-//from https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro +})
-//function createElementFromHTML(htmlString) { +
-//var div = document.createElement('div'); +
-//div.innerHTML = htmlString.trim(); +
- +
-//// Change this to div.childNodes to support multiple top-level nodes. +
-//return div; +
-//} +
- +
-//function makeSvgElement(directory, id){ +
-//let svgElement = createElementFromHTML(readFile(directory)) +
-//svgElement.id = id +
-//document.body.appendChild(svgElement) +
-//} +
- +
- +
-//makeSvgElement("./destressingButton.svg", "destressingButton"+
- +
-//document.addEventListener('DOMContentLoaded', e => { +
-////document.appendChild(destressingButton) +
-//console.log(`Document is ready!`) +
-//}) +
- +
-displaySvgs(destressingCanvas, "https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=destressingbutton.svg"+
- +
-displaySvgs(elderlyCanvas, "https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=elderlybutton.svg"+
- +
-displaySvgs(microCanvas, "https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=microbutton.svg"+
- +
-displaySvgs(hydraCanvas, "https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=hydrabutton.svg"+
- +
-displaySvgs(visualCanvas, "https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=visualbutton.svg"+
- +
-displaySvgs(simulationCanvas, "https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=simulationbutton.svg"+
- +
-displaySvgs(studentsCanvas, "https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=studentsbutton.svg"+
- +
-displaySvgs(impressionCanvas, "https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=impressionbutton.svg")+
  
-let destressingSvgs []; +let lastDeltaX=0 
-let destressingSvgsObj {}; +let lastDeltaY=0 
- +document.addEventListener("wheel", e => 
-let elderlySvgs = []; +    if (e.wheelDelta<0 && e.deltaY==0){ 
-let elderlySvgsObj = {}; +        checkIfSwitchImageLeft(e.target)
- +
-//micro means micro-controllers +
-let microSvgs = []; +
-let microSvgsObj = {}; +
- +
-let simulationSvgs = []; +
-let simulationSvgsObj = {}; +
- +
-//educating public about hydra +
-let hydraSvgs = []; +
-let hydraSvgsObj = {}; +
- +
-//visual cue +
-let visualSvgs = []; +
-let visualSvgsObj = {}; +
- +
-let studentsSvgs = []; +
-let studentsSvgsObj = {}; +
- +
-//image of the elderly (I ran out of keywords) +
-let impressionSvgs = []; +
-let impressionSvgsObj = {}; +
- +
-allSvgs.forEach(e => { +
-    if (e.node.id.includes("destressing")) { +
-        destressingSvgs.push(e); +
-        putSvgsInObject(destressingSvgsdestressingSvgsObj, true); +
-    } else if (e.node.id.includes("elderly")) { +
-        elderlySvgs.push(e); +
-        putSvgsInObject(elderlySvgs, elderlySvgsObj, true); +
-    } else if (e.node.id.includes("micro")) { +
-        microSvgs.push(e); +
-        putSvgsInObject(microSvgs, microSvgsObj, true); +
-    } else if (e.node.id.includes("simulation")) { +
-        simulationSvgs.push(e); +
-        putSvgsInObject(simulationSvgs, simulationSvgsObj, true) +
-    } else if (e.node.id.includes("hydra")) { +
-        hydraSvgs.push(e); +
-        putSvgsInObject(hydraSvgs, hydraSvgsObj, true) +
-    } else if (e.node.id.includes("visual")) { +
-        visualSvgs.push(e); +
-        putSvgsInObject(visualSvgs, visualSvgsObj, true) +
-    } else if (e.node.id.includes("students")) { +
-        studentsSvgs.push(e); +
-        putSvgsInObject(studentsSvgs, studentsSvgsObj, true); +
-    } else if (e.node.id.includes("impression")) { +
-        impressionSvgs.push(e); +
-        putSvgsInObject(impressionSvgs, impressionSvgsObj, true);+
     }     }
-});+    else if (e.deltaX>lastDeltaX && e.deltaY==0){ 
 +        checkIfSwitchImageRight(e.target) 
 +    } 
 +    lastDeltaX=JSON.parse(JSON.stringify(e.deltaX)) 
 +    lastDeltaY=JSON.parse(JSON.stringify(e.deltaY)) 
 +})
  
 +let mouse = new Point(0, 0)
 +let lastMousePosition=new Point(0,0)
 +let scrollPosition=new Point(0,0)
  
-let animationDuration 250; +document.addEventListener('scroll', ((e) => { 
-let buttonSize 400;+//calculating Mouse position: 
 +  mouse.x mouse.x+(window.scrollX-scrollPosition.x) 
 +  mouse.y = mouse.y + (window.scrollY - scrollPosition.y) 
 +  scrollPosition = new Point(window.scrollX,window.scrollY) 
 +}))
  
-let destressingGroup; +let switchImageCooldown=false 
- +if (deviceType!='mobile'){ 
- +    document.addEventListener('pointermove', ((e=> 
-let descriptions { +        mouse.x = e.pageX 
-    destressingDescription: destressingCanvas.text("Recognizing that everyone is stressed \nout, students designed and programmed \ninteractive digital images to reduce \nstress. To accomplish this, they used \nseveral JavaScript programming \nlibraries and physical computing.").move(19, 268).font({ +        mouse.y = e.pageY 
-        family: 'arial'+        if (mouse.x>=window.innerWidth-2 && switchImageCooldown==false){ 
-        size: 20 +            checkIfSwitchImageRight() 
-    }).opacity(0), +        } 
-    elderlyDescription: elderlyCanvas.text("Another service that we are trying \nto provide this semester is a \nbiographical introduction of our \npartners at the Taipei Datong Elderly \nDaycare Center. These individuals \nwelcomed us and graciously shared \nstories from their lives, teaching us both \nabout what society was like in the \npast and also about some details of their \ncurrent activities and daily pursuits.").move(19, 268).font({ +        else if (mouse.x<2 && switchImageCooldown==false){ 
-        family: 'arial', +            checkIfSwitchImageLeft() 
-        size: 20 +        } 
-    }).opacity(0), +    }))
-    microDescription: microCanvas.text("We wanted to learn how to add unique \nphysical control to our stress-relieving \nimages. To accomplish this, we studied \nhow to build and program circuits which \ninvolve microcontrollers, particularly the \nArduino Uno microcontroller.").move(20, 268).font(+
-        family: 'arial', +
-        size: 20 +
-    }).opacity(0), +
-    simulationDescription: simulationCanvas.text("A super big thanks to all our friends at \nthe Center for Innovation Taipei who \ntook valuable time from their busy \nworking schedules to help us out with \nour crazy simulations. Not only were \nthey required to wear our elderly \nsimulation suit, they had to undertake a \nseries of difficult tasks.").move(19, 268).font({ +
-        family: 'arial', +
-        size: 20 +
-    }).opacity(0), +
-    hydraDescription: hydraCanvas.text("Hydra is an image processing \nsoftware that we utilized this semester to \ncreate some interesting visual effects, \nlater utilizing it in the design of our \nde-stressing images for our elderly \nfriends.").move(19, 268).font(+
-        family: 'arial', +
-        size: 20 +
-    }).opacity(0)+
-    visualDescriptions: visualCanvas.text("One of the services the students \ndesigned this semester was visual art \nthat could help with the alleviation of \nstress. An early step in this learning \nprocess involved the students \nexploring their own reactions to \ncertain visual stimulus, with input \ncoming from work from \nprofessional artists in the art field.").move(19, 268).font({ +
-        family: 'arial', +
-        size: 20, +
-    }).opacity(0), +
-    studentsDescription: studentsCanvas.text("This education program currently \ninvolves a small group of students. Each \nis unique and talented in their own way, \nwith different strengths and \ncontributions to our team.").move(19, 268).font(+
-        family: 'arial', +
-        size: 20 +
-    }).opacity(0)+
-    impressionDescription: impressionCanvas.text("Among the main topics of this \nsemester's work was that of aging \nsociety and its elderly members. If we \nare to attempt to devise ideas to \nfacilitate an easier life experience for \nthese treasured members of our \ncommunity, we will need to start by \nconsidering their current role in the \nsocial group and how others perceive \nthem.").move(19, 268).font({ +
-        family: 'arial', +
-        size: 20 +
-    }).opacity(0)+
 } }
  
- +if (deviceType!='mobile')
-let titles = { +    window.addEventListener("resize", function(e){ 
-    destressingTitle: destressingCanvas.text("Destressing Images").move(168, 321.5).font(+        console.log('options',deviceType!='mobile',deviceOrientation!='portrait' 
-        family: 'arial', +        if (window.innerWidth<window.innerHeight){ 
-        size: 19.5 +            //document.location.reload() 
-    }), +                console.log('Resize detected: portrait mode'
-    elderlyTitle: elderlyCanvas.text("Elderly Biography").move(188, 321.5).font(+                deviceOrientation='portrait
-        family: 'arial', +                higs.sequenceActions('quickRight') 
-        size: 19.+                setTimeout(()=>
-    }), +                    higs.carosel.style.height=higs.centeredImg.getBoundingClientRect().height+'px
-    microTitle: microCanvas.text("Micro-controllers \nand Hydra").move(196.5, 302).font({ +                },300) 
-        family: 'arial', +            
-        size: 19.5, +            //adaptToOrientationChange() 
-        leading: '1em' +        else{  
-    }), +            //document.location.reload() 
-    simulationTitle: simulationCanvas.text("Elderly Simulation").move(184, 322).font(+            console.log('Resize detectedlandscape mode'
-        size: 19.5, +                deviceOrientation='landscape
-        family: 'arial', +                higs.sequenceActions('quickRight'
-    }), +               setTimeout(()=>{ 
-    hydraTitle: hydraCanvas.text("Educating the Public \nAbout Hydra").move(161, 302).font({ +                    higs.carosel.style.height=higs.centeredImg.getBoundingClientRect().height+'px
-        family: 'arial', +                },200
-        size: 19.5+            //adaptToOrientationChange() 
-        leading: "1em" +        }
-    }), +
-    visualTitle: visualCanvas.text("Perceptions \nof Visual Cues").move(215, 302).font(+
-        family: 'arial', +
-        size: 19.5, +
-        leading: "1em" +
-    }), +
-    studentsTitle: studentsCanvas.text("About our Students").move(173.5, 322).font({ +
-        family: 'arial', +
-        size: 19.5 +
-    }), +
-    impressionTitle: impressionCanvas.text("Image of the Elderly").move(168, 321).font({ +
-        family: 'arial', +
-        size: 19.5+
     })     })
- 
 } }
- +else
- +    screen.orientation.onchange=(()=>
-class Button +        if (screen.orientation.type == 'portrait-primary' || screen.orientation.type == 'portrait-secondary'){ 
-    constructor(name, description, title, svgsArray, svgsObj, titleShiftX, titleShiftY, descriptionShift) { +            //document.location.reload() 
-        this.name name; +                console.log('Resize detected: portrait mode'
-        this.description description; +                deviceOrientation='portrait' 
-        this.title title; +                higs.sequenceActions('quickRight'
-        this.svgsArray svgsArray; +                setTimeout(()=>{ 
-        this.svgsObj svgsObj +                    higs.carosel.style.height=higs.centeredImg.getBoundingClientRect().height+'px' 
-        this.titleShift = { +                },300) 
-            x: titleShiftX+            } 
-            y: titleShiftY+            //adaptToOrientationChange() 
 +        else{  
 +            //document.location.reload() 
 +            console.log('Resize detected: landscape mode'
 +                deviceOrientation='landscape' 
 +                higs.sequenceActions('quickRight'
 +               setTimeout(()=>
 +                    higs.carosel.style.height=higs.centeredImg.getBoundingClientRect().height+'px' 
 +                },200) 
 +            //adaptToOrientationChange()
         }         }
-        //descriptionShift only has one value because it is only shifting up +    })
-        this.descriptionShift = descriptionShift +
-    }+
 } }
  
-//the dmove animation of titles +//Screen orientation on mobile devies: https://stackoverflow.com/a/5499030/19515980 
-//different shifts of two lines titles and one line title, two lines titles have their special numbers +//screen.orientationhttps://developer.mozilla.org/en-US/docs/Web/API/Screen/orientation 
-//distance between title and left side should be about 21px, and about 30px for the top distance +//screenorientation APIhttps://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation
-let titleShifts = { +
-    destressing+
-        x: -150, +
-        y-304 +
-    }, +
-    elderly+
-        x: -170, +
-        y: -304 +
-    }, +
-    micro: { +
-        x: -176, +
-        y: -282 +
-    }, +
-    hydra: { +
-        x: -140, +
-        y: -279.+
-    }, +
-    visual: { +
-        x: -195, +
-        y: -284 +
-    }, +
-    simulation: { +
-        x: -167, +
-        y: -304 +
-    }, +
-    students: { +
-        x: -152, +
-        y: -304 +
-    }, +
-    impression: { +
-        x: -150, +
-        y: -304 +
-    } +
-}+
  
 +/*
 +let startPoint;
 +window.addEventListener("touchstart", function(e){
 +    console.log('start',e.touches[0].clientX)
 +    startPoint=JSON.parse(JSON.stringify(new Point(e.touches[0].clientX,e.touches[0].clientY)))
 +})
  
-//the dmove animation of descriptions +window.addEventListener("touchend", function(e){ 
-//this one only needs oneLine or twoLines opetions +    console.log('end',e) 
-let descriptionShifts = +    if (startPoint.x<e.clientX)
-    oneLine: -180+        console.log('swiped left',e.clientX) 
-    twoLines: -140 +        checkIfSwitchImageLeft(e.target) 
-}+    } 
 +    else { 
 +        console.log('swiped right'
 +        checkIfSwitchImageRight(e.target) 
 +        } 
 +}) 
 +*/
  
-//------------------------------------------------------------------------------ +window.addEventListener('touchstart', handleTouchStart, false);         
-///------------------------------------------------------------------------------ +window.addEventListener('touchmove', handleTouchMove, false);
-////------------------------------------------------------------------------------ +
-////------------------------------------------------------------------------------ +
-///!!!!!!!!super important here!!!!!!!!!!!!+
  
-//last four numbers: title shift x, title shift y,  description shift y +var xDown null;                                                         
-let destressingButtonObject new Button("destressingButton", descriptions.destressingDescription, titles.destressingTitle, destressingSvgs, destressingSvgsObj, titleShifts.destressing.x, titleShifts.destressing.y, descriptionShifts.oneLine) +var yDown null;
-makeButton(destressingCanvas, destressingButtonObject, "https://renickbell.net/ed/2022service/doku.php?id=destressing-images")+
  
-let elderlyButtonObject = new Button("elderlyButton", descriptions.elderlyDescription, titles.elderlyTitle, elderlySvgs, elderlySvgsObj, titleShifts.elderly.x, titleShifts.elderly.y, descriptionShifts.oneLine+function getTouches(evt) { 
-makeButton(elderlyCanvas, elderlyButtonObject, "https://renickbell.net/ed/2022service/doku.php?id=elderly-biography")+  return evt.touches ||             // browser API 
 +         evt.originalEvent.touches; // jQuery 
 +}                                                      
 +                                                                          
 +function handleTouchStart(evt) { 
 +    const firstTouch = getTouches(evt)[0];                                       
 +    xDown = firstTouch.clientX;                                       
 +    yDown = firstTouch.clientY;                                       
 +};                                                 
 +                                                                          
 +let swipeCooldown=false 
 +function handleTouchMove(evt) { 
 +console.log('swipe 1'
 +    if ! xDown || ! yDown ) { 
 +        return; 
 +    } 
 +console.log('swipe 2') 
 +    var xUp = evt.touches[0].clientX;                                     
 +    var yUp evt.touches[0].clientY;
  
-let microButtonObject new Button("microButton", descriptions.microDescription, titles.microTitle, microSvgs, microSvgsObj, titleShifts.micro.xtitleShifts.micro.ydescriptionShifts.twoLines+    var xDiff xDown - xUp; 
-makeButton(microCanvas, microButtonObject, "https://renickbell.net/ed/2022service/doku.php?id=arduino")+    var yDiff = yDown - yUp; 
 +                                                                          
 +    if Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/ 
 +        if ( xDiff > 0 && swipeCooldown==false) { 
 +            console.log('swiped left'
 +            swipeCooldown=true 
 +            checkIfSwitchImageLeft(evt.target) 
 +            setTimeout(()=>
 +                swipeCooldown=false 
 +            },500) 
 +        }  
 +        else if (swipeCooldown==false) { 
 +            console.log('swiped right'
 +            swipeCooldown=true 
 +            checkIfSwitchImageRight(evt.target) 
 +            setTimeout(()=>
 +                swipeCooldown=false 
 +            },500) 
 +        }                        
 +    } else { 
 +        if ( yDiff > 0 ) { 
 +            console.log('donw swipe'
 +        } else {  
 +            console.log('up swipe'
 +        }                                                                  
 +    } 
 +    /* reset values */ 
 +    xDown null; 
 +    yDown = null;                                              
 +};
  
-let hydraButtonObject = new Button("hydraButton", descriptions.hydraDescription, titles.hydraTitle, hydraSvgs, hydraSvgsObj, titleShifts.hydra.x, titleShifts.hydra.y, descriptionShifts.twoLines) +//swiping code by: https://stackoverflow.com/a/23230280/19515980
-makeButton(hydraCanvas, hydraButtonObject, "https://renickbell.net/ed/2022service/doku.php?id=social-innovation-center-sharing")+
  
-let visualButtonObject = new Button("visualButton", descriptions.visualDescriptions, titles.visualTitle, visualSvgs, visualSvgsObj, titleShifts.visual.x, titleShifts.visual.y, descriptionShifts.twoLines) 
-makeButton(visualCanvas, visualButtonObject, "https://renickbell.net/ed/2022service/doku.php?id=art-museum") 
  
-let simulationButtonObject = new Button("simulationButton", descriptions.simulationDescription, titles.simulationTitle, simulationSvgs, simulationSvgsObj, titleShifts.simulation.x, titleShifts.simulation.y, descriptionShifts.oneLine+function adaptToOrientationChange (){ 
-makeButton(simulationCanvas, simulationButtonObject, "https://renickbell.net/ed/2022service/doku.php?id=elderly-simulation-map") +    let returnCarosels=[] 
- +    carosels.forEach(x=>{ 
-let studentsButtonObject = new Button("studentsButton", descriptions.studentsDescription, titles.studentsTitle, studentsSvgs, studentsSvgsObj, titleShifts.students.x, titleShifts.students.y, descriptionShifts.oneLine) +        returnCarosels.push(new ImageCarosel (x.caroselSize,x.info,x.type,x.caroselLocation)) 
-makeButton(studentsCanvas, studentsButtonObject, "https://renickbell.net/ed/2022service/doku.php?id=about-students"+    }) 
- +    removeAllCarosels() 
-let impressionButtonObject = new Button("impressionButton", descriptions.impressionDescriptiontitles.impressionTitleimpressionSvgs, impressionSvgsObj, titleShifts.impression.x, titleShifts.impression.ydescriptionShifts.oneLine) +    carosels=returnCarosels
-makeButton(impressionCanvas, impressionButtonObject, "https://renickbell.net/ed/2022service/doku.php?id=elderly-report") +
- +
- +
-let exampleButtonObj = { +
-    name: null, //some name +
-    description: null, //some description +
-    title: null, //some title +
-    svgsArray: null, //the somethingSvgs array of the button +
-    svgsObj: null //the somethingSvgsObj object of the button+
 } }
  
-function makeButton(svgCanvas, buttonObject, url) { +function removeAllCarosels (){ 
-    let titleRunner; +    let caroselElems=document.getElementsByClassName('imageCarosel'
-    let textBoxRunner; +    for (let = 0; i < caroselElems.lengthi++) { 
-    let backgroundRunner; +        caroselElems[i].remove()
-    let descriptionRunner; +
-    let svgsArray buttonObject.svgsArray; +
-    let svgsObj = buttonObject.svgsObj; +
-    let buttonGroup = svgCanvas.group(); +
-    let textbox = svgsObj.textbox; +
-    let background = svgsObj.background; +
-    let image = svgsObj.image; +
-    let title = buttonObject.title; +
-    console.log(textbox) +
-    let description buttonObject.description; +
-    let titleShift = buttonObject.titleShift; +
-    console.log(titleShift) +
-    //make the white box invisible +
-    background.opacity(0); +
-    //add them to a group so it is easier to move them together +
-    //buttonGroup.add(image).add(background).add(textbox).add(title).add(description) +
-    //buttonGroup.size(buttonSize, buttonSize) +
-    //buttonGroup.move(0, 0) +
-    let hitBox = svgCanvas.rect(buttonSize, buttonSize).move(0, 0).opacity(0); +
-    //title position +
-    let titleP = { +
-        x: title.x()+
-        y: title.y() +
-    } +
-    //description position +
-    let descriptionP = +
-        x: description.x(), +
-        y: description.y()+
     }     }
 +}
  
-    let overAnimaton = true; +function checkIfSwitchImageRight (target){ 
-    let outAnimation = false; +    setTimeout(()=>{ 
-    hitBox.on("mouseover", function() { +        if (target !=undefined && switchImageCooldown==false){ 
-        changeCursor("pointer"+            switchImageCooldown=true 
-        if (overAnimaton) { +            carosels.forEach(x=>{ 
-            //console.log("over") +                if (x.mainImg1==target || x.mainImg2==target){ 
-            backgroundRunner = background.animate(animationDuration).opacity(0.8) +                    x.sequenceActions('quickRight'
-            textBoxRunner textbox.animate(animationDuration).opacity(0+                }
-            titleRunner = title.animate(animationDuration).dmove(titleShift.x, titleShift.y).font({ +
-                size: 36+
             })             })
-            descriptionRunner = description.animate(animationDuration).opacity(1).dmove(0buttonObject.descriptionShift)+        setTimeout(()=>{ 
-            outAnimation = true;+                switchImageCooldown=false},700)
         }         }
-        //animationTimer = setTimeout(() => {}, 0) +        if (mouse.x>=window.innerWidth-2 && switchImageCooldown==false){ 
-    }) +            switchImageCooldown=true 
-    hitBox.on("mouseout", function() { +            carosels.forEach(x=>
-        changeCursor("default"+                x.sequenceActions('quickRight')
-        if (outAnimation) { +
-            //console.log("out"+
-            backgroundRunner background.animate(animationDuration).opacity(0+
-            textBoxRunner textbox.animate(animationDuration).opacity(1) +
-            titleRunner = title.animate(animationDuration).move(titleP.x, titleP.y).font(+
-                size: 19.5+
             })             })
-            descriptionRunner = description.animate(animationDuration).opacity(0).move(descriptionP.x, descriptionP.y) +        setTimeout(()=>
-            overAnimaton false +                switchImageCooldown=false},700)
-            outAnimation = false +
-            let setOverAnimationToTrue = setTimeout(function() +
-                overAnimaton true +
-            }, 250)+
         }         }
-        //clearTimeout(animationTimer) +    },200
-    }); +}
-    hitBox.on("click"function({ +
-        window.location.href = url; +
-    }); +
- +
-    //readFile function by: https://javascript.info/file +
- +
-    // Code based on: Kirill Shumilov  https://jsfiddle.net/brusher/tgddv9pw/ +
- +
-    // Everything should be ungrouped. And on the same layer. Object to path. +
-}; +
- +
- +
- +
- +
-let buttonsCollection = document.getElementsByClassName("buttons")  +
- +
-let buttonsArray = [...buttonsCollection] +
- +
-let br = document.createElement("br"+
- +
-let whereButtonsGo = document.getElementById("some_website_highlights_一些網頁精彩高光"+
- +
-whereButtonsGo.appendChild(br) +
- +
-buttonsArray.forEach(i => whereButtonsGo.appendChild(i)) +
  
 +function checkIfSwitchImageLeft (target){
 +    setTimeout(()=>{
 +        if (target !=undefined && switchImageCooldown==false){
 +            switchImageCooldown=true
 +            carosels.forEach(x=>{
 +                if (x.mainImg1==target || x.mainImg2==target){
 +                    x.sequenceActions('quickLeft')
 +                }
 +            })
 +        setTimeout(()=>{
 +                switchImageCooldown=false},700)
 +        }
 +        else if (mouse.x<2 && switchImageCooldown==false){
 +            switchImageCooldown=true
 +            carosels.forEach(x=>{
 +                x.sequenceActions('quickLeft')
 +            })
 +        setTimeout(()=>{
 +                switchImageCooldown=false},700)
 +        }
 +    },200)
 +}
 +function createWikiSpacing (){
 +    for (let i = 0; i < (1/browserZoomLevel)*3000; i++) {     document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public_計畫如何做出改變來協助年長者及社會大眾紓解壓力').appendChild(document.createElement('br'))
 +    }
 +}
 +//https://thewebdev.info/2021/03/10/how-to-detect-page-zoom-levels-in-modern-browsers/
 +//open link: https://stackoverflow.com/questions/13071967/adding-an-onclick-function-to-go-to-url-in-javascript
 +//https://www.quackit.com/javascript/javascript_refresh_page.cfm#:~:text=In%20JavaScript%2C%20you%20refresh%20the,server%20(instead%20of%20cache).
 +//For wrap text help: https://stackoverflow.com/a/23842462/19515980
 +//swiping code by: https://stackoverflow.com/a/23230280/19515980
 +//UserAgent by: Abdessalam Benharira: https://abdessalam.dev/blog/detect-device-type-javascript/
 </script> </script>
-</body> 
- 
 </html> </html>
  
  • steve-image-carosel-test-page.1675066125.txt.gz
  • Last modified: 2023/01/30 00:08
  • by steve.wang