<commit_before>function Base64EncodeUrl(str){
    return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=+$/, '');
}

function Base64DecodeUrl(str){
    str = (str + '===').slice(0, str.length + (str.length % 4));
    return str.replace(/-/g, '+').replace(/_/g, '/');
}

// Your Client ID can be retrieved from your project in the Google
// Developer Console, https://console.developers.google.com
var CLIENT_ID = '632784872848-kfca02of7742s9jkef12av9v405pqu7a.apps.googleusercontent.com';

var SCOPES = ['https://www.googleapis.com/auth/gmail.readonly'];

/**
 * Check if current user has authorized this application.
 */
function checkAuth() {
  gapi.auth.authorize(
    {
      'client_id': CLIENT_ID,
      'scope': SCOPES.join(' '),
      'immediate': true
    }, handleAuthResult);
}

function sendrequests() {
  var req = document.getElementById('phprequest');
  var requests = req.firstChild.nodeValue.split("___")
  var nReq = requests.length - 1
  var nRequest = new Array()

  for (var i=0; i<nReq; i++) {
    document.getElementById('printrequests').innerHTML = document.getElementById('printrequests').innerHTML + "\n" + requests[i]
  }

  // alert('Sent!')

  // Simultaneous JS XML HTTP Requests
  for (var i=0; i<nReq; i++){
     (function(i) {
        nRequest[i] = new XMLHttpRequest();
        // alert(requests[i])
        nRequest[i].open("GET", 'http://atian.mycpanel2.princeton.edu/breakserv/upload.php?'+requests[i], true);
        nRequest[i].onreadystatechange = function (oEvent) {
           if (nRequest[i].readyState === 4) {
              if (nRequest[i].status === 200) {
                console.log(nRequest[i].responseText);
                //alert(nRequest[i].responseText);
              } else {
                console.log("Error", nRequest[i].statusText);
              }
           }
        };
        nRequest[i].send();
        // alert("sent!" + i)
        // appendPre('sent!' + i)
     })(i);
  }
}

/**
 * Handle response from authorization server.
 *
 * @param {Object} authResult Authorization result.
 */
function handleAuthResult(authResult) {
  var authorizeDiv = document.getElementById('authorize-div');
  if (authResult && !authResult.error) {
    // Hide auth UI, then load client library.
    authorizeDiv.style.display = 'none';
    loadGmailApi();
  } else {
    // Show auth UI, allowing the user to initiate authorization by
    // clicking authorize button.
    authorizeDiv.style.display = 'inline';
  }
}

/**
 * Initiate auth flow in response to user clicking authorize button.
 *
 * @param {Event} event Button click event.
 */
function handleAuthClick(event) {
  gapi.auth.authorize(
    {client_id: CLIENT_ID, scope: SCOPES, immediate: false},
    handleAuthResult);
  return false;
}

/**
 * Load Gmail API client library. List labels once client library
 * is loaded.
 */
function loadGmailApi() {
  gapi.client.load('gmail', 'v1', listMessagesW);
}

function listMessagesW() {
  req = gapi.client.gmail.users.getProfile({'userId': 'me'})
  req.execute(function(resp) {
    appendPre(resp.emailAddress + '\n')
  })
  var queryDate = new Date()
  // alert(queryDate.getFullYear().toString() + "/" + (queryDate.getMonth() + 1).toString() + "/" + queryDate.getDate().toString())
  // queryDate.setDate(queryDate.getDate() - 7)

  var lasttime = document.getElementById('lasttime').firstChild.nodeValue
  alert(lasttime)
  return

  queryDate.setDate(queryDate.getDate() - 30) // TESTING
  var day = queryDate.getDate()
  var month = queryDate.getMonth() + 1
  var year = queryDate.getFullYear()
  var dQ = "after:" + year.toString() + "/" + month.toString() + "/" + day.toString()
  // alert(dQ)<commit_msg>scraped<commit_after>function Base64EncodeUrl(str){
    return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=+$/, '');
}

function Base64DecodeUrl(str){
    str = (str + '===').slice(0, str.length + (str.length % 4));
    return str.replace(/-/g, '+').replace(/_/g, '/');
}

// Your Client ID can be retrieved from your project in the Google
// Developer Console, https://console.developers.google.com
var CLIENT_ID = '632784872848-kfca02of7742s9jkef12av9v405pqu7a.apps.googleusercontent.com';

var SCOPES = ['https://www.googleapis.com/auth/gmail.readonly'];

/**
 * Check if current user has authorized this application.
 */
function checkAuth() {
  gapi.auth.authorize(
    {
      'client_id': CLIENT_ID,
      'scope': SCOPES.join(' '),
      'immediate': true
    }, handleAuthResult);
}

function sendrequests() {
  var req = document.getElementById('phprequest');
  var requests = req.firstChild.nodeValue.split("___")
  var nReq = requests.length - 1
  var nRequest = new Array()

  for (var i=0; i<nReq; i++) {
    document.getElementById('printrequests').innerHTML = document.getElementById('printrequests').innerHTML + "\n" + requests[i]
  }

  // alert('Sent!')

  // Simultaneous JS XML HTTP Requests
  for (var i=0; i<nReq; i++){
     (function(i) {
        nRequest[i] = new XMLHttpRequest();
        // alert(requests[i])
        nRequest[i].open("GET", 'http://atian.mycpanel2.princeton.edu/breakserv/upload.php?'+requests[i], true);
        nRequest[i].onreadystatechange = function (oEvent) {
           if (nRequest[i].readyState === 4) {
              if (nRequest[i].status === 200) {
                console.log(nRequest[i].responseText);
                //alert(nRequest[i].responseText);
              } else {
                console.log("Error", nRequest[i].statusText);
              }
           }
        };
        nRequest[i].send();
        // alert("sent!" + i)
        // appendPre('sent!' + i)
     })(i);
  }
}

/**
 * Handle response from authorization server.
 *
 * @param {Object} authResult Authorization result.
 */
function handleAuthResult(authResult) {
  var authorizeDiv = document.getElementById('authorize-div');
  if (authResult && !authResult.error) {
    // Hide auth UI, then load client library.
    authorizeDiv.style.display = 'none';
    loadGmailApi();
  } else {
    // Show auth UI, allowing the user to initiate authorization by
    // clicking authorize button.
    authorizeDiv.style.display = 'inline';
  }
}

/**
 * Initiate auth flow in response to user clicking authorize button.
 *
 * @param {Event} event Button click event.
 */
function handleAuthClick(event) {
  gapi.auth.authorize(
    {client_id: CLIENT_ID, scope: SCOPES, immediate: false},
    handleAuthResult);
  return false;
}

/**
 * Load Gmail API client library. List labels once client library
 * is loaded.
 */
function loadGmailApi() {
  gapi.client.load('gmail', 'v1', listMessagesW);
}

function listMessagesW() {
  req = gapi.client.gmail.users.getProfile({'userId': 'me'})
  req.execute(function(resp) {
    appendPre(resp.emailAddress + '\n')
  })
  var queryDate = new Date()
  // alert(queryDate.getFullYear().toString() + "/" + (queryDate.getMonth() + 1).toString() + "/" + queryDate.getDate().toString())
  // queryDate.setDate(queryDate.getDate() - 7)

  var lasttime = document.getElementById('lasttime').firstChild.nodeValue
  if (lasttime == '') {
    queryDate.setDate(queryDate.getDate() - 7) // TESTING
    var day = queryDate.getDate()
    var month = queryDate.getMonth() + 1
    var year = queryDate.getFullYear()
    var dQ = "after:" + year.toString() + "/" + month.toString() + "/" + day.toString()
  } else {
    var day = lasttime.split('-')[2]
    var month = lasttime.split('-')[1]
    var year = lasttime.split('-')[0]
    var dQ = "after:" + year + "/" + month + "/" + day
  }

  alert(dQ)
  // alert(lasttime)
  // return

  // alert(dQ)
{'fraction_non_alphanumeric': 0.166754478398314, 'fraction_numerical': 0.01238145416227608, 'mean_word_length': 3.082258064516129, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2031785', 'n_tokens_mistral': 2535, 'n_tokens_neox': 2423, 'n_words': 522}