Файлы cookie JavaScriptHtml

Программисты Html
Ответить
Anonymous
 Файлы cookie JavaScript

Сообщение Anonymous »

Я пытаюсь настроить файлы cookie с помощью блокнота, чтобы на странице сохранялось то, что находится на листе персонажа. Я попробовал несколько вещей, но, похоже, это не работает. Кажется, это в разделе «Файлы cookie».
Я разместил всю веб-страницу. Я попробовал несколько вещей, например, поиск синтаксиса и чтение файлов cookie с помощью журналов консоли. Эта часть работает. Что не работает, так это часть, в которой загружается файл cookie при загрузке страницы. Если это не сработает, я просто обрежу код до раздела cookie.
Размещенная веб-страница: таблица персонажей Одинокого волка


Feuille de jeu pour les livres Loup Solitaire première section

//******************************
//******************************
//*********Javascript***********
//******************************
//******************************

CombatTable = new Array(13);

for(i=0; i myValue)
myValue = myPull;
}
document.getElementById("Chiffres").innerHTML = myValue;
}

//For combat returns a number instead of writing to the webpage
//Nine is bad and zero is good. But one is like... I forgot
function PullCombatNumber(myCount){
myValue = 0;
for(i=0; i < myCount; i++){
myPull = Math.floor(10 * Math.random());
if(myPull > myValue)
myValue = myPull;
}
return(myValue);
}

function HitMe(){
console.log('Found');
Difficulty = document.getElementById("theDifficulty").value;
myHp = document.getElementById("PlayerHP").value;
hisHp = document.getElementById("EnnemyHP").value;
console.log("Read my HP " + myHp);
console.log("Read his HP " + hisHp);
console.log("Read Difficulty " + Difficulty);
SkillCheck = document.getElementById("Agility").value - document.getElementById("EnnemyAgility").value;
if(SkillCheck > 11)
SkillCheck = 11;
if(SkillCheck < -11)
SkillCheck = -11;
console.log("Skill Check: " + SkillCheck);
SkillIndex = Math.ceil(SkillCheck / 2);
SkillIndex += 5;
console.log("Skill Index: " + SkillIndex);
if(SkillIndex >= 6){
SkillIndex++;
console.log("Skill Index: " + SkillIndex);
}
theHit = PullCombatNumber(Difficulty);
console.log("TheHit " + theHit);
theHit = Math.abs(theHit - 9);
console.log("TheHit " + theHit);
myDamage = CombatTable[SkillIndex][0][theHit];
hisDamage = CombatTable[SkillIndex][1][theHit];
console.log("myDamage: " + myDamage);
console.log("hisDamage: " + hisDamage);
myHp -= hisDamage;
hisHp -= myDamage;
console.log("My HP: " + myHp);
console.log("His HP: " + hisHp);
document.getElementById("PlayerHP").value = myHp;
document.getElementById("EnnemyHP").value = hisHp;

//Done

//Works, array is read backwards though.
//I'll just log the HP and be done for now.

/*Ok so.... There is a problem with the table.
It reads the whole section isntead of giving me an integer (Grrr)*/

//CombatTable
//scales from skill -12 to +12 at 0 to 12. Ish.
//0 to 12. 13 length. 5 both sides, middle and excess.
//fix the skill check for an index, might be done.
//0 is uh, him or me, other one isn't.

//I have my random system 0 to 9. (is good).
//Book system goes 1 is bad 0 is good.
//Index scales to my system
//Tables are just a different label.
//SO!!!

//Skill check gets me an index
//Other index is the hit
//Hp changes
//.....
//Go!

//Needs to seek the tables
//I logged them from top to bottom. Top is bad, i think.
//Yeah....
//So i would just log the..
//Tired i guess.

//The numbers scale weird
//I need to scale the skill check to an index for the tables
//Zero divided to two is zero.
//Section is done.

//Thinking of adding a background
//Cookies...
//Divs, colorful
//Needs to fix them floatz
//Later
}

//*************************************
//***********COOKIE SECTION************
//*************************************

function Surprise(){
console.log('Save the game');
console.log(document.cookie);
document.cookie = "Number=88;love=fake;";
document.cookie = "love=true;";
document.cookie = "myTest01= Bye!";
console.log(document.cookie);
}

function SneakyShhh(){
document.cookie = "name=Mathieu;";
// document.cookie = "expires=Thu, 01 Jan 2026 00:00:00 UTC";
}

function LoadTheSheet(){
console.log('Load the sheet');
let allCookies = decodeURIComponent(document.cookie);
let myArray = allCookies.split(';');
for(i = 0; i < 15; i++)
console.log(myArray);
}

function debugMe(){
testArray = [[[0,1],[2,3]]];
console.log("Test: " + testArray[0][0][1]);
console.log("Test: " + testArray[0][0][0]);
console.log("Test: " + testArray[0][1][1]);
console.log("Test: " + testArray[0][1][0]);
}

function testingCookie01(){

/*******************VERBOSE SNIP*****************************

// console.log();
// Toss a couple of cookie defenitions and look up the syntax. Overwriting eachother. See what is read.

console.log('Testing cookies 01');
// document.cookie = "username=;myTest02=Hello?;";
document.cookie = 8;
console.log(document.cookie);
console.log(document.cookie[0]);
console.log(document.cookie.value);

console.log('Testing cookies 02');
let load10 = decodeURIComponent(document.cookie);
let load11 = load10.split(';');
console.log(load11);
console.log(load11[0]);

console.log('Comment00');
console.log(document.cookie);
console.log(toString(document.cookie));
let myTest00 = document.cookie;
console.log(myTest00[0]);
console.log(myTest00);
console.log(myTest00.value);
console.log(myTest00.myTest01);

console.log(myTest00.myTest01);
console.log(toString(myTest00.myTest01));
// console.log(myTest00.myTest01.value);

console.log('Comment02');
let myTest02 = 'myTest01=';
console.log(myTest02);

console.log('Comment03');
let load00 = decodeURIComponent(document.cookie);
console.log(load00);
let load01 = load00.split(';');
console.log(load01);
console.log(load01.myTest01);

console.log('Comment04');
console.log(load01.length);
console.log(toString(load01));
console.log(toString(load01.value));
console.log(toString(load01.myTest01));

console.log('Comment05');
console.log(load01[0]);

console.log('Comment06');
let myTest10 = 10;
console.log(myTest10);

//omg, i'm thinking a cookie blocker.
//.....
//check on that later.
//*******************************************************************
//Yeah.

*******************VERBOSE SNIP******************************/

document.cookie = "name=MAthieu";
}

//*********************************

//*********************************

//*************HTML****************

//*********************************

//*********************************









Disciplines Kai











Armes





Objets Spéciaux

Sac à dos

















Repas



Bourse





Habilité



Endurance Maximum/Actuelle







Combat


Habilité de l'ennemi



Endurance Loup Solitaire



Endurance Ennemi



Difficulté

















Table du hasard









Подробнее здесь: https://stackoverflow.com/questions/798 ... pt-cookies
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Html»