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 Jul 14, 2014 23:04:49 GMT -8
Okay so I have a field that I only wish to use back end to sort the missions posted in order of importance (10 is critical 0 is least critical).
This is to be included within a for loop as its only used on all mission display. How would I use this to do so:
missions.settings.mission_creation.priority_backend And the for loop:
for (index = 0, len = missions.settings.mission_creation.length; index < len; index = index + 1) {
}
I'm also wondering if there's any way to create a notification when a new mission is posted on the missions board that show on the main page. I'm aware this would rely on a key
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Jul 16, 2014 0:13:51 GMT -8
Use the sort method, but pass in a function like so...
var chocolate_covered_prawn_pringles = missions.settings.mission_creation.sort(function(a, b){ return (a["priority_backend"] > b["priority_backend"])? 1 : 0; });
As for notifications, I wouldn't bother with a key, I would just use localStorage, that way you can write to it anytime. The problem with a key, is that the member must initiate (member action) the writing / updating (i.e by clicking a button, making a post, ...), so it could be a little while before they know about a new mission.
|
|
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 Jul 16, 2014 0:34:04 GMT -8
Thanks Peter - could you give me some more info on localStorage? Pretty much the way I'd be planning on notifications working is initally if they've never visited the page it would show a notification in the bottom right "Hey have you checked missions today" following that I'm trying to work out a way to then when I add in new missions it'd then show "New missions have been added to the board".
Then again I'm also thinking of creating a new profile tab "Missions done" type page for each person ((I have too many ideas!)
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Jul 16, 2014 0:36:57 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 Jul 16, 2014 0:38:37 GMT -8
Okay I get how variables work, but how would I then throw this in to make it sort, would it need to be then incorporated into the for loop to sort it? ((Sorry for the questions!))
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Jul 16, 2014 2:23:11 GMT -8
Call the "sort" method on your autoform array, it will do the magic for you (use the code I posted above).
var sorted_missions = autoform.sort(...)
Once that is done, you then have an autoform array sorted based on the priority, you then loop through them as you have been so they are displayed on the page.
|
|
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 Jul 16, 2014 8:18:27 GMT -8
and to reference the autoform it'd be the name of the autoform correct?
|
|