<commit_before>// Saves options to localStorage.
function save_options() {
  var waybackWarcSource = document.getElementById('waybackWarcSource').value;
  var handling;
  if(document.getElementById('output_save').checked == "checked"){handling = "save";}
  else if(document.getElementById('output_display').checked == "checked"){handling = "display";}
  localStorage["warcSRC"] = waybackWarcSource;
  localStorage["handlingMethod"] = handling;
  // Update status to let user know options were saved.
  var status = $("#status");
  alert("status saved!");
  status.html("Options Saved.");
  status.css("display","block");
  setTimeout(function() {
  	$("#status").fadeOut();
  }, 750);
  
}
// Restores select box state to saved value from localStorage.
function restore_options() {
  var warcSRC = localStorage["warcSRC"];
  var waybackWarcSource = document.getElementById("waybackWarcSource");
  if (!warcSRC || warcSRC == "") {
	waybackWarcSource.value = "C:\\xampp\\tomcat\\webapps\\ROOT\\files1\\"; //TODO, remove this obsolete code!
    return;
  }
  
  var handling;
  if(localStorage["handlingMethod"] == "save"){
	document.getElementById('output_save').checked = "checked";
	document.getElementById('output_display').removeAttribute('checked');
  }
  else if(localStorage["handlingMethod"] == "display"){
	document.getElementById('output_save').removeAttribute('checked');  
	document.getElementById('output_display').checked = "checked";
  }
  
  
  waybackWarcSource.value = warcSRC;
}

function clear_options(){
	localStorage["warcSRC"] = "";
	restore_options();
	document.getElementById("waybackWarcSource").value = "sdf";
}

function checkURI(uri){
	var req=new XMLHttpRequest();              
	try{	
		req.open("GET", uri, false);                             
		req.send(null);
		return req.status;
	}catch(e){
		return -1;
	}
}

var lastSavedStateString = ""; //string representation of the last saved state of the form inputs
function setSaveChangesButtonEnabledBasedOnOptionsChange(){
	if(lastSavedStateString != ""){
		var currentSavedState = $("#filenameScheme").val()+$("#uploadTo").val()+$("#postGeneration_save").is(':checked')+$("#postGeneration_upload").is(':checked');

		if(lastSavedStateString == currentSavedState){
			$("#save").attr("disabled","disabled");
		}else {
			$("#save").removeAttr("disabled");
		}
	}else{	//set the initial state
		lastSavedStateString = $("#filenameScheme").val()+$("#uploadTo").val()+$("#postGeneration_save").is(':checked')+$("#postGeneration_upload").is(':checked');
		$("#save").attr("disabled","disabled");
		$("#filenameScheme").on('keyup',setSaveChangesButtonEnabledBasedOnOptionsChange);
		$("#uploadTo").on('keyup',setSaveChangesButtonEnabledBasedOnOptionsChange);
		$("#postGeneration_save").on('click',setSaveChangesButtonEnabledBasedOnOptionsChange);
		$("#postGeneration_upload").on('click',setSaveChangesButtonEnabledBasedOnOptionsChange);
	}
}

window.onload = function(){
	$('#postGeneration_save').on('click',function(){
		$('#uploadTo').attr("disabled","disabled");
		$('#filenameScheme').removeAttr("disabled");
		$("#exampleFileName").show();
	});
	$('#postGeneration_upload').on('click',function(){
		$('#uploadTo').removeAttr("disabled");
		$('#filenameScheme').attr("disabled","disabled");
		$("#exampleFileName").hide();
		
	});
	$("#restoreDefaults").on('click',function(){
		$("#uploadTo").val("http://warcreate.com/warcs").attr("disabled","disabled");
		$('#postGeneration_save').prop("checked","checked");
		$('#postGeneration_upload').removeAttr("checked");
		$('#filenameScheme').val("YYYYMMDDHHMMssSSS");
		showFilenameExample();
	});
	$('#save').on("click",function(){
		var uploadToURI;
		var filenameScheme;
		if($('#postGeneration_upload').prop("checked")){
			uploadToURI = $("#uploadTo").val();
			filenameScheme = "";
		}else {
			uploadToURI = "";
			filenameScheme = $("#filenameScheme").val();<commit_msg>Relating to #34, enable save button if resetting to defaults causes a change in the user settings.<commit_after>// Saves options to localStorage.
function save_options() {
  var waybackWarcSource = document.getElementById('waybackWarcSource').value;
  var handling;
  if(document.getElementById('output_save').checked == "checked"){handling = "save";}
  else if(document.getElementById('output_display').checked == "checked"){handling = "display";}
  localStorage["warcSRC"] = waybackWarcSource;
  localStorage["handlingMethod"] = handling;
  // Update status to let user know options were saved.
  var status = $("#status");
  alert("status saved!");
  status.html("Options Saved.");
  status.css("display","block");
  setTimeout(function() {
  	$("#status").fadeOut();
  }, 750);
  
}
// Restores select box state to saved value from localStorage.
function restore_options() {
  var warcSRC = localStorage["warcSRC"];
  var waybackWarcSource = document.getElementById("waybackWarcSource");
  if (!warcSRC || warcSRC == "") {
	waybackWarcSource.value = "C:\\xampp\\tomcat\\webapps\\ROOT\\files1\\"; //TODO, remove this obsolete code!
    return;
  }
  
  var handling;
  if(localStorage["handlingMethod"] == "save"){
	document.getElementById('output_save').checked = "checked";
	document.getElementById('output_display').removeAttribute('checked');
  }
  else if(localStorage["handlingMethod"] == "display"){
	document.getElementById('output_save').removeAttribute('checked');  
	document.getElementById('output_display').checked = "checked";
  }
  
  
  waybackWarcSource.value = warcSRC;
}

function clear_options(){
	localStorage["warcSRC"] = "";
	restore_options();
	document.getElementById("waybackWarcSource").value = "sdf";
}

function checkURI(uri){
	var req=new XMLHttpRequest();              
	try{	
		req.open("GET", uri, false);                             
		req.send(null);
		return req.status;
	}catch(e){
		return -1;
	}
}

var lastSavedStateString = ""; //string representation of the last saved state of the form inputs
function setSaveChangesButtonEnabledBasedOnOptionsChange(){
	if(lastSavedStateString != ""){
		var currentSavedState = $("#filenameScheme").val()+$("#uploadTo").val()+$("#postGeneration_save").is(':checked')+$("#postGeneration_upload").is(':checked');

		if(lastSavedStateString == currentSavedState){
			$("#save").attr("disabled","disabled");
		}else {
			$("#save").removeAttr("disabled");
		}
	}else{	//set the initial state
		lastSavedStateString = $("#filenameScheme").val()+$("#uploadTo").val()+$("#postGeneration_save").is(':checked')+$("#postGeneration_upload").is(':checked');
		$("#save").attr("disabled","disabled");
		$("#filenameScheme").on('keyup',setSaveChangesButtonEnabledBasedOnOptionsChange);
		$("#uploadTo").on('keyup',setSaveChangesButtonEnabledBasedOnOptionsChange);
		$("#postGeneration_save").on('click',setSaveChangesButtonEnabledBasedOnOptionsChange);
		$("#postGeneration_upload").on('click',setSaveChangesButtonEnabledBasedOnOptionsChange);
	}
}

window.onload = function(){
	$('#postGeneration_save').on('click',function(){
		$('#uploadTo').attr("disabled","disabled");
		$('#filenameScheme').removeAttr("disabled");
		$("#exampleFileName").show();
	});
	$('#postGeneration_upload').on('click',function(){
		$('#uploadTo').removeAttr("disabled");
		$('#filenameScheme').attr("disabled","disabled");
		$("#exampleFileName").hide();
		
	});
	$("#restoreDefaults").on('click',function(){
		$("#uploadTo").val("http://warcreate.com/warcs").attr("disabled","disabled");
		$('#postGeneration_save').prop("checked","checked");
		$('#postGeneration_upload').removeAttr("checked");
		$('#filenameScheme').val("YYYYMMDDHHMMssSSS");
		showFilenameExample();
		setSaveChangesButtonEnabledBasedOnOptionsChange();
	});
	$('#save').on("click",function(){
		var uploadToURI;
		var filenameScheme;
		if($('#postGeneration_upload').prop("checked")){
			uploadToURI = $("#uploadTo").val();
			filenameScheme = "";
		}else {
			uploadToURI = "";
			filenameScheme = $("#filenameScheme").val();
{'fraction_non_alphanumeric': 0.19552088575742324, 'fraction_numerical': 0.001509813789632612, 'mean_word_length': 6.232939035486806, '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': '860376', 'n_tokens_mistral': 2389, 'n_tokens_neox': 2316, 'n_words': 360}