Access page loads

View Demo

Source


<!doctype html>

<html lang="en">

<head>
  <meta charset="utf-8">

  <title>Custom profile button / Muut Demo</title>

  <!-- optimize for mobile versions -->
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <!-- force latest IE rendering engine -->
  <meta http-equiv="X-UA-Compatible" content="IE=edge">

  <!-- stylesheets -->
  <link rel="stylesheet" href="https://cdn.muut.com/1/moot.css">

  <!-- page specific CSS -->
  <style>
    body {
      font-family: "myriad pro", tahoma, verdana, arial, sans-serif;
      font-size: 18px; margin: 0; padding: 0;
    }
  </style>

</head>

<body>
  <div id="content">

    <!-- Muut client -->
    <a class="muut" href="https://muut.com/i/goma">The GoMA community (demo)</a>

  </div>

  <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
  <script src="https://cdn.muut.com/1/moot.min.js"></script>

  <script>
    // know when muut API is ready
    muut(function(app) {

      var btn

      // called on every page load (profile, categories etc...)
      app.on('load', function(page) {

        // insert custom button on user profile page
        if (page.type == 'user') {
          btn = $('<button>').text('A custom button').insertAfter('#m-user-profile').click(function() {
            var user = page.user
            alert(user.username)
          })

        // remove it on other pages
        } else {
          btn && btn.remove()
        }

      })

    })
  </script>

</body>

</html>

View Demo