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 OmluvnyList {
	
	private ArrayList<Pair<String, String>> data = new ArrayList<>();

	private boolean wasDownloaded = false;

	public void downloadOmluvnyList() throws UnknownHostException, IOException
	{
		Document doc = Downloader.download("https://www.spsejecna.cz/absence/student").get();

		Elements omluv = doc.select("table.absence-list").select("tr");

		for(Element e : omluv)
		{
			String date = e.child(0).text();
			String text = e.child(1).text();

			data.add(new Pair<String, String>(date, text));
		}

		wasDownloaded = true;
	}

	public ArrayList<Pair<String, String>> getData()
	{
		return data;
	}
}
