package xyz.thastertyn.JecnaParse;

import java.io.IOException;
import java.net.UnknownHostException;
import java.util.ArrayList;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import xyz.thastertyn.Tuples.Pair;

public class Sdeleni {
	
	ArrayList<Pair<String, Boolean>> sdeleniList = new ArrayList<>(); 

	public void downloadSdeleni() throws UnknownHostException, IOException
	{
		Document sdeleniDoc = Downloader.download("https://www.spsejecna.cz/user-student/record-list").get();

		Elements sdeleni = sdeleniDoc.select("ul.list li");

		for(Element e : sdeleni)
		{
			boolean isPositive = false;
			String label = "";

			Elements spans = e.select("li").select("a.item").select("span");

			isPositive = spans.get(0).hasClass("sprite-icon-tick-16");
			label = spans.get(1).text();
			
			//if(!label.startsWith(" "))
			//{
			//	label = " " + label;
			//}

			//label = label.replaceAll("\\s+$", "");

			sdeleniList.add(new Pair<String, Boolean>(label, isPositive));
		}
	}

	public ArrayList<Pair<String, Boolean>> getSdeleni()
	{
		return sdeleniList;
	}
}
