<commit_before>document.documentElement.style.height = '100%';
document.body.style.height = '100%';
document.documentElement.style.width = '100%';
document.body.style.width = '100%';

var open = false;
function showPane()
{
  var div = document.createElement('div');
  div.id = 'sidepane';
  div.style.height = '100%';
  div.style.right = '0px';
  div.style.top = '0px';
  div.style.width = '30%';
  div.style.backgroundColor = '#f8f9fa';
  div.style.borderStyle = "solid";
  div.style.borderWidth = "1px";
  div.style.position = 'fixed';
  div.style.zIndex = '1000';
  var ul = document.createElement('ul');
  ul.id = 'descrips';
  ul.listStyleType = "none";
  document.body.appendChild(div);
  div.appendChild(ul);
  open = true;
}


function startQuery(quer){
  var searchUrl = 'https://api.wolframalpha.com/v2/query' + '?appid=' + encodeURIComponent(appID) +
  '&input=' + quer + '&format=plaintext&output=JSON';
  var x = new XMLHttpRequest();
//  x.responseType = 'json';
  x.onload = function() {
    var response = JSON.parse(x.response);
    console.log(response);
    if (!response || !response["queryresult"]["success"] || response["queryresult"]["error"] ){
      console.log('Invalid search to Wolfram');
      return;
    }
    var pods = response["queryresult"]["pods"];
    console.log(pods);
    var ul = document.getElementById('descrips');
    for(i = 0; i < pods.length; i++) {
      var li = document.createElement('li');
      var tex = document.createTextNode(pods[i].subpods[0].plaintext);
      if (!tex.length > 0)
        continue;
      li.style.fontFamily = "Arial";
      li.style.display = "block";
      li.style.paddingTop = "25px";
      li.style.borderWidth = "1px";
      li.style.borderStyle = "ridge";

      li.appendChild(tex);
      ul.appendChild(li);
//      ul.appendChild(li2);
    };
  };
  x.onerror = function(err) {
    console.log(err);
  };
  x.open('GET', searchUrl, true);
  x.send();
}

function clearQuery()
{
  var clear = document.getElementById('descrips');
  while(clear.firstChild){
    clear.removeChild(clear.firstChild);
  }
}

function endQuery()
{
  var ex = document.getElementById('sidepane');
  document.body.removeChild(ex);
  open = false;
}

chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
  console.log("Message recieved");
  console.log(open);
  if(request.message === "open_sidebar" && open == false){
    console.log("Selection event. Looking up: " + request.content);
    showPane();
    startQuery(request.content);
    return true;
  }
  else if(request.message === "close_sidebar" && open == true){
    console.log("Closing tab");
    endQuery();
    return true;
  }
  else if(request.message === "open_sidebar" && open == true){
    console.log("Selection. Clearing then looking up: " + request.content);
    clearQuery();
    startQuery(request.content);
    return true;
  }
});

/*
var isSidebarOpen = false;
function openInfo(lookup){

return true;
}<commit_msg>change content.js from remove pane to hide<commit_after>document.documentElement.style.height = '100%';
document.body.style.height = '100%';
document.documentElement.style.width = '100%';
document.body.style.width = '100%';

var open = false;
function showPane()
{
  if (document.getElementById('sidepane'))
  {
    var div = document.getElementById('sidepane');
    div.style.display = 'block';
  }
  else
  {
  var div = document.createElement('div');
  div.id = 'sidepane';
  div.style.height = '100%';
  div.style.right = '0px';
  div.style.top = '0px';
  div.style.width = '30%';
  div.style.backgroundColor = '#f8f9fa';
  div.style.borderStyle = "solid";
  div.style.borderWidth = "1px";
  div.style.position = 'fixed';
  div.style.zIndex = '1000';
  }
  var ul = document.createElement('ul');
  ul.id = 'descrips';
  ul.listStyleType = "none";
  document.body.appendChild(div);
  div.appendChild(ul);
  open = true;
}


function startQuery(quer){
  var searchUrl = 'https://api.wolframalpha.com/v2/query' + '?appid=' + encodeURIComponent(appID) +
  '&input=' + quer + '&format=plaintext&output=JSON';
  var x = new XMLHttpRequest();
//  x.responseType = 'json';
  x.onload = function() {
    var response = JSON.parse(x.response);
    console.log(response);
    if (!response || !response["queryresult"]["success"] || response["queryresult"]["error"] ){
      console.log('Invalid search to Wolfram');
      return;
    }
    var pods = response["queryresult"]["pods"];
    console.log(pods);
    var ul = document.getElementById('descrips');
    for(i = 0; i < pods.length; i++) {
      var li = document.createElement('li');
      var tex = document.createTextNode(pods[i].subpods[0].plaintext);
      if (!tex.length > 0)
        continue;
      li.style.fontFamily = "Arial";
      li.style.display = "block";
      li.style.paddingTop = "25px";
      li.style.borderWidth = "1px";
      li.style.borderStyle = "ridge";

      li.appendChild(tex);
      ul.appendChild(li);
//      ul.appendChild(li2);
    };
  };
  x.onerror = function(err) {
    console.log(err);
  };
  x.open('GET', searchUrl, true);
  x.send();
}

function clearQuery()
{
  var clear = document.getElementById('descrips');
  while(clear.firstChild){
    clear.removeChild(clear.firstChild);
  }
}

function endQuery()
{
  var ex = document.getElementById('sidepane');
  ex.style.display = 'none';
  open = false;
}

chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
  console.log("Message recieved");
  console.log(open);
  if(request.message === "open_sidebar" && open == false){
    console.log("Selection event. Looking up: " + request.content);
    showPane();
    startQuery(request.content);
    return true;
  }
  else if(request.message === "close_sidebar" && open == true){
    console.log("Closing tab");
    clearQuery();
    endQuery();
    return true;
  }
  else if(request.message === "open_sidebar" && open == true){
    console.log("Selection. Clearing then looking up: " + request.content);
    clearQuery();
    startQuery(request.content);
    return true;
  }
});

/*
var isSidebarOpen = false;
function openInfo(lookup){

return true;
}
{'fraction_non_alphanumeric': 0.17287363798991706, 'fraction_numerical': 0.011058708733127337, 'mean_word_length': 3.620586025544703, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '1238336', 'n_tokens_mistral': 2082, 'n_tokens_neox': 2053, 'n_words': 388}