<commit_before>$(document).ready(function() {
	var URLactual = window.location.pathname;

	switch(URLactual) {
		case '/losCedrosTapiales/institucional':
			$( "#instalaciones" ).addClass("active");
			$( "#servicios" ).remove("active");
			$( "#coberturas" ).remove("active");
			$( "#especialidades" ).remove("active");
		break;
		case '/losCedrosTapiales/servicios':
			$( "#instalaciones" ).remove("active");
			$( "#servicios" ).addClass("active");
			$( "#coberturas" ).remove("active");
			$( "#especialidades" ).remove("active");
		break;
		case '/losCedrosTapiales/coberturamedica':
			$( "#instalaciones" ).remove("active");
			$( "#servicios" ).remove("active");
			$( "#coberturas" ).addClass("active");
			$( "#especialidades" ).remove("active");
		break;
		case '/losCedrosTapiales/especialidades':
			$( "#instalaciones" ).remove("active");
			$( "#servicios" ).remove("active");
			$( "#coberturas" ).remove("active");
			$( "#especialidades" ).addClass("active");
		default:
			$( "#instalaciones" ).remove("active");
			$( "#servicios" ).remove("active");
			$( "#coberturas" ).remove("active");
			$( "#especialidades" ).remove("active");
		break;
	}
});

$(document).ready(menu);
var contador = 1;
function menu(){
   $('.toggle').click(function(){
	      if(contador == 1){

              $('#element').animate({
                      right: '0em'
              });

              $('.menu-element').css("height", "328px");

              contador = 0;
	      } else {
              contador = 1;

              $('#element').animate({
                      right: '-100%'
              });

              $('.menu-element').css("height", "auto");
	      }
   });
}

$(document).ready(fixedMenu);
function fixedMenu() {
        $( window ).resize(function(){
                var ventana = $(window).width();
                var	right = $('#element').css('right');
                var	pat = 'px';

                right = right.replace(pat, '');
                right = parseInt(right);

                if((ventana > 1024) && (right < -1024)) {
                        $('#element').css('right', '2em');
                }
        });
}

$(document).ready(openVideo);
function openVideo(){
        $('#button-video-open').click(function(){
                $( "#video-container" ).addClass("video-open");
        });
}

$(document).ready(closeVideo);
function closeVideo(){
        $('#button-video-close').click(function(){
                $( "#video-container" ).removeClass("video-open");

                var v = document.getElementsByTagName("video")[1];
                v.pause();
                v.load();
        });
}

$(document).ready(closeVideoContainer);
function closeVideoContainer(){
        $('#video-container').click(function(){
                $( "#video-container" ).removeClass("video-open");

                var v = document.getElementsByTagName("video")[1];
                v.pause();
                v.load();
        });
}

$(document).ready(heightMap);
function heightMap() {
	var h = $("#informationBox").outerHeight() + "px";
	$("#map").css("height", h);
	$(window).resize(function() {
		var h = $("#informationBox").outerHeight() + "px";
		$("#map").css("height", h);
	});
}

$(document).ready(modalEspecialidades);
function modalEspecialidades() {
	$("#element-list").click(function(e){
		elemento = e.target.id;
		elemento = "#modal" + elemento;
		$(elemento).addClass("show");
	});

	$('#button-close-information').click(function(e){
		 $(elemento).removeClass("show");
	});

	$(".modal").click(function(e){
		$(elemento).removeClass("show");
	});
}

$(document).ready(instalaciones);
function instalaciones() {

	// Función slider
	var sliderFunction = function (slider) {
		/**
		/* Código del listado de imágenes debajo del slider (accesos directos a cada imagen)
		**/

		//Declaro un array donde guardo el listado de imagenes para poder recorrerlo
		var listadoImagenes = [];
		$(slider + " .container-image-secondary a").each(function(index){
			listadoImagenes.push(this);
		});

		//Contador de páginas o imagenes a las que se le dará NEXT
		var page = 1;

		//Capturo el ID de la imagen cliqueada para que se muestre
		//directamente en el slider sin cliquear los botones NEXT y PREV
		$(slider + " .container-image-secondary").click(function(e){
			//Le quito el funcionamiento por defecto al link
			e.preventDefault();

			//Capturo el ID
			var a = e.target.id;

			//Recorro el array de imágenes
			for(var i = 0; i < listadoImagenes.length; i++) {
				//Si "a" (que contiene el ID de la imagen cliqueada) es IGUAL al id de la imagen del ARRAY
				if(a == listadoImagenes[i].id) {
					//Capturo la posición del contenedor
					//Ancho de la imagen * la posición del ARRAY * -1
					//(para hacerlo negativo, por ser necesario para los estilos)
					var posicion = $(slider + " .content-imagen li img").width() * i * -1;
					//Le doy el valor de "posicion" al estilo LEFT
					$(slider + " .content-imagen").css("left", posicion);
					//Le indico al contador general en qué página o imagen estoy ubicada
					//para darle la información a los botones NEXT y PREV
					page = (i + 1);
				}
			}
		});

		var cantImagenes = $(slider + " .content-imagen li").size();
		var anchoLi = (100 / cantImagenes) + "%";

		$(slider + " .content-image-primary").css("width", anchoLi);

		var anchoContenedor = (cantImagenes * 100) + "%";
		$(slider + " .content-imagen").css("width", anchoContenedor);

		var espacioAmover = 0;
		$(slider + " #button-next").click(function(){
			var anchoImagen = $(slider + " .content-imagen li img").width() * -1;
			if (page >= cantImagenes) {
				page = 1;
				$(slider + " .content-imagen").animate({left: "0px"}, 500);
			} else {
				if (espacioAmover == (anchoImagen * page)) {
					espacioAmover = anchoImagen * (page + 1);
				} else if (page == cantImagenes) {
					espacioAmover = anchoImagen * (page - 1);
				} else {
					espacioAmover = anchoImagen * page;
				}
				page++;
				$(slider + " .content-imagen").animate({left: (espacioAmover + "px")}, 500);
			}

			$(window).resize(function(){
				var anchoImagen = $(slider + " .content-imagen li img").width() * -1;
				espacioAmover = anchoImagen * (page - 1);
				$(slider + " .content-imagen").css("left", (espacioAmover + "px"));
			});
		});

		$(slider + " #button-prev").click(function(){
			var anchoImagen = $(slider + " .content-imagen li img").width() * -1;
			if (page <= 1) {
				page = cantImagenes;
				page--;
				espacioAmover = anchoImagen * (cantImagenes - 1);
				$(slider + " .content-imagen").animate({left: (espacioAmover + "px")}, 500);
			} else {
				page--;
				if (espacioAmover == (anchoImagen * page)) {
					espacioAmover = anchoImagen * (page - 1);
				} else {
					espacioAmover = anchoImagen * page;
				}
				$(slider + " .content-imagen").animate({left: (espacioAmover + "px")}, 500);
			}

			$(window).resize(function(){
				var anchoImagen = $(slider + " .content-imagen li img").width();
				espacioAmover = anchoImagen * (page - 1);
				$(slider + " .content-imagen").css("left", (espacioAmover + "px"));
			});
		});
	} //funcion slider ();

	//Primer slider, por defecto abierto
	sliderFunction("#slider-1");

	//Ubico el item del listado (menu de sliders) en el que hago click
	$(".menu-instalaciones2 li span").click(function(e){
		var li = e.target.parentNode;
		//Recorro todo el menú y le remuevo la clase ".item-active" a todos
		$(".menu-instalaciones2 li").each(function(){
			$(".menu-instalaciones2 li").removeClass("item-active");
		});
		//Le agrego la clase ".item-active" al que se cliqueó
		$(li).addClass("item-active");

		//Preparo la variable con el ID del slider que corresponde al item cliqueado
		slider = "#slider-" + li.id;
		//Remuevo de todos los slider la clase ".slider-active"
		$(".container-all-slider > div").each(function(){
			$(".container-all-slider > div").removeClass("slider-active");
		});

		//Le agrego la clase ".slider-active" al slider correspondiente al item cliqueado
		$(slider).addClass("slider-active");

		//Hago funcionar el slider con el ID correspondiente al slider en cuestión
		sliderFunction(slider);
	});
}
<commit_msg>Arreglo de bug en los slider<commit_after>$(document).ready(function() {
	var URLactual = window.location.pathname;

	switch(URLactual) {
		case '/losCedrosTapiales/institucional':
			$( "#instalaciones" ).addClass("active");
			$( "#servicios" ).remove("active");
			$( "#coberturas" ).remove("active");
			$( "#especialidades" ).remove("active");
		break;
		case '/losCedrosTapiales/servicios':
			$( "#instalaciones" ).remove("active");
			$( "#servicios" ).addClass("active");
			$( "#coberturas" ).remove("active");
			$( "#especialidades" ).remove("active");
		break;
		case '/losCedrosTapiales/coberturamedica':
			$( "#instalaciones" ).remove("active");
			$( "#servicios" ).remove("active");
			$( "#coberturas" ).addClass("active");
			$( "#especialidades" ).remove("active");
		break;
		case '/losCedrosTapiales/especialidades':
			$( "#instalaciones" ).remove("active");
			$( "#servicios" ).remove("active");
			$( "#coberturas" ).remove("active");
			$( "#especialidades" ).addClass("active");
		default:
			$( "#instalaciones" ).remove("active");
			$( "#servicios" ).remove("active");
			$( "#coberturas" ).remove("active");
			$( "#especialidades" ).remove("active");
		break;
	}
});

$(document).ready(menu);
var contador = 1;
function menu(){
   $('.toggle').click(function(){
	      if(contador == 1){

              $('#element').animate({
                      right: '0em'
              });

              $('.menu-element').css("height", "328px");

              contador = 0;
	      } else {
              contador = 1;

              $('#element').animate({
                      right: '-100%'
              });

              $('.menu-element').css("height", "auto");
	      }
   });
}

$(document).ready(fixedMenu);
function fixedMenu() {
        $( window ).resize(function(){
                var ventana = $(window).width();
                var	right = $('#element').css('right');
                var	pat = 'px';

                right = right.replace(pat, '');
                right = parseInt(right);

                if((ventana > 1024) && (right < -1024)) {
                        $('#element').css('right', '2em');
                }
        });
}

$(document).ready(openVideo);
function openVideo(){
        $('#button-video-open').click(function(){
                $( "#video-container" ).addClass("video-open");
        });
}

$(document).ready(closeVideo);
function closeVideo(){
        $('#button-video-close').click(function(){
                $( "#video-container" ).removeClass("video-open");

                var v = document.getElementsByTagName("video")[1];
                v.pause();
                v.load();
        });
}

$(document).ready(closeVideoContainer);
function closeVideoContainer(){
        $('#video-container').click(function(){
                $( "#video-container" ).removeClass("video-open");

                var v = document.getElementsByTagName("video")[1];
                v.pause();
                v.load();
        });
}

$(document).ready(heightMap);
function heightMap() {
	var h = $("#informationBox").outerHeight() + "px";
	$("#map").css("height", h);
	$(window).resize(function() {
		var h = $("#informationBox").outerHeight() + "px";
		$("#map").css("height", h);
	});
}

$(document).ready(modalEspecialidades);
function modalEspecialidades() {
	$("#element-list").click(function(e){
		elemento = e.target.id;
		elemento = "#modal" + elemento;
		$(elemento).addClass("show");
	});

	$('#button-close-information').click(function(e){
		 $(elemento).removeClass("show");
	});

	$(".modal").click(function(e){
		$(elemento).removeClass("show");
	});
}

$(document).ready(instalaciones);
function instalaciones() {

	// Función slider
	var sliderFunction = function (slider) {
		/**
		/* Código del listado de imágenes debajo del slider (accesos directos a cada imagen)
		**/

		//Declaro un array donde guardo el listado de imagenes para poder recorrerlo
		var listadoImagenes = [];
		$(slider + " .container-image-secondary a").each(function(index){
			listadoImagenes.push(this);
		});

		//Contador de páginas o imagenes a las que se le dará NEXT
		var page = 1;

		//Capturo el ID de la imagen cliqueada para que se muestre
		//directamente en el slider sin cliquear los botones NEXT y PREV
		$(slider + " .container-image-secondary").click(function(e){
			//Le quito el funcionamiento por defecto al link
			e.preventDefault();

			//Capturo el ID
			var a = e.target.id;

			//Recorro el array de imágenes
			for(var i = 0; i < listadoImagenes.length; i++) {
				//Si "a" (que contiene el ID de la imagen cliqueada) es IGUAL al id de la imagen del ARRAY
				if(a == listadoImagenes[i].id) {
					//Capturo la posición del contenedor
					//Ancho de la imagen * la posición del ARRAY * -1
					//(para hacerlo negativo, por ser necesario para los estilos)
					var posicion = $(slider + " .content-imagen li img").width() * i * -1;
					//Le doy el valor de "posicion" al estilo LEFT
					$(slider + " .content-imagen").css("left", posicion);
					//Le indico al contador general en qué página o imagen estoy ubicada
					//para darle la información a los botones NEXT y PREV
					page = (i + 1);
				}
			}
		});

		var cantImagenes = $(slider + " .content-imagen li").size();
		var anchoLi = (100 / cantImagenes) + "%";

		$(slider + " .content-image-primary").css("width", anchoLi);

		var anchoContenedor = (cantImagenes * 100) + "%";
		$(slider + " .content-imagen").css("width", anchoContenedor);

		var espacioAmover = 0;
		$(slider + " #button-next").click(function(){
			var anchoImagen = $(slider + " .content-imagen li img").width() * -1;
			var tiempoDesliz = cantImagenes * 100;

			if (page == cantImagenes) {
				page = 1;
				$(slider + " .content-imagen").animate({left: "0px"}, tiempoDesliz);
				espacioAmover = 0;
			} else {
				if (espacioAmover == (anchoImagen * page)) {
					espacioAmover = anchoImagen * (page + 1);
				} else {
					espacioAmover = anchoImagen * page;
				}
				page++;
				$(slider + " .content-imagen").animate({left: (espacioAmover + "px")}, tiempoDesliz);
			}

			$(window).resize(function(){
				var anchoImagen = $(slider + " .content-imagen li img").width() * -1;
				var espacioAmover = 0;
				espacioAmover = anchoImagen * (page - 1);
				$(slider + " .content-imagen").css("left", (espacioAmover + "px"));
			});
		});

		$(slider + " #button-prev").click(function(){
			var anchoImagen = $(slider + " .content-imagen li img").width() * -1;
			var tiempoDesliz = cantImagenes * 300;

			if (page <= 1) {
				page = cantImagenes;
				espacioAmover = anchoImagen * (cantImagenes - 1);
				$(slider + " .content-imagen").animate({left: (espacioAmover + "px")}, tiempoDesliz);
			} else {
				page--;
				if (espacioAmover == (anchoImagen * page)) {
					espacioAmover = anchoImagen * (page - 1);
				} else {
					espacioAmover = anchoImagen * page;
				}
				$(slider + " .content-imagen").animate({left: (espacioAmover + "px")}, tiempoDesliz);
			}

			$(window).resize(function(){
				var anchoImagen = $(slider + " .content-imagen li img").width();
				var espacioAmover = 0;
				espacioAmover = anchoImagen * (page - 1);
				$(slider + " .content-imagen").css("left", (espacioAmover + "px"));
			});
		});
	} //funcion slider ();

	//Primer slider, por defecto abierto
	sliderFunction("#slider-1");

	//Ubico el item del listado (menu de sliders) en el que hago click
	$(".menu-instalaciones2 li span").click(function(e){
		var li = e.target.parentNode;
		//Recorro todo el menú y le remuevo la clase ".item-active" a todos
		$(".menu-instalaciones2 li").each(function(){
			$(".menu-instalaciones2 li").removeClass("item-active");
		});
		//Le agrego la clase ".item-active" al que se cliqueó
		$(li).addClass("item-active");

		//Preparo la variable con el ID del slider que corresponde al item cliqueado
		slider = "#slider-" + li.id;
		//Remuevo de todos los slider la clase ".slider-active"
		$(".container-all-slider > div").each(function(){
			$(".container-all-slider > div").removeClass("slider-active");
		});

		//Le agrego la clase ".slider-active" al slider correspondiente al item cliqueado
		$(slider).addClass("slider-active");

		//Hago funcionar el slider con el ID correspondiente al slider en cuestión
		sliderFunction(slider);
	});
}
<|endoftext|>


<commit_before>#!/usr/bin/node
/**
 * query.js
 * Usage: ./query.js dbDir>
 */

var Fact = require('./fact.js');
var Level = require('level');
var Path = require('path');
var Process = process;

// putting [[],[0,[0,0,1],[0,[0,1,2],[0,0,2]]],[]];752fd06a4648a2f576d2e65961f7a2b3dfac09a7 => {"Core":[[],[0,[0,0,1],[0,[0,1,2],[0,0,2]]],[]],"Skin":{"Name":"nic-luk1","HypNames":[],"DepNames":["nic-dfim","nic-bi2","nic-ax","nic-isw2","nic-idel","nic-bi1","nic-idbl","nic-imp","nic-swap","nic-ich","nic-mp"],"VarNames":["ph","ps","ch","ta"],"TermNames":["->","-/\\","<->","/\\","-.","\\/"],"Delimiters":[]},"Tree":{"Cmd":"thm","Deps":[[[[],[0,[0,[0,0,[0,1,1]],[1,0,1]],[0,[0,[0,0,[0,1,1]],[0,0,[0,1,1]]],[0,[1,0,1],[1,0,1]]]],[]],[1,0,2,3,4,5]],[[[[0,[0,1,0],[0,[0,1,1],[0,0,0]]]],[0,0,[0,1,1]],[]],[1,2,0,3,4]],[[[],[0,[0,0,[0,1,2]],[0,[0,3,[0,3,3]],[0,[0,4,1],[0,[0,0,4],[0,0,4]]]]],[]],[1,2,0,3,4]],[[[[0,0,[0,2,1]]],[0,0,[0,1,2]],[]],[1,2,0,3,4]],[[[[0,0,[0,1,2]]],[0,0,[0,1,1]],[]],[1,2,0,3,4]],[[[[0,[0,0,1],[0,[0,0,0],[0,1,1]]]],[0,0,[0,1,1]],[]],[1,2,0,3,4]],[[[[0,1,[0,0,0]]],[0,[0,0,0],[0,[0,1,1],[0,1,1]]],[]],[1,2,0,3,4]],[[[[0,2,[0,1,3]]],[0,[0,0,1],[0,[0,2,0],[0,2,0]]],[]],[1,2,0,3,4]],[[[],[0,[0,0,1],[0,[0,1,0],[0,1,0]]],[]],[1,2,0,3,4]],[[[[0,0,[0,2,2]],[0,2,[0,1,1]]],[0,0,[0,1,1]],[]],[1,2,0,3,4]],[[[1,[0,1,[0,2,0]]],0,[]],[1,2,0,3,4]]],"Proof":[0,1,"Deps.0","Deps.1",0,1,1,3,[1,2,2],"Deps.2","Deps.3","Deps.4",0,2,"Deps.0","Deps.5","Deps.6",[1,[1,2,2],1],"Deps.7",1,2,"Deps.0","Deps.1",1,[1,2,2],"Deps.8","Deps.9",[1,[0,0,2],[0,0,2]],"Deps.7","Deps.9","Deps.9",[0,1,2],[0,0,2],"Deps.0","Deps.5","Deps.9","Deps.9",[0,0,1],[0,[0,1,2],[0,0,2]],"Deps.0","Deps.5","Deps.10"]}}

var args = Process.argv;
var outDir = args[2];
var factsDb = Level(Path.join(outDir, 'facts.leveldb'));

// Welcome to callback HELL! Muhuhahaha. Ha.

var context = {};
context.requestFact = function(core, hint, cb) {
    var oldHit = context.map[hint.name];
    if (oldHit) {
        console.log("Requeried " + hint.name);
        // move to front of dll
        if (oldHit.node) {
            var p = oldHit.node.prev;
            var q = oldHit.node.next;
            if (p) {
                p.next = q;
            }
            if (q) {
                q.prev = p;
            }
            oldHit.node.prev = null;
            var oldHead = context.proofs.dll;
            oldHit.node.next = oldHead;
            oldHead.prev = oldHit.node;
            context.proofs.dll = oldHit.node;
        }
        cb(null, oldHit.fact);
        return;
    }
    var opts = {start:JSON.stringify(core) + ";"};
    opts.end = opts.start + "\xff";
    var best;
    factsDb.createReadStream(opts).
        on('error', function(err) {
            cb(err, null);
        }).
        on('close', function() {
            /*
            cb("Closed!\n  Query=" + JSON.stringify(opts) +
               "\n  Best=" + JSON.stringify(best), null);
            */
        }).
        on('data', function(data) {
            var fact = new Fact(JSON.parse(data.value));
            //console.log("Queried " + hint.name + " got " + fact.Skin.Name);
            if (!best) {
                best = fact;
            } else if (fact.Skin.Name == hint.name) {
                if ((best.Skin.Name != hint.name) ||
                    ((fact.Tree.Cmd != 'stmt') &&
                     (best.Tree.Cmd == 'stmt'))) {
                    best = fact;
                }
            } else if (fact.Skin.Name == hint.name) {
                console.log("XXXX DUPLICATE! " + hint.name +
                            "\n  fact=" + JSON.stringify(fact) +
                            "\n  best=" + JSON.stringify(best));
            }
        }).
        on('end', function() {
            if (best) {
                if (context.map[best.Skin.Name]) {
                    console.log("# XXXX Already got it");
                    cb(null, best);
                } else {
                    var newNode = {text:null,
                                   prev:null,
                                   next:null};
                    context.map[best.Skin.Name] = {fact: best};
                    var isThm = best.Tree.Cmd !== 'stmt';
                    if (isThm) {
                        context.map[best.Skin.Name].node = newNode;
                    }
                    var where = isThm ? context.proofs : context.iface;
                    newNode.next = where.dll;
                    if (where.dll) {
                        where.dll.prev = newNode;
                    }
                    where.dll = newNode;
                    console.log("# XXXX Getting ghilbert for " +
                                best.Skin.Name +
                                " as " + best.Tree.Cmd);
                    best.toGhilbert(context, function(err, out) {
                        if (err) {
                            console.log("# XXXX Can't get it");
                            cb(err, null);
                        } else {
                            console.log("# XXXX Finished " + best.Skin.Name);
                            newNode.text = out;
                            cb(null, best);
                        }
                    });
                }
            } else {
                cb("Not found!\n  Query=" + JSON.stringify(opts), null);
            }
        });
};

context.map = {};
context.proofs = {
    dll: null,
}

context.iface = {
    dll: null,
}

factsDb.get("[[],[0,[0,0,1],[0,[0,1,2],[0,0,2]]],[]];752fd06a4648a2f576d2e65961f7a2b3dfac09a7", function(err, data) {
    if (err) {
        console.log(err);
    } else {
        var fact = new Fact(JSON.parse(data));
        var node = {
            text:null,
            next:null,
            prev:null
        }
        context.proofs.dll = node;
        context.map[fact.Skin.Name] = {fact:fact, node:node};
        fact.toGhilbert(context, function(err, out) {
            if (err) {
                console.log("ERROR: " + err);
                Process.exit(-1);
            } else {
                node.text = out;
                finish();
            }
        });
    }
});

function logDll(node) {
    if (node) {
        console.log("# Text:\n" + node.text);
        logDll(node.next);
    }
}
function finish() {
    console.log("#### IFACE");
    logDll(context.iface.dll);
    console.log("#### PROOFS");
    logDll(context.proofs.dll);
}<commit_msg>WIP: Scoring for dependencies<commit_after>#!/usr/bin/node
/**
 * query.js
 * Usage: ./query.js dbDir>
 */

var Fact = require('./fact.js');
var Level = require('level');
var Path = require('path');
var Process = process;

// putting [[],[0,[0,0,1],[0,[0,1,2],[0,0,2]]],[]];752fd06a4648a2f576d2e65961f7a2b3dfac09a7 => {"Core":[[],[0,[0,0,1],[0,[0,1,2],[0,0,2]]],[]],"Skin":{"Name":"nic-luk1","HypNames":[],"DepNames":["nic-dfim","nic-bi2","nic-ax","nic-isw2","nic-idel","nic-bi1","nic-idbl","nic-imp","nic-swap","nic-ich","nic-mp"],"VarNames":["ph","ps","ch","ta"],"TermNames":["->","-/\\","<->","/\\","-.","\\/"],"Delimiters":[]},"Tree":{"Cmd":"thm","Deps":[[[[],[0,[0,[0,0,[0,1,1]],[1,0,1]],[0,[0,[0,0,[0,1,1]],[0,0,[0,1,1]]],[0,[1,0,1],[1,0,1]]]],[]],[1,0,2,3,4,5]],[[[[0,[0,1,0],[0,[0,1,1],[0,0,0]]]],[0,0,[0,1,1]],[]],[1,2,0,3,4]],[[[],[0,[0,0,[0,1,2]],[0,[0,3,[0,3,3]],[0,[0,4,1],[0,[0,0,4],[0,0,4]]]]],[]],[1,2,0,3,4]],[[[[0,0,[0,2,1]]],[0,0,[0,1,2]],[]],[1,2,0,3,4]],[[[[0,0,[0,1,2]]],[0,0,[0,1,1]],[]],[1,2,0,3,4]],[[[[0,[0,0,1],[0,[0,0,0],[0,1,1]]]],[0,0,[0,1,1]],[]],[1,2,0,3,4]],[[[[0,1,[0,0,0]]],[0,[0,0,0],[0,[0,1,1],[0,1,1]]],[]],[1,2,0,3,4]],[[[[0,2,[0,1,3]]],[0,[0,0,1],[0,[0,2,0],[0,2,0]]],[]],[1,2,0,3,4]],[[[],[0,[0,0,1],[0,[0,1,0],[0,1,0]]],[]],[1,2,0,3,4]],[[[[0,0,[0,2,2]],[0,2,[0,1,1]]],[0,0,[0,1,1]],[]],[1,2,0,3,4]],[[[1,[0,1,[0,2,0]]],0,[]],[1,2,0,3,4]]],"Proof":[0,1,"Deps.0","Deps.1",0,1,1,3,[1,2,2],"Deps.2","Deps.3","Deps.4",0,2,"Deps.0","Deps.5","Deps.6",[1,[1,2,2],1],"Deps.7",1,2,"Deps.0","Deps.1",1,[1,2,2],"Deps.8","Deps.9",[1,[0,0,2],[0,0,2]],"Deps.7","Deps.9","Deps.9",[0,1,2],[0,0,2],"Deps.0","Deps.5","Deps.9","Deps.9",[0,0,1],[0,[0,1,2],[0,0,2]],"Deps.0","Deps.5","Deps.10"]}}

var args = Process.argv;
var outDir = args[2];
var factsDb = Level(Path.join(outDir, 'facts.leveldb'));

// Welcome to callback HELL! Muhuhahaha. Ha.

function score(fact, hint) {
    var n = 0;
    if (fact.Skin.Name == hint.name) {
        n += 10;
    }
    if ((fact.Tree.Cmd == "stmt") === (hint.name.match(/^ax-/) ? true : false)) {
        n += 1;
    }
    return n;
}
var context = {};
context.requestFact = function(core, hint, cb) {
    var oldHit = context.map[hint.name];
    if (oldHit) {
        console.log("Requeried " + hint.name);
        // move to front of dll
        if (oldHit.node) {
            var p = oldHit.node.prev;
            var q = oldHit.node.next;
            if (p) {
                p.next = q;
            }
            if (q) {
                q.prev = p;
            }
            oldHit.node.prev = null;
            var oldHead = context.proofs.dll;
            oldHit.node.next = oldHead;
            oldHead.prev = oldHit.node;
            context.proofs.dll = oldHit.node;
        }
        cb(null, oldHit.fact);
        return;
    }
    var opts = {start:JSON.stringify(core) + ";"};
    opts.end = opts.start + "\xff";
    var best;
    factsDb.createReadStream(opts).
        on('error', function(err) {
            cb(err, null);
        }).
        on('close', function() {
            /*
            cb("Closed!\n  Query=" + JSON.stringify(opts) +
               "\n  Best=" + JSON.stringify(best), null);
            */
        }).
        on('data', function(data) {
            var fact = new Fact(JSON.parse(data.value));
            //console.log("Queried " + hint.name + " got " + fact.Skin.Name);
            if (!best || (score(fact, hint) > score(best, hint))) {
                best = fact;
            }
        }).
        on('end', function() {
            if (best) {
                if (context.map[best.Skin.Name]) {
                    console.log("# XXXX Already got it");
                    cb(null, best);
                } else {
                    var newNode = {text:null,
                                   prev:null,
                                   next:null};
                    context.map[best.Skin.Name] = {fact: best};
                    var isThm = best.Tree.Cmd !== 'stmt';
                    if (isThm) {
                        context.map[best.Skin.Name].node = newNode;
                    }
                    var where = isThm ? context.proofs : context.iface;
                    newNode.next = where.dll;
                    if (where.dll) {
                        where.dll.prev = newNode;
                    }
                    where.dll = newNode;
                    console.log("# XXXX Getting ghilbert for " +
                                best.Skin.Name +
                                " as " + best.Tree.Cmd);
                    best.toGhilbert(context, function(err, out) {
                        if (err) {
                            console.log("# XXXX Can't get it");
                            cb(err, null);
                        } else {
                            console.log("# XXXX Finished " + best.Skin.Name);
                            newNode.text = out;
                            cb(null, best);
                        }
                    });
                }
            } else {
                cb("Not found!\n  Query=" + JSON.stringify(opts), null);
            }
        });
};

context.map = {};
context.proofs = {
    dll: null,
}

context.iface = {
    dll: null,
}

factsDb.get("[[],[0,[0,0,1],[0,[0,1,2],[0,0,2]]],[]];752fd06a4648a2f576d2e65961f7a2b3dfac09a7", function(err, data) {
    if (err) {
        console.log(err);
    } else {
        var fact = new Fact(JSON.parse(data));
        var node = {
            text:null,
            next:null,
            prev:null
        }
        context.proofs.dll = node;
        context.map[fact.Skin.Name] = {fact:fact, node:node};
        fact.toGhilbert(context, function(err, out) {
            if (err) {
                console.log("ERROR: " + err);
                Process.exit(-1);
            } else {
                node.text = out;
                finish();
            }
        });
    }
});

function logDll(node) {
    if (node) {
        console.log("# Text:\n" + node.text);
        logDll(node.next);
    }
}
function finish() {
    console.log("#### IFACE");
    logDll(context.iface.dll);
    console.log("#### PROOFS");
    logDll(context.proofs.dll);
}<|endoftext|>


<commit_before>foam.CLASS({
  name: 'ExGen',
  extends: 'foam.u2.Controller',

  requires: [
    'foam.audio.Beep',
    'foam.util.Timer'
  ],

  classes: [
    {
      name: 'Exercise',
      properties: [
        {
          class: 'String',
          name: 'name',
        },
        {
          class: 'Int',
          name: 'length'
        },
        {
          class: 'Float',
          name: 'weight',
          value: 1
        }
      ]
    }
  ],

  css: `
    ^ {
      color: #555;
      font-size: larger;
    }
    ^title {
      background: #eee;
      font-size: larger;
      width: 100%;
    }
    ^row {
      padding-left: 4px;
    }
    ^row:hover {
      background: cornflowerblue;
      color: white;
      left-margin: 4px;
    }
    .foam-u2-ProgressView {
      height: 40px;
      vertical-align: bottom;
    }
    .property-duration input { width: 80px; }
    .foam-u2-ActionView-regenerate { margin-right: 60px !important; }
    .foam-u2-ActionView-startTimer, .foam-u2-ActionView-pause, .foam-u2-ActionView-skip  { margin-left: 4px; float: right; }
  `,

  properties: [
    {
      class: 'FObjectArray',
      of: 'Exercise',
      name: 'dictionary'
    },
    {
      class: 'Int',
      name: 'duration',
      value: 10
    },
    {
      class: 'FObjectArray',
      of: 'Exercise',
      name: 'program'
    },
    {
      class: 'FObjectProperty',
      of: 'foam.util.Timer',
      name: 'timer',
      factory: function() { return this.Timer.create(); }
    },
    {
      name: 'totalWeight_',
      expression: function (dictionary) {
        return dictionary.reduce((acc, e) => acc + e.weight, 0);
      }
    },
    {
      name: 'totalDuration_',
      expression: function (program) {
        return program.reduce((acc, e) => acc + e.length, 0);
      }
    },
    {
      name: 'beep',
      factory: function() { return this.Beep.create(); }
    }
  ],

  methods: [
    function initE() {
      this.SUPER();

      var self = this;

      this.dictionary = [
        { name: 'Chin Ups',            length: 1 },
        { name: 'Clean & Press (L+R)', length: 2, weight: 2 },
        { name: 'Curls',               length: 1 },
        { name: 'Dips',                length: 1, weight: 2 },
        { name: 'Floor Press (L+R)',   length: 2, weight: 2 },
        { name: 'Goblet Squat',        length: 1, weight: 1.5 },
        { name: 'Plank',               length: 3, weight: 0.25 },
        { name: 'Press (L+R)',         length: 2, weight: 2 },
        { name: 'Push Ups',            length: 1 },
        { name: 'Rows (L+R)',          length: 2 },
        { name: 'Snatch (L+R)',        length: 2, weight: 1.5 },
        { name: 'Swings (10)',         length: 1, weight: 3 },
        { name: 'Swings (20)',         length: 2 },
        { name: 'Swings (30)',         length: 3, weight: 0.5 },
        { name: 'TGU (L+R)',           length: 2, weight: 2 },
        { name: 'Thrusters',           length: 1, weight: 1 },
      ];

      this.regenerate();
      this.duration$.sub(()=>this.regenerate());

      // Stop timer when workout done
      this.timer.minute$.sub(()=>{
        this.beep.play();
        if ( this.timer.minute >= this.duration ) {
          this.timer.stop();
          this.minute = this.duration-1;
        }
      });

      var startTime;
      this
        .addClass(this.myClass())
        .start('h1')
          .addClass(self.myClass('title'))
          .add('Exercise Generator v1.0')
        .end()
        .add('Duration: ', this.DURATION, ' ', this.REGENERATE, ' ')
        .add(' Seconds: ')
        .tag({class: foam.u2.ProgressView, data$: this.timer.second$.map(s=>100*s/60)})
        .start('span').style({width: '50px', display: 'inline-block', 'padding-left': '4px'}).nbsp().add(' ', this.timer.second$).end()
        .add(' Minutes: ')
        .tag({class: foam.u2.ProgressView, data$: this.timer.minute$.map(m=>100*(m+1)/this.duration)})
        .nbsp().add(' ', this.timer.minute$.map(m=>m+1))
        .add(' ', this.START_TIMER, ' ', this.PAUSE, this.SKIP)
        .tag('hr')
        .forEach(this.program$, function(e, i) {
          if ( i == 0 ) startTime = 0;
          this
          .start()
            .addClass(self.myClass('row'))
            .add(' ')
            .start('span')
              .style({width: '400px', display: 'inline-block', 'margin-bottom': '4px'})
              .add(' ', e.name)
            .end()
            .call(function() {
              for ( var i = 0 ; i < e.length ; i++ ) {
                let myStartTime = startTime + i;
                this.start({class: foam.u2.ProgressView, data$: self.timer.slot(function(minute, second) {
                  return self.timer.minute < myStartTime ? 0 : self.timer.minute > myStartTime ? 100 : 100*self.timer.second/60;
                })})
                  /*
                  .style({'outline': self.timer.slot(function(minute, second) {
                    return minute == myStartTime ? '2px solid red' : '';
                  })})
                  */
                .end();
              }
            })
            .start('span')
              .add('x')
              .style({'padding-top': '7px', 'margin-right': '4px', float: 'right'})
              .on('click', () => {
                var a = foam.Array.clone(self.program);
                a.splice(i, 1);
                self.program = a;
                self.fill();
              })
            .end()
          .end();
          startTime += e.length;
        });
    },

    function pickRandomExercise() {
      var i = Math.random() * this.totalWeight_;
      for ( var j = 0, w = 0 ; ; j++ ) {
        w += this.dictionary[j].weight;
        if ( i < w ) return this.dictionary[j];
      }
    },

    function fill() {
      while ( this.totalDuration_ < this.duration ) {
        var e = this.pickRandomExercise();
        if ( this.totalDuration_ + e.length <= this.duration ) {
          var a = foam.Array.clone(this.program);
          a.push(e);
          this.program = a;
        }
      }
    }
  ],

  actions: [
    function regenerate() {
      this.program = [];
      this.fill();
    },

    {
      name: 'startTimer',
      label: 'Start',
      code: function start() {
        console.log('Start Time: ', new Date());
        this.timer.start();
      }
    },

    function skip() {
      this.timer.time = Math.floor((this.timer.time + 60000) / 60000) * 60000;
    },

    function pause() {
      this.timer.stop();
    }
  ]
});
<commit_msg>Updated.<commit_after>foam.CLASS({
  name: 'ExGen',
  extends: 'foam.u2.Controller',

  requires: [
    'foam.audio.Beep',
    'foam.util.Timer'
  ],

  classes: [
    {
      name: 'Exercise',
      properties: [
        {
          class: 'String',
          name: 'name',
        },
        {
          class: 'Int',
          name: 'length'
        },
        {
          class: 'Float',
          name: 'weight',
          value: 1
        }
      ]
    }
  ],

  css: `
    ^ {
      color: #555;
      font-size: larger;
    }
    ^title {
      padding-left: 4px;
      background: #eee;
      font-size: larger;
      width: 100%;
    }
    ^row {
      padding-left: 4px;
    }
    .foam-u2-ActionView-medium {
      font-size: 10px !important;
      vertical-align: middle !important;
    }
    ^row:hover {
      background: cornflowerblue;
      color: white;
      left-margin: 4px;
    }
    .foam-u2-ProgressView {
      margin-right: 2px;
      height: 40px;
      vertical-align: middle;
    }
    .property-duration input {
      width: 80px;
    }
    .foam-u2-ActionView-regenerate {
      margin-right: 80px !important;
    }
    .foam-u2-ActionView-startTimer, .foam-u2-ActionView-pause, .foam-u2-ActionView-next  {
      margin-left: 4px; float: right;
    }
  `,

  properties: [
    {
      class: 'FObjectArray',
      of: 'Exercise',
      name: 'dictionary'
    },
    {
      class: 'Int',
      name: 'duration',
      value: 30
    },
    {
      class: 'FObjectArray',
      of: 'Exercise',
      name: 'program'
    },
    {
      class: 'FObjectProperty',
      of: 'foam.util.Timer',
      name: 'timer',
      factory: function() { return this.Timer.create({minute: -1}); }
    },
    {
      name: 'totalWeight_',
      expression: function (dictionary) {
        return dictionary.reduce((acc, e) => acc + e.weight, 0);
      }
    },
    {
      name: 'totalDuration_',
      expression: function (program) {
        return program.reduce((acc, e) => acc + e.length, 0);
      }
    },
    {
      name: 'beep',
      factory: function() { return this.Beep.create(); }
    }
  ],

  methods: [
    function initE() {
      this.SUPER();

      var self = this;

      this.dictionary = [
        { name: 'Chin Ups',            length: 1 },
        { name: 'Clean & Press (L+R)', length: 2, weight: 2 },
        { name: 'Curls',               length: 1 },
        { name: 'Dips',                length: 1, weight: 2 },
        { name: 'Floor Press (L+R)',   length: 2, weight: 2 },
        { name: 'Goblet Squat',        length: 1, weight: 1.5 },
        { name: 'Plank',               length: 3, weight: 0.25 },
        { name: 'Press (L+R)',         length: 2, weight: 1 },
        { name: 'Push Ups',            length: 0.9 },
        { name: 'Rows (L+R)',          length: 2 },
        { name: 'Snatch (L+R)',        length: 2, weight: 1.5 },
        { name: 'Swings (10)',         length: 1, weight: 4 },
        { name: 'Swings (20)',         length: 2, weight: 2 },
        { name: 'Swings (30)',         length: 3, weight: 0.5 },
        { name: 'TGU (L+R)',           length: 2, weight: 2 },
        { name: 'Thrusters',           length: 1, weight: 1 },
      ];

      this.regenerate();
      this.duration$.sub(()=>this.regenerate());

      // Stop timer when workout done
      this.timer.minute$.sub(()=>{
        this.beep.play();
        if ( this.timer.minute >= this.duration ) {
          this.timer.stop();
          this.minute = this.duration-1;
        }
      });

      var startTime;
      this
        .addClass(this.myClass())
        .start('h1')
          .addClass(self.myClass('title'))
          .add('Exercise Generator v1.0')
        .end()
        .add('Duration: ', this.DURATION, ' ', this.REGENERATE)

        .add('Minutes: ')
        .tag({class: foam.u2.ProgressView, data$: this.timer.minute$.map(m=>100*(m+1)/this.duration)})
        .start('span')
          .style({width: '10px', display: 'inline-block', 'padding-left': '4px', 'vertical-align': 'middle'})
          .start('span')
            .style({'margin-left':'-110px', color: '#aaa'})
            .add(this.timer.minute$.map(m=>m+1))
          .end()
        .end()

        .add('Seconds: ')
        .tag({class: foam.u2.ProgressView, data$: this.timer.second$.map(s=>100*s/60)})
        .start('span')
          .style({width: '10px', display: 'inline-block', 'padding-left': '4px', 'vertical-align': 'middle'})
          .start('span')
            .style({'margin-left':'-110px', color: '#aaa'})
            .add(this.timer.second$)
          .end()
        .end()

        .add(' ', this.START_TIMER, ' ', this.PAUSE, this.NEXT)
        .tag('hr')
        .forEach(this.program$, function(e, i) {
          if ( i == 0 ) startTime = 0;
          this
          .start()
            .addClass(self.myClass('row'))
            .add(' ')
            .start('span')
              .style({width: '400px', display: 'inline-block', 'margin-bottom': '4px'})
              .add(' ', e.name)
            .end()
            .call(function() {
              for ( var i = 0 ; i < e.length ; i++ ) {
                let myStartTime = startTime + i;
                this.start({class: foam.u2.ProgressView, data$: self.timer.slot(function(minute, second) {
                  return self.timer.minute < myStartTime ? 0 : self.timer.minute > myStartTime ? 100 : 100*self.timer.second/60;
                })})
                  /*
                  .style({'outline': self.timer.slot(function(minute, second) {
                    return minute == myStartTime ? '2px solid red' : '';
                  })})
                  */
                .end();
              }
            })
            .start('span')
              .add('x')
              .style({'padding-top': '7px', 'margin-right': '4px', float: 'right'})
              .on('click', () => {
                var a = foam.Array.clone(self.program);
                a.splice(i, 1);
                self.program = a;
                self.fill();
              })
            .end()
          .end();
          startTime += e.length;
        });
    },

    function pickRandomExercise() {
      var i = Math.random() * this.totalWeight_;
      for ( var j = 0, w = 0 ; ; j++ ) {
        w += this.dictionary[j].weight;
        if ( i < w ) return this.dictionary[j];
      }
    },

    function fill() {
      while ( this.totalDuration_ < this.duration ) {
        var e = this.pickRandomExercise();
        if ( this.totalDuration_ + e.length <= this.duration ) {
          var a = foam.Array.clone(this.program);
          a.push(e);
          this.program = a;
        }
      }
    }
  ],

  actions: [
    function regenerate() {
      this.program = [];
      this.fill();
    },

    {
      name: 'startTimer',
      label: 'Start',
      code: function start() {
        console.log('Start Time: ', new Date());
        this.timer.start();
      }
    },

    function next() {
      this.timer.time = Math.floor((this.timer.time + 60000) / 60000) * 60000;
    },

    function pause() {
      this.timer.stop();
    }
  ]
});
<|endoftext|>


<commit_before>foam.CLASS({
  name: 'ExGen',
  extends: 'foam.u2.Controller',

  requires: [ 'foam.util.Timer' ],

  classes: [
    {
      name: 'Exercise',
      properties: [
        {
          class: 'String',
          name: 'name',
        },
        {
          class: 'Int',
          name: 'length'
        },
        {
          class: 'Float',
          name: 'weight',
          value: 1
        }
      ]
    }
  ],

  css: `
    ^ {
      font-size: larger;
      color: #555;
    }
    ^row {
      padding-left: 4px;
    }
    ^row:hover {
      left-margin: 4px;
      color: white;
      background: cornflowerblue;
    }
    .foam-u2-ProgressView {
      height: 40px;
      vertical-align: bottom;
    }
    .property-duration input { width: 80px; }
    .foam-u2-ActionView-regenerate { margin-right: 60px !important; }
    .foam-u2-ActionView-startTimer, .foam-u2-ActionView-pause, .foam-u2-ActionView-skip  { margin-left: 4px; float: right; }
  `,

  properties: [
    {
      class: 'FObjectArray',
      of: 'Exercise',
      name: 'dictionary'
    },
    {
      class: 'Int',
      name: 'duration',
      value: 10
    },
    {
      class: 'FObjectArray',
      of: 'Exercise',
      name: 'program'
    },
    {
      class: 'FObjectProperty',
      of: 'foam.util.Timer',
      name: 'timer',
      factory: function() { return this.Timer.create({timeWarp: 10}); }
    },
    {
      name: 'totalWeight_',
      expression: function (dictionary) {
        return dictionary.reduce((acc, e) => acc + e.weight, 0);
      }
    },
    {
      name: 'totalDuration_',
      expression: function (program) {
        return program.reduce((acc, e) => acc + e.length, 0);
      }
    }
  ],

  methods: [
    function initE() {
      this.SUPER();

      var self = this;

      this.dictionary = [
        { name: 'Chin Ups',            length: 1 },
        { name: 'Clean & Press (L+R)', length: 2, weight: 2 },
        { name: 'Curls',               length: 1 },
        { name: 'Dips',                length: 1, weight: 2 },
        { name: 'Floor Press (L+R)',   length: 2, weight: 2 },
        { name: 'Goblet Squat',        length: 1, weight: 1.5 },
        { name: 'Plank',               length: 3, weight: 0.25 },
        { name: 'Press (L+R)',         length: 2, weight: 2 },
        { name: 'Push Ups',            length: 1 },
        { name: 'Rows (L+R)',          length: 2 },
        { name: 'Snatch (L+R)',        length: 2, weight: 1.5 },
        { name: 'Swings (10)',         length: 1, weight: 3 },
        { name: 'Swings (20)',         length: 2 },
        { name: 'Swings (30)',         length: 3, weight: 0.5 },
        { name: 'TGU (L+R)',           length: 2, weight: 2 },
        { name: 'Thrusters',           length: 1, weight: 1 },
      ];

      this.regenerate();
      this.duration$.sub(()=>this.regenerate());

      // Stop timer when workout done
      this.timer.minute$.sub(()=>{
        if ( this.timer.minute >= this.duration ) {
          this.timer.stop();
          this.minute = this.duration-1;
        }
      });

      var startTime;
      this
        .addClass(this.myClass())
        .add('Duration: ', this.DURATION, ' ', this.REGENERATE, ' ')
        .add(' Seconds: ')
        .tag({class: foam.u2.ProgressView, data$: this.timer.second$.map(s=>100*s/60)})
        .start('span').style({width: '50px', display: 'inline-block', 'padding-left': '4px'}).add(this.timer.second$).end()
        .add(' Minutes: ')
        .tag({class: foam.u2.ProgressView, data$: this.timer.minute$.map(m=>100*m/this.duration)})
        .add(' ', this.timer.minute$.map(m=>m+1))
        .add(' ', this.START_TIMER, ' ', this.PAUSE, this.SKIP)
        .tag('hr')
        .forEach(this.program$, function(e, i) {
          if ( i == 0 ) startTime = 0;
          this
          .start()
            .addClass(self.myClass('row'))
            .tag({class: 'foam.u2.CheckBox'})
            .add(' ')
            .start('span')
              .style({width: '400px', display: 'inline-block'})
              .add(' ', e.name)
            .end()
            .call(function() {
              for ( var i = 0 ; i < e.length ; i++ ) {
                let myStartTime = startTime + i;
                this.start({class: foam.u2.ProgressView, data$: self.timer.slot(function(minute, second) {
                  return self.timer.minute < myStartTime ? 0 : self.timer.minute > myStartTime ? 100 : 100*self.timer.second/60;
                })})
                  /*
                  .style({'outline': self.timer.slot(function(minute, second) {
                    return minute == myStartTime ? '2px solid red' : '';
                  })})
                  */
                .end();
              }
            })
            .start('span')
              .add('x')
              .style({'vertical-align': 'super', 'margin-right': '4px', float: 'right'})
              .on('click', () => {
                var a = foam.Array.clone(self.program);
                a.splice(i, 1);
                self.program = a;
                self.fill();
              })
            .end()
          .end();
          startTime += e.length;
        });
    },

    function pickRandomExercise() {
      var i = Math.random() * this.totalWeight_;
      for ( var j = 0, w = 0 ; ; j++ ) {
        w += this.dictionary[j].weight;
        if ( i < w ) return this.dictionary[j];
      }
    },

    function fill() {
      while ( this.totalDuration_ < this.duration ) {
        var e = this.pickRandomExercise();
        if ( this.totalDuration_ + e.length <= this.duration ) {
          var a = foam.Array.clone(this.program);
          a.push(e);
          this.program = a;
        }
      }
    }
  ],

  actions: [
    function regenerate() {
      this.program = [];
      this.fill();
    },

    {
      name: 'startTimer',
      label: 'Start',
      code: function start() {
        this.timer.start();
      }
    },

    function skip() {
      this.timer.stop();
    },

    function pause() {
      this.timer.stop();
    }
  ]
});
<commit_msg>Version 1.0<commit_after>foam.CLASS({
  name: 'ExGen',
  extends: 'foam.u2.Controller',

  requires: [ 'foam.util.Timer' ],

  classes: [
    {
      name: 'Exercise',
      properties: [
        {
          class: 'String',
          name: 'name',
        },
        {
          class: 'Int',
          name: 'length'
        },
        {
          class: 'Float',
          name: 'weight',
          value: 1
        }
      ]
    }
  ],

  css: `
    ^ {
      color: #555;
      font-size: larger;
    }
    ^title {
      background: #eee;
      font-size: larger;
      width: 100%;
    }
    ^row {
      padding-left: 4px;
    }
    ^row:hover {
      background: cornflowerblue;
      color: white;
      left-margin: 4px;
    }
    .foam-u2-ProgressView {
      height: 40px;
      vertical-align: bottom;
    }
    .property-duration input { width: 80px; }
    .foam-u2-ActionView-regenerate { margin-right: 60px !important; }
    .foam-u2-ActionView-startTimer, .foam-u2-ActionView-pause, .foam-u2-ActionView-skip  { margin-left: 4px; float: right; }
  `,

  properties: [
    {
      class: 'FObjectArray',
      of: 'Exercise',
      name: 'dictionary'
    },
    {
      class: 'Int',
      name: 'duration',
      value: 10
    },
    {
      class: 'FObjectArray',
      of: 'Exercise',
      name: 'program'
    },
    {
      class: 'FObjectProperty',
      of: 'foam.util.Timer',
      name: 'timer',
      factory: function() { return this.Timer.create(); }
    },
    {
      name: 'totalWeight_',
      expression: function (dictionary) {
        return dictionary.reduce((acc, e) => acc + e.weight, 0);
      }
    },
    {
      name: 'totalDuration_',
      expression: function (program) {
        return program.reduce((acc, e) => acc + e.length, 0);
      }
    }
  ],

  methods: [
    function initE() {
      this.SUPER();

      var self = this;

      this.dictionary = [
        { name: 'Chin Ups',            length: 1 },
        { name: 'Clean & Press (L+R)', length: 2, weight: 2 },
        { name: 'Curls',               length: 1 },
        { name: 'Dips',                length: 1, weight: 2 },
        { name: 'Floor Press (L+R)',   length: 2, weight: 2 },
        { name: 'Goblet Squat',        length: 1, weight: 1.5 },
        { name: 'Plank',               length: 3, weight: 0.25 },
        { name: 'Press (L+R)',         length: 2, weight: 2 },
        { name: 'Push Ups',            length: 1 },
        { name: 'Rows (L+R)',          length: 2 },
        { name: 'Snatch (L+R)',        length: 2, weight: 1.5 },
        { name: 'Swings (10)',         length: 1, weight: 3 },
        { name: 'Swings (20)',         length: 2 },
        { name: 'Swings (30)',         length: 3, weight: 0.5 },
        { name: 'TGU (L+R)',           length: 2, weight: 2 },
        { name: 'Thrusters',           length: 1, weight: 1 },
      ];

      this.regenerate();
      this.duration$.sub(()=>this.regenerate());

      // Stop timer when workout done
      this.timer.minute$.sub(()=>{
        if ( this.timer.minute >= this.duration ) {
          this.timer.stop();
          this.minute = this.duration-1;
        }
      });

      var startTime;
      this
        .addClass(this.myClass())
        .start('h1')
          .addClass(self.myClass('title'))
          .add('Exercise Generator v1.0')
        .end()
        .add('Duration: ', this.DURATION, ' ', this.REGENERATE, ' ')
        .add(' Seconds: ')
        .tag({class: foam.u2.ProgressView, data$: this.timer.second$.map(s=>100*s/60)})
        .start('span').style({width: '50px', display: 'inline-block', 'padding-left': '4px'}).nbsp().add(' ', this.timer.second$).end()
        .add(' Minutes: ')
        .tag({class: foam.u2.ProgressView, data$: this.timer.minute$.map(m=>100*(m+1)/this.duration)})
        .nbsp().add(' ', this.timer.minute$.map(m=>m+1))
        .add(' ', this.START_TIMER, ' ', this.PAUSE, this.SKIP)
        .tag('hr')
        .forEach(this.program$, function(e, i) {
          if ( i == 0 ) startTime = 0;
          this
          .start()
            .addClass(self.myClass('row'))
            .add(' ')
            .start('span')
              .style({width: '400px', display: 'inline-block', 'margin-bottom': '4px'})
              .add(' ', e.name)
            .end()
            .call(function() {
              for ( var i = 0 ; i < e.length ; i++ ) {
                let myStartTime = startTime + i;
                this.start({class: foam.u2.ProgressView, data$: self.timer.slot(function(minute, second) {
                  return self.timer.minute < myStartTime ? 0 : self.timer.minute > myStartTime ? 100 : 100*self.timer.second/60;
                })})
                  /*
                  .style({'outline': self.timer.slot(function(minute, second) {
                    return minute == myStartTime ? '2px solid red' : '';
                  })})
                  */
                .end();
              }
            })
            .start('span')
              .add('x')
              .style({'padding-top': '7px', 'margin-right': '4px', float: 'right'})
              .on('click', () => {
                var a = foam.Array.clone(self.program);
                a.splice(i, 1);
                self.program = a;
                self.fill();
              })
            .end()
          .end();
          startTime += e.length;
        });
    },

    function pickRandomExercise() {
      var i = Math.random() * this.totalWeight_;
      for ( var j = 0, w = 0 ; ; j++ ) {
        w += this.dictionary[j].weight;
        if ( i < w ) return this.dictionary[j];
      }
    },

    function fill() {
      while ( this.totalDuration_ < this.duration ) {
        var e = this.pickRandomExercise();
        if ( this.totalDuration_ + e.length <= this.duration ) {
          var a = foam.Array.clone(this.program);
          a.push(e);
          this.program = a;
        }
      }
    }
  ],

  actions: [
    function regenerate() {
      this.program = [];
      this.fill();
    },

    {
      name: 'startTimer',
      label: 'Start',
      code: function start() {
        console.log('Start Time: ', new Date());
        this.timer.start();
      }
    },

    function skip() {
      this.timer.time = Math.floor((this.timer.time + 60000) / 60000) * 60000;
    },

    function pause() {
      this.timer.stop();
    }
  ]
});
<|endoftext|>


<commit_before>function createAttribute(label , val){
    return {
        "label" : label,
        "value": val //Array
    }
}

function updateLabel(oldLabel,newLabel){
    var shape = findInArray(labellingData[ imgSelected.name ].shapes, "label", oldLabel);
    shape.label = newLabel;
}

function updateFeaturePointInStore(shapeId , pointid, position, newLabel){
    var shape = getShape(shapeId);
    var featurePoints = shape.featurePoints;
    var index = indexOf(featurePoints, "id", pointid);

    if(position){
        featurePoints[index].x = position.cx;
        featurePoints[index].y = position.cy;
    }

    if(newLabel){
        featurePoints[index].label = newLabel
    }
}
function getShape(shapeId){
    return findInArray(labellingData[ imgSelected.name ].shapes, "id", shapeId);
}
function attachPointToShape(shapeId , pointid, position){
    var shape = getShape(shapeId);
    shape.featurePoints.push( {
        "x": position.cx,
        "y": position.cy,
        "label" : shape.featurePoints.length,
        "id" : pointid
    });
}

function detachShape(shapeId){
    var shapes = labellingData[ imgSelected.name ].shapes;
    var index = indexOf(shapes, "id", shapeId);
    shapes.splice(index,1);
}

function detachPoint(shapeId, pointid){
    var shape = getShape(shapeId);
    var featurePoints = shape.featurePoints;
    var index = indexOf(featurePoints, "id", pointid);
    featurePoints.splice(index, 1);
}

function detachPointByIndex(shapeId, pointIndex){
    var shape = getShape(shapeId);
    var featurePoints = shape.featurePoints;
    featurePoints.splice(pointIndex, 1);
}

function updateShapeDetailInStore(shapeId, bbox, points){
    var shapes = labellingData[ imgSelected.name ].shapes;
    var index = indexOf(shapes, "id", shapeId);

    bbox && (shapes[index].bbox = bbox);
    points && (shapes[index].points = points);
}
function attachShapeToImg(id, type, bbox, points){
    labellingData[ imgSelected.name ].shapes.push( {
        "id" : id,
        "label" : "unlabelled",
        "type" : type,
        "points": points,
        "bbox" : bbox || {
            "x": 0,
            "y": 0,
            "w": 0,
            "h": 0        },
        "attributes": [],
        "tags": [],
        "featurePoints": []
    } );
}
function addImgToStore(imgname, size) {
    //If we already have this image data in localstorage,
    //don't initialize its properties
    if(!labellingData[imgname]){
        labellingData[imgname] = {
            //"path" : "",
            "imagename": imgname,
            "attributes": [],
            "tags": [],
            "size" : {
                "width": size.width,
                "height": size.height
            },
            "shapes": []
        }
    }
}

var labellingData = {};
// circle: schema.data[n].shapes[n].points = [cx, cy, r]
// eclipse: schema.data[n].shapes[n].points = [cx, cy, rx, ry]
// line: schema.data[n].shapes[n].points = [x1, y1, x2, y2]
// rectangle: schema.data[n].shapes[n].points = [x, y, w, h]
// polygon: schema.data[n].shapes[n].points = [x1, y1, x2, y2, ...]
// path: schema.data[n].shapes[n].path = ""<commit_msg>feat: added zoomScale and defaultZoomScale in labellingData for each Shape<commit_after>function createAttribute(label , val){
    return {
        "label" : label,
        "value": val //Array
    }
}

function updateLabel(oldLabel,newLabel){
    var shape = findInArray(labellingData[ imgSelected.name ].shapes, "label", oldLabel);
    shape.label = newLabel;
}

function updateFeaturePointInStore(shapeId , pointid, position, newLabel){
    var shape = getShape(shapeId);
    var featurePoints = shape.featurePoints;
    var index = indexOf(featurePoints, "id", pointid);

    if(position){
        featurePoints[index].x = position.cx;
        featurePoints[index].y = position.cy;
    }

    if(newLabel){
        featurePoints[index].label = newLabel
    }
}
function getShape(shapeId){
    return findInArray(labellingData[ imgSelected.name ].shapes, "id", shapeId);
}
function attachPointToShape(shapeId , pointid, position){
    var shape = getShape(shapeId);
    shape.featurePoints.push( {
        "x": position.cx,
        "y": position.cy,
        "label" : shape.featurePoints.length,
        "id" : pointid
    });
}

function detachShape(shapeId){
    var shapes = labellingData[ imgSelected.name ].shapes;
    var index = indexOf(shapes, "id", shapeId);
    shapes.splice(index,1);
}

function detachPoint(shapeId, pointid){
    var shape = getShape(shapeId);
    var featurePoints = shape.featurePoints;
    var index = indexOf(featurePoints, "id", pointid);
    featurePoints.splice(index, 1);
}

function detachPointByIndex(shapeId, pointIndex){
    var shape = getShape(shapeId);
    var featurePoints = shape.featurePoints;
    featurePoints.splice(pointIndex, 1);
}

function updateShapeDetailInStore(shapeId, bbox, points){
    var shapes = labellingData[ imgSelected.name ].shapes;
    var index = indexOf(shapes, "id", shapeId);

    bbox && (shapes[index].bbox = bbox);
    points && (shapes[index].points = points);
}
function attachShapeToImg(id, type, bbox, points){
    labellingData[ imgSelected.name ].shapes.push( {
        "id" : id,
        "label" : "unlabelled",
        "type" : type,
        "points": points,
        "bbox" : bbox || {
            "x": 0,
            "y": 0,
            "w": 0,
            "h": 0        },
        "attributes": [],
        "tags": [],
        "featurePoints": [],
        "zoomScale" : 1,
        "defaultZoomScale": 1/imgSelected.size.imageScale//this scale is in relation with the image scale
    } );
}
function addImgToStore(imgname, size) {
    //If we already have this image data in localstorage,
    //don't initialize its properties
    if(!labellingData[imgname]){
        labellingData[imgname] = {
            //"path" : "",
            "imagename": imgname,
            "attributes": [],
            "tags": [],
            "size" : {
                "width": size.width,
                "height": size.height
            },
            "shapes": []
        }
    }
}

var labellingData = {};
// circle: schema.data[n].shapes[n].points = [cx, cy, r]
// eclipse: schema.data[n].shapes[n].points = [cx, cy, rx, ry]
// line: schema.data[n].shapes[n].points = [x1, y1, x2, y2]
// rectangle: schema.data[n].shapes[n].points = [x, y, w, h]
// polygon: schema.data[n].shapes[n].points = [x1, y1, x2, y2, ...]
// path: schema.data[n].shapes[n].path = ""
<|endoftext|>


<commit_before>var appStore = [
{
  name: 'Feedly',
  tags: ['chrome', 'firefox', 'mobile'],
  description: 'Feedly is a news aggregator application for various Web browsers and mobile devices running iOS and Android.',
  url: 'http://feedly.com/',
  icon: 'http://feedly.com/favicon.ico',
  registration: {
    name: 'Feedly',
    url: 'http://www.feedly.com/home#subscription/feed/{feed}'
  }
},
{
  name: 'The Old Reader',
  tags: ['web', 'popular', 'advanced'],
  description: 'The Old Reader was built to be a Google Reader replacement, and it does it well!',
  url: 'http://theoldreader.com/',
  icon: 'http://theoldreader.com/favicon.ico',
  registration: {
    name: 'The Old Reader',
    url: 'http://theoldreader.com/feeds/subscribe?url={feed}'
  },
  installed: false
},
{
  name: 'Feedbin',
  tags: ['web'],
  description: 'A fast, simple RSS feed reader that delivers a great reading experience.',
  url: 'https://feedbin.me/',
  icon: 'https://feedbin.me/favicon.ico',
  registration: {
    name: 'Feedbin',
    url: 'https://feedbin.me/?subscribe={feed}'
  }
},
{
  name: 'BazQux Reader',
  tags: ['web', 'comments'],
  description: 'RSS feed reader that shows comments to posts and supports reading of Facebook and Google+ pages.',
  url: 'https://bazqux.com/',
  icon: 'https://bazqux.com/favicon.ico',
  registration: {
    name: 'BazQux',
    url: 'https://bazqux.com/add?url={url}'
  }
},
{
  name: 'NewsBlur',
  tags: ['web', 'mobile', 'advanced', 'open source'],
  description: 'NewsBlur is a personal news reader bringing people together to talk about the world.',
  url: 'http://www.newsblur.com/',
  icon: 'http://newsblur.com/favicon.ico',
  registration: {
    name: 'NewsBlur',
    url: 'http://www.newsblur.com/?url={url}'
  },
    installed: true
},
{
  name: 'Digg',
  tags: ['web', 'mobile'],
  description: 'Digg is still one of the most famous news site out there. The Digg reader lets you digg stories up.',
  url: 'https://digg.com/reader/',
  icon: 'https://digg.com//static/images/reader/digg_favicon_reader.png',
  registration: {
    name: 'Digg Reader',
    url: 'http://digg.com/reader/search/{url}'
  }
},
{
  name: 'Rivered',
  tags: ['web'],
  description: 'An uncluttered River of News; no unread item count, no complexity. Just the content you subscribe to.',
  url: 'http://www.rivered.io/',
  icon: 'http://www.rivered.io/favicon.ico',
  registration: {
    name: 'Rivered',
    url: 'http://www.rivered.io/add?url={url}'
  }
},
{
  name: 'Bloglovin',
  tags: ['web', 'iOS', 'blog'],
  description: 'Bloglovin was created to make reading blogs awesome.',
  url: 'http://www.bloglovin.com/',
  icon: 'http://www.bloglovin.com/images/favicon.ico',
  registration: {
    name: 'Bloglovin',
    url: 'http://www.bloglovin.com/search/{url}'
  }
},
{
  name: 'Blogtrottr',
  tags: ['email', 'digests'],
  description: 'Blogtrottr delivers updates from all of your favourite news, feeds, and blogs directly to your email inbox.',
  url: 'http://blogtrottr.com/',
  icon: 'http://blogtrottr.com/favicon.ico',
  registration: {
    name: 'Blogtrottr',
    url: 'http://blogtrottr.com/?subscribe={feed}'
  }
},
{
  name: 'Feedleap',
  tags: ['web', 'kippt', 'bookmark', 'open source'],
  description: 'FeedLeap lets you subscribe to your favorite RSS feeds and store new entries as Clips in any Kippt List you want.',
  url: 'https://feedleap.herokuapp.com',
  icon: 'https://feedleap.herokuapp.com/static/favicon.ico',
  registration: {
    name: 'Feedleap',
    url: 'https://feedleap.herokuapp.com/feeds/new/?feed={feed}&source=subtome'
  }
},
{
  name: 'FeedHQ',
  tags: ['web', 'mobile', 'open source'],
  description: 'FeedHQ is a feed reader built with readability and mobility in mind',
  url: 'https://feedhq.org/',
  icon: 'https://feedhq.org/static/core/img/icon-rss.png',
  registration: {
    name: 'FeedHQ',
    url: 'https://feedhq.org/subscribe/?feeds={feeds}&url={url}'
  }
},
{
  name: 'AOL Reader',
  tags: ['web', 'mobile', 'tablets'],
  description: 'All your favorite websites, in one place',
  url: 'http://reader.aol.com/',
  icon: 'http://www.aol.com/favicon.ico',
  registration: {
    name: 'AOL Reader',
    url: 'http://reader.aol.com/#quickadd/{url}'
  }
},
{
  name: 'InoReader',
  tags: ['web', 'advanced'],
  description: 'Light and Fast RSS/Atom Reader inspired by Google Reader',
  url: 'https://inoreader.com/',
  icon: 'https://inoreader.com/images/icons/72_x_72_pixels.png',
  registration: {
    name: 'InoReader',
    url: 'https://www.inoreader.com/?add_feed={feed}'
  }
},
{
  name: 'ReadHQ',
  tags: ['web', 'mobile'],
  description: "ReadHQ is a new RSS reader which allows you to import, add, manage, organize and enjoy your feeds.",
  url:"https://www.readhq.com",
  icon:"https://www.readhq.com/favicon.ico",
  registration:{
    name: "ReadHQ",
    url: 'https://www.readhq.com/api/v1/subtome?url={url}'
  }
},
{
  name: "MnmlRdr",
  tags: ["web", "mobile", "minimal", "lightweight"],
  description: "A fast and lightweight feed reader without \"feature clutter\" so you can focus on the content.",
  url:"https://mnmlrdr.com/",
  icon:"https://mnmlrdr.com/static/images/logo.png",
  registration:{
    name: "MnmlRdr",
    url: "https://mnmlrdr.com/settings/subscriptions/add?feed={url}"
  }
},
{
  name: "Netvibes",
  tags: ["web", "dashboard", "analytics"],
  description: "Netvibes is the all-in-one dashboard intelligence platform.",
  url:"http://www.netvibes.com",
  icon:"http://cdn.netvibes.com/img/favicon-12.png",
  registration:{
    name: "Netvibes",
    url: "http://www.netvibes.com/subscribe.php?url={url}"
  }
},
{
  name: "Squirro",
  tags: ["web", "intelligence", "assistant"],
  description: "Squirro is the leader in Context Intelligence, combining structured and unstructured data to provide the 'Why' behind the data.",
  url:"http://squirro.com/",
  icon:"http://squirro.com/files/2213/3673/7722/favicon.ico",
  registration:{
    name: "Squirro",
    url: "https://squirro.com/app/#add/query/{url}"
  }
},
{
  name: "Player FM",
  tags: ["podcast", "mobile", "web"],
  description: "Listen to talk shows on hundreds of topics, everything from Politics to Pokemon! ",
  url:"http://player.fm/",
  icon:"http://player.fm/favicon.ico",
  registration:{
    name: "Player FM",
    url: "http://player.fm/series?url={feed}&referrer={url}&related_feeds={feeds}"
  }
},
{
  name: "RSS feed redirect",
  tags: ["developer"],
  description: "Redirects you to the raw RSS feed. This is for advanced users only.",
  url:"",
  icon:"https://upload.wikimedia.org/wikipedia/en/4/43/Feed-icon.svg",
  registration:{
    name: "RSS feed",
    url: "/#/redirect?to={feed}"
  }
}
];
<commit_msg>adding My Yahoo per user request<commit_after>var appStore = [
{
  name: 'Feedly',
  tags: ['chrome', 'firefox', 'mobile'],
  description: 'Feedly is a news aggregator application for various Web browsers and mobile devices running iOS and Android.',
  url: 'http://feedly.com/',
  icon: 'http://feedly.com/favicon.ico',
  registration: {
    name: 'Feedly',
    url: 'http://www.feedly.com/home#subscription/feed/{feed}'
  }
},
{
  name: 'The Old Reader',
  tags: ['web', 'popular', 'advanced'],
  description: 'The Old Reader was built to be a Google Reader replacement, and it does it well!',
  url: 'http://theoldreader.com/',
  icon: 'http://theoldreader.com/favicon.ico',
  registration: {
    name: 'The Old Reader',
    url: 'http://theoldreader.com/feeds/subscribe?url={feed}'
  },
  installed: false
},
{
  name: 'Feedbin',
  tags: ['web'],
  description: 'A fast, simple RSS feed reader that delivers a great reading experience.',
  url: 'https://feedbin.me/',
  icon: 'https://feedbin.me/favicon.ico',
  registration: {
    name: 'Feedbin',
    url: 'https://feedbin.me/?subscribe={feed}'
  }
},
{
  name: 'BazQux Reader',
  tags: ['web', 'comments'],
  description: 'RSS feed reader that shows comments to posts and supports reading of Facebook and Google+ pages.',
  url: 'https://bazqux.com/',
  icon: 'https://bazqux.com/favicon.ico',
  registration: {
    name: 'BazQux',
    url: 'https://bazqux.com/add?url={url}'
  }
},
{
  name: 'NewsBlur',
  tags: ['web', 'mobile', 'advanced', 'open source'],
  description: 'NewsBlur is a personal news reader bringing people together to talk about the world.',
  url: 'http://www.newsblur.com/',
  icon: 'http://newsblur.com/favicon.ico',
  registration: {
    name: 'NewsBlur',
    url: 'http://www.newsblur.com/?url={url}'
  },
    installed: true
},
{
  name: 'Digg',
  tags: ['web', 'mobile'],
  description: 'Digg is still one of the most famous news site out there. The Digg reader lets you digg stories up.',
  url: 'https://digg.com/reader/',
  icon: 'https://digg.com//static/images/reader/digg_favicon_reader.png',
  registration: {
    name: 'Digg Reader',
    url: 'http://digg.com/reader/search/{url}'
  }
},
{
  name: 'Rivered',
  tags: ['web'],
  description: 'An uncluttered River of News; no unread item count, no complexity. Just the content you subscribe to.',
  url: 'http://www.rivered.io/',
  icon: 'http://www.rivered.io/favicon.ico',
  registration: {
    name: 'Rivered',
    url: 'http://www.rivered.io/add?url={url}'
  }
},
{
  name: 'Bloglovin',
  tags: ['web', 'iOS', 'blog'],
  description: 'Bloglovin was created to make reading blogs awesome.',
  url: 'http://www.bloglovin.com/',
  icon: 'http://www.bloglovin.com/images/favicon.ico',
  registration: {
    name: 'Bloglovin',
    url: 'http://www.bloglovin.com/search/{url}'
  }
},
{
  name: 'Blogtrottr',
  tags: ['email', 'digests'],
  description: 'Blogtrottr delivers updates from all of your favourite news, feeds, and blogs directly to your email inbox.',
  url: 'http://blogtrottr.com/',
  icon: 'http://blogtrottr.com/favicon.ico',
  registration: {
    name: 'Blogtrottr',
    url: 'http://blogtrottr.com/?subscribe={feed}'
  }
},
{
  name: 'Feedleap',
  tags: ['web', 'kippt', 'bookmark', 'open source'],
  description: 'FeedLeap lets you subscribe to your favorite RSS feeds and store new entries as Clips in any Kippt List you want.',
  url: 'https://feedleap.herokuapp.com',
  icon: 'https://feedleap.herokuapp.com/static/favicon.ico',
  registration: {
    name: 'Feedleap',
    url: 'https://feedleap.herokuapp.com/feeds/new/?feed={feed}&source=subtome'
  }
},
{
  name: 'FeedHQ',
  tags: ['web', 'mobile', 'open source'],
  description: 'FeedHQ is a feed reader built with readability and mobility in mind',
  url: 'https://feedhq.org/',
  icon: 'https://feedhq.org/static/core/img/icon-rss.png',
  registration: {
    name: 'FeedHQ',
    url: 'https://feedhq.org/subscribe/?feeds={feeds}&url={url}'
  }
},
{
  name: 'AOL Reader',
  tags: ['web', 'mobile', 'tablets'],
  description: 'All your favorite websites, in one place',
  url: 'http://reader.aol.com/',
  icon: 'http://www.aol.com/favicon.ico',
  registration: {
    name: 'AOL Reader',
    url: 'http://reader.aol.com/#quickadd/{url}'
  }
},
{
  name: 'InoReader',
  tags: ['web', 'advanced'],
  description: 'Light and Fast RSS/Atom Reader inspired by Google Reader',
  url: 'https://inoreader.com/',
  icon: 'https://inoreader.com/images/icons/72_x_72_pixels.png',
  registration: {
    name: 'InoReader',
    url: 'https://www.inoreader.com/?add_feed={feed}'
  }
},
{
  name: 'ReadHQ',
  tags: ['web', 'mobile'],
  description: "ReadHQ is a new RSS reader which allows you to import, add, manage, organize and enjoy your feeds.",
  url:"https://www.readhq.com",
  icon:"https://www.readhq.com/favicon.ico",
  registration:{
    name: "ReadHQ",
    url: 'https://www.readhq.com/api/v1/subtome?url={url}'
  }
},
{
  name: "MnmlRdr",
  tags: ["web", "mobile", "minimal", "lightweight"],
  description: "A fast and lightweight feed reader without \"feature clutter\" so you can focus on the content.",
  url:"https://mnmlrdr.com/",
  icon:"https://mnmlrdr.com/static/images/logo.png",
  registration:{
    name: "MnmlRdr",
    url: "https://mnmlrdr.com/settings/subscriptions/add?feed={url}"
  }
},
{
  name: "Netvibes",
  tags: ["web", "dashboard", "analytics"],
  description: "Netvibes is the all-in-one dashboard intelligence platform.",
  url:"http://www.netvibes.com",
  icon:"http://cdn.netvibes.com/img/favicon-12.png",
  registration:{
    name: "Netvibes",
    url: "http://www.netvibes.com/subscribe.php?url={url}"
  }
},
{
  name: "Squirro",
  tags: ["web", "intelligence", "assistant"],
  description: "Squirro is the leader in Context Intelligence, combining structured and unstructured data to provide the 'Why' behind the data.",
  url:"http://squirro.com/",
  icon:"http://squirro.com/files/2213/3673/7722/favicon.ico",
  registration:{
    name: "Squirro",
    url: "https://squirro.com/app/#add/query/{url}"
  }
},
{
  name: "Player FM",
  tags: ["podcast", "mobile", "web"],
  description: "Listen to talk shows on hundreds of topics, everything from Politics to Pokemon! ",
  url:"http://player.fm/",
  icon:"http://player.fm/favicon.ico",
  registration:{
    name: "Player FM",
    url: "http://player.fm/series?url={feed}&referrer={url}&related_feeds={feeds}"
  }
},
{
  name: "My Yahoo",
  tags: ["yahoo", "legacy"],
  description: "My Yahoo is a customizable web page with news, stock quotes, weather, and many other features.",
  url:"http://my.yahoo.com/",
  icon:"http://my.yahoo.com/favicon.ico",
  registration:{
    name: "My Yahoo",
    url: "http://add.my.yahoo.com/rss?url={feed}"
  }
},
{
  name: "RSS feed redirect",
  tags: ["developer"],
  description: "Redirects you to the raw RSS feed. This is for advanced users only.",
  url:"",
  icon:"https://upload.wikimedia.org/wikipedia/en/4/43/Feed-icon.svg",
  registration:{
    name: "RSS feed",
    url: "/#/redirect?to={feed}"
  }
}
];
<|endoftext|>


<commit_before>/***
Get to testing!
    * [x] What kind of thing is `game.board`...? What does it do?
    * [x] How about `game.reset`? What does it _return_? Any side-effects?
    * [ ] Resetting a board with no moves is lame, HOW U EVEN `game.applyMove`?
    * [ ] First move is free, next one costs $10.
    * [ ] Just calling `game.applyMove` is cheating; `game.next`...!
    * [ ] Now that you've got some moves, maybe `game.reset` is more interesting?
    * [ ] You can `game.next` but can you `game.prev`...?
    * [ ] Y'know, `game.end` is really a lot of `game.next`...
    * [ ] That `game.play`, tho... How U even `setInterval`?
  * [ ] Wipe the tracer bullets out before you push!

***/
(function(globals){

it('should be a function', function(){
  chai.expect(game.board).to.be.a('function'); //game is the name of the object that board is a property of

});

it('should return an array', function(){
  chai.expect(game.board()).to.be.an('array');
});

it('should be a function', function(){
  chai.expect(game.reset).to.be.a('function');
});

it('should return an object', function(){
  chai.expect(game.reset()).to.be.an('object');
});

it.skip('should be a dictionary', function(){             //moves is not defined?
  chai.expect(global.moves[0]).to.be.an('object');
});

it('should be a function', function(){
  chai.expect(game.applyMove).to.be.a('function');
});

it('should move one piece', function(){
  var board = game.board();

  //precondition
  chai.expect(board[6][3]).to.equal('p');
  chai.expect(board[4][3]).to.be.null;

  //action
  chai.expect(game.applyMove(
    {rank: 6, to: 3},
    {rank: 4, to: 3}
  )).to.equal(undefined);

// game.reset();
  //post condition
  chai.expect(board[6][3]).to.be.null;
  chai.expect(board[4][3]).to.be.equal('p');
});
})(window || module && module.exports || this);
<commit_msg>changes<commit_after>/***
Get to testing!
    * [x] What kind of thing is `game.board`...? What does it do?
    * [x] How about `game.reset`? What does it _return_? Any side-effects?
    * [ ] Resetting a board with no moves is lame, HOW U EVEN `game.applyMove`?
    * [ ] First move is free, next one costs $10.
    * [ ] Just calling `game.applyMove` is cheating; `game.next`...!
    * [ ] Now that you've got some moves, maybe `game.reset` is more interesting?
    * [ ] You can `game.next` but can you `game.prev`...?
    * [ ] Y'know, `game.end` is really a lot of `game.next`...
    * [ ] That `game.play`, tho... How U even `setInterval`?
  * [ ] Wipe the tracer bullets out before you push!

***/
(function(globals){

it('should be a function', function(){
  chai.expect(game.board).to.be.a('function'); //game is the name of the object that board is a property of

});

it('should return an array', function(){
  chai.expect(game.board()).to.be.an('array');
});

it('should be a function', function(){
  chai.expect(game.reset).to.be.a('function');
});

it('should return an object', function(){
  chai.expect(game.reset()).to.be.an('object');
});

it.skip('should be a dictionary', function(){             //moves is not defined?
  chai.expect(global.moves[0]).to.be.an('object');
});

it('should be a function', function(){
  chai.expect(game.applyMove).to.be.a('function');
});

it('should move one piece', function(){
  var board = game.board();

  //precondition
  chai.expect(board[6][3]).to.equal('p');
  chai.expect(board[4][3]).to.be.null;

  //action
  chai.expect(game.applyMove()).to.equal(undefined);

// game.reset();
  //post condition
  chai.expect(board[6][3]).to.be.null;
  chai.expect(board[4][3]).to.be.equal('p');
});
})(window || module && module.exports || this);
<|endoftext|>


<commit_before>//(c) Scott Gavin, PIPSQUEAK 2015
//requires JQuery, filesystem.js

//the way this works is that squeak is basically a namespace, and any "pub.x" items are made public, whereas the rest are private to the namespace
var squeak = (function () {
    'use strict';
    var pub = {},
        id = 0,
        listOfActions = [],
        writeListToFrontend;
    //adds an action to the list of actions
    pub.addAction = function (startLine, endLine, startTime, endTime, action) {
        var i;
        endLine = endLine == null ? startLine : endLine;
        if(endLine < startLine) {
            i = endLine;
            endline = startLine;
            startLine = endLine;
        }
        if (startTime > endTime) {
            console.log("The end time cannot be before the start time");
            return false;
        }
        //add additional actions names here
        if (action !== 'strike' && action !== 'highlight' && action !== 'focus' && action !== 'fadeIn' && action !== 'fadeOut' && action !== 'anchor' && action !== 'autoScroll') {
            throw action + " is not an allowed action";
        }

        for(i = startLine; i <= endLine; i++) {
            var actionNode = {}; //ugly, but it works
            id += 1;
            actionNode.tool = action;
            actionNode.line = i;
            actionNode.startTime = startTime;
            actionNode.endTime = endTime;
            actionNode.id = id;
            listOfActions.push(actionNode);
        }
        writeListToFrontend();
    };
    //deletes a node from the list.
    pub.deleteAction = function (remId) {
        var ii = 0;
        if (remId <= 0 || remId > id) {
            console.log("Id was not found");
            return false;
        }
        //since the id starts at 1 and were keeping them in order theres no need to search for an id.
        //increase the ids of all higher nodes
        for (ii = remId; ii < id; ii += 1) {
            listOfActions[ii].id = listOfActions[ii].id - 1;
        }
        //delete the node
        listOfActions.splice(remId - 1, 1);
        id -= 1;
        writeListToFrontend();
        return true;
    };
    //TODO - fix this so it can undo deletes, and add a redo. will need at least 1 more "stack" (array)
    //undo a change. Probably needs a bit of tweaking, for instance ability to undo deletes.
    pub.undo = function () {
        if (id <= 0) {
            return false;
        }
        id -= 1;
        listOfActions.splice(id, 1);
        writeListToFrontend();
        return true;
    };

    //function that writes the list to the running frontend display
    writeListToFrontend = function () {
        var i;

        //clear the table - extremely hamfisted
        $('.actionsTable').html("

Line #	Time	Tool	Delete

");
        //run through the list.
        for(i = 0; i < listOfActions.length; i++) {
            $('.actionsTable > tbody:last').append('
' + listOfActions[i].line + '	' + listOfActions[i].startTime.toFixed(2) + ' - ' + listOfActions[i].endTime.toFixed(2) + '	'+listOfActions[i].tool+'	X
');
        }
        return true;
    }
    //TODO - most of this.
    //will need to pull the video and codemirror segment and write those to the output template in the right places

    pub.publish = function () {
        var i,
            sinAction,
            runAction,
            popcornFile = "";
        initialize();
        runAction = function (line, startTime, endTime, action) {
        //only runAction can call the worker functions
            var focus,
                highlight,
                strike,
                annotate,
                fadeIn,
                fadeOut,
                anchor,
                autoScroll;
             //TODO - actual worker functions
            focus = function (line, startTime, endTime) {
                return false;
            };
            highlight = function (line, startTime, endTime) {
				//the code will be the css we decide to use for highlight
				//use jquery .css, but need to figure out how we want a highlight to look.
                var start,
                    end;
                start = "pop.code ({\n\tstart: " + startTime + ",\n\tend: " + startTime
                    + ",\n\tonStart: function() {\n\t\t$(\'"+line+"\').addClass(\"highlight\")\n\t}\n});\n";
                end = "pop.code ({\n\tstart: " + endTime + ",\n\tend: " + endTime
                    + ",\n\tonStart: function() {\n\t\t$(\'"+line+"\').removeClass(\"highlight\")\n\t}\n});\n";
                popcornFile += start;
                popcornFile += end;
                return true;
            };
            strike = function (line, startTime, endTime) {
				//need to determine how were finding a line, adding a class to each line.
				//for strike we'll need a pop for start time, and then a pop for end time.
				//start will strike the code, end will unstrike the code.
				var code = $("" + line + "").html(),
					start = "pop.code ({\n\tstart: " + startTime + ",\n\tend: " + startTime
                    + ",\n\tonStart: function() {\n\t\t$(\'"+line+"\').addClass(\"strike\")\n\t}\n});\n",
					end = "pop.code ({\n\tstart: " + endTime + ",\n\tend: " + endTime
                    + ",\n\tonStart: function() {\n\t\t$(\'"+line+"\').removeClass(\"strike\")\n\t}\n});\n";
                popcornFile += start;
                popcornFile += end;
                return true;
            };
            annotate = function (line, startTime, endTime) {
                return false;
            };
            fadeIn = function (line, startTime, endTime) {
                return false;
            };
            fadeOut = function (line, startTime, endTime) {
                return false;
            };
            anchor = function (line, startTime, endTime) {
                return false;
            };
            autoScroll = function (line, startTime, endTime) {
                return false;
            };
            //body of runAction
            if (action === 'strike') {
                //call strike function
                console.log("Striking line " + line + " from time " + startTime + " to time " + endTime + ".");
                console.log(strike(line, startTime, endTime));
            } else if (action === 'highlight') {
                //call highlight function
                console.log("Highlighting line " + line + " from time " + startTime + " to time " + endTime + ".");
                console.log(highlight(line, startTime, endTime));
            } else if (action === 'focus') {
                //call focus function
                console.log("Focusing line " + line + " from time " + startTime + " to time " + endTime + ".");
                console.log(focus(line, startTime, endTime));
            } else if (action === 'annotate') {
                //call annotate function
                console.log("Annotating line " + line + " from time " + startTime + " to time " + endTime + ".");
                console.log(annotate(line, startTime, endTime));

            } else if (action === 'fadeOut') {
                //call fadeOut function
                console.log("Fading out line " + line + " from time " + startTime + " to time " + endTime + ".");
                console.log(fadeOut(line, startTime, endTime));

            } else if (action === 'fadeIn') {
                //call fadeIn function
                console.log("Fading in line " + line + " from time " + startTime + " to time " + endTime + ".");
                console.log(fadeIn(line, startTime, endTime));

            } else if (action === 'anchor') {
                //call anchor function
                console.log("Anchoring? line " + line + " from time " + startTime + " to time " + endTime + ".");
                console.log(anchor(line, startTime, endTime));

            } else if (action === 'autoScroll') {
                //call autoScroll function
                console.log("Scrolling? line " + line + " from time " + startTime + " to time " + endTime + ".");
                console.log(autoScroll(line, startTime, endTime));

            }
            else {
                console.log(action + " is not an accepted action in function runAction");
                return false;
            }
            return true;
        };
        //when they hit publish run through the codemirror div and assign each individual LINE to an array location, with arr[0] being empty for simplicity
        //TODO - read in codemirror portion and parse into individual lines for wrapping or class adding.
        var start, end;
        for (i = 0; i < id; i += 1) {
            //if i remember right this is more efficient that calling to the array each time, but i could be wrong
            sinAction = listOfActions[i];
            start = "pop.code ({\n\tstart: " + sinAction.startTime + ",\n\tend: " + sinAction.startTime
                    + ",\n\tonStart: function() {\n\t\t$(\'"+sinAction.line+"\').addClass(\"" + sinAction.tool + "\")\n\t}\n});\n";
            end = "pop.code ({\n\tstart: " + sinAction.endTime + ",\n\tend: " + sinAction.endTime
                    + ",\n\tonStart: function() {\n\t\t$(\'"+sinAction.line+"\').removeClass(\"" + sinAction.tool + "\")\n\t}\n});\n";
            popcornFile += start;
            popcornFile += end;
            /*if (runAction(sinAction.line, sinAction.startTime, sinAction.endTime, sinAction.tool) === false) {
                console.log("Error in running the Actions list");
                //may want some error handling in here or something.
            }*/

        }
        //TODO - write the media and input code to a template file
        //write the popcorn functions to a javascript file
        writeFile("./publish/js/pop.js",popcornFile);
        alert("The tutorial has been published to " + process.cwd() + "/publish");
        return true;
    };
    //just a tester function
    pub.showList = function () {
        console.log(listOfActions);
    };
    return pub;
}());<commit_msg>copy video to media on publish<commit_after>//(c) Scott Gavin, PIPSQUEAK 2015
//requires JQuery, filesystem.js

//the way this works is that squeak is basically a namespace, and any "pub.x" items are made public, whereas the rest are private to the namespace
var squeak = (function () {
    'use strict';
    var pub = {},
        id = 0,
        listOfActions = [],
        writeListToFrontend;
    //adds an action to the list of actions
    pub.addAction = function (startLine, endLine, startTime, endTime, action) {
        var i;
        endLine = endLine == null ? startLine : endLine;
        if(endLine < startLine) {
            i = endLine;
            endline = startLine;
            startLine = endLine;
        }
        if (startTime > endTime) {
            console.log("The end time cannot be before the start time");
            return false;
        }
        //add additional actions names here
        if (action !== 'strike' && action !== 'highlight' && action !== 'focus' && action !== 'fadeIn' && action !== 'fadeOut' && action !== 'anchor' && action !== 'autoScroll') {
            throw action + " is not an allowed action";
        }

        for(i = startLine; i <= endLine; i++) {
            var actionNode = {}; //ugly, but it works
            id += 1;
            actionNode.tool = action;
            actionNode.line = i;
            actionNode.startTime = startTime;
            actionNode.endTime = endTime;
            actionNode.id = id;
            listOfActions.push(actionNode);
        }
        writeListToFrontend();
    };
    //deletes a node from the list.
    pub.deleteAction = function (remId) {
        var ii = 0;
        if (remId <= 0 || remId > id) {
            console.log("Id was not found");
            return false;
        }
        //since the id starts at 1 and were keeping them in order theres no need to search for an id.
        //increase the ids of all higher nodes
        for (ii = remId; ii < id; ii += 1) {
            listOfActions[ii].id = listOfActions[ii].id - 1;
        }
        //delete the node
        listOfActions.splice(remId - 1, 1);
        id -= 1;
        writeListToFrontend();
        return true;
    };
    //TODO - fix this so it can undo deletes, and add a redo. will need at least 1 more "stack" (array)
    //undo a change. Probably needs a bit of tweaking, for instance ability to undo deletes.
    pub.undo = function () {
        if (id <= 0) {
            return false;
        }
        id -= 1;
        listOfActions.splice(id, 1);
        writeListToFrontend();
        return true;
    };

    //function that writes the list to the running frontend display
    writeListToFrontend = function () {
        var i;

        //clear the table - extremely hamfisted
        $('.actionsTable').html("

Line #	Time	Tool	Delete

");
        //run through the list.
        for(i = 0; i < listOfActions.length; i++) {
            $('.actionsTable > tbody:last').append('
' + listOfActions[i].line + '	' + listOfActions[i].startTime.toFixed(2) + ' - ' + listOfActions[i].endTime.toFixed(2) + '	'+listOfActions[i].tool+'	X
');
        }
        return true;
    }
    //TODO - most of this.
    //will need to pull the video and codemirror segment and write those to the output template in the right places

    //requires video path from frontend
    pub.publish = function (media) {
        var i,
            sinAction,
            runAction,
            popcornFile = "";
        if(video == null) {
            throw "Error, no media input to publish";
        }
        initialize();
        //TODO: handle file to get its name from its path, and determine if video or audio, as well as published directory name.
        //proof of concept
        fs.createReadStream(media).pipe(fs.createWriteStream('./publish/assets/video/video.ogv'));
        /*runAction = function (line, startTime, endTime, action) {
        //only runAction can call the worker functions
            var focus,
                highlight,
                strike,
                annotate,
                fadeIn,
                fadeOut,
                anchor,
                autoScroll;
             //TODO - actual worker functions
            focus = function (line, startTime, endTime) {
                return false;
            };
            highlight = function (line, startTime, endTime) {
				//the code will be the css we decide to use for highlight
				//use jquery .css, but need to figure out how we want a highlight to look.
                var start,
                    end;
                start = "pop.code ({\n\tstart: " + startTime + ",\n\tend: " + startTime
                    + ",\n\tonStart: function() {\n\t\t$(\'"+line+"\').addClass(\"highlight\")\n\t}\n});\n";
                end = "pop.code ({\n\tstart: " + endTime + ",\n\tend: " + endTime
                    + ",\n\tonStart: function() {\n\t\t$(\'"+line+"\').removeClass(\"highlight\")\n\t}\n});\n";
                popcornFile += start;
                popcornFile += end;
                return true;
            };
            strike = function (line, startTime, endTime) {
				//need to determine how were finding a line, adding a class to each line.
				//for strike we'll need a pop for start time, and then a pop for end time.
				//start will strike the code, end will unstrike the code.
				var code = $("" + line + "").html(),
					start = "pop.code ({\n\tstart: " + startTime + ",\n\tend: " + startTime
                    + ",\n\tonStart: function() {\n\t\t$(\'"+line+"\').addClass(\"strike\")\n\t}\n});\n",
					end = "pop.code ({\n\tstart: " + endTime + ",\n\tend: " + endTime
                    + ",\n\tonStart: function() {\n\t\t$(\'"+line+"\').removeClass(\"strike\")\n\t}\n});\n";
                popcornFile += start;
                popcornFile += end;
                return true;
            };
            annotate = function (line, startTime, endTime) {
                return false;
            };
            fadeIn = function (line, startTime, endTime) {
                return false;
            };
            fadeOut = function (line, startTime, endTime) {
                return false;
            };
            anchor = function (line, startTime, endTime) {
                return false;
            };
            autoScroll = function (line, startTime, endTime) {
                return false;
            };
            //body of runAction
            if (action === 'strike') {
                //call strike function
                console.log("Striking line " + line + " from time " + startTime + " to time " + endTime + ".");
                console.log(strike(line, startTime, endTime));
            } else if (action === 'highlight') {
                //call highlight function
                console.log("Highlighting line " + line + " from time " + startTime + " to time " + endTime + ".");
                console.log(highlight(line, startTime, endTime));
            } else if (action === 'focus') {
                //call focus function
                console.log("Focusing line " + line + " from time " + startTime + " to time " + endTime + ".");
                console.log(focus(line, startTime, endTime));
            } else if (action === 'annotate') {
                //call annotate function
                console.log("Annotating line " + line + " from time " + startTime + " to time " + endTime + ".");
                console.log(annotate(line, startTime, endTime));

            } else if (action === 'fadeOut') {
                //call fadeOut function
                console.log("Fading out line " + line + " from time " + startTime + " to time " + endTime + ".");
                console.log(fadeOut(line, startTime, endTime));

            } else if (action === 'fadeIn') {
                //call fadeIn function
                console.log("Fading in line " + line + " from time " + startTime + " to time " + endTime + ".");
                console.log(fadeIn(line, startTime, endTime));

            } else if (action === 'anchor') {
                //call anchor function
                console.log("Anchoring? line " + line + " from time " + startTime + " to time " + endTime + ".");
                console.log(anchor(line, startTime, endTime));

            } else if (action === 'autoScroll') {
                //call autoScroll function
                console.log("Scrolling? line " + line + " from time " + startTime + " to time " + endTime + ".");
                console.log(autoScroll(line, startTime, endTime));

            }
            else {
                console.log(action + " is not an accepted action in function runAction");
                return false;
            }
            return true;
        }; */
        //when they hit publish run through the codemirror div and assign each individual LINE to an array location, with arr[0] being empty for simplicity
        //TODO - read in codemirror portion and parse into individual lines for wrapping or class adding.
        var start, end;
        for (i = 0; i < id; i += 1) {
            //if i remember right this is more efficient that calling to the array each time, but i could be wrong
            sinAction = listOfActions[i];
            start = "pop.code ({\n\tstart: " + sinAction.startTime + ",\n\tend: " + sinAction.startTime
                    + ",\n\tonStart: function() {\n\t\t$(\'"+sinAction.line+"\').addClass(\"" + sinAction.tool + "\")\n\t}\n});\n";
            end = "pop.code ({\n\tstart: " + sinAction.endTime + ",\n\tend: " + sinAction.endTime
                    + ",\n\tonStart: function() {\n\t\t$(\'"+sinAction.line+"\').removeClass(\"" + sinAction.tool + "\")\n\t}\n});\n";
            popcornFile += start;
            popcornFile += end;
            /*if (runAction(sinAction.line, sinAction.startTime, sinAction.endTime, sinAction.tool) === false) {
                console.log("Error in running the Actions list");
                //may want some error handling in here or something.
            }*/

        }
        //TODO - write the media and input code to a template file
        //write the popcorn functions to a javascript file
        writeFile("./publish/js/pop.js",popcornFile);
        alert("The tutorial has been published to " + process.cwd() + "/publish");
        return true;
    };
    //just a tester function
    pub.showList = function () {
        console.log(listOfActions);
    };
    return pub;
}());<|endoftext|>