<commit_before>function ddg_spice_quixey(data) {
	/********/
	/* Init */
	/********/
	var state = {};
	// placeholder for the apps
	state.apps = [];
	function setup() {
		/* Initialize globals */
		state.min_win = 500;
		// minimum window width to show dots
		state.li_width = 90;
		// default total width and border of each carousel <li>
		state.li_padding = 14;
		state.li_border = 0;
		state.frame_padding = 14;
		// default frame padding and border
		state.frame_border = 2;
		state.current_item = 0;
		// current video in nav
		//Set total width of <li>
		state.thumb_width = state.li_width + state.li_padding + state.li_border;
		// store window width
		state.win = YAHOO.util.Dom.getRegion("nav").width;
		var frame_width = state.win - state.frame_padding - state.frame_border;
		// increment by how many thumbs
		state.inc = Math.floor(frame_width / state.thumb_width);
		// stretch li to fit max
		var extra = frame_width - state.thumb_width * state.inc;
		state.li_width += Math.ceil(extra / state.inc);
		// last video
		var linc = state.apps.length % state.inc;
		state.last = Math.max(0, state.apps.length - (linc ? linc : state.inc));
		// whole states
		state.current_item -= state.current_item % state.inc;
		// check if zero click box has mouse or keyboard focus
		state.hasFocus = false;
		// add the navigation
		createNav();
		// moves the slide to their current position
		setSlides();
		// style for prev / next
		pnClasses();
		// add the dots
		makeDots();
		// listen for window resizes
		YAHOO.util.Event.addListener(window, "resize", function() {
			clearTimeout(state.resize);
			state.resize = setTimeout(setup, 400);
		});
	}
	
	/************************/
	/* FUNCTION DEFINITIONS */
	/************************/

	/********************/
	/* Helper Functions */
	/********************/

	// Make sure a property is defined on an object
	function isProp(obj, prop) {
		prop = prop.split(".");
		for (var i = 0, len = prop.length; i < len; i++) {
			if ((obj = obj[prop[i]]) === undefined) return false;
		}
		return true;
	}
	// Cross-browser prevent default
	function preventDefault(e) {
		e.preventDefault ? e.preventDefault() : e.returnValue = false;
	}

	// simple function to shorten strings
	function shorten(string, length) {
		if (length === undefined) length = 40;
		if (string.length > length) {
			return string.slice(0, length - 3) + "...";
		} else {
			return string;
		}
	}

	function imageProxy(url) {
		return "/iu/?f=1&u=" + url;
	}

	/******************/
	/* Event Handlers */
	/******************/

	// Click handler for prev / next arrows
	function wrapCB(next) {
		return function(e) {
			preventDefault(e);
			if (state.current_item === 0 && !next) return;
			if (state.current_item === state.last && next) return;
			state.current_item += (next ? 1 : -1) * state.inc;
			// edge conditions when resizing
			if (state.current_item < 0) state.current_item = 0;
			if (state.current_item > state.last) state.current_item = state.last;
			doNav(state.current_item / state.inc);
		};
	}
	// Close around clicking thumbs
	function clickA(app) {
		return function(e) {
			preventDefault(e);
			var ul = d.getElementById("slides");
			var j = 0, len = ul.childNodes.length;
			for (;j < len; j++) {
				YAHOO.util.Dom.removeClass(ul.childNodes[j], "sel");
			}
			YAHOO.util.Dom.addClass(this.parentNode, "sel");
			addPreview(app);
		};
	}

	/****************/
	/* JSON Parsing */
	/****************/
	function getInfo(app) {
		var app_id_string = app.id.toString();
		var app_container = d.createElement("div");
		var img_anchor = d.createElement("a");
		var img = d.createElement("img");
		img_anchor.href = app.url || app.developer.url || dir_url;
		img.src = imageProxy(app.icon_url);
		var info = d.createElement("div");
		var name_wrap = d.createElement("div");
		var details = d.createElement("div");
		details.innerHTML = getDetails(app);
		var name = d.createElement("a");
		name.href = app.url;
		name.innerHTML = shorten(app.name, 80);
		var price = d.createElement("div");
		price.innerHTML = getPriceRange(app.editions);
		var rating = d.createElement("div");
		if (app.rating != null)
			rating.innerHTML = getRating(app);
		var description = d.createElement("div");
		var clear = d.createElement("div");
		if (isProp(app, "short_desc")) 
			description.innerHTML += shorten(app.short_desc, 180);
		name_wrap.appendChild(name);
		name_wrap.appendChild(rating);
		name_wrap.appendChild(price);
		name_wrap.appendChild(description);
		img_anchor.appendChild(img);
		info.appendChild(img_anchor);
		info.appendChild(name_wrap);
		app_container.appendChild(info);
		app_container.appendChild(details);
		app_container.appendChild(clear);
		// Set Styles
		YAHOO.util.Dom.setAttribute(app_container, "id", app_id_string);
		YAHOO.util.Dom.setAttribute(details, "id", "details_" + app_id_string);
		if (app.rating != null) {
			YAHOO.util.Dom.setAttribute(rating, "title", app.rating.toFixed(1));
			YAHOO.util.Dom.addClass(rating, "rating");
		}
		YAHOO.util.Dom.setAttribute(description, "title", app.short_desc);
		YAHOO.util.Dom.addClass(app_container, "app_container");
		YAHOO.util.Dom.addClass(img_anchor, "app_icon_anchor");
		YAHOO.util.Dom.addClass(img, "app_icon");
		YAHOO.util.Dom.addClass(info, "app_info");
		YAHOO.util.Dom.addClass(price, "price");
		YAHOO.util.Dom.addClass(name_wrap, "name_wrap");
		YAHOO.util.Dom.addClass(details, "app_details ");<commit_msg>added check for nux, load quixey.css when needed, cleaned up js a bit<commit_after>function ddg_spice_quixey(data) {

	// Check that nothing else is already in the ZCI Box
	if ( nux() ) return;

	var zc_wrapper2 = d.getElementById("zero_click_wrapper2");

	YAHOO.util.Dom.addClass(zc_wrapper2, "quixey");

	var quixey_css = DDG.get_asset_path("quixey.css");
	nrc(quixey_css);

	/********/
	/* Init */
	/********/

	var state = {};
	// placeholder for the apps
	state.apps = [];
	function setup() {

		/* Initialize globals */
		// minimum window width to show dots
		state.min_win = 500;
		// default total width and border of each carousel <li>
		state.li_width = 90;
		state.li_padding = 14;
		state.li_border = 0;
		state.frame_padding = 13;
		// default frame padding and border
		state.frame_border = 2;
		// current video in nav
		state.current_item = 0;
		//Set total width of <li>
		state.thumb_width = state.li_width + state.li_padding + state.li_border;
		// store window width
		state.win = YAHOO.util.Dom.getRegion("nav").width;
		var frame_width = state.win - state.frame_padding - state.frame_border;
		// increment by how many thumbs
		state.inc = Math.floor(frame_width / state.thumb_width);
		// stretch li to fit max
		var extra = frame_width - state.thumb_width * state.inc;
		state.li_width += Math.ceil(extra / state.inc);
		// last video
		var linc = state.apps.length % state.inc;
		state.last = Math.max(0, state.apps.length - (linc ? linc : state.inc));
		// whole states
		state.current_item -= state.current_item % state.inc;
		// add the navigation
		createNav();
		// moves the slide to their current position
		setSlides();
		// style for prev / next
		pnClasses();
		// add the dots
		makeDots();
		// listen for window resizes
		YAHOO.util.Event.addListener(window, "resize", function() {
			clearTimeout(state.resize);
			state.resize = setTimeout(setup, 400);
		});
	}
	
	/************************/
	/* FUNCTION DEFINITIONS */
	/************************/

	/********************/
	/* Helper Functions */
	/********************/

	// Make sure a property is defined on an object
	function isProp(obj, prop) {
		prop = prop.split(".");
		for (var i = 0, len = prop.length; i < len; i++) {
			if ((obj = obj[prop[i]]) === undefined) return false;
		}
		return true;
	}
	// Cross-browser prevent default
	function preventDefault(e) {
		e.preventDefault ? e.preventDefault() : e.returnValue = false;
	}

	// simple function to shorten strings
	function shorten(string, length) {
		if (length === undefined) length = 40;
		if (string.length > length) {
			return string.slice(0, length - 3) + "...";
		} else {
			return string;
		}
	}

	function imageProxy(url) {
		return "/iu/?f=1&u=" + url;
	}

	/******************/
	/* Event Handlers */
	/******************/

	// Click handler for prev / next arrows
	function wrapCB(next) {
		return function(e) {
			preventDefault(e);
			if (state.current_item === 0 && !next) return;
			if (state.current_item === state.last && next) return;
			state.current_item += (next ? 1 : -1) * state.inc;
			// edge conditions when resizing
			if (state.current_item < 0) state.current_item = 0;
			if (state.current_item > state.last) state.current_item = state.last;
			doNav(state.current_item / state.inc);
		};
	}
	// Close around clicking thumbs
	function clickA(app) {
		return function(e) {
			preventDefault(e);
			var ul = d.getElementById("slides");
			var j = 0, len = ul.childNodes.length;
			for (;j < len; j++) {
				YAHOO.util.Dom.removeClass(ul.childNodes[j], "sel");
			}
			YAHOO.util.Dom.addClass(this.parentNode, "sel");
			addPreview(app);
		};
	}

	/****************/
	/* JSON Parsing */
	/****************/
	function getInfo(app) {
		var app_id_string = app.id.toString();
		var app_container = d.createElement("div");
		var img_anchor = d.createElement("a");
		var img = d.createElement("img");
		img_anchor.href = app.url || app.developer.url || dir_url;
		img.src = imageProxy(app.icon_url);
		var info = d.createElement("div");
		var name_wrap = d.createElement("div");
		var details = d.createElement("div");
		details.innerHTML = getDetails(app);
		var name = d.createElement("a");
		name.href = app.url;
		name.innerHTML = shorten(app.name, 80);
		var price = d.createElement("div");
		price.innerHTML = getPriceRange(app.editions);
		var rating = d.createElement("div");
		if (app.rating != null)
			rating.innerHTML = getRating(app);
		var description = d.createElement("div");
		var clear = d.createElement("div");
		if (isProp(app, "short_desc")) 
			description.innerHTML += shorten(app.short_desc, 180);
		name_wrap.appendChild(name);
		name_wrap.appendChild(rating);
		name_wrap.appendChild(price);
		name_wrap.appendChild(description);
		name_wrap.appendChild(details);
		img_anchor.appendChild(img);
		info.appendChild(img_anchor);
		info.appendChild(name_wrap);
		app_container.appendChild(info);
		app_container.appendChild(clear);
		// Set Styles
		YAHOO.util.Dom.setAttribute(app_container, "id", app_id_string);
		YAHOO.util.Dom.setAttribute(details, "id", "details_" + app_id_string);
		if (app.rating != null) {
			YAHOO.util.Dom.setAttribute(rating, "title", app.rating.toFixed(1));
			YAHOO.util.Dom.addClass(rating, "rating");
		}
		YAHOO.util.Dom.setAttribute(description, "title", app.short_desc);
		YAHOO.util.Dom.addClass(app_container, "app_container");
		YAHOO.util.Dom.addClass(img_anchor, "app_icon_anchor");
		YAHOO.util.Dom.addClass(img, "app_icon");
		YAHOO.util.Dom.addClass(info, "app_info");
		YAHOO.util.Dom.addClass(price, "price");
		YAHOO.util.Dom.addClass(name_wrap, "name_wrap");
		YAHOO.util.Dom.addClass(details, "app_details ");
{'fraction_non_alphanumeric': 0.177196935556557, 'fraction_numerical': 0.006399278954484002, 'mean_word_length': 3.739854762921828, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '1753287', 'n_tokens_mistral': 4129, 'n_tokens_neox': 3708, 'n_words': 832}