<commit_before>﻿/* incident.js
 * this file contains all the controllers for modify, add, delete for incidents
*/

// Includes
var express = require('express');
var bodyParser = require('body-parser');
var path = require('path');
var modules = require('./../../util/modules.js');

var router = express.Router();
var urlencodedParser = bodyParser.urlencoded({ extended: false })


router.get('/', function (req, res) {
    res.sendFile(path.resolve(__dirname + "/../views/addIncident.html"));
});

router.post('/addNew', urlencodedParser, function (req, res) {
    // Create the item for the db
    console.log('Adding new');
    item = {
        'id': req.body.id,
        'title':req.body.title,
        'type': req.body.type,
        'open': new Date().toISOString().replace('Z', ''),
        'geo': req.body.geo
    };
    
    // Get the database module and give it the item to push to the db
    db = modules.getModule('firebase');
    db.addNewItem(item);
    
    // Just give them the json that was submitted to the db
    res.end(JSON.stringify(item));
});

router.post('/update', urlencodedParser, function(req, res){
    var id = req.body.id;
    var values = req.body.values;
    
    db = modules.getModule('firebase');
    
    for(i in values){
        var value = JSON.parse(values[i]);
        
        db.setItem(value['path'] +'/'+ id, value['value']);
    }
    
    res.end('thanks');
});

router.post('/add', urlencodedParser, function(req, res){
    // Get the path to add
    // Get the vaule to add
    var path = req.body.path;
    var value = req.body.value;
    
    console.log('Add recieved');
    console.log(req);
    
    db = modules.getModule('firebase');
    //fb.addItem(path, value);
    
    res.end('thanks');
    
});

module.exports = router;<commit_msg>making a stupid form work<commit_after>﻿/* incident.js
 * this file contains all the controllers for modify, add, delete for incidents
*/

// Includes
var express = require('express');
var bodyParser = require('body-parser');
var path = require('path');
var modules = require('./../../util/modules.js');

var router = express.Router();
var urlencodedParser = bodyParser.urlencoded({ extended: false })


router.get('/', function (req, res) {
    res.sendFile(path.resolve(__dirname + "/../views/addIncident.html"));
});

router.post('/addNew', urlencodedParser, function (req, res) {
    // Create the item for the db
    console.log('Adding new');
    item = {
        'id': '23456',//req.body.id,
        'title':req.body.title,
        'type': req.body.type,
        'open': new Date().toISOString().replace('Z', ''),
        'geo': req.body.geo
    };
    
    // Get the database module and give it the item to push to the db
    db = modules.getModule('firebase');
    db.addNewItem(item);
    
    // Just give them the json that was submitted to the db
    res.end(JSON.stringify(item));
});

router.post('/update', urlencodedParser, function(req, res){
    var id = req.body.id;
    var values = req.body.values;
    
    db = modules.getModule('firebase');
    
    for(i in values){
        var value = JSON.parse(values[i]);
        
        db.setItem(value['path'] +'/'+ id, value['value']);
    }
    
    res.end('thanks');
});

router.post('/add', urlencodedParser, function(req, res){
    // Get the path to add
    // Get the vaule to add
    var path = req.body.path;
    var value = req.body.value;
    
    console.log('Add recieved');
    console.log(req);
    
    db = modules.getModule('firebase');
    //fb.addItem(path, value);
    
    res.end('thanks');
    
});

module.exports = router;
{'fraction_non_alphanumeric': 0.1679579413392363, 'fraction_numerical': 0.001383508577753182, 'mean_word_length': 2.7306501547987616, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2230301', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1124, 'n_words': 295}