//Remove Duplicate Lines from Text (Javascript) is Copyright 2011 TextMechanic.com All Rights Reserved

function cleartext(){
document.getElementById('input_output').value = '';
document.getElementById('removed').innerHTML = ''
if(document.getElementById('dis_rem').checked == true) document.getElementById('removed_output').value = '';}
function rduplin(){
var text = document.getElementById('input_output').value;
text = text.replace(/\r/g,'');
var textinarr = new Array();
textinarr = text.split('\n');
var len = textinarr.length;
var textoutarr = new Array();
var textoutarrcnt = 0;
var cachearr = new Array();
var cachecnt = 0;
var hash = {};
var xkey = '';
var hkey = '';
var belong2 = 'pbclevtug grkgzrpunavp.pbz';
var cs = document.getElementById('case_sen').checked;
var rel = document.getElementById('rel').checked;
var dis = document.getElementById('dis_rem').checked;
//ttt
if(cs == true && rel == true && dis == true){
for(var x=0;x<len;x++){
xkey = textinarr[x];
hkey = ' ' + xkey;
if(hash[hkey] == null && xkey != '') {hash[hkey] = x+1; textoutarr[textoutarrcnt] = xkey; textoutarrcnt++;} else {if(xkey == '') cachearr[cachecnt] = '(Line ' + (x+1) + ' was an empty line.)'; else cachearr[cachecnt] = '(Line ' + (x+1) + ' was a duplicate of line ' + hash[hkey] + '.) ' + xkey; cachecnt++;}}}
//ttf
if(cs == true && rel == true && dis == false){
for(var x=0;x<len;x++){
xkey = textinarr[x];
hkey = ' ' + xkey;
if(hash[hkey] == null && xkey != '') {hash[hkey] = x+1; textoutarr[textoutarrcnt] = xkey; textoutarrcnt++;} else {cachecnt++;}}}
//tft
if(cs == true && rel == false && dis == true){
for(var x=0;x<len;x++){
xkey = textinarr[x];
hkey = ' ' + xkey;
if(hash[hkey] == null || xkey == '') {hash[hkey] = x+1; textoutarr[textoutarrcnt] = xkey; textoutarrcnt++;} else {cachearr[cachecnt] = '(Line ' + (x+1) + ' was a duplicate of line ' + hash[hkey] + '.) ' + xkey; cachecnt++;}}}
//tff
if(cs == true && rel == false && dis == false){
for(var x=0;x<len;x++){
xkey = textinarr[x];
hkey = ' ' + xkey;
if(hash[hkey] == null || xkey == '') {hash[hkey] = x+1; textoutarr[textoutarrcnt] = xkey; textoutarrcnt++;} else {cachecnt++;}}}
//ftt
if(cs == false && rel == true && dis == true){
for(var x=0;x<len;x++){
xkey = textinarr[x];
hkey = ' ' + xkey.toUpperCase();
if(hash[hkey] == null && xkey != '') {hash[hkey] = x+1; textoutarr[textoutarrcnt] = xkey; textoutarrcnt++;} else {if(xkey == '') cachearr[cachecnt] = '(Line ' + (x+1) + ' was an empty line.)'; else cachearr[cachecnt] = '(Line ' + (x+1) + ' was a duplicate of line ' + hash[hkey] + '.) ' + xkey; cachecnt++;}}}
//ftf
if(cs == false && rel == true && dis == false){
for(var x=0;x<len;x++){
xkey = textinarr[x];
hkey = ' ' + xkey.toUpperCase();
if(hash[hkey] == null && xkey != '') {hash[hkey] = x+1; textoutarr[textoutarrcnt] = xkey; textoutarrcnt++;} else {cachecnt++;}}}
//fft
if(cs == false && rel == false && dis == true){
for(var x=0;x<len;x++){
xkey = textinarr[x];
hkey = ' ' + xkey.toUpperCase();
if(hash[hkey] == null || xkey == '') {hash[hkey] = x+1; textoutarr[textoutarrcnt] = xkey; textoutarrcnt++;} else {cachearr[cachecnt] = '(Line ' + (x+1) + ' was a duplicate of line ' + hash[hkey] + '.) ' + xkey; cachecnt++;}}}
//fff
if(cs == false && rel == false && dis == false){
for(var x=0;x<len;x++){
xkey = textinarr[x];
hkey = ' ' + xkey.toUpperCase();
if(hash[hkey] == null || xkey == '') {hash[hkey] = x+1; textoutarr[textoutarrcnt] = xkey; textoutarrcnt++;} else {cachecnt++;}}}
document.getElementById('input_output').value = textoutarr.join('\n');
if(dis == true) document.getElementById('removed_output').value = cachearr.join('\n');
var lines = 'lines';
if(cachecnt == 1) lines = 'line';
document.getElementById('removed').innerHTML = cachecnt + ' duplicate ' + lines + ' removed.';}
function SelectAll(id) {
document.getElementById(id).focus();
document.getElementById(id).select();}
