package eu.ydp.empiria.player.client.controller.communication;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.core.client.JavaScriptObject;

public class DisplayOptions extends DisplayContentOptions {
	
	public DisplayOptions(){
		super();
	}

	public DisplayOptions(List<String> tags){
		ignoredTags = tags;
	}

	public static DisplayOptions fromJsObject(JavaScriptObject o){

		if (o == null)
			return new DisplayOptions();
		
		List<String> tags2Ignore = new ArrayList<String>(); 
		int arrayLength = decodeDisplayOptionsObjectArrayLength(o);
		for (int i = 0 ; i < arrayLength ; i ++){
			tags2Ignore.add( decodeDisplayOptionsObjectArrayItem(o, i) );
		}
		
		return new DisplayOptions(tags2Ignore);
	}
	private native static int decodeDisplayOptionsObjectArrayLength(JavaScriptObject obj)/*-{
		return obj.length;
	}-*/;

	private native static String decodeDisplayOptionsObjectArrayItem(JavaScriptObject obj, int index)/*-{
		return obj[index];
	}-*/;
}

@@ -473,16 +473,94 @@
 );%0D%0A%09%09%0D%0A
+%09%09JavaScriptObject is = decodeDisplayOptionsObjectGetIgnoredSections(o);%0D%0A%09%09%0D%0A
 %09%09List%3CS
@@ -665,17 +665,18 @@
 yLength(
-o
+is
 );%0D%0A%09%09fo
@@ -772,17 +772,18 @@
 rayItem(
-o
+is
 , i) );%0D
@@ -839,16 +839,237 @@
 );%0D%0A%09%7D%0D%0A
+%09private native static JavaScriptObject decodeDisplayOptionsObjectGetIgnoredSections(JavaScriptObject obj)/*-%7B%0D%0A%09%09if (typeof obj.ignoredSections == 'object')%7B%0D%0A%09%09%09return obj.ignoredSections;%0D%0A%09%09%7D%0D%0A%09%09return %5B%5D;%0D%0A%09%7D-*/;%0D%0A%0D%0A
 %09private

change DisplayOptions configuration