<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Return to first page after a delimited time]]></title><description><![CDATA[<p dir="auto">Hi everybody,</p>
<p dir="auto">First of all thank you for this software and all contributor, i’m french so sorry in advance for my bad english.</p>
<p dir="auto">i have MagicMirror with some pages, and i search a tip to automatically return to the first page after a delimited time.</p>
<p dir="auto">Is it a simple module or a tip on the module MMM-pages to do it automatically?</p>
<p dir="auto">Thanks in advance :)</p>
]]></description><link>https://forum.magicmirror.builders/topic/12945/return-to-first-page-after-a-delimited-time</link><generator>RSS for Node</generator><lastBuildDate>Wed, 20 May 2026 22:27:50 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/12945.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 29 May 2020 11:48:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Return to first page after a delimited time on Fri, 29 May 2020 16:41:33 GMT]]></title><description><![CDATA[<p dir="auto">i solved my case.</p>
<p dir="auto">probably not the better way but here is the js modified :</p>
<pre><code>Module.register('MMM-pages', {

  // We require the older style of function declaration for compatibility
  // reasons.

  /**
   * By default, we have don't pseudo-paginate any modules. We also exclude
   * the page indicator by default, in case people actually want to use the
   * sister module. We also don't rotate out modules by default.
   */
  defaults: {
    modules: [],
    excludes: [], // Keep for compatibility
    fixed: ['MMM-page-indicator'],
    animationTime: 1000,
    rotationTime: 0,
    rotationFirstpage:0,
    rotationDelay: 10000
	
  },

  /**
   * Apply any styles, if we have any.
   */
  getStyles: function () {
    return ['pages.css'];
  },


  /**
   * Modulo that also works with negative numbers.
   *
   * @param {number} x The dividend
   * @param {number} n The divisor
   */
  mod: function (x, n) {
    return ((x % n) + n) % n;
  },

  /**
   * Pseudo-constructor for our module. Makes sure that values aren't negative,
   * and sets the default current page to 0.
   */
  start: function () {
    this.curPage = 0;
    this.rotationPaused = false;

    // Compatibility
    if (this.config.excludes.length) {
      Log.warn('[Pages]: The config option "excludes" is deprecated. Please use "fixed" instead.');
      this.config.fixed = this.config.excludes;
    }

    // Disable rotation if an invalid input is given
    this.config.rotationTime = Math.max(this.config.rotationTime, 0);
    this.config.rotationDelay = Math.max(this.config.rotationDelay, 0);
    this.config.rotationFirstpage = Math.max(this.config.rotationFirstpage, 0);
  },

  /**
   * Handles incoming notifications. Responds to the following:
   *   'PAGE_CHANGED' - Set the page to the specified payload page.
   *   'PAGE_INCREMENT' - Move to the next page.
   *   'PAGE_DECREMENT' - Move to the previous page.
   *   'DOM_OBJECTS_CREATED' - Starts the module.
   *   'QUERY_PAGE_NUMBER' - Requests the current page number
   *
   * @param {string} notification the notification ID
   * @param {number} payload the page to change to/by
   */
  notificationReceived: function (notification, payload) {
    switch (notification) {
      case 'PAGE_CHANGED':
        Log.log('[Pages]: received a notification '
          + `to change to page ${payload} of type ${typeof payload}`);
        this.curPage = payload;
        this.updatePages();
        break;
      case 'PAGE_INCREMENT':
        Log.log('[Pages]: received a notification to increment pages!');
        this.changePageBy(payload, 1);
        this.updatePages();
        break;
      case 'PAGE_DECREMENT':
        Log.log('[Pages]: received a notification to decrement pages!');
        // We can't just pass in -payload for situations where payload is null
        // JS will coerce -payload to -0.
        this.changePageBy(payload ? -payload : payload, -1);
        this.updatePages();
        break;
      case 'DOM_OBJECTS_CREATED':
        Log.log('[Pages]: received that all objects are created;'
          + 'will now hide things!');
        this.sendNotification('MAX_PAGES_CHANGED', this.config.modules.length);
        this.animatePageChange();
        this.resetTimerWithDelay(0);
        break;
      case 'QUERY_PAGE_NUMBER':
        this.sendNotification('PAGE_NUMBER_IS', this.curPage);
        break;
      case 'PAUSE_ROTATION':
        if (!this.rotationPaused) {
          Log.log('[Pages]: pausing rotation due to notification');
          clearInterval(this.timer);
          clearInterval(this.delayTimer);
          this.rotationPaused = true;
        } else {
          Log.warn('[Pages]: Was asked to paused but rotation was already paused!');
        }
        break;
      case 'RESUME_ROTATION':
        if (this.rotationPaused) {
          Log.log('[Pages]: resuming rotation due to notification');
          this.resetTimerWithDelay(this.rotationDelay);
          this.rotationPaused = false;
        } else {
          Log.warn('[Pages]: Was asked to resume but rotation was not paused!');
        }
        break;
      default: // Do nothing
    }
  },

  /**
   * Changes the internal page number by the specified amount. If the provided
   * amount is invalid, use the fallback amount. If the fallback amount is
   * missing or invalid, do nothing.
   *
   * @param {number} amt the amount of pages to move forward by. Accepts
   * negative numbers.
   * @param {number} fallback the fallback value to use. Accepts negative
   * numbers.
   */
  changePageBy: function (amt, fallback) {
    if (typeof amt !== 'number') {
      Log.warn(`[Pages]: ${amt} is not a number!`);
    }

    if (typeof amt === 'number' &amp;&amp; !Number.isNaN(amt)) {
      this.curPage = this.mod(
        this.curPage + amt,
        this.config.modules.length
      );
    } else if (typeof fallback === 'number') {
      this.curPage = this.mod(
        this.curPage + fallback,
        this.config.modules.length
      );
    }
  },

  /**
   * Handles hiding the current page's elements and showing the next page's
   * elements.
   */
  updatePages: function () {
    // Update iff there's at least one page.
    if (this.config.modules.length !== 0) {
      this.animatePageChange();
      if (!this.rotationPaused) {
        this.resetTimerWithDelay(this.config.rotationDelay);
      }
      this.sendNotification('NEW_PAGE', this.curPage);
    } else { Log.error("[Pages]: Pages aren't properly defined!"); }
  },

  /**
   * Animates the page change from the previous page to the current one. This
   * assumes that there is a discrepancy between the page currently being shown
   * and the page that is meant to be shown.
   */
  animatePageChange: function () {
    const self = this;

    // Hides all modules not on the current page. This hides any module not
    // meant to be shown.
    MM.getModules()
      .exceptWithClass(this.config.fixed)
      .exceptWithClass(this.config.modules[this.curPage])
      .enumerate(module =&gt; module.hide(
        self.config.animationTime / 2,
        { lockString: self.identifier }
      ));

    // Shows all modules meant to be on the current page, after a small delay.
    setTimeout(() =&gt; {
      MM.getModules()
        .withClass(self.config.modules[self.curPage])
        .enumerate((module) =&gt; {
          module.show(
            self.config.animationTime / 2,
            { lockString: self.identifier }
          );
        });
    }, this.config.animationTime / 2);
  },

  /**
   * Resets the page changing timer with a delay.
   *
   * @param {number} delay the delay, in milliseconds.
   */
  resetTimerWithDelay: function (delay) {
    if (this.config.rotationTime &gt; 0) {
      // This timer is the auto rotate function.
      clearInterval(this.timer);
      // This is delay timer after manually updating.
      clearInterval(this.delayTimer);
      const self = this;

      this.delayTimer = setTimeout(() =&gt; {
        self.timer = setInterval(() =&gt; {
          self.sendNotification('PAGE_INCREMENT');
          self.changePageBy(1);
          self.updatePages();
        }, self.config.rotationTime);
      }, delay);
    }if (this.config.rotationFirstpage &gt; 0) {
      // This timer is the auto rotate function.
      clearInterval(this.timer);
      // This is delay timer after manually updating.
      clearInterval(this.delayTimer);
      const self = this;

      this.delayTimer = setTimeout(() =&gt; {
        self.timer = setInterval(() =&gt; {
          self.sendNotification('PAGE_CHANGED', 0);
          self.changePageBy(-this.curPage);
          self.updatePages();
        }, self.config.rotationFirstpage);
      }, delay);
	}
  },
});

</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/76096</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/76096</guid><dc:creator><![CDATA[Burnallover]]></dc:creator><pubDate>Fri, 29 May 2020 16:41:33 GMT</pubDate></item><item><title><![CDATA[Reply to Return to first page after a delimited time on Fri, 29 May 2020 12:55:11 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for your reply,</p>
<p dir="auto">The problem is i have some confidential information on other page and i don’t want each page to loop.</p>
<p dir="auto">I just want that when i manually go on the third page, after 30 sec MagicMirror automatically return on the first one.</p>
]]></description><link>https://forum.magicmirror.builders/post/76085</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/76085</guid><dc:creator><![CDATA[Burnallover]]></dc:creator><pubDate>Fri, 29 May 2020 12:55:11 GMT</pubDate></item><item><title><![CDATA[Reply to Return to first page after a delimited time on Fri, 29 May 2020 11:54:14 GMT]]></title><description><![CDATA[<p dir="auto">salut.</p>
<p dir="auto">You can use mmm pages and define display time for all pages. there is an automaticallly loop</p>
]]></description><link>https://forum.magicmirror.builders/post/76078</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/76078</guid><dc:creator><![CDATA[chassain 0]]></dc:creator><pubDate>Fri, 29 May 2020 11:54:14 GMT</pubDate></item></channel></rss>