Share
Embed
インターネット -第10回- Firefox OSアプリ開発 応用編
前回はHello, Worldアプリを作成しましたが、今回はFirefox OSアプリケーションの開発の応用編としてラーメンタイマーの実装を行います
Hirotaka Nakajima
June 23, 2015
Transcript
47 slides
-
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. Πϯλʔωοτ ୈճ'JSFGPY04ΞϓϦ։ൃԠ༻ฤ ଜҪ७ɹೆथɹதౡതܟ UXJUUFSJOFUT -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ࣄલ४උ w ҎԼͷ߲Λ֬ೝ͠·͠ΐ͏ w 8FC*%&ͷىಈํ๏ w 'JSFGPY04γϛϡϨʔλͷΠϯετʔϧىಈํ ๏ w લճͷ)FMMP8PSMEΞϓϦͷ࡞Γํ w μϯϩʔυ w तۀͰ༻͢ΔͷͰ4'$4'4͔ΒϓϩάϥϜΛμ ϯϩʔυͯ͠อଘ͍ͯͩ͘͠͞ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. 'JSFGPY04ΞϓϦ։ൃԠ༻ฤ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ϥʔϝϯλΠϚʔ w ϥʔϝϯλΠϚʔͱ w ΧοϓϥʔϝϯΛ࡞ΔΛܭΔλΠϚʔ w )FMMP8PSMEͱฒΜͰϓϩάϥϛϯάֶशॳ৺ऀ ͕Α͘࡞͢ΔϓϩάϥϜͷҰछ w ϥʔϝϯλΠϚʔ w -JOVYΞϯαΠΫϩϖσΟΞ ʠҒͦ͏ʹޠΔͤ͘ʹɺϥʔϝϯλΠϚʔͭ·ͱʹ࡞Δ ͜ͱͰ͖ͳ͍Τη։ൃऀ w (PPHMF4FBSDIϥʔϝϯλΠϚʔ࡞ͬͯΈͨɹ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ࿅शૉࡐͱͯ͠ྑ͍ w Χϯτμϯ͢Δ͚ͩ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ·ͣσβΠϯ w ͍͖ͳΓίʔυΛॻ͖࢝Ίͳ͍ w ͲΜͳػೳը໘͕ඞཁ͔ߟ͑Δ w ػೳؒͷؔੑΛߟ͑Δ w ػೳ w ؒ࣌ؒΛܭΔ͜ͱ͕ग़དྷΔ w ελʔτͯ͠ɺετοϓͰ͖Δ w ը໘ w Χϯτμϯͷจࣈ͕දࣔ͞ΕΔ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ίϯηϓτΛܾΊΑ͏ w ࢥ͍͖ͭͰ͍Ζ͍ΖՃͨ͘͠ͳΔ w Կ͕ॏཁͰԿʹϑΥʔΧεͯ͠࡞ͬͯΔͷ͔Λ ֬ೝ͢Δඞཁ͕͋Δ w ϥʔϝϯλΠϚʔͷ߹ w λΠϚʔͳͷͰ͋ͱԿ͔Γ͍ͨ w ඵ୯ҐͰΧϯτμϯͯ͠Δͱಈ͍ͯΔ ײ͕ग़Δ w ଞͷΞϓϦΛ͍ͬͯͯ௨͕དྷΔΑ͏ʹ͍ͨ͠ w ͱΓ͋͑ͣݻఆͰ0, -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. σβΠϯ͕ઌ͔ɺػೳ͕ઌ͔ w σβΠϯΛ࡞Δ w ը໘ʹදࣔ͠ͳ͚ΕͳΒͳ͍ύʔπΛߟ͑Δ w Ͳ͏ը໘ʹϨΠΞτ͢Δ͔ߟ͑Δ w ύʔπʹͲΜͳػೳΛׂΓͯΔ͔ߟ͑Δ w ػೳΛߟ͑Δ w ػೳʹରͯ͠ͲΜͳϘλϯ͕ඞཁ͔ߟ͑Δ w ʜ w جຊతʹը໘͔Βߟ͑ͨํ͕Α͍߹͕ଟ͍ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. σβΠϯΛ࡞Δ w ίϯηϓτʹج͍ͮͯεέον͢Δ w ࢴͱԖචͰΔ͜ͱ͕Φεεϝ w ը໘ͷେ·͔ͳਤΛखॻ͖͢Δ w ϫΠϠʔϑϨʔϜਤ w .JDSPTPGU7JTJP w 0NOJ(SBGqF w େ࣌ؒͷແବ w खॻ͖ͰεΩϟϯ͕ྑ͍ XJSFGSBNFCZCBMEJSJJTMJDFOTFEVOEFS$$#: -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. σβΠϯΛߟ͑Δ ΞϓϦͷ໊લ Γ࣌ؒΛදࣔ σδλϧͬΆ͍ϑΥϯτ ελʔτϘλϯ ։࢝ͨ͠Βετοϓʹ͍ͨ͠ ϦηοτϘλϯ ϔομʔ෦ Χϯτμϯ෦ Ϙλϯ෦ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. σβΠϯͷ࣮ w ·ͣ)5.-ͱ$44Λ࣮͍ͬͯͯ͘͠ w JOEFYIUNM͕ىಈ࣌ʹ࣮ߦ͞ΕΔ w EJWཁૉΛ༻͍ͯ ͦΕͧΕϔομʔ Χϯτμϯ Ϙλϯ෦ Λ࡞͍ͬͯ͘ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ৽͍͠ϓϩδΣΫτΛ࡞ w ͔͜͜ΒϥΠϒίʔσΟϯάΛ͍͖ͯ͠·͢ w ͨ͠ϓϩάϥϜ4'$4'4ʹ্͕͍ͬͯΔ ͷͰɺ͍ͭͯߦ͔ͳͯ͘େৎͰ͢ ͱ͍͏͔ແཧͰ͢ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. σβΠϯͷ࣮ <body> <div> <div> <h1>ラーメンタイマー</h1> </div> <div> <div> <p id="timer-digits"> 0:00.00 </p> </div> <ul> <div> <button id="button-start">スタート</button> </div> <div> <button id="button-reset">リセット</button> </div> </ul> </div> </div> </body> -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ϥΠϒϥϦΛ׆༻͢Δ w ૉͷ)5.-Ͱ͔ͬ͜Α͘ͳ্͍ʹ͍ͮΒ͍ w ྑ͍ײ͡ͷΠϯλϑΣΠεʹ͍ͨ͠ w ϥΠϒϥϦΛ׆༻͢Δ w ػೳίʔυΛ࠶ར༻Ͱ͖ΔΑ͏·ͱΊͨϞϊ w +BWB4DSJQUͰࢉज़ԋࢉΛߦ͏ࡍʹར༻͢Δ.BUIͳ ͲϥΠϒϥϦͷྫ w ϥΠϒϥϦͷछྨଟذʹΘͨΓɺϢʔβΠϯλϑΣ Πεͷ࣮Λॿ͚Δͷ͋Δ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. 6*ϥΠϒϥϦΛ͓͏ w 6* 6TFS*OUFSGBDF ͚ͷϥΠϒϥϦ w දతͳ6*ϥΠϒϥϦ w K2VFSZ6* w ࠷ϙϐϡϥʔͳ+BWB4DSJQUϥΠϒϥϦͷ6*ϥ ΠϒϥϦ w #PPUTUSBQ w 5XJUUFSͷσβΠϯΛϕʔεʹ։ൃ w .BUFSJBM%FTJHO w "OESPJEͰఏҊ͞Εͨ৽͍͠σβΠϯ w 1PMZNFS1SPKFDU -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. K2VFSZ.PCJMF6*ΛͬͯΈΔ w ͍Ζ͍Ζ6*ϥΠϒϥϦ͋Γ·͕͢ ͱΓ͋͑ͣK2VFSZ.PCJMF6*ΛͬͯΈ· ͠ΐ͏ w K2VFSZ.PCJMF6*Λ͏ͨΊʹඞཁͳͷ w K2VFSZຊମ +BWB4DSJQU w K2VFSZ.PCJMF6* +BWB4DSJQU w K2VFSZ.PCJMF6*4UZMFTIFFU $44 -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. K2VFSZ.PCJMF6* w JOEFYIUNMͰͦΕͧΕಡΈࠐΉ <link rel="stylesheet" href="css/jquery.mobile-1.4.5.min.css"> <script src="js/jquery.min.js"></script> <script src="js/jquery.mobile.min.js"></script> -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. K2VFSZ.PCJMF6*ͦͷ w K2VFSZ.PCJMF6*ʹରͯ͠ ͦΕͧΕͷEJWཁૉ͕ͲΜͳׂͷEJWͳͷ͔ ͑Δඞཁ͕͋Δ w આ໌ׂѪ͠·͕͢ɺEBUBSPMF EBUBQPTJUJPO ͳͲͷଐੑΛ͍·͢ w ৄ͘͠K2VFSZ.PCJMF6*ͷυΩϡϝϯτΛ ݟ·͠ΐ͏ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. K2VFSZ.PCJMF6*ͦͷ <body> <div data-role="page"> <div data-role="header" data-position="fixed"> <h1>ラーメンタイマー</h1> </div> <div data-role="content"> <div data-theme="a" data-form="ui-body-a" class="ui-body ui-body-a ui-corner-all"> <p id="timer-digits"> 0:00.00 </p> </div> <ul data-role="ui-grid-a"> <div class="ui-block-a"> <button class="ui-btn ui-corner-all" id="button-start">スタート</button> </div> <div class="ui-block-b"> <button class="ui-btn ui-corner-all" id="button-reset">リセット</button> </div> </ul> </div> </div> </body> -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ͏গ͠σβΠϯΛௐ͠Α͏ w Χϯτμϯ෦ w จࣈ͕ࠨدͤʹͳͬͯΔͷ͕ͪΐͬͱඍົ w จࣈΛେ͖͍ͨ͘͠ w σδλϧͬΆ͍ϑΥϯτʹ͍ͨ͠ w Χϯτμϯͷจࣈ w UJNFSEJHJUTΛJEଐੑʹ࣋ͭQཁૉ w ͦ͜ʹରͯ͠ελΠϧΛద༻͢Δ w $44ϑΝΠϧΛ࡞ͯ͠ɺಡΈࠐ·ͤΔ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. $44Λ࡞͢Δ #timer-digits { margin:10 auto; text-align: center; font-size: 36px; font-family: Consolas, 'Courier New', Courier, Monaco, monospace; } <link rel="stylesheet" href="css/styles.css"> -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. σβΠϯ͕ग़དྷͨΒػೳΛ࣮͢Δ w σβΠϯେମͰ͖͕͋ͬͨ w ͦΕͧΕͷϘλϯʹରͯ͠ػೳΛ࣮͍ͯ͘͠ w Ϙλϯ w ελʔτετοϓϘλϯ w ϘλϯΛԡ͢ͱΧϯτμϯ͕։࢝ w ετοϓΛԡ͢ͱΧϯτ͕ఀࢭ w ϦηοτϘλϯ w ϘλϯΛԡ͢ͱΧϯτ͕Ϧηοτ͢Δ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ϘλϯʹػೳΛ࣮͢Δ w ʮϘλϯ͕ԡ͞Εͨʯͱ͍ͬͨΠϕϯτʹର͠ ͯػೳΛ࣮͢Δ w Πϕϯτ͕ൃੜͨ͠ࡍʹ࣮ߦ͢ΔؔΛΠϕϯ τϦεφʔͱ͍͏ w ΠϕϯτϦεφʔΛ࡞ͬͯɺϘλϯʹରͯ͠ఆ ٛ͢Δ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ϘλϯʹػೳΛ࣮͢Δ // タイマーの機能を実装する var setRamenTimer1 = function() { var startButton = document.getElementById('button-start'); startButton.addEventListener('click', function() { setTimeout(function() { alert("時間だよ") createNotification1(timerMessage); }, 3*60*1000); }); }; setRamenTimer1(); -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ௨ํ๏ͷվྑ w BMFSUΛͬͯϢʔβʹ࣌ؒͷ౸ୡΛ௨ͨ͠ w BMFSUͷܽΞϓϦ͕όοΫάϥϯυʹͳͬͯ ͍Δ߹ʹ௨͞Εͳ͍ w J04"OESPJEͰϓογϡ௨͕ར༻ग़དྷΔ w όοΫάϥϯυͰ௨Λड͚औΔ͜ͱ͕ग़དྷΔ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. 8FC/PUJpDBUJPO w 8FC"QQͰ௨Λར༻Մೳͱ͢ΔΈ w 'JSFGPY04ΞϓϦ͚ͩͰͳ͘ (PPHMF$ISPNFͳͲͰར༻ग़དྷΔ *NBHFGSPNۓٸใCZ&YUFOTJPO -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. 8FC/PUJpDBUJPOΛͬͯΈΔ w 'JSFGPY04ͷҰ෦ͷػೳϢʔβͷಉҙແ͠ʹ ར༻ग़དྷͳ͍Α͏ʹͳ͍ͬͯΔ w উखʹ(14ͰҐஔଌఆͱ͔͞ΕͨΒࠔΔ w 1PXFSGVM'FBUVSFͱ͔ݴ͍·͢ w ΞϓϦΛΠϯετʔϧͨ͠λΠϛϯάͰͲΜͳ ػೳΛ͏͔໌ࣔతʹڐՄΛٻΊΔΈ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. .BOJGFTUͷฤू w ΞϓϦͷ໊લEFTDSJQUJPOɺͲΜͳಛݖΛར ༻͢Δ͔ͳͲΞϓϦͷใΛऩΊͨϑΝΠϧ w 8FC/PUJpDBUJPOಛݖΛ͏ػೳͳͷͰɺ NBOJGFTUʹॻ͘ w ͍ͭͰʹΞϓϦͷ໊લEFTDSJQUJPOͳͲม ߋͯ͠͠·͍·͠ΐ͏ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. .BOJGFTUͷฤू { "name": "RamenTimer", "description": "カップラーメンを作るときに最適な3分タイマーです", "launch_path": "/index.html", "icons": { "16": "/icons/icon16x16.png", "48": "/icons/icon48x48.png", "60": "/icons/icon60x60.png", "128": "/icons/icon128x128.png" }, "developer": { "name": "Hirotaka Nakajima", "url": "https://blog.nunnun.jp" }, "permissions": { "desktop-notification": { "description": "ラーメンの出来上がりを通知します" } } } -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. 8FC/PUJpDBUJPOͷ࣮ w ΞϓϦ͔Β௨Λ࡞͢Δʹ w Ϣʔβ͕௨ΛڐՄͯ͠ͳ͍߹͕͋ΔͷͰɺ ֬ೝ༻ͷίʔυࠐΉ // ユーザに通知する var createNotification1 = function(message) { var n = new Notification("ラーメンタイマー", { body: "時間だよ" }); } -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. 8FC/PUJpDBUJPOͷ࣮ // WebNotificationを使うので、通知許可を取得する // 許可を得てない場合は確認する if (Notification && Notification.permission !== "granted") { Notification.requestPermission(function(status) { if (Notification.permission !== status) { Notification.permission = status; } }); } var timerMessage = "時間だよ"; // ユーザに通知する var createNotification1 = function(message) { var n = new Notification("ラーメンタイマー", { body: message }); } -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. Χϯτμϯ͍ͤͨ͞ w ࠓͷ··ͩͱޙԿͰͳͷ͔Θ͔Βͳ͍ w όϦΧλͰ৯͍ͨਓʹจ۟ݴΘΕͦ͏ w Γ࣌ؒΛදࣔ͢ΔͨΊͷػೳΛ࣮͢Δ w Ͳ͏͍͏ػೳ͕ඞཁ͔ߟ͑ͯΈΔ w Ұఆ࣌ؒຖʹΓ࣌ؒΛ֬ೝͯ͠දࣔ͢Δ w Ұఆ࣌ؒඵʹͯ͠ΈΔ w ࣮ͯ͠ΈΔ w Ұఆ࣌ؒຖʹಛఆͷಈ࡞Λͤ͞Δʹ TFU*OUFSWBM GVOD EVSBUJPO Λ͏ͱߦ͑Δ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. Χϯτμϯ࣮ var timerMilliSec = 3 * 60 * 1000; // 残り時間を表⽰示するようにする var setRamenTimer2 = function() { // スタートボタンを取得 var startButton = document.getElementById('button-start'); // 時間を表⽰示するエリアを取得する var timerDigits = document.getElementById('timer-digits'); startButton.addEventListener('click', function() { var tmp = timerMilliSec; // 10ミリ秒毎に以下の処理を繰り返す var i = setInterval(function() { var c = tmp -= 10; timerDigits.textContent = c; // 時間切れになった場合の処理 if (tmp == 0) { // 通知を飛ばす createNotification1(timerMessage); } }, 10); }); }; setRamenTimer2(); -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ϛϦඵΛඵϛϦඵʹม͢Δ w ࣌ؒίϯϐϡʔλͰॲཧ͢Δͷ͕͔͍ͬͳ ͷͰɺඵϛϦඵͰॲཧ͢Δ͜ͱ͕ଟ͍ w TFU*OUFSWBMͰϛϦඵͰ͕࣮ؔߦ͞ΕΔ࣌ؒ Λࢦఆ͍ͯ͠Δ w ࠓճΛ Y ඵ Y ϛϦඵඵ ͱͯ͠ܭࢉ͍ͯ͠Δ w දࣔ͢Δͱ͖ϛϦඵΛม͠ͳ͍ͱ͍͚ͳ͍ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ϛϦඵΛඵϛϦඵʹม͢Δ w ~~ˠϏοτԋࢉࢠ w ࠓճখΛΓࣺͯΔͱೝ͍ࣝͯͩ͘͠͞ ʢຊҧ͏ʣ • var a = 2.11; ~~a → 2 //ミリ秒を分、秒、ミリ秒に変換する var c = tmp -= 10, // cはtmpから10を引いた値が⼊入る m = ~~(c / 60 / 1000), // 分はミリ秒を1000で割り、60で割ると求まる s = ~~((c - m * 60 * 1000) / 1000) + '', // 秒はミリ秒から分を引いた値を1000で割ると求まる ms = (c - m * 60 * 1000 - s * 1000) / 10 + ''; // ミリ秒は10ミリ秒単位で表⽰示する timerDigits.textContent = m + ':' + s + "." + ms; -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ද่ࣔΕΛ͢ w ඵϛϦඵͱ͍ͬͨͱ͖ʹ ͱදࣔ͞ΕΔˠຊདྷͱͨ͠ ͍ w TMFOHUITͷ͞ w TMFOHUI w Tͷ͕͞ҎԼͷ߹Λ಄ʹՃ͢Δ timerDigits.textContent = m + ':' + (s.length > 1 ? '' : '0') + s + "." + (ms.length > 1 ? '' : '0') + ms; -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ετοϓػೳΛ࣮͢Δ w ͜ͷ··ͩͱελʔτग़དྷͯࢭΊΔ͜ͱ͕ग़དྷ ͳ͍ w ελʔτ͢ΔͱελʔτϘλϯ͕ετοϓϘλϯʹ มΘΔΑ͏ʹ͍ͨ͠ w σβΠϯ w ελʔτΛԡͨ࣌͠ͷػೳͱ ετοϓΛԡͨ͠ͱ͖ͷػೳΛผʑͷؔͱͯ͠ఆٛ͢ Δ w ͦΕͧΕͷػೳΛΓସ͑ΔػೳΛؔͱͯ͠ఆٛ͢Δ w ͦΕͧΕͷػೳΛΓସ͑ΔػೳΛަޓʹ࣮ߦͰ͖ΔΑ ͏ΠϕϯτϦεφʔΛఆٛ͢Δ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. 3BNFO5JNFSͷఆٛ // 残り時間を表⽰示して、⽌止められるようにする var setRamenTimer3 = function() { // スタートボタンを取得 var startButton = document.getElementById('button-start'); // 時間を表⽰示するエリアを取得する var timerDigits = document.getElementById('timer-digits'); var timerInterval; var timeRemaining = timerMilliSec; }; setRamenTimer3(); w setInterval()clearInterval()Λ͏ͱఀ ࢭ͢Δ͜ͱ͕ग़དྷΔ w setIntervalΛ࣋ͨͤΔͨΊʹtimerInterval ͱ͍͏มΛఆٛ͢Δ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ελʔτϘλϯΛԡͨ͠ͱ͖ͷػೳΛؔఆٛ var startEventHander = function() { // 10ミリ秒毎に以下の処理を繰り返す timerInterval = setInterval(function() { // ミリ秒を分、秒、ミリ秒に変換する var c = timeRemaining -= 10, // cはtmpから10を引いた値が⼊入る m = ~~(c / 60 / 1000), // 分はミリ秒を1000で割り、60で割ると求まる s = ~~((c - m * 60 * 1000) / 1000) + '', // 秒はミリ秒から分を引いた値を1000で割ると求まる ms = (c - m * 60 * 1000 - s * 1000) / 10 + ''; // ミリ秒は10ミリ秒単位で表⽰示する timerDigits.textContent = m + ':' + (s.length > 1 ? '' : '0') + s + "." + (ms.length > 1 ? '' : '0') + ms; // 時間切れになった場合の処理 if (timeRemaining == 0) { // setIntervalを停⽌止する clearInterval(timerInterval); // 通知を飛ばす createNotification1(timerMessage); // スタートボタンに戻す renameStartStopButton(TIMER_START); } }, 10); // タイマーが始まったらスタートボタンをストップボタンに書き換える renameStartStopButton(TIMER_STOP); }; -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ετοϓΛԡͨ͠ͱ͖ͷػೳΛؔͱͯ͠ఆٛ // ストップボタンを押した際のイベントハンドラ var stopEventHandler = function() { if (timerInterval) clearInterval(timerInterval); // タイマーが停⽌止したらストップボタンをスタートに書き換える renameStartStopButton(TIMER_START); }; -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ελʔτɾετοϓΛΓସ͑Δؔ // ボタンを書き換える const TIMER_START = 0; const TIMER_STOP = 1; var renameStartStopButton = function(mode) { if (mode == TIMER_START) { startButton.innerHTML = "スタート"; startButton.removeEventListener('click', stopEventHandler, false); startButton.addEventListener('click', startEventHander); } else { startButton.innerHTML = "ストップ"; startButton.removeEventListener('click', startEventHander, false); startButton.addEventListener('click', stopEventHandler); } }; -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ελʔτϘλϯΛ࠷ॳʹઃఆ startButton.addEventListener('click', startEventHander); -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ௨Λվྑ͢Δ w ϝοηʔδग़Δ͕ΞΠίϯΛද͍ࣔͤͨ͞ w Ի͡Όؾ͔ͳ͍͜ͱ͋ΔͷͰɺόΠϒϨʔ γϣϯͤͨ͞ํ͕ศར w ·ͣΞΠίϯΛ࡞͢Δ *MMVTUSBUPSͱ͔1IPUPTIPQͰ࡞͢Δ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ௨ʹΞΠίϯΛͤΔ w ࡞ͬͨΞΠίϯΛ ͍͔ͭ͘ͷαΠζʹ͚ͯอଘ͢Δ w ͱΓ͋͑ͣYαΠζͷΞΠίϯΛ JDPOYQOHͱͯ͠อଘ͢Δ // 通知は⾳音だけでなく、バイブレーションもしてみる var createNotification2 = function(message) { // 通知にアイコンを表⽰示させる var n = new Notification("ラーメンタイマー", { body: message, icon: window.location.origin + "/icons/icon128x128.png" }); } -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ௨ͨ͠ΒόΠϒϨʔγϣϯͤ͞Δ w όΠϒϨʔγϣϯ OBWJHBUPSWJCSBUF EVSBUJPO Ͱىಈ͢Δ͜ͱ͕ग़དྷΔ w EVSBUJPOʹྻΛ͢ͱύλʔϯͰ࣮ߦ͢Δ͜ ͱ͕ग़དྷΔ w ࠓճͱΓ͋͑ͣඵόΠϒϨʔγϣϯͤͯ͞ ΈΔ navigator.vibrate(3000); -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ·ͩ·ͩ5P%P͍ͬͺ͍ w ϦηοτϘλϯػೳ w ϦηοτΛԡͨ͠ΒΧϯλʔ͕Δ w ௨Ի͚ͩ͡Όͳ͘ɺԻΛ໐Β͍ͨ͠ w ͡ΌରԠ͠ͳ͍ΧοϓϥʔϝϯʹରԠͨ͠ ͍ w ͜͏ͨ͠5P%Pʹ༏ઌॱҐΛ͚࣮͍ͭͯͯ͠ ͘ -
Unless otherwise noted, the text of and illustrations in this
slide are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License by Hirotaka Nakajima. Keio University Logo is licensed by its copyright holders. ຊͷ՝ w ϥʔϝϯλΠϚʔʹԿΒ͔ͷมߋΛՃ͑ͯಈ࡞ ͍ͯ͠Δঢ়ଶͷεΫϦʔϯγϣοτΛࡱͬͯఏ ग़͍ͯͩ͘͠͞ɻ w ྫ w ͖ͬͨΒจࣈͷ৭Λม͑Δ w ͕࣌ؒมߋͰ͖Δ