inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Dec 19, 2015 23:07:08 GMT -8
I'm a bit stuck on a few things -
1. How to store things onto a key (I've managed to set it!) 2. How to convert the server date into a date (as it does not look like a date)
//Problem: Award people Money on their birthday
//Solution: P1 - Store when a persons birthday is.
//P1.1 - Check against server if this is persons Birthday
//P2. If yes check key if money has already been given.
//Variable Hoarde
var birthdayPay = pb.plugin.get('monetary_birthday');
var dateServer = pb.data('serverDate');
var BirthdayKey = pb.plugin.key('birthday');
var birthDate = pb.data('user').birthday
BirthdayKey.set;
console.log (BirthdayKey);
console.log(dateServer);
//P3. If money hasn't already been given given money.(check)
if (birthDate===dateServer && BirthdayKey.get()===false){
monetary.data(yootil.user.id()).increase.money(parseFloat( birthdayPay.settings.pay) );
//p4. Store that yes money has been paid to key
BirthdayKey.push();
console.log(BirthdayKey);
}
else if (birthDate!==dateServer){
alert("Today is not your Birthday!");
}
else {
alert("You've already been paid!");
}
This is what I've got so far (I'm sure that I've done some clumsy coding so far but I'm trying!)
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Dec 20, 2015 3:21:01 GMT -8
$(document).ready(function() { var today = new Date(proboards.data("serverDate")); var dd = today.getDate(); var mm = today.getMonth()+1; //January is 0! var hbirthday = localStorage.getItem("hbirthday"); if(hbirthday != 'yes') if(parseInt(dd) == parseInt(pb.data('user').birthday.day) && parseInt(mm) == parseInt(pb.data('user').birthday.month)) {pb.window.alert(pb.plugin.get('happy_birthday').settings.text_to_display) localStorage.setItem("hbirthday", 'yes');} if(parseInt(dd) != parseInt(pb.data('user').birthday.day)){localStorage.removeItem("hbirthday")} }); This is my simple happy birthday code. Should help with serverdate and birthday
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Dec 20, 2015 3:43:03 GMT -8
ty... I shall sita nd try and understand it at least.
So if I get it right - setting new Date will sort the proboards data serverDate out into something it should understand correct?
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Dec 20, 2015 13:20:07 GMT -8
ty... I shall sita nd try and understand it at least. So if I get it right - setting new Date will sort the proboards data serverDate out into something it should understand correct? New date is a javascript function that turns a timestamp (which includes a time from year to millisecond in a condensed number) into a date object that can be easily read with date commands. (The process is like turning machine code into English for javascript)
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Dec 21, 2015 3:00:02 GMT -8
I'm a bit stuck on a few things - 1. How to store things onto a key (I've managed to set it!) 2. How to convert the server date into a date (as it does not look like a date)
//Problem: Award people Money on their birthday
//Solution: P1 - Store when a persons birthday is.
//P1.1 - Check against server if this is persons Birthday
//P2. If yes check key if money has already been given.
//Variable Hoarde
var birthdayPay = pb.plugin.get('monetary_birthday');
var dateServer = pb.data('serverDate');
var BirthdayKey = pb.plugin.key('birthday');
var birthDate = pb.data('user').birthday
BirthdayKey.set;
console.log (BirthdayKey);
console.log(dateServer);
//P3. If money hasn't already been given given money.(check)
if (birthDate===dateServer && BirthdayKey.get()===false){
monetary.data(yootil.user.id()).increase.money(parseFloat( birthdayPay.settings.pay) );
//p4. Store that yes money has been paid to key
BirthdayKey.push();
console.log(BirthdayKey);
}
else if (birthDate!==dateServer){
alert("Today is not your Birthday!");
}
else {
alert("You've already been paid!");
}
This is what I've got so far (I'm sure that I've done some clumsy coding so far but I'm trying!) var BirthdayKey = pb.plugin.key('birthday'); The key should be named monetary birthday key for consistancy Birthday isnt a unique name and doesnt really describe the plugin Var BirthdayKey = pb.plugin.key('monetary_birthday_key')
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Dec 21, 2015 3:04:01 GMT -8
Remove BirthdayKey.set Also dont use birthdaykey.push() Use birthdaykey.set(new value)
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Dec 21, 2015 10:28:11 GMT -8
Remove BirthdayKey.set Also dont use birthdaykey.push() Use birthdaykey.set(new value) Why set and can you explain what 'new value' it should be etc? Cause I don't understand this bit?
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Dec 21, 2015 16:09:10 GMT -8
Remove BirthdayKey.set Also dont use birthdaykey.push() Use birthdaykey.set(new value) Why set and can you explain what 'new value' it should be etc? Cause I don't understand this bit? Your key is not an array so you do not use push. Set is like storing a variable of any type. New value would be the variable you are now storing on the server. This would have to be done through a popup
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Dec 24, 2015 19:57:14 GMT -8
On risk of sounding stupid.... would it not be able to be done by pushing a variable'd date to the key (or setting or w/e) when the if codeblock runs, at the same time having a variable called isTrue set by default to 'false', but during the if codeblock setting it to true and creating a function that tests "has 364 days passed since last time/has the year changed? - if yes set isTrue back to false)
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Dec 26, 2015 3:03:30 GMT -8
On risk of sounding stupid.... would it not be able to be done by pushing a variable'd date to the key (or setting or w/e) when the if codeblock runs, at the same time having va variable called isTrue set by default to 'false', but during the if codeblock setting it to true and creating a function that tests "has 364 days passed since last time/has the year changed? - if yes set isTrue back to false) Sounds complicated. Check the date in the key. Compare that to the server date. If the key is empty award them a birthday. Save the users birthday including year. If the key has a date, check for a different year. If the year is different see if its after the month. If the month is later or equal to, check if the day is greater or equal to, award the birthday or dont. Save new birthdate. Make sure to account for leap years. Or evaluate the two timestamps in a subtraction equation. Which might be more confusing
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Jan 3, 2016 3:00:30 GMT -8
I'm a bit stuck on a few things - 1. How to store things onto a key (I've managed to set it!) 2. How to convert the server date into a date (as it does not look like a date)
//Problem: Award people Money on their birthday
//Solution: P1 - Store when a persons birthday is.
//P1.1 - Check against server if this is persons Birthday
//P2. If yes check key if money has already been given.
//Variable Hoarde
var birthdayPay = pb.plugin.get('monetary_birthday');
var dateServer = pb.data('serverDate');
var BirthdayKey = pb.plugin.key('birthday');
var birthDate = pb.data('user').birthday
BirthdayKey.set;
console.log (BirthdayKey);
console.log(dateServer);
//P3. If money hasn't already been given given money.(check)
if (birthDate===dateServer && BirthdayKey.get()===false){
monetary.data(yootil.user.id()).increase.money(parseFloat( birthdayPay.settings.pay) );
//p4. Store that yes money has been paid to key
BirthdayKey.push();
console.log(BirthdayKey);
}
else if (birthDate!==dateServer){
alert("Today is not your Birthday!");
}
else {
alert("You've already been paid!");
}
This is what I've got so far (I'm sure that I've done some clumsy coding so far but I'm trying!) How far have you gotten?
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Jan 3, 2016 4:43:02 GMT -8
I'm really stuck on just the key stuff - I don't understand half of what you've said with the keys or how to use a pb dialog (and I can't find any api related information in terms of syntax on how it would work).
//Problem: Award people Money on their birthday //Solution: P1 - Store when a persons birthday is. //P1.1 - Check against server if this is persons Birthday //P2. If yes check key if money has already been given. //Variable Hoarde var birthdayPay = pb.plugin.get('monetary_birthday'); var dateServer = new Date (pb.data('serverDate')); var BirthdayKey = pb.plugin.key('birthday_money'); var birthDay = pb.data('user').birthday.day; var birthMonth= pb.data('user').birthday.month; var birthDate=""+ birthDay + birthMonth; var isTrue=false;
BirthdayKey.set; console.log (BirthdayKey); console.log(dateServer); console.log(birthDate);
//P3. If money hasn't already been given given money.(check) if (isTrue=== false ){ monetary.data(yootil.user.id()).increase.money(parseFloat( birthdayPay.settings.pay) ); alert("enjoy your money!"); isTrue=true;
//p4. Store that yes money has been paid to key BirthdayKey.set(isTrue); console.log(BirthdayKey); } else if (isTrue===true){ alert("Today is not your Birthday!"); } else { alert("You've already been paid!"); }
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Jan 3, 2016 22:45:20 GMT -8
I'm really stuck on just the key stuff - I don't understand half of what you've said with the keys or how to use a pb dialog (and I can't find any api related information in terms of syntax on how it would work). //Problem: Award people Money on their birthday //Solution: P1 - Store when a persons birthday is. //P1.1 - Check against server if this is persons Birthday //P2. If yes check key if money has already been given. //Variable Hoarde var birthdayPay = pb.plugin.get('monetary_birthday'); var dateServer = new Date (pb.data('serverDate')); var BirthdayKey = pb.plugin.key('birthday_money'); var birthDay = pb.data('user').birthday.day; var birthMonth= pb.data('user').birthday.month; var birthDate=""+ birthDay + birthMonth; var isTrue=false;
BirthdayKey.set; console.log (BirthdayKey); console.log(dateServer); console.log(birthDate);
//P3. If money hasn't already been given given money.(check) if (isTrue=== false ){ monetary.data(yootil.user.id()).increase.money(parseFloat( birthdayPay.settings.pay) ); alert("enjoy your money!"); isTrue=true;
//p4. Store that yes money has been paid to key BirthdayKey.set(isTrue); console.log(BirthdayKey); } else if (isTrue===true){ alert("Today is not your Birthday!"); } else { alert("You've already been paid!"); }
U really havent gotten anywhere. Is there a more directed line if questioning you want to go through or have you seen my guide?
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Jan 3, 2016 22:47:19 GMT -8
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Jan 4, 2016 0:19:48 GMT -8
I've read that (just) - its still making no sense @_@ I'm starting to think I'm too stupid to take any of this in no matter how much I try
|
|