Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- log = {
- log: {
- date: FIELD,
- type: 'R',
- season: FIELD,
- sample: TRUE,
- comments: "STUFF",
- attributes: [
- {
- name: "bird status",
- value: "DEAD"
- },
- {
- name: "location",
- value: "bloody island"
- }
- ],
- breeding: {
- mate: 122073238,
- attributes: [
- {
- },
- {
- }
- ]
- }
- }
- };
- {
- response: {}
- errors: []
- }
- var log_prepare_object = function() {
- var log = {};
- log['log'] = {};
- l = log['log'];
- # Prepare log info page of the wizard
- l['date'] = $('#log-datefield').val();
- l['type'] = $('#log-type').val();
- # Prepare resight page
- # Prepare file page if necessary
- if (l['type'] == 'F') {
- }
- # Prepare breeding page if necessary
- if (l['type'] == 'B') {
- }
- return log;
- };
- var log_validate = function(log) {
- var errors = 0;
- // check the date
- if (log['log']['date'] > Date()) {
- validation_errors.push("LOG DATE IS IN THE FUTURE!");
- errors++;
- return false;
- }
- if (errors > 0) {
- return false;
- } else {
- return true;
- }
- }
- var validation_errors = [];
- var submitform = function(event) {
- event.preventDefault();
- log = log_prepare_object();
- if (log_validate(log)) {
- console.log(JSON.stringify(log));
- } else {
- // display error panel with list of errors found in validation
- }
- }
- $(document).ready = function() {
- $("#submitbtn).click(submitform);
- };
- log.log.date
- log['log']['log']['date']
- log.log.attributes.push({name: 'Colour', value: 'BLUE'})
- for (var i=0; i<log.log.attributes.length; i++) {
- console.log(log.log.attributes[i].name + ':' + log.log.attributes[i].value)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement