All Projects โ†’ nihey โ†’ Nihey.github.io

nihey / Nihey.github.io

๐ŸŒŸ My homepage

Programming Languages

javascript
184084 projects - #8 most used programming language

ไปๅนณ / Nihey Takizawa

My Personal Homepage (here)

Build Status Dependency Status

What is this?

This is a HTML5 presentation that will tell you a bit about me.

How does it work?

Installing & Building

$ npm install
$ npm run build

This is the project structure:

.
โ”œโ”€โ”€ assets
โ”‚   โ”œโ”€โ”€ fonts
โ”‚   โ”œโ”€โ”€ images
โ”‚   โ”‚   โ”œโ”€โ”€ clouds
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ 1.png
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ 2.png
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ 3.png
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ 4.png
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ 5.png
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ 6.png
โ”‚   โ”‚   โ”œโ”€โ”€ favicon.png
โ”‚   โ”‚   โ”œโ”€โ”€ me.png
โ”‚   โ”‚   โ”œโ”€โ”€ random-chars
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ 1.png
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ 2.png
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ 3.png
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ 4.png
โ”‚   โ”‚   โ””โ”€โ”€ terrain.png
โ”‚   โ””โ”€โ”€ texts
โ”‚       โ”œโ”€โ”€ css.txt
โ”‚       โ”œโ”€โ”€ javascript.txt
โ”‚       โ””โ”€โ”€ text.txt
โ”œโ”€โ”€ environment.json
โ”œโ”€โ”€ index.html
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ plugins
โ”‚   โ””โ”€โ”€ html-plugin.js
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ screenshot.png
โ”œโ”€โ”€ scripts
โ”‚   โ”œโ”€โ”€ animate.js
โ”‚   โ””โ”€โ”€ index.js
โ”œโ”€โ”€ styles
โ”‚   โ”œโ”€โ”€ index.less
โ”‚   โ””โ”€โ”€ prefixed.less
โ””โ”€โ”€ webpack.config.js

There are 5 files that handle most of the magic on the presentation:

  • assets/texts/text.txt
  • assets/texts/javascript.txt
  • assets/texts/css.txt
  • scrips/animate.js
  • scripts/index.js

scripts/index.js is our entry point. It'll initialize all the resources the dynamic javascript will need to operate directly on the user browser. You can see it exposes a lot of variables onto the browser global scope (via window).

// 'page' global variable will store anything we might need to make the
// presentation during the 'eval' calls.
window.page = {
  checkTags: function() {
    Object.keys(this.tags).forEach(function(tag) {
      this.control[tag] || ((this.tags[tag] > 0) && this.continues[tag]());
    }, this);
  },
  checkFinished: function() {
    // Hide skip button once all tags have finished
    var allFinished = Object.keys(this.tags).every(tag => this.finished[tag]);
    allFinished && $('#skip').hide();
  },
  control: {},
  continues: {},
  finished: {},
  tags: {
    'text': 1,
    'javascript': 0,
    'css': 0,
  },
};

window.$ = $;
window.hljs = hljs;

scripts/animation.js handle most of the hard work:

  • It operates the semaphore-like structure at window.page.tags.
  • It times the presentation character output.
  • It calls the progress callback so that we may update the page behavior according to the content inside each text-box
  // Tell animate which text it should input, which element id this text should
  // be output, and which function to call on the callback signal
  animate(require('../assets/texts/javascript.txt'), 'javascript', function(finished, chunk) {
    // This callback function will execute the output chunk
    eval(chunk);
    // Highlight its text if a global highlight function was created
    window.highlight && window.highlight('#javascript');
    // Mark this box as finished if it has finished
    window.page.finished.javascript = finished;
    window.page.checkFinished();
  });

assets/texts/*.txt files are the content that will be displayed on the browser. You may notice that there are some special markup on them:

  • ** is the progress markup, it tells animate that the progress callback should be fired on that line

  • ++[anything] or --[anything] tells animate that the semaphore-like window.page.tags should be either incremented or decremented, if a tag value is zero (or any falsy value), its presentation will stop - e.g.: window.page.tags.javascript = 0; window.page.checkTags() will make JavaScript presentation stop.

  • ยง is a slight delay request before proceeding, you can stack those up to increase the delay time: ยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยงยง.

I hope that helps you, feel free to look into this code in any way you want.

Acknowledgements

  • I thank STRML who was the first one I've seen that have done something like that.

  • OpenGameArt provided the images of clouds and terrain

  • Famitsu provided the characters' sprites.

License

This code is released under CC0 (Public Domain)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].