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-page3 [2023/01/31 02:35] steve.wangsteve-image-carosel-test-page3 [2023/02/09 06:44] (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>
Line 32: Line 32:
           -webkit-transform: scaleX(-1);           -webkit-transform: scaleX(-1);
             transform: scaleX(-1);             transform: scaleX(-1);
-        opacity:0.7;+        opacity:0.5;
           color: grey;           color: grey;
           background-color:transparent;           background-color:transparent;
Line 39: Line 39:
  
 .left:hover{ .left:hover{
-        opacity:1;+        opacity:0.9;
 } }
  
Line 47: Line 47:
         line-height: 34px;         line-height: 34px;
         display: inline-block;         display: inline-block;
-        opacity:0.7;+        opacity:0.5;
         color: grey;         color: grey;
         background-color:transparent;         background-color:transparent;
Line 54: Line 54:
  
 .right:hover{ .right:hover{
-        opacity:1;+        opacity:0.9;
 } }
 .arrow{ .arrow{
Line 128: Line 128:
 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 146: Line 146:
 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 195: Line 195:
         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 213: Line 213:
         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 226: Line 226:
         }         }
         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 235: Line 235:
         }         }
         else{         else{
-            this.mainImg2.src=this.info[0].portriatSrc+            this.mainImg2.src=this.info[0].portraitSrc
         }         }
         this.mainImg2.className='mainImg'         this.mainImg2.className='mainImg'
Line 284: Line 284:
             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 300: Line 300:
         this.left.style.top='50%'         this.left.style.top='50%'
         this.left.className='left'         this.left.className='left'
 +        /*
 +        this.mainImg1.style.position='absolute'
 +        this.mainImg2.style.position='absolute'
 +        let arrowSizes=browserZoomLevel/2
 +        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.correctCenteredImgPosition=new Point(this.centeredImg.getBoundingClientRect().x,this.centeredImg.getBoundingClientRect().y)
         this.carosel.insertBefore(this.right,this.mainImg2)         this.carosel.insertBefore(this.right,this.mainImg2)
Line 445: Line 458:
             }             }
         },8000)         },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){     changeContent (toChangeTo){
Line 452: Line 498:
             }             }
             else{             else{
-                toChangeTo.src=this.info[this.currentImage].portriatSrc+                toChangeTo.src=this.info[this.currentImage].portraitSrc
             }             }
         }         }
Line 459: Line 505:
              this.carosel.parentElement.insertBefore(document.createElement('br'),this.carosel)              this.carosel.parentElement.insertBefore(document.createElement('br'),this.carosel)
          }          }
-     }+    }
 } }
 +
 +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)}
 +}
 +
 +
 +function manuallyMoveHtmlToLeft (elem,startX,moveBy,times,counter){
 +    if (counter==undefined){
 +        counter=1}
 +    elem.style.left=startX-moveBy*counter+'px'
 +    if (counter<times){
 +        setTimeout(()=>{
 +            manuallyMoveHtmlToLeft(elem,startX,moveBy,times,counter+1)},14)}
 +}
 +
 +/*
 +async function sequencingSwitchingImages (imageCaroselNumber){
 +   await carosels[imageCaroselNumber][carosels[imageCaroselNumber][queue][0]]()
 +   carosels[imageCaroselNumber][queue]=safeSplice(carosels[imageCaroselNumber][queue],1,0)
 +    if (carosels[imageCaroselNumber][queue].length>0){
 +        sequencingSwitchingImages(imageCaroselNumber)
 +    }
 +}
 +
 +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 let imageAutoSwitchCooldown=false
Line 482: Line 568:
             setTimeout(()=>{             setTimeout(()=>{
                 resetImageSwitchCooldown(currentImageCarosel)                 resetImageSwitchCooldown(currentImageCarosel)
-            },3000)+            },5000)
         }         }
-    },2000)+    },3000)
 } }
  
Line 490: Line 576:
 window.addEventListener("load", function(e){ window.addEventListener("load", function(e){
      browserZoomLevel = Math.round(window.devicePixelRatio * 100);      browserZoomLevel = Math.round(window.devicePixelRatio * 100);
-    if (window.innerWidth<window.innerHeight){ +if (window.innerWidth<window.innerHeight){ 
-        deviceOrientation='portriat+    console.log('portrait mode'
-    +    deviceOrientation='portrait
-    else{ +
-        deviceOrientation='landscape' +else{ 
-    +    console.log('landscape mode'
-    higs=new ImageCarosel('doku',info,'main'+    deviceOrientation='landscape' 
-    higs.createArrows() +
-    carosels.push(higs) +console.log('loaded'
-    higs.autoScroller()+//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(()=>{     setTimeout(()=>{
-            updateCaroselWidth(higs+        if (deviceOrientation=='landscape')
-            document.getElementById('design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public').appendChild(higs.carosel)+            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)             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(()=>{             setTimeout(()=>{
                 higs.addSpaceAbove(2)                 higs.addSpaceAbove(2)
-                if (window.innerHeight<750 || deviceType=='mobile')+                //higs.carosel.style.height=higs.mainImg1.getBoundingClientRect().height+'px'; 
-                    console.log('option 1 chosen') +           // higs.carosel.style.height='800px' 
-                    higs.carosel.style.height='800px' +                higs.carosel.style.height=higs.mainImg1.getBoundingClientRect().height+'px' 
-                    higs.carosel.style.height=higs.mainImg1.getBoundingClientRect().height+'px' +            },100
-                } +    },300)
-                else{ +
-                    console.log('option 2 chosen'+
-                    higs.carosel.style.height='800px' +
-                } +
-            },200+
-    },10)+
 }) })
- 
-window.addEventListener("resize", function(e){ 
-    console.log('resize detected') 
-    let oldOrientation=deviceOrientation 
-    browserZoomLevel = Math.round(window.devicePixelRatio * 100); 
-    if (window.innerWidth<window.innerHeight){ 
-        deviceOrientation='portriat' 
-    } 
-    else{ 
-        deviceOrientation='landscape' 
-    } 
-        carosels.forEach(x=>{ 
-            updateCaroselWidth(x) 
-            updateCaroselHeight(x) 
-            x.mainImg1.style.width=x.carosel.getBoundingClientRect().width+'px' 
-            x.mainImg1.style.height==x.carosel.getBoundingClientRect().height+'px' 
-            x.mainImg2.style.width=x.carosel.getBoundingClientRect().width+'px' 
-            x.mainImg2.style.height==x.carosel.getBoundingClientRect().height+'px' 
-            x.right.remove() 
-            x.left.remove() 
-            x.createArrows() 
-        }) 
-}) 
- 
-function updateCaroselWidth (caroselElem){ 
-    if (deviceType=='mobile' || window.innerWidth<1600){ 
-        caroselElem.carosel.style.width=window.innerWidth-100+'px' 
-    } 
-    else { 
-        caroselElem.carosel.style.width='1600px' 
-    } 
- 
-} 
- 
-function updateCaroselHeight (caroselElem){ 
-    if (window.innerHeight<750 || deviceType=='mobile'){ 
-         caroselElem.carosel.style.height=document.getElementsByClassName('mainImg')[0].getBoundingClientRect().height+'px' 
-    } 
-    else{ 
-        caroselElem.carosel.style.height='800px' 
-    } 
-} 
- 
-async function afterCaroselAppended (){ 
-    await waitForCaroselAppend() 
-    higs.addSpaceAbove(2) 
-    if (window.innerHeight<750 || deviceType=='mobile'){ 
-        console.log('option 1 chosen') 
-        higs.carosel.style.height='800px' 
-        higs.carosel.style.height=higs.mainImg1.getBoundingClientRect().height+'px' 
-    } 
-    else{ 
-        console.log('option 2 chosen') 
-        higs.carosel.style.height='800px' 
-    } 
-} 
- 
-function waitForCaroselAppend (){ 
-    return new Promise((resolve,reject) => { 
-        if (higs.carosel.parentElement.id=='design_and_change_for_assistance_and_pressure_alleviation_of_the_elderly_stressed_and_general_public'){ 
-        resolve(true) 
-        } 
-    }); 
-} 
  
 function getDeviceType () { function getDeviceType () {
Line 643: Line 685:
     }))     }))
 } }
 +
 +if (deviceTyp!='mobile'){
 +    window.addEventListener("resize", function(e){
 +        console.log('options',deviceType!='mobile',deviceOrientation!='portrait'
 +        if (window.innerWidth<window.innerHeight){
 +            //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()
 +        }
 +    })
 +}
 +
 +/*
 +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)
 +        }
 +})
 +*/
  
 document.addEventListener('touchstart', handleTouchStart, false);         document.addEventListener('touchstart', handleTouchStart, false);        
Line 766: Line 854:
 } }
 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 777: Line 865:
 </script> </script>
 </html> </html>
 +
 +=== Some Website Highlights 一些網頁精彩亮點 ===
 +
 +<html>
 +
 +<head>
 +    <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>
 +    <script src="https://cdnjs.cloudflare.com/ajax/libs/svg.js/3.1.2/svg.min.js"></script>
 +    <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'
 +
 +
 +
 +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))
 +
 +
 +</script>
 +</body>
 +
 +</html>
 +
 +
  
  • steve-image-carosel-test-page3.1675161313.txt.gz
  • Last modified: 2023/01/31 02:35
  • by steve.wang