<commit_before>const styles = require('./styles.js')
const Firebase = require('firebase');
const StatusBar = require('./components/StatusBar');
const ActionButton = require('./components/ActionButton');
const ListItem = require('./components/ListItem');
const { ListView, TextInput, Switch, SliderIOS, AlertIOS, DatePickerIOS, Picker, PickerIOS } = React;

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 */
'use strict';
import React, {
  AppRegistry,
  Component,
  StyleSheet,
  Text,
  View
} from 'react-native';

import Form from 'react-native';

const FirebaseUrl = 'https://amber-inferno-9686.firebaseio.com/data';
const FirebaseUrlRequest = 'https://amber-inferno-9686.firebaseio.com/request'
const FirebaseUrlCode = 'https://amber-inferno-9686.firebaseio.com/code'
var ref = new Firebase(FirebaseUrl);
var refRequest = new Firebase(FirebaseUrlRequest);
var refCode = new Firebase(FirebaseUrlCode);

class Survu extends Component {
  render() {
    return (
      <View style={styles.container}>

        <StatusBar title="Grocery List" />

        <ListView
          dataSource={this.state.dataSource}
          renderRow={this._renderItem.bind(this)}
          style={styles.listview}/>

          <ActionButton title="New Code" onPress={this._newSurvey.bind(this)} />
      </View>
    );
  }


  constructor(props) {
    super(props);
    this.state = {
      dataSource: new ListView.DataSource({
        rowHasChanged: (row1, row2) => row1 !== row2,
      })
    };
  }

  _newSurvey() {
    AlertIOS.prompt(
      'Enter Code',
      null,
      [
        {
          text: 'Done',
          onPress: (text) => {
            refRequest.push({ reqCode: text })
          }
        },
        {
          text: 'Cancel',
          onPress: (text) => console.log('Cancel')
        }
      ],
      'plain-text'
    );
  }

  refRequest.on("child_added", function(snapshot, prevChildKey) {
    var newPost = snapshot.val();
    console.log("Title: " + newPost.title);
    console.log("Text: " + newPost.text);
    console.log("Previous Post ID: " + prevChildKey);

    // process the newest child (code request)
    refCode.orderByValue().on("value", function(snapshot) {
      snapshot.forEach(function(data) {
        if (data.val().value === newPost.reqCode) {
          codeValid();
          return;
        }
      });
      codeInvalid();
    });
  });

  codeValid() {
    AlertIOS.alert(
      'Code Valid',
      null,<commit_msg>validate code2<commit_after>const styles = require('./styles.js')
const Firebase = require('firebase');
const StatusBar = require('./components/StatusBar');
const ActionButton = require('./components/ActionButton');
const ListItem = require('./components/ListItem');
const { ListView, TextInput, Switch, SliderIOS, AlertIOS, DatePickerIOS, Picker, PickerIOS } = React;

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 */
'use strict';
import React, {
  AppRegistry,
  Component,
  StyleSheet,
  Text,
  View
} from 'react-native';

import Form from 'react-native';

const FirebaseUrl = 'https://amber-inferno-9686.firebaseio.com/data';
const FirebaseUrlRequest = 'https://amber-inferno-9686.firebaseio.com/request'
const FirebaseUrlCode = 'https://amber-inferno-9686.firebaseio.com/code'
var ref = new Firebase(FirebaseUrl);
var refRequest = new Firebase(FirebaseUrlRequest);
var refCode = new Firebase(FirebaseUrlCode);

class Survu extends Component {
  render() {
    return (
      <View style={styles.container}>

        <StatusBar title="Grocery List" />

        <ListView
          dataSource={this.state.dataSource}
          renderRow={this._renderItem.bind(this)}
          style={styles.listview}/>

          <ActionButton title="New Code" onPress={this._newSurvey.bind(this)} />
      </View>
    );
  }


  constructor(props) {
    super(props);
    this.state = {
      dataSource: new ListView.DataSource({
        rowHasChanged: (row1, row2) => row1 !== row2,
      })
    };
  }

  _newSurvey() {
    AlertIOS.prompt(
      'Enter Code',
      null,
      [
        {
          text: 'Done',
          onPress: (text) => {
            refRequest.push({ reqCode: text })
          }
        },
        {
          text: 'Cancel',
          onPress: (text) => console.log('Cancel')
        }
      ],
      'plain-text'
    );
  }

  refRequest.on("child_added", function(snapshot, prevChildKey) {
    var newPost = snapshot.val();
    console.log("Title: " + newPost.title);
    console.log("Text: " + newPost.text);
    console.log("Previous Post ID: " + prevChildKey);

    // process the newest child (code request)
    refCode.orderByKey().on("child_added", function(snapshot) {
      snapshot.forEach(function(data) {
        if (data.val().value === newPost.reqCode) {
          codeValid();
          return;
        }
      });
      codeInvalid();
    });
  });

  codeValid() {
    AlertIOS.alert(
      'Code Valid',
      null,
{'fraction_non_alphanumeric': 0.14777531709281255, 'fraction_numerical': 0.006643849406080129, 'mean_word_length': 2.68, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 8, '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': '2595400', 'n_tokens_mistral': 1571, 'n_tokens_neox': 1526, 'n_words': 298}