Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
steve-image-carosel-test-page2 [2023/01/08 05:03] steve.wangsteve-image-carosel-test-page2 [2023/04/16 02:15] (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> <html>
 <style> <style>
-body { +    body { 
- margin: 0; +        stylemargin: 0; 
- padding: 0; +        stylepadding: 0; 
- /*font: 75%/120% sans-serif;*/ +        style/*font: 75%/120% sans-serif;*/ 
-}+    }
  
 .imageCarosel{ .imageCarosel{
-    overflow:hidden; +        overflow:hidden; 
-    border-width:2px; +        border-width:2px; 
-    border-style:solid; +        border-style:solid; 
-    border-color:black;+        border-color:black
 +        background-color:grey;
 } }
- 
  
 .mainImg{ .mainImg{
-    position:absolute;+        position:absolute
 +        transition-property:left; 
 +        transition-duration: 0.5s; 
 +        transition-delay: 100ms; 
 +        cursor:ew-resize;
 } }
  
 .left{ .left{
-    z-Index:2; +        z-Index:2; 
-    line-height: 34px; +        line-height: 34px; 
-    display: inline-block; +        display: inline-block; 
-    white-space: nowrap; +        white-space: nowrap; 
-      -webkit-transform: scaleX(-1); +          -webkit-transform: scaleX(-1); 
-        transform: scaleX(-1); +            transform: scaleX(-1); 
-    opacity:0.4+        opacity:0.5
-      color: grey; +          color: grey; 
-      background-color:transparent; +          background-color:transparent; 
-      border:none; +          border:none; 
-    }+        }
  
 .left:hover{ .left:hover{
-    opacity:0.8;+        opacity:0.9;
 } }
  
  
 .right{ .right{
-    z-Index:2; +        z-Index:2; 
-    line-height: 34px; +        line-height: 34px; 
-    display: inline-block; +        display: inline-block; 
-    opacity:0.4+        opacity:0.5
-    color: grey; +        color: grey; 
-    background-color:transparent; +        background-color:transparent; 
-      border:none;+          border:none;
 } }
  
 .right:hover{ .right:hover{
-    opacity:0.8;+        opacity:0.9;
 } }
 .arrow{ .arrow{
-    z-Index:3; +        z-Index:3; 
-    line-height: 34px; +        line-height: 34px; 
-    position:absolute; +        position:absolute; 
-    top:50%; +        top:50%; 
-    opacity:0.4+        opacity:0.2
-    color: grey;+        color: grey;
 } }
 /* Make text go to the middle: /* Make text go to the middle:
-https://stackoverflow.com/a/14061404/19515980 + https://stackoverflow.com/a/14061404/19515980 
- + * 
-*/+ */
 /* /*
-.moveLeft{ + .moveLeft{ 
-    transition:4s; + *     transition:4s; 
-    transform:translateX(-3000) + *         transform:translateX(-3000) 
-}+ *         } 
 + * 
 +         .moveRight{ 
 +             transition:4s; 
 +                 transform:translateX(3000) 
 +                 } 
 +                 */
  
-.moveRight{ 
-    transition:4s; 
-    transform:translateX(3000) 
-} 
-*/ 
  
 </style> </style>
Line 123: Line 129:
 let info=[{ let info=[{
     imageSrc:'./what is this.png',     imageSrc:'./what is this.png',
-    portriatSrc:'./measure-portriat.PNG',+    portraitSrc:'./measure-portrait.PNG',
     href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=about-space_invaders',     href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=about-space_invaders',
     description:'hi,hi,hi',     description:'hi,hi,hi',
 },{ },{
     imageSrc:'./steve-color-scrolling.png',     imageSrc:'./steve-color-scrolling.png',
-    portriatSrc:'./homework-portriat.PNG',+    portraitSrc:'./homework-portrait.PNG',
     href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=my_planet',     href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=my_planet',
     description:'hio,hio,hio',     description:'hio,hio,hio',
 },{ },{
     imageSrc:'./steve-drawing-fractals.png',     imageSrc:'./steve-drawing-fractals.png',
-    portriatSrc:'./circuits-portriat.jpg',+    portraitSrc:'./circuits-portrait.jpg',
     href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=agriculture',     href:'https://renickbell.net/jrhigh/2022exploring/doku.php?id=agriculture',
     description:'hiv,hiv,hiv',     description:'hiv,hiv,hiv',
Line 141: Line 147:
 let info=[{ let info=[{
     imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-students.jpg',     imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-students.jpg',
-    portriatSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-portrait-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',     href:'https://renickbell.net/ed/2022service/doku.php?id=about-students',
     description:'about our students',     description:'about our students',
 },{ },{
     imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-arduino.jpg',     imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-arduino.jpg',
-    portriatSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-portrait-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',     href:'https://renickbell.net/ed/2022service/doku.php?id=arduino',
     description:'arduino',     description:'arduino',
 },{ },{
     imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-simulation.jpg',     imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-simulation.jpg',
-    portriatSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-portrait-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',     href:'https://renickbell.net/ed/2022service/doku.php?id=partner-simulation',
     description:'simulation of elderly experience',     description:'simulation of elderly experience',
 },{ },{
     imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-hydra.jpg',     imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-hydra.jpg',
-    portriatSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-portrait-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',     href:'https://renickbell.net/ed/2022service/doku.php?id=hydra-practice',
     description:'hydra',     description:'hydra',
 },{ },{
     imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-visual.jpg',     imageSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-landscape-visual.jpg',
-    portriatSrc:'https://renickbell.net/ed/2022service/lib/exe/fetch.php?media=image-carosel-portrait-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',     href:'https://renickbell.net/ed/2022service/doku.php?id=art-museum',
     description:'visual cues',     description:'visual cues',
Line 190: Line 196:
         else if (domLocation=='doku'){         else if (domLocation=='doku'){
             //document.getElementById('dokuwiki__content').appendChild(this.carosel)             //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)+            document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public_計畫如何做出改變來協助年長者及社會大眾紓解壓力').appendChild(this.carosel)
         }         }
         else{         else{
Line 208: Line 214:
         else if (domLocation=='doku'){         else if (domLocation=='doku'){
             //document.getElementById('dokuwiki__content').appendChild(this.carosel)             //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)+            document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public_計畫如何做出改變來協助年長者及社會大眾紓解壓力').appendChild(this.carosel)
  }  }
         else{         else{
Line 221: Line 227:
         }         }
         else{         else{
-            this.mainImg1.href=this.info[1].portriatSrc+            this.mainImg1.href=this.info[1].portraitSrc
         }         }
         this.mainImg1.className='mainImg'         this.mainImg1.className='mainImg'
Line 230: Line 236:
         }         }
         else{         else{
-            this.mainImg2.src=this.info[0].portriatSrc+            this.mainImg2.src=this.info[0].portraitSrc
         }         }
         this.mainImg2.className='mainImg'         this.mainImg2.className='mainImg'
         if (domLocation=='main' || domLocation=='doku'){         if (domLocation=='main' || domLocation=='doku'){
             this.mainImg1.style.width='100%'             this.mainImg1.style.width='100%'
-            this.mainImg1.style.height=window.innerHeight-10+'px'+            this.mainImg1.style.height='auto'
             this.mainImg2.style.width='100%'             this.mainImg2.style.width='100%'
-            this.mainImg2.style.height=window.innerHeight-10+'px'+            this.mainImg2.style.height='auto'
         }         }
         this.carosel.appendChild(this.mainImg1)         this.carosel.appendChild(this.mainImg1)
Line 245: Line 251:
         this.centeredImg=this.mainImg2         this.centeredImg=this.mainImg2
         this.caroselSize=sizePoint         this.caroselSize=sizePoint
-        this.correctCenteredImgPosition=new Point(this.centeredImg.getBoundingClientRect().x,this.centeredImg.getBoundingClientRect().y)+        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.imageCaroselNumber=carosels.length
         this.queue=[]         this.queue=[]
Line 277: Line 285:
             arrowSizes=100             arrowSizes=100
         }         }
-        else if (deviceOrientation=='portriat'){+        else if (deviceOrientation=='portrait'){
             console.log('acknowledged')             console.log('acknowledged')
-            arrowSizes=browserZoomLevel/4+            arrowSizes=browserZoomLevel/6
         }         }
         this.right.style.width=arrowSizes+'px'         this.right.style.width=arrowSizes+'px'
Line 334: Line 342:
         this.queue.forEach((x,i)=>{         this.queue.forEach((x,i)=>{
             if (x!='quickRight'&& x!='quickLeft'){             if (x!='quickRight'&& x!='quickLeft'){
-                this.queue=[...safeSplice(this.queue,this.queue.length-i-1,i),action,...safeSplice(queue,i,0)]+                this.queue=[...safeSplice(this.queue,this.queue.length-i-1,i),action,...safeSplice(this.queue,i,0)]
             console.log('trying',this.queue)             console.log('trying',this.queue)
             }             }
         })         })
     }     }
-       quickRight (){ +    quickRight (){ 
-        manuallyMoveHtmlToRight(this.centeredImg,this.centeredImg.getBoundingClientRect().x,100,this.carosel.getBoundingClientRect().right/100+        console.log('quick right'
-        this.currentImage+=1 +        this.currentImage-=1 
-        if (this.currentImage>this.info.length-1){ +        if (this.currentImage<0){ 
-            this.currentImage=0+            this.currentImage=this.info.length-1
         }         }
-        console.log(this.currentImage) +        if (this.centeredImg==this.mainImg1){ 
-        if (this.mainImg2==this.centeredImg){ +            this.changeContent(this.mainImg2)
-            this.changeContent(this.mainImg1)+
             setTimeout(()=>{             setTimeout(()=>{
-                this.mainImg1.style.left=this.caroselLocation.x-this.mainImg1.getBoundingClientRect().width-browserZoomLevel+'px' +                this.mainImg2.style.transitionProperty='none' 
-                if (deviceOrientation=='landscape'){ +                this.mainImg2.style.left=this.correctCenteredImgPosition.x-this.mainImg2.getBoundingClientRect().width+'px' 
-                manuallyMoveHtmlToRight(this.mainImg1,this.mainImg1.getBoundingClientRect().x,90,(this.correctCenteredImgPosition.x-this.mainImg1.getBoundingClientRect().x)/92) +                this.centeredImg.style.left=this.carosel.getBoundingClientRect().right+this.centeredImg.getBoundingClientRect().width+'px' 
-                +                this.mainImg2.style.transitionProperty='left
-                else { +                this.mainImg2.style.left=this.correctCenteredImgPosition.x+'px' 
-                    console.log('this is correct') +                this.centeredImg=this.mainImg2
-                manuallyMoveHtmlToRight(this.mainImg1,this.mainImg1.getBoundingClientRect().x,92,(this.correctCenteredImgPosition.x-this.mainImg1.getBoundingClientRect().x)/95) +
-                } +
-                this.centeredImg=this.mainImg1+
             },100)             },100)
-            /* 
-            setTimeout(()=>{ 
-                this.centeredImg.style.left=this.caroselLocation/10+'px' 
-            },(this.caroselLocation/10)*14) 
-            */ 
         }         }
         else{         else{
-            this.changeContent(this.mainImg2) +            this.changeContent(this.mainImg1)
-            console.log('main img1')+
             setTimeout(()=>{             setTimeout(()=>{
-                this.mainImg2.style.left=this.caroselLocation.x-this.mainImg2.getBoundingClientRect().width-browserZoomLevel+'px' +                this.mainImg1.style.transitionProperty='none' 
-                if (deviceOrientation=='landscape'){ +                this.mainImg1.style.left=this.correctCenteredImgPosition.x-this.mainImg1.getBoundingClientRect().width+'px' 
-                    manuallyMoveHtmlToRight(this.mainImg2,this.mainImg2.getBoundingClientRect().x,90,(this.correctCenteredImgPosition.x-this.mainImg2.getBoundingClientRect().x)/91) +            this.centeredImg.style.left=this.carosel.getBoundingClientRect().right+this.centeredImg.getBoundingClientRect().width+'px' 
-                +                this.mainImg1.style.transitionProperty='left
-                else{ +                this.mainImg1.style.left=this.correctCenteredImgPosition.x+'px' 
-                    console.log('this is correct') +                this.centeredImg=this.mainImg1
-                    manuallyMoveHtmlToRight(this.mainImg2,this.mainImg2.getBoundingClientRect().x,92,(this.correctCenteredImgPosition.x-this.mainImg2.getBoundingClientRect().x)/95) +
-                } +
-                this.centeredImg=this.mainImg2+
             },100)             },100)
-            /* 
-            setTimeout(()=>{ 
-                this.centeredImg.style.left=this.caroselLocation/10+'px' 
-            },(this.caroselLocation/10)*14) 
-            */ 
         }         }
         return new Promise((resolve,reject)=>{         return new Promise((resolve,reject)=>{
Line 392: Line 382:
     }     }
     quickLeft (){     quickLeft (){
-        console.log('switched left',this.centeredImg) +        console.log('quick left')
-        manuallyMoveHtmlToLeft(this.centeredImg,this.centeredImg.getBoundingClientRect().x,100,(this.carosel.getBoundingClientRect().left+this.centeredImg.getBoundingClientRect().width+90)/100)+
         this.currentImage-=1         this.currentImage-=1
         if (this.currentImage<0){         if (this.currentImage<0){
             this.currentImage=this.info.length-1             this.currentImage=this.info.length-1
         }         }
-        console.log(this.currentImage) +        if (this.centeredImg==this.mainImg1){ 
-      //  setTimeout(()=>+            this.changeContent(this.mainImg2
-        if (this.mainImg2==this.centeredImg){ +            this.mainImg2.style.transitionProperty='none
-                this.changeContent(this.mainImg1+            this.mainImg2.style.left=this.correctCenteredImgPosition.x+this.mainImg2.getBoundingClientRect().width+'px' 
-                console.log('main img1') +            this.centeredImg.style.left=this.correctCenteredImgPosition.x-this.centeredImg.getBoundingClientRect().width+'px' 
-            setTimeout(()=>+            this.mainImg2.style.transitionProperty='left
-                    this.mainImg1.style.left=this.carosel.getBoundingClientRect().x+this.mainImg1.getBoundingClientRect().width+browserZoomLevel+'px' +            this.mainImg2.style.left=this.correctCenteredImgPosition.x+'px' 
-                if (deviceOrientation=='landscape'){ +            this.centeredImg=this.mainImg2
-                manuallyMoveHtmlToLeft(this.mainImg1,this.mainImg1.getBoundingClientRect().x,90,(this.mainImg1.getBoundingClientRect().x-this.correctCenteredImgPosition.x)/91) +
-                } +
-                else { +
-                manuallyMoveHtmlToLeft(this.mainImg1,this.mainImg1.getBoundingClientRect().x,88,(this.mainImg1.getBoundingClientRect().x-this.correctCenteredImgPosition.x)/90) +
-                } +
-                    this.centeredImg=this.mainImg1 +
-            },100) +
-            } +
-            else{ +
-                this.changeContent(this.mainImg2) +
-                console.log('main img2') +
-                setTimeout(()=>+
-                    this.mainImg2.style.left=this.carosel.getBoundingClientRect().x+this.mainImg2.getBoundingClientRect().width+browserZoomLevel+'px' +
-                    if (deviceOrientation=='landscape'){ +
-                        manuallyMoveHtmlToLeft(this.mainImg2,this.mainImg2.getBoundingClientRect().x,90,(this.mainImg2.getBoundingClientRect().x-this.carosel.getBoundingClientRect().x)/91) +
-                    } +
-                    else{ +
-                        manuallyMoveHtmlToLeft(this.mainImg2,this.mainImg2.getBoundingClientRect().x,88,(this.mainImg2.getBoundingClientRect().x-this.carosel.getBoundingClientRect().x)/90) +
-                    } +
-                    this.centeredImg=this.mainImg2 +
-                },100) +
-            } +
-       // },10) +
-        return new Promise((resolve,reject)=>+
-            setTimeout(()=>+
-                resolve(true) +
-            },10*35) +
-        }) +
-    } +
-    switchRight (){ +
-        console.log('switched right'+
-        manuallyMoveHtmlToRight(this.centeredImg,this.centeredImg.getBoundingClientRect().x,10,this.carosel.getBoundingClientRect().right/10) +
-        this.currentImage+=1 +
-        console.log(this.currentImage) +
-        if (this.currentImage>this.info.length-1){ +
-            this.currentImage=0+
         }         }
-        console.log(this.currentImage) +        else{
-        if (this.mainImg2==this.centeredImg){ +
-            console.log('main img2'+
-            this.mainImg1.style.left=this.caroselLocation.x-this.mainImg1.getBoundingClientRect().width+'px    '+
             this.changeContent(this.mainImg1)             this.changeContent(this.mainImg1)
-            setTimeout(()=>{ +            this.mainImg1.style.transitionProperty='none' 
-                manuallyMoveHtmlToRight(this.mainImg1,this.mainImg1.getBoundingClientRect().x,10,(this.correctCenteredImgPosition.x-this.mainImg1.getBoundingClientRect().x)/10) +            this.mainImg1.style.left=this.correctCenteredImgPosition.x+this.mainImg1.getBoundingClientRect().width+'px' 
-            },200)+            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             this.centeredImg=this.mainImg1
-            /* 
-            setTimeout(()=>{ 
-                this.centeredImg.style.left=this.caroselLocation/10+'px' 
-            },(this.caroselLocation/10)*14) 
-            */ 
-        } 
-        else{ 
-            console.log('main img1') 
-            this.mainImg2.style.left=this.caroselLocation.x-this.mainImg2.getBoundingClientRect().width+'px' 
-            this.changeContent(this.mainImg2) 
-            setTimeout(()=>{ 
-                manuallyMoveHtmlToRight(this.mainImg2,this.mainImg2.getBoundingClientRect().x,10,(this.correctCenteredImgPosition.x-this.mainImg2.getBoundingClientRect().x)/10) 
-            },200) 
-            this.centeredImg=this.mainImg2 
-            /* 
-            setTimeout(()=>{ 
-                this.centeredImg.style.left=this.caroselLocation/9+'px' 
-            },(this.caroselLocation/10)*14) 
-            */ 
         }         }
         return new Promise((resolve,reject)=>{         return new Promise((resolve,reject)=>{
             setTimeout(()=>{             setTimeout(()=>{
                 resolve(true)                 resolve(true)
-            },14*100)+            },10*35)
         })         })
     }     }
-    switchLeft (){ +    switchRight (){ 
-        console.log('switched left'+        console.log('switch right')
-        manuallyMoveHtmlToLeft(this.centeredImg,this.centeredImg.getBoundingClientRect().x,10,(this.carosel.getBoundingClientRect().left+this.centeredImg.getBoundingClientRect().width+90)/10)+
         this.currentImage-=1         this.currentImage-=1
         if (this.currentImage<0){         if (this.currentImage<0){
             this.currentImage=this.info.length-1             this.currentImage=this.info.length-1
         }         }
-        console.log(this.currentImage) +        if (this.centeredImg==this.mainImg1){
-      //  setTimeout(()=>+
-            if (this.mainImg2==this.centeredImg){ +
-                console.log('main img0'+
-                this.mainImg1.style.left=this.carosel.getBoundingClientRect().x+this.mainImg1.getBoundingClientRect().width+150+'px' +
-            this.changeContent(this.mainImg1) +
-            manuallyMoveHtmlToLeft(this.mainImg1,this.mainImg1.getBoundingClientRect().x,10,(this.carosel.getBoundingClientRect().x+this.mainImg1.getBoundingClientRect().x)/10) +
-                this.centeredImg=this.mainImg1 +
-            } +
-            else{ +
-                console.log('main img2'+
-                this.mainImg2.style.left=this.carosel.getBoundingClientRect().x+this.mainImg2.getBoundingClientRect().width+150+'px'+
             this.changeContent(this.mainImg2)             this.changeContent(this.mainImg2)
-                manuallyMoveHtmlToLeft(this.mainImg2,this.mainImg2.getBoundingClientRect().x,10,(this.carosel.getBoundingClientRect().x+this.mainImg2.getBoundingClientRect().x)/10)+            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                 this.centeredImg=this.mainImg2
-            } +            },100) 
-       // },10)+        } 
 +        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)=>{         return new Promise((resolve,reject)=>{
             setTimeout(()=>{             setTimeout(()=>{
                 resolve(true)                 resolve(true)
-            },14*100)+            },10*35)
         })         })
     }     }
Line 516: Line 453:
     autoScroller (){     autoScroller (){
         this.scrollInterval=setInterval(()=>{         this.scrollInterval=setInterval(()=>{
-            this.sequenceActions('switchRight'+            if (this.queue.length==0 && imageAutoSwitchCooldown==false){ 
-        },5000)+                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 (){     textDesciption (){
Line 544: Line 499:
             }             }
             else{             else{
-                toChangeTo.src=this.info[this.currentImage].portriatSrc +                toChangeTo.src=this.info[this.currentImage].portraitSrc
-            } +
-            if (this.infoText!=undefined){ +
-                this.infoText.textContent=this.info[this.currentImage].description+
             }             }
         }         }
 +     addSpaceAbove (amount){
 +         for (let i = 0; i < amount; i++) {
 +             this.carosel.parentElement.insertBefore(document.createElement('br'),this.carosel)
 +         }
 +    }
 } }
 +
 +function loadImg (){
 +    let imageElemForLoading= new Image()
 +    if (deviceOrientation == ' portrait'){
 +        info.forEach(x=>{
 +            imageElemForLoading.src=x.portraitSrc
 +        })
 +    }
 +    else{
 +        info.forEach(x=>{
 +            imageElemForLoading.src=x.imageSrc
 +        })
 +    }
 +}
 +
 +
 function manuallyMoveHtmlToRight (elem,startX,moveBy,times,counter){ function manuallyMoveHtmlToRight (elem,startX,moveBy,times,counter){
     if (counter==undefined){     if (counter==undefined){
Line 578: Line 551:
     }     }
 } }
 +
 +async function sequencingSwitchingImages (imageCaroselNumber){
 +   let currentImageCarosel=carosels[imageCaroselNumber]
 +   await currentImageCarosel[currentImageCarosel.queue[0]]()
 +   //document.getElementById('console_output').innerHTML+='<br><br>'+currentImageCarosel.queue[0]
 +   currentImageCarosel.queue=safeSplice(currentImageCarosel.queue,1,0)
 +    if (currentImageCarosel.queue.length>0){
 +        sequencingSwitchingImages(imageCaroselNumber)
 +    }
 +}
 +
 */ */
  
 +let imageAutoSwitchCooldown=false
 async function sequencingSwitchingImages (imageCaroselNumber){ async function sequencingSwitchingImages (imageCaroselNumber){
 +   imageAutoSwitchCooldown=true
    let currentImageCarosel=carosels[imageCaroselNumber]    let currentImageCarosel=carosels[imageCaroselNumber]
    await currentImageCarosel[currentImageCarosel.queue[0]]()    await currentImageCarosel[currentImageCarosel.queue[0]]()
-    document.getElementById('console_output').innerHTML+='<br><br>'+currentImageCarosel.queue[0] 
    currentImageCarosel.queue=safeSplice(currentImageCarosel.queue,1,0)    currentImageCarosel.queue=safeSplice(currentImageCarosel.queue,1,0)
     if (currentImageCarosel.queue.length>0){     if (currentImageCarosel.queue.length>0){
         sequencingSwitchingImages(imageCaroselNumber)         sequencingSwitchingImages(imageCaroselNumber)
 +        resetImageSwitchCooldown(currentImageCarosel)
     }     }
 +}
 +
 +function resetImageSwitchCooldown (currentImageCarosel){
 +    setTimeout(()=>{
 +        if (currentImageCarosel.queue.length==0){
 +            imageAutoSwitchCooldown=false
 +        }
 +        else {
 +            setTimeout(()=>{
 +                resetImageSwitchCooldown(currentImageCarosel)
 +            },5000)
 +        }
 +    },3000)
 } }
  
Line 594: Line 593:
      browserZoomLevel = Math.round(window.devicePixelRatio * 100);      browserZoomLevel = Math.round(window.devicePixelRatio * 100);
 if (window.innerWidth<window.innerHeight){ if (window.innerWidth<window.innerHeight){
-    console.log('portriat mode'+    console.log('portrait mode'
-    deviceOrientation='portriat'+    deviceOrientation='portrait'
 } }
 else{ else{
Line 601: Line 600:
     deviceOrientation='landscape'     deviceOrientation='landscape'
 } }
 +loadImg()
 console.log('loaded') console.log('loaded')
 //higs=new ImageCarosel(new Point(1920,1000),info,'main') //higs=new ImageCarosel(new Point(1920,1000),info,'main')
Line 608: Line 608:
 carosels.push(higs) carosels.push(higs)
 //higs.sequenceActions(higs.quickRight) //higs.sequenceActions(higs.quickRight)
 +higs.quickRight()
 //higs.autoScroller() //higs.autoScroller()
 +/*
     setTimeout(()=>{     setTimeout(()=>{
         if (deviceOrientation=='landscape'){         if (deviceOrientation=='landscape'){
             higs.carosel.style.height=window.innerHeight+'px';             higs.carosel.style.height=window.innerHeight+'px';
             higs.carosel.style.width=window.innerWidth-100+'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)+            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)             higs.caroselLocation=new Point(0,300)
         }         }
Line 619: Line 621:
             higs.carosel.style.height=window.innerHeight+'px';             higs.carosel.style.height=window.innerHeight+'px';
             higs.carosel.style.width=window.innerWidth+'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)+            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)             higs.caroselLocation=new Point(100,300)
         }         }
     },1000)     },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)
 }) })
  
Line 685: Line 702:
     }))     }))
 } }
-/* 
-window.addEventListener("resize", function(e){ 
-    if (window.innerWidth<window.innerHeight && deviceOrientation!='landscape'){ 
-        document.location.reload() 
- console.log('portriat mode') 
- //deviceOrientation='landscape' 
-        //adaptToOrientationChange() 
-    } 
-    else if (deviceOrientation!='portriat'){ 
-        document.location.reload() 
- console.log('landscape mode') 
- //deviceOrientation='portriat' 
-        //adaptToOrientationChange() 
-    } 
-}) 
-*/ 
  
-/* +if (deviceType!='mobile'){ 
-let startPoint; +    window.addEventListener("resize", function(e){ 
-window.addEventListener("touchstart", function(e){ +        if (window.innerWidth<window.innerHeight){ 
-    console.log('start',e.touches[0].clientX+            //document.location.reload() 
-    startPoint=JSON.parse(JSON.stringify(new Point(e.touches[0].clientX,e.touches[0].clientY))) +                console.log('Resize detected: portrait mode') 
-}) +                deviceOrientation='portrait' 
- +                higs.sequenceActions('quickRight'
-window.addEventListener("touchend", function(e){ +                setTimeout(()=>{ 
-    console.log('end',e+                    higs.carosel.style.height=higs.centeredImg.getBoundingClientRect().height+'px' 
-    if (startPoint.x<e.clientX){ +                },300
-        console.log('swiped left',e.clientX+            } 
-        checkIfSwitchImageLeft(e.target) +            //adaptToOrientationChange(
-    } +        else{  
-    else +            //document.location.reload() 
-        console.log('swiped right') +            console.log('Resize detected: landscape mode') 
-        checkIfSwitchImageRight(e.target)+                deviceOrientation='landscape' 
 +                higs.sequenceActions('quickRight') 
 +               setTimeout(()=>
 +                    higs.carosel.style.height=higs.centeredImg.getBoundingClientRect().height+'px' 
 +                },200
 +            //adaptToOrientationChange()
         }         }
-}) +    }) 
-*/+
 +else{ 
 +    screen.orientation.onchange=(()=>
 +        if (screen.orientation.type == 'portrait-primary' || screen.orientation.type == 'portrait-secondary'){ 
 +            //document.location.reload() 
 +                console.log('Resize detected: portrait mode'
 +                deviceOrientation='portrait' 
 +                higs.sequenceActions('quickRight'
 +                setTimeout(()=>
 +                    higs.carosel.style.height=higs.centeredImg.getBoundingClientRect().height+'px' 
 +                },300) 
 +            } 
 +            //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() 
 +        } 
 +    }) 
 +}
  
-document.addEventListener('touchstart', handleTouchStart, false);         +//Screen orientation on mobile devies: https://stackoverflow.com/a/5499030/19515980 
-document.addEventListener('touchmove', handleTouchMove, false);+//screen.orientation: https://developer.mozilla.org/en-US/docs/Web/API/Screen/orientation 
 +//screenorientation API: https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation
  
-var xDown = null;                                                         
-var yDown = null; 
  
-function getTouches(evt) { 
-  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) { 
-    if ( ! xDown || ! yDown ) { 
-        return; 
-    } 
- 
-    var xUp = evt.touches[0].clientX;                                     
-    var yUp = evt.touches[0].clientY; 
- 
-    var xDiff = xDown - xUp; 
-    var yDiff = yDown - yUp; 
-                                                                          
-    if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/ 
-        if ( xDiff > 0 && swipeCooldown==false) { 
-            swipeCooldown=true 
-            checkIfSwitchImageLeft(evt.target) 
-            setTimeout(()=>{ 
-                swipeCooldown=false 
-            },500) 
-        }  
-        else if (swipeCooldown==false) { 
-            swipeCooldown=true 
-            checkIfSwitchImageRight(evt.target) 
-            setTimeout(()=>{ 
-                swipeCooldown=false 
-            },500) 
-        }                        
-    } else { 
-        if ( yDiff > 0 ) { 
-            /* down swipe */  
-        } else {  
-            /* up swipe */ 
-        }                                                                  
-    } 
-    /* reset values */ 
-    xDown = null; 
-    yDown = null;                                              
-}; 
- 
-//swiping code by: https://stackoverflow.com/a/23230280/19515980 
  
 function adaptToOrientationChange (){ function adaptToOrientationChange (){
Line 842: Line 820:
 } }
 function createWikiSpacing (){ 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'))+    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'))
     }     }
 } }
Line 853: Line 831:
 </script> </script>
 </html> </html>
-{{:aging.png?400|}} {{:service.png?400|}} [[destressing-images-overview|{{:destressing.png?400|}}]] 
  
-====== Console Output: ====== +=== Some Website Highlights 一些網頁精彩亮點 ===
  
 +<html>
 +
 +<head loading = 'lazy'>
 +    <title>Interactive buttons test</title>
 +    <style>
 + .buttons{
 +      width: auto;
 +      height: 400px;
 +    }
 +    </style>
 +    <!--<link rel="icon" type="image/x-icon" href="./favicon.ico">-->
 +    <link rel="shortcut icon" href="#">
 +</head>
 +
 +<body loading = 'lazy'>
 +    <script loading = 'lazy' src="https://cdnjs.cloudflare.com/ajax/libs/svg.js/3.1.2/svg.min.js"></script>
 +    <script loading = 'lazy'>
 +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'
 +
 +
 +
 +let allSvgs = []
 +
 +let allSvgsObj = {}
 +
 +//some notes: create a bunch of SVG canvas, and stuff different butotns in one by one.
 +//Make a function that activates buttons
 +//
 +
 +
 +function checkIfSVGjsElement(item) {
 +    try {
 +        item.dmove(0, 0)
 +        return true
 +    } catch {
 +        return false
 +    }
 +}
 +
 +
 +function getAllShapes(svgArray, canvas) {
 +    let newSvgArray = []
 +    //console.log("svgArray: ")
 +    //console.log(svgArray)
 +    if (svgArray == undefined) {
 +        //console.log("destressingButton.children: ")
 +        //console.log(destressingButton.children()[0])
 +        //console.log(canvas.children()[0].children())
 +        //getAllShapes(destressingButton.children()[0].children())
 +        //getAllShapes(destressingButton.children()[1].children())
 +        canvas.children().forEach(e => {
 +            getAllShapes(e.children())
 +        })
 +    } else {
 +        svgArray.forEach(x => {
 +            if (x.type == 'g') {
 +                x.children().forEach(y => {
 +                    //console.log(y)
 +                    newSvgArray.push(y)
 +                })
 +            } else if (x.type != 'defs' && x.type.includes('sodipodi') == false && checkIfSVGjsElement(x)) {
 +                //remove the css color, and replace it with the .fill() color in SVG.js
 +                //console.log(x)
 +                x.fill(x.node.style.fill)
 +                x.node.style = null;
 +                //console.log("here")
 +                //console.log(x)
 +                allSvgs.push(x)
 +            }
 +        })
 +    }
 +    if (newSvgArray.length > 0) {
 +        getAllShapes(newSvgArray)
 +    }
 +}
 +
 +//from https://stackoverflow.com/questions/14446447/how-to-read-a-local-text-file-in-the-browser
 +//reads a text file
 +function readTextFile(file) {
 +    let rawFile = new XMLHttpRequest();
 +    rawFile.open("GET", file, false);
 +    let allText;
 +    rawFile.onreadystatechange = function() {
 +        if (rawFile.readyState === 4) {
 +            if (rawFile.status === 200 || rawFile.status == 0) {
 +                allText = rawFile.responseText;
 +                //console.log(allText);
 +            }
 +        }
 +    }
 +    rawFile.send(null);
 +    return allText;
 +}
 +
 +//Change files to the format that we can use
 +function readFile(input) {
 +    let file = input.files[0];
 +    //console.log('"file" in readFile function')
 +    //console.log(file)
 +
 +    let reader = new FileReader();
 +
 +    reader.readAsText(file);
 +
 +    reader.onload = function() {
 +        //console.log(reader.result);
 +    };
 +
 +    reader.onerror = function() {
 +        //console.log(reader.error);
 +    };
 +    return reader
 +}
 +
 +//code from Chat-GPT, https://chat.openai.com/chat/8884aedb-3f4d-4e14-87bf-d9cfe3223d90
 +function removeCamelCase(str) {
 +    // Split the string into an array of words
 +    let words = str.split(/(?=[A-Z])/);
 +
 +    // Remove the first word and join the remaining words with a space
 +    let result = words.slice(1).join(" ").toLowerCase();
 +
 +    return result;
 +}
 +
 +//put svgs into an object and use their ids as their keys
 +function putSvgsInObject(svgArray, object, camelCase) {
 +    if (camelCase) {
 +        svgArray.forEach(e => object[removeCamelCase(e.node.id)] = e)
 +    } else {
 +        svgArray.forEach(e => object[e.node.id] = e)
 +    }
 +}
 +
 +function printObject(obj) {
 +    for (const [key, value] of Object.entries(obj)) {
 +        //console.log(`${key}: ${value}`)
 +    }
 +}
 +
 +function changeCursor(style) {
 +    document.getElementsByTagName("body")[0].style.cursor = style
 +}
 +
 +
 +function displaySvgs(canvas, ...files) {
 +    //let svgXml = readTextFile(file)
 +    files.forEach(e => {
 +        canvas.svg(readTextFile(e))
 +    })
 +    //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)
 +}
 +
 +
 +
 +//if (document.readyState === 'complete') {
 +//console.log("hi9")
 +//}
 +
 +//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 destressingSvgsObj = {};
 +
 +let elderlySvgs = [];
 +let elderlySvgsObj = {};
 +
 +//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(destressingSvgs, destressingSvgsObj, 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);
 +    }
 +});
 +
 +
 +let animationDuration = 250;
 +let buttonSize = 400;
 +
 +let destressingGroup;
 +
 +
 +let descriptions = {
 +    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({
 +        family: 'arial',
 +        size: 20
 +    }).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({
 +        family: 'arial',
 +        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)
 +}
 +
 +
 +let titles = {
 +    destressingTitle: destressingCanvas.text("Destressing Images").move(168, 321.5).font({
 +        family: 'arial',
 +        size: 19.5
 +    }),
 +    elderlyTitle: elderlyCanvas.text("Elderly Biography").move(188, 321.5).font({
 +        family: 'arial',
 +        size: 19.5
 +    }),
 +    microTitle: microCanvas.text("Micro-controllers \nand Hydra").move(196.5, 302).font({
 +        family: 'arial',
 +        size: 19.5,
 +        leading: '1em'
 +    }),
 +    simulationTitle: simulationCanvas.text("Elderly Simulation").move(184, 322).font({
 +        size: 19.5,
 +        family: 'arial',
 +    }),
 +    hydraTitle: hydraCanvas.text("Educating the Public \nAbout Hydra").move(161, 302).font({
 +        family: 'arial',
 +        size: 19.5,
 +        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
 +    })
 +
 +}
 +
 +
 +class Button {
 +    constructor(name, description, title, svgsArray, svgsObj, titleShiftX, titleShiftY, descriptionShift) {
 +        this.name = name;
 +        this.description = description;
 +        this.title = title;
 +        this.svgsArray = svgsArray;
 +        this.svgsObj = svgsObj
 +        this.titleShift = {
 +            x: titleShiftX,
 +            y: titleShiftY
 +        }
 +        //descriptionShift only has one value because it is only shifting up
 +        this.descriptionShift = descriptionShift
 +    }
 +}
 +
 +//the dmove animation of titles
 +//different shifts of two lines titles and one line title, two lines titles have their special numbers
 +//distance between title and left side should be about 21px, and about 30px for the top distance
 +let titleShifts = {
 +    destressing: {
 +        x: -150,
 +        y: -304
 +    },
 +    elderly: {
 +        x: -170,
 +        y: -304
 +    },
 +    micro: {
 +        x: -176,
 +        y: -282
 +    },
 +    hydra: {
 +        x: -140,
 +        y: -279.5
 +    },
 +    visual: {
 +        x: -195,
 +        y: -284
 +    },
 +    simulation: {
 +        x: -167,
 +        y: -304
 +    },
 +    students: {
 +        x: -152,
 +        y: -304
 +    },
 +    impression: {
 +        x: -150,
 +        y: -304
 +    }
 +}
 +
 +
 +//the dmove animation of descriptions
 +//this one only needs oneLine or twoLines opetions
 +let descriptionShifts = {
 +    oneLine: -180,
 +    twoLines: -140
 +}
 +
 +//------------------------------------------------------------------------------
 +///------------------------------------------------------------------------------
 +////------------------------------------------------------------------------------
 +////------------------------------------------------------------------------------
 +///!!!!!!!!super important here!!!!!!!!!!!!
 +
 +//last four numbers: title shift x, title shift y,  description shift y
 +let destressingButtonObject = new Button("destressingButton", descriptions.destressingDescription, titles.destressingTitle, destressingSvgs, destressingSvgsObj, titleShifts.destressing.x, titleShifts.destressing.y, descriptionShifts.oneLine)
 +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)
 +makeButton(elderlyCanvas, elderlyButtonObject, "https://renickbell.net/ed/2022service/doku.php?id=elderly-biography")
 +
 +let microButtonObject = new Button("microButton", descriptions.microDescription, titles.microTitle, microSvgs, microSvgsObj, titleShifts.micro.x, titleShifts.micro.y, descriptionShifts.twoLines)
 +makeButton(microCanvas, microButtonObject, "https://renickbell.net/ed/2022service/doku.php?id=arduino")
 +
 +let hydraButtonObject = new Button("hydraButton", descriptions.hydraDescription, titles.hydraTitle, hydraSvgs, hydraSvgsObj, titleShifts.hydra.x, titleShifts.hydra.y, descriptionShifts.twoLines)
 +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)
 +makeButton(simulationCanvas, simulationButtonObject, "https://renickbell.net/ed/2022service/doku.php?id=elderly-simulation-map")
 +
 +let studentsButtonObject = new Button("studentsButton", descriptions.studentsDescription, titles.studentsTitle, studentsSvgs, studentsSvgsObj, titleShifts.students.x, titleShifts.students.y, descriptionShifts.oneLine)
 +makeButton(studentsCanvas, studentsButtonObject, "https://renickbell.net/ed/2022service/doku.php?id=about-students")
 +
 +let impressionButtonObject = new Button("impressionButton", descriptions.impressionDescription, titles.impressionTitle, impressionSvgs, impressionSvgsObj, titleShifts.impression.x, titleShifts.impression.y, descriptionShifts.oneLine)
 +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) {
 +    let titleRunner;
 +    let textBoxRunner;
 +    let backgroundRunner;
 +    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;
 +    let outAnimation = false;
 +    hitBox.on("mouseover", function() {
 +        changeCursor("pointer")
 +        if (overAnimaton) {
 +            //console.log("over")
 +            backgroundRunner = background.animate(animationDuration).opacity(0.8)
 +            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(0, buttonObject.descriptionShift);
 +            outAnimation = true;
 +        }
 +        //animationTimer = setTimeout(() => {}, 0)
 +    })
 +    hitBox.on("mouseout", function() {
 +        changeCursor("default")
 +        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)
 +            overAnimaton = false
 +            outAnimation = false
 +            let setOverAnimationToTrue = setTimeout(function() {
 +                overAnimaton = true
 +            }, 250)
 +        }
 +        //clearTimeout(animationTimer)
 +    });
 +    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))
 +
 +//STEVE CODE:
 +
 +
 +/*
 +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)))
 +})
 +
 +window.addEventListener("touchend", function(e){
 +    console.log('end',e)
 +    if (startPoint.x<e.clientX){
 +        console.log('swiped left',e.clientX)
 +        checkIfSwitchImageLeft(e.target)
 +    }
 +    else {
 +        console.log('swiped right')
 +        checkIfSwitchImageRight(e.target)
 +        }
 +})
 +*/
 +
 +window.addEventListener('touchstart', handleTouchStart, false);        
 +window.addEventListener('touchmove', handleTouchMove, false);
 +
 +var xDown = null;                                                        
 +var yDown = null;
 +
 +function getTouches(evt) {
 +  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;
 +
 +    var xDiff = xDown - xUp;
 +    var yDiff = yDown - yUp;
 +                                                                         
 +    if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/
 +        if ( xDiff > 0 && swipeCooldown==false) {
 +            evt.preventDefault()
 +            console.log('swiped left')
 +            swipeCooldown=true
 +            checkIfSwitchImageLeft(evt.target)
 +            setTimeout(()=>{
 +                swipeCooldown=false
 +            },500)
 +        } 
 +        else if (swipeCooldown==false) {
 +            evt.preventDefault()
 +            console.log('swiped right')
 +            swipeCooldown=true
 +            checkIfSwitchImageRight(evt.target)
 +            setTimeout(()=>{
 +                swipeCooldown=false
 +            },500)
 +        }                       
 +    } else {
 +        if ( yDiff > 0 ) {
 +        } else { 
 +        }                                                                 
 +    }
 +    /* reset values */
 +    xDown = null;
 +    yDown = null;                                             
 +};
 +
 +//swiping code by: https://stackoverflow.com/a/23230280/19515980
 +
 +</script>
 +</body>
 +
 +</html>
  
  • steve-image-carosel-test-page2.1673183022.txt.gz
  • Last modified: 2023/01/08 05:03
  • by steve.wang