<commit_before>.. highlight:: html
Getting Started
===============

Getting started with DuelJS.

Requirements
------------

With DuelJS you no need to any requirements - only vanilla js and modern web browser.
Don't try to use it with node.js without browser emulators.

Installing DuelJS
-----------------

You can install it using bower or simple copy duel.js main file into your site or even clone git repository.

* Bower package: ``bower install duel --save``
* Git repo: ``git clone https://github.com/studentIvan/dueljs.git``
* Main file: `https://github.com/studentIvan/dueljs/blob/master/public/lib/duel.min.js <https://github.com/studentIvan/dueljs/blob/master/public/lib/duel.min.js>`_


Put it into your webpage:
.. code-block:: html
    <script type="text/javascript" src="path/to/duel.min.js"></script>

So we've got all the set up out of the way. Let's write some simple code.
.. code-block:: javascript
    <script type="text/javascript">
    var channel = duel.channel('my_first_channel'); // now you have opened some channel, this tab is connected to it
    setInterval(function () {
        if (channel.currentWindowIsMaster()) { // here you checking is this tab active (in focus) or not
            // you can use alternative syntax: if (window.isMaster()) { ...
            document.title = 'Master ' + duel.getWindowID(); // duel.getWindowID returns a unique browser tab id
        } else {
            document.title = 'Slave ' + duel.getWindowID();
        }
    </script>
<commit_msg>docs updated<commit_after>.. highlight:: html
Getting Started
===============

Getting started with DuelJS.

Requirements
------------

With DuelJS you no need to any requirements - only vanilla js and modern web browser.
Don't try to use it with node.js without browser emulators.

Installing DuelJS
-----------------

You can install it using bower or simple copy duel.js main file into your site or even clone git repository.

* Bower package: ``bower install duel --save``
* Git repo: ``git clone https://github.com/studentIvan/dueljs.git``
* Main file: `https://github.com/studentIvan/dueljs/blob/master/public/lib/duel.min.js <https://github.com/studentIvan/dueljs/blob/master/public/lib/duel.min.js>`_


Put it into your webpage:

.. code-block:: html
    <script type="text/javascript" src="path/to/duel.min.js"></script>

So we've got all the set up out of the way. Let's write some simple code.

.. code-block:: javascript
    <script type="text/javascript">
    var channel = duel.channel('my_first_channel'); // now you have opened some channel, this tab is connected to it
    setInterval(function () {
        if (channel.currentWindowIsMaster()) { // here you checking is this tab active (in focus) or not
            // you can use alternative syntax: if (window.isMaster()) { ...
            document.title = 'Master ' + duel.getWindowID(); // duel.getWindowID returns a unique browser tab id
        } else {
            document.title = 'Slave ' + duel.getWindowID();
        }
    </script>

{'fraction_non_alphanumeric': 0.14035087719298245, 'fraction_numerical': 0.0, 'mean_word_length': 3.0079575596816976, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1969373', 'n_tokens_mistral': 898, 'n_tokens_neox': 871, 'n_words': 307}