Uncaught ReferenceError: прием не определен - PullRequest
0 голосов
/ 01 сентября 2018

(ЭТО ИСПРАВЛЕНО СЕЙЧАС) (Если вы хотите использовать это, не забудьте поместить его внутри под и перед и. Завершите тег body, так как вы должны поместить его в начало и конец кода. Поэтому я пытаюсь реализовать функцию, с помощью которой вы можете опубликовать свой статус, а другие смогут увидеть, что другие написали, основываясь на логине Google, который вы получаете в начале. Я кодирую Javascript внутри HTML документа, и у меня есть один CSS рядом с ним. Я использовал Firebase хостинг, облако и базу данных в реальном времени с NODE.JS. Часть моего кода основана на видео этого джентльмена: https://youtu.be/QuiZE5ZE4EE (Пол Баумгартен) Это точная ошибка:

Uncaught ReferenceError: receive is not defined
at receiveUpdate ((index):141)
at firebase-app.js:1677
at fc (firebase-app.js:1677)
at bf (firebase-app.js:1677)
at cf (firebase-app.js:1677)
at Object.G (firebase-app.js:1677)
at firebase-app.js:1677
at Ag.g.wd (firebase-app.js:1677)
at og.wd (firebase-app.js:1677)
at Yf.Xf (firebase-app.js:1677)

Html

var config = {
  apiKey: "AIzaSyC1ls01V0-7A1nCnZwfnuBsUwaboTUOE1E",
  authDomain: "ariadnes-string.firebaseapp.com",
  databaseURL: "https://ariadnes-string.firebaseio.com",
  projectId: "ariadnes-string",
  storageBucket: "ariadnes-string.appspot.com",
  messagingSenderId: "737704779364"
};
firebase.initializeApp(config);

function login() {
  function newLoginHappened(user) {
    if (user) {
      // User is signed in
      app(user);
    } else {
      var provider = new firebase.auth.GoogleAuthProvider();
      firebase.auth().signInWithRedirect(provider);
    }
  }

  firebase.auth().onAuthStateChanged(newLoginHappened)
}

function app(user) {
  // user.displayName
  // user.email
  // user.photoURL
  // user.uid

  function updateMyStatus(e) {
    var myUpdate = {};
    myUpdate.email = user.email;
    myUpdate.displayName = user.displayName;
    myUpdate.status = document.getElementById("clientStatus").value;
    fb.child("user.uid").set(myUpdate);
  }

  function receiveUpdate(received) {
    var data = received.val();
    console.log(data);
    document.getElementById("messages").innerHtml = "";
    for (var key in data) {
      var person = data[key];
      var p = "<p>" + person.displayName + " (" + person.email + ") said:" + person.status + "</p>";
      document.getElementById("messages").innerHTML += p;
    }
  }

  document.getElementById("clientName").innerHTML = user.displayName;
  document.getElementById("clientPhoto").setAttribute("src", user.photoURL)
  var fb = firebase.database().ref("whatsmystatus");
  document.getElementById("clientStatus").addEventListener("input", updateMyStatus);
  fb.on("value", receiveUpdate);
}
window.onload = login;
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>GSS</title>
  <link href="GSS_Home_Style.css" rel="stylesheet" type="text/css" />
  <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
  <link rel="icon" href="/favicon.ico" type="image/x-icon">
</head>
<header>
  <img src="logo.png" alt="logo" class="logo" />
  <input type="checkbox" id="nav-toggle" class="nav-toggle">
  <nav>
    <ul>
      <li><a href="GSS_Home_Html.html">Home</a></li>
      <li><a href="#">Forums</a></li>
      <li><a href="#">Settings</a></li>
      <li><a href="#">Support</a></li>
      <li><a href="GSS_Login_Html.html">Login</a></li>
    </ul>
  </nav>
  <label for="nav-toggle" class="nav-toggle-label">
            <span></span>
        </label>
</header>

<div class="loginbox">
  <img id="clientPhoto" src="" class="avatar">
  <h1>Hello <span id="clientName"></span></h1>
  <form>
    <div style="text-align: center">
      <div style="padding-bottom: 20px;">
        <p>What is your current status?</p>
        <div>
          <input type="text" id="clientStatus" maxlength="100" placeholder="Status...">
        </div>
        <p>Other people have left the following status messages:</p>
        <div id="messages"></div>

      </div>
    </div>
  </form>
</div>
<section id="hideonmobile2">
  <div class="loginboxright">
    <h1>Latest News</h1>
    <form>
      <div style="text-align: center">
        <div style="padding-bottom: 20px;">
          <p>Currently working on website - desktop program under construction</p>
          <p>Welcome to "Gamer's String". Our program is buildt to make an amazing community where you can post, view and complete tips and tricks. Get your post to the top by leveling up or purchasing our pro version. <strong>Good luck!</strong></p>
        </div>
      </div>
    </form>
  </div>
</section>


<section id="hideonmobile3">
  <footer>
    <div class="footer-social-icons">
      <ul class="social-icons">
        <li>
          <a href="
        https://www.facebook.com/ariadnes.string.9" class="social-icon">
            <i class="fa fa-facebook"></i></a>
        </li>
      </ul>
    </div>
  </footer>
</section>
<section id="showonmobile1">
  <footer>
    <div class="footer-social-icons">
      <ul class="social-icons">
        <li>
          <a href="https://www.facebook.com/ariadnes.string.9" class="social-icon"><i class="fa fa-facebook"></i></a>
        </li>
      </ul>
    </div>
  </footer>
  <script src="https://www.gstatic.com/firebasejs/3.8.0/firebase.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
  </script>  <script src="#">  </script>

У меня был CSS, но я решил, что ради этого не имеет значения
Я был бы очень признателен за любую помощь.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...