no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | protogrid:create_new_card_via_link [2018-11-09 10:39] (current) – created 46.140.51.3 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Create New Card Via Link ====== | ||
+ | Imagine you need to check if a certain Card for a given Proto exists and if not you want to redirect the user to crate a new Card. | ||
+ | To do so, you first need to create a new Card-Key (example in javascript) | ||
+ | <code javascript> | ||
+ | function generate_key() | ||
+ | { | ||
+ | //helper functions to generate random strings of length 4 | ||
+ | function s4() | ||
+ | { | ||
+ | return Math.floor((1 + Math.random()) * 0x10000) | ||
+ | .toString(16) | ||
+ | .substring(1); | ||
+ | } | ||
+ | return s4() + s4() + ' | ||
+ | s4() + ' | ||
+ | } | ||
+ | </ | ||
+ | Using this function you can now move on and redirect the user to create a new card based on a given proto | ||
+ | <code javascript> | ||
+ | //specify the parent proto in proto_key | ||
+ | function create_new_card(proto_key) | ||
+ | { | ||
+ | let url = '/' | ||
+ | window.open(url, | ||
+ | } | ||
+ | </ |