Skip to content

Commit

Permalink
Merge pull request #45 from IwamotoKakeru/fix/cookie-mangager
Browse files Browse the repository at this point in the history
fix(CookieManager): cookieを連想配列形式にしてから値を取得するように変更
  • Loading branch information
IwamotoKakeru authored Jun 2, 2024
2 parents f2a1b7a + 6499112 commit 04088ec
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Assets/Plugins/CookieManager.jslib
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@ function SetClearTimes(clearTimes) {
console.log("Set clearTimes = %d ", clearTimes);
}

// TODO: 現在の実装だとclearTimes以外の保存したいデータに対応できないので修正
function GetClearTimes() {
var clearTimes;
var clearTimes = 0;
var arr = new Array();

try {
clearTimes = parseInt(document.cookie.split("=")[1]);
if (document.cookie != "") {
var tmp = document.cookie.split("; ");
for (var i = 0; i < tmp.length; i++) {
var data = tmp[i].split("=");
arr[data[0]] = decodeURIComponent(data[1]);
}
}
clearTimes = parseInt(arr["clear_times"]);
console.log("clearTimes = %d ", clearTimes);
} catch {
console.log("Unable Get clearTimes", clearTimes);
}
return clearTimes;
}

// 使用したい関数をオブジェクトとして配置
const cookiePlugins = {};
cookiePlugins[SetClearTimes.name] = SetClearTimes;
cookiePlugins[GetClearTimes.name] = GetClearTimes;
Expand Down

0 comments on commit 04088ec

Please sign in to comment.