Skip to content

Instantly share code, notes, and snippets.

View ncmbedu's full-sized avatar

ニフクラ mobile backend Education ncmbedu

View GitHub Profile
@ncmbedu
ncmbedu / exercise_7.js
Created November 2, 2020 07:17 — forked from natsumo/exercise_7.js
参考書第二版 応用編まとめ模範解答(虫食い:その7)
// *********【虫食い:その7】メッセージデータの取得 **********
chat.order("createDate", true)
.limit(5)
.include("user")
.fetchAll()
.then(function(records){
// 取得成功時の処理
console.log("取得成功:" + JSON.stringify(records));
setData(records);
})
@ncmbedu
ncmbedu / exercise_6.js
Created November 2, 2020 07:17 — forked from natsumo/exercise_6.js
参考書第二版 応用編まとめ模範解答(虫食い:その6)
// ****【虫食い:その6】参照権限とポインタを設定してデータを保存 *****
// [NCMB] 参照権限とポインタを設定してデータを保存
chat.set("message", message)
.set("user", currentUser)
.set("acl", acl)
.save()
.then(function() {
// 保存成功時の処理
console.log("保存成功");
// 画面更新
@ncmbedu
ncmbedu / exercise_5.js
Created November 2, 2020 07:17 — forked from natsumo/exercise_5.js
参考書第二版 応用編まとめ模範解答(虫食い:その5)
// *************【虫食い:その5】参照権限の設定 *************
// [NCMB] 参照権限の設定
var acl = new ncmb.Acl();
// 全員読み込み可・メッセージ作成ユーザーのみ書き込み可
acl.setPublicReadAccess(true)
.setUserReadAccess(currentUser, true)
.setUserWriteAccess(currentUser, true);
// ********************************************************
@ncmbedu
ncmbedu / exercise_4.js
Created November 2, 2020 07:17 — forked from natsumo/exercise_4.js
参考書第二版 応用編まとめ模範解答(虫食い:その4)
// *********【虫食い:その4】カレントユーザーの取得 *********
// [NCMB] カレントユーザーの取得
currentUser = ncmb.User.getCurrentUser();
// ********************************************************
@ncmbedu
ncmbedu / exercise_3.js
Created November 2, 2020 07:17 — forked from natsumo/exercise_3.js
参考書第二版 応用編まとめ模範解答(虫食い:その3)
// ***********【虫食い:その3】ログアウトの実装 *************
// ログアウト
ncmb.User.logout()
.then(function(user) {
// ログアウト成功時の処理
console.log("ログアウト成功:" + JSON.stringify(user));
currentUser = null;
window.location.href = "./index.html";
})
.catch(function(error) {
@ncmbedu
ncmbedu / exercise_2.js
Created November 2, 2020 07:17 — forked from natsumo/exercise_2.js
参考書第二版 応用編まとめ模範解答(虫食い:その2)
// ************【虫食い:その2】ログインの実装 **************
// ユーザー名・パスワードでログイン
ncmb.User.login(userName, password)
.then(function(user) {
// ログイン成功時の処理
console.log("ログイン成功:" + JSON.stringify(user));
window.location.href = "./chatPage.html";
})
.catch(function(error) {
// ログイン失敗時の処理
@ncmbedu
ncmbedu / exercise_1.js
Created November 2, 2020 07:17 — forked from natsumo/exercise_1.js
参考書第二版 応用編まとめ模範解答(虫食い:その1)
// **********【⾍⾷い:その1】新規ユーザー登録の実装 *************
// ユーザークラスのインスタンスを⽣成
var user = new ncmb.User();
// ユーザー名/パスワードで新規ユーザー登録
user.set("userName", userName)
.set("password", password)
.signUpByAccount()
.then(function (user) {
// 新規ユーザー登録成功時の処理
console.log("新規ユーザー登録成功:" + JSON.stringify(user));
@ncmbedu
ncmbedu / practice_10_app.js
Created November 2, 2020 07:15 — forked from natsumo/practice_10_app.js
参考書第二版 第10章章末演習「ユーザーによって見え方の違うお知らせアプリを作る」模範解答 app.js
function passwordCheck(checked) {
var pwd = document.getElementById("password");
if(checked) {
pwd.setAttribute("type", "text");
} else {
pwd.setAttribute("type", "password");
}
}
var applicationKey = "******";
@ncmbedu
ncmbedu / practice_10_mainPage.html
Created November 2, 2020 07:15 — forked from natsumo/practice_10_mainPage.html
参考書第二版 第10章章末演習「ユーザーによって見え方の違うお知らせアプリを作る」模範解答 mainPage.html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta http-equiv="Content-Security-Policy" content="default-src * data: gap: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
<link rel="stylesheet" href="components/loader.css">
<script src="components/loader.js"></script>
<script src="js/app.js"></script>
</head>
@ncmbedu
ncmbedu / practice_09_mainPage.html
Created November 2, 2020 07:14 — forked from natsumo/practice_09_mainPage.html
参考書第二版 第9章章末演習「新規ユーザー登録・ログイン・ログアウトを実装したアプリを作る」模範解答 mainPage.html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta http-equiv="Content-Security-Policy" content="default-src * data: gap: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
<link rel="stylesheet" href="components/loader.css">
<script src="components/loader.js"></script>
<script src="js/app.js"></script>
</head>