<commit_before>(function (angular) {
    'use strict';
    var archivoPerfilControllerApp = angular.module('archivoPerfil', ['ngAnimate', 'ngSanitize', 'ui.bootstrap', 'ui.grid', 'ngTouch', 'ui.grid.edit', 'ui.grid.autoResize', 'ui.grid.selection', 'ui.grid.cellNav', 'xeditable'])
    .controller('archivoPerfilController', ['$scope', '$http', '$window', '$location', '$filter', 'uiGridConstants', 'i18nService', '$scope', function ($scope, $http, $window, $location, $filter, i18nService, uiGridConstants) {
        var init = function () {
            $scope.archivoID = $window.localStorage.getItem("archivoID");
            // DATOS PRINCIPALES
            $scope.cargarDatosPrincipales();
            // ANOTACIONES
            $scope.cargarNotas();
        };

        //Datos principales
        $scope.archivoDatos = {};
        $scope.datosPrincipales = {};
        $scope.datosPrincipales.archivoTitulo = "";
        $scope.datosPrincipales.archivoNombre = "";
        $scope.datosPrincipales.institucionFondo = "";
        $scope.datosPrincipales.seccion = "";
        $scope.datosPrincipales.numRefDentroFondo = "";
        $scope.datosPrincipales.archivoFecha = "";
        $scope.datosPrincipales.folioInicial = "";
        $scope.datosPrincipales.folioFinal = "";
        $scope.datosPrincipales.legajo = "";
        $scope.datosPrincipales.numOrden = "";
        $scope.datosPrincipales.numPaginas = "";
        $scope.datosPrincipales.palabrasClaves = {};
        $scope.datosPrincipales.disponibilidad = "";

        //Bandera para saber cuando guardar o no
        $scope.datosPrincipales.editado = false;

        $scope.cargarDatosPrincipales = function () {
            $http.get('http://monsalvediaz.com:5000/PIMC0.1/ConsultaArchivo?archivoID=' + $scope.archivoID).then(function (data) {
                //Obtener los datos JSON
                $scope.archivoDatos = data.data[0];
                //Log
                console.log($scope.archivoDatos);

                //Llenamos los datos del archivo
                $scope.datosPrincipales.archivoTitulo = $scope.archivoDatos.titulo;
                $scope.datosPrincipales.archivoNombre = $scope.archivoDatos.fondo;
                $scope.datosPrincipales.institucionFondo = $scope.archivoDatos.institucionFondo;
                $scope.datosPrincipales.seccion = $scope.archivoDatos.seccion;
                $scope.datosPrincipales.numRefDentroFondo = $scope.archivoDatos.numRefDentroFondo;
                $scope.datosPrincipales.archivoFecha = $filter('date')(new Date($scope.archivoDatos.fechaInicial), String($scope.archivoDatos.fechaInicialFormato).toLowerCase()) + " - " + $filter('date')(new Date($scope.archivoDatos.fechaFinal), String($scope.archivoDatos.fechaFinalFormato).toLowerCase());
                $scope.datosPrincipales.folioInicial = $scope.archivoDatos.folioInicial;
                $scope.datosPrincipales.folioFinal = $scope.archivoDatos.folioFinal;
                $scope.datosPrincipales.legajo = $scope.archivoDatos.legajo;
                $scope.datosPrincipales.numOrden = $scope.archivoDatos.numOrden;
                $scope.datosPrincipales.numPaginas = $scope.archivoDatos.numPaginas;
                $scope.datosPrincipales.palabrasClaves = $scope.archivoDatos.palabrasClaves.split(",");
                $scope.datosPrincipales.palabrasClaves = $scope.datosPrincipales.palabrasClaves.map(function (e) { return e.trim(); });

                $scope.datosPrincipales.disponibilidad = $scope.archivoDatos.disponibilidad;
                //Limpiamos la bandera de editado
                $scope.datosPrincipales.editado = false;

                //Para palabras claves
                $scope.palabraNueva = {mensaje:"+Agregar"};

            });
        };

        // Anotaciones
        $scope.notas = "";
        $scope.notasAEliminar = [];
        $scope.notasCambio = false;
        $scope.cargarNotas = function () {
            $http.get('http://monsalvediaz.com:5000/PIMC0.1/Consulta/ArchivosNotas?archivoID=' + $scope.archivoID).then(function (data) {
                if (!String(data.data).startsWith("[WARNING]")) {
                    $scope.notas = data.data;
                    $scope.notas.forEach( function (nota) {
                        nota.modificada = false;
                    });
                    // LOG
                    console.log($scope.notas);
                }
            });

        };
        $scope.agregarNotaVacia = function () {
            // Una nota que no tiene fecha de creacion es una nota que no existe en la base de datos aun
            if ($scope.notas === "") {
                $scope.notas = [{
                    nota:"",
                    referencia:"",
                    fechaCreacion:"",
                    fechaHistorica:"",
                    fechaHistFormato:"",
                    modificada: false
                }];
            } else {
                $scope.notas.push({
                    nota:"",
                    referencia:"",
                    fechaCreacion:"",
                    fechaHistorica:"",
                    fechaHistFormato:"",
                    modificada: false
                });
            }
            $scope.notasCambios = true;
        }
        $scope.eliminarNota = function(indexNota) {
            if ($scope.notas[indexNota].fechaCreacion != "") {
                $scope.notasAEliminar.push($scope.notas[indexNota]);
            }
            $scope.notas.splice(indexNota,1);
            $scope.notasCambios = true;
        };
        $scope.modificarNota = function(indexNota,nuevaNota) {
            $scope.notas[indexNota].nota = nuevaNota;
            if ($scope.notas[indexNota].fechaCreacion != "") {
                $scope.notas[indexNota].modificada = true;
            };
            $scope.notasCambios = true;
        };
        $scope.modificarReferencia = function(indexNota,nuevaReferencia) {
            $scope.notas[indexNota].referencia = nuevaReferencia;
            if ($scope.notas[indexNota].fechaCreacion != "") {
                $scope.notas[indexNota].modificada = true;
            }
            $scope.notasCambios = true;

        };

        // Para borrar palabras claves
        $scope.borrarSiVacio = function (indexEditada, palabra) {
            if (palabra == "") {
                $scope.datosPrincipales.palabrasClaves.splice(indexEditada,1);
            }
        }
        //Para agregar palabras claves
        $scope.palabraNueva = {mensaje: '+Agregar'};

        $scope.borrarCampo = function () {
            $scope.palabraNueva.mensaje = "";
        }
        $scope.mostrarCampo = function () {
            $scope.palabraNueva.mensaje = "+Agregar";
        }
        $scope.agregarPalabraNueva = function (palabra) {
            if (!$scope.datosPrincipales.palabrasClaves.includes(palabra) && palabra.length != 0) {
                $scope.datosPrincipales.palabrasClaves.push(palabra);
            }
            $scope.palabraNueva.mensaje = "+Agregar";
        }

        //Para guardar borrar y barra
        $scope.ultimaAccion = "";
        // Button functions
        $scope.borrarCambios = function () {
            if (window.confirm("Esta Seguro que quiere borrar los cambios?") === true) {
                init();
            }
        };
        $scope.guardarCambios = function () {
            if($scope.notasCambios) {
                $scope.notasCambios = false;
                $scope.notas.forEach(function (nota) {
                    // Insertamos notas nuevas
                    if (nota.fechaCreacion.length == 0 && nota.nota.length != 0)
                        $http.get('http://monsalvediaz.com:5000/PIMC0.1/Insertar/ArchivosNotas?ArchivoID='+ $scope.archivoID +'&nota="' + nota.nota + '"&referencia="'  + nota.referencia + '"').then(function (data) {
                            console.log(data);
                        });
                    // Modificamos notas viejas
                    if (nota.modificada == true) {
                        $http.get('http://monsalvediaz.com:5000/PIMC0.1/Modificar/ArchivosNotas?idUnico=archivoId&idUnico=notaID&notaID='+ nota.notaID +' &ArchivoID=' + $scope.archivoID +'&nota="' + nota.nota + '"&referencia="'  + nota.referencia + '"').then(function (data) {
                            console.log(data);
                        });
                    }
                });
                // Eliminamos notas eliminadas
                $scope.notasAEliminar.forEach(function (nota) {
                    $http.get('http://monsalvediaz.com:5000/PIMC0.1/Eliminar/ArchivosNotas?idUnico=archivoId&idUnico=notaID&notaID='+ nota.notaID +' &ArchivoID=' + $scope.archivoID).then(function (data) {
                            console.log(data);
                        });
                });

            }
            //Revisamos datos principales editados
            if ($scope.datosPrincipales.editado) {

            }
            init();
        };

        // Initialization fucntion
        init();

    }]);
    archivoPerfilControllerApp.run(function (editableOptions,editableThemes) {
        editableThemes.bs3.inputClass = 'input-sm';
        editableThemes.bs3.buttonsClass = 'btn-sm';
        editableOptions.theme = 'bs3';
        editableOptions.buttons = 'no';
    });
})(window.angular);

<commit_msg>Agregar Notas<commit_after>(function (angular) {
    'use strict';
    var archivoPerfilControllerApp = angular.module('archivoPerfil', ['ngAnimate', 'ngSanitize', 'ui.bootstrap', 'ui.grid', 'ngTouch', 'ui.grid.edit', 'ui.grid.autoResize', 'ui.grid.selection', 'ui.grid.cellNav', 'xeditable'])
    .controller('archivoPerfilController', ['$scope', '$http', '$window', '$location', '$filter', 'uiGridConstants', 'i18nService', '$scope', function ($scope, $http, $window, $location, $filter, i18nService, uiGridConstants) {
        var init = function () {
            $scope.archivoID = $window.localStorage.getItem("archivoID");
            // DATOS PRINCIPALES
            $scope.cargarDatosPrincipales();
            // ANOTACIONES
            $scope.cargarNotas();
        };

        //Datos principales
        $scope.archivoDatos = {};
        $scope.datosPrincipales = {};
        $scope.datosPrincipales.archivoTitulo = "";
        $scope.datosPrincipales.archivoNombre = "";
        $scope.datosPrincipales.institucionFondo = "";
        $scope.datosPrincipales.seccion = "";
        $scope.datosPrincipales.numRefDentroFondo = "";
        $scope.datosPrincipales.archivoFecha = "";
        $scope.datosPrincipales.folioInicial = "";
        $scope.datosPrincipales.folioFinal = "";
        $scope.datosPrincipales.legajo = "";
        $scope.datosPrincipales.numOrden = "";
        $scope.datosPrincipales.numPaginas = "";
        $scope.datosPrincipales.palabrasClaves = {};
        $scope.datosPrincipales.disponibilidad = "";

        //Bandera para saber cuando guardar o no
        $scope.datosPrincipales.editado = false;

        $scope.cargarDatosPrincipales = function () {
            $http.get('http://monsalvediaz.com:5000/PIMC0.1/ConsultaArchivo?archivoID=' + $scope.archivoID).then(function (data) {
                //Obtener los datos JSON
                $scope.archivoDatos = data.data[0];
                //Log
                console.log($scope.archivoDatos);

                //Llenamos los datos del archivo
                $scope.datosPrincipales.archivoTitulo = $scope.archivoDatos.titulo;
                $scope.datosPrincipales.archivoNombre = $scope.archivoDatos.fondo;
                $scope.datosPrincipales.institucionFondo = $scope.archivoDatos.institucionFondo;
                $scope.datosPrincipales.seccion = $scope.archivoDatos.seccion;
                $scope.datosPrincipales.numRefDentroFondo = $scope.archivoDatos.numRefDentroFondo;
                $scope.datosPrincipales.archivoFecha = $filter('date')(new Date($scope.archivoDatos.fechaInicial), String($scope.archivoDatos.fechaInicialFormato).toLowerCase()) + " - " + $filter('date')(new Date($scope.archivoDatos.fechaFinal), String($scope.archivoDatos.fechaFinalFormato).toLowerCase());
                $scope.datosPrincipales.folioInicial = $scope.archivoDatos.folioInicial;
                $scope.datosPrincipales.folioFinal = $scope.archivoDatos.folioFinal;
                $scope.datosPrincipales.legajo = $scope.archivoDatos.legajo;
                $scope.datosPrincipales.numOrden = $scope.archivoDatos.numOrden;
                $scope.datosPrincipales.numPaginas = $scope.archivoDatos.numPaginas;
                $scope.datosPrincipales.palabrasClaves = $scope.archivoDatos.palabrasClaves.split(",");
                $scope.datosPrincipales.palabrasClaves = $scope.datosPrincipales.palabrasClaves.map(function (e) { return e.trim(); });

                $scope.datosPrincipales.disponibilidad = $scope.archivoDatos.disponibilidad;
                //Limpiamos la bandera de editado
                $scope.datosPrincipales.editado = false;

                //Para palabras claves
                $scope.palabraNueva = {mensaje:"+Agregar"};

            });
        };

        // Anotaciones
        $scope.notas = "";
        $scope.notasAEliminar = [];
        $scope.notasCambio = false;
        $scope.cargarNotas = function () {
            $http.get('http://monsalvediaz.com:5000/PIMC0.1/Consulta/ArchivosNotas?archivoID=' + $scope.archivoID).then(function (data) {
                if (!String(data.data).startsWith("[WARNING]")) {
                    $scope.notas = data.data;
                    $scope.notas.forEach( function (nota) {
                        nota.modificada = false;
                    });
                    // LOG
                    console.log($scope.notas);
                }
            });

        };
        $scope.agregarNotaVacia = function () {
            // Una nota que no tiene fecha de creacion es una nota que no existe en la base de datos aun
            if ($scope.notas === "") {
                $scope.notas = [{
                    nota:"",
                    referencia:"",
                    fechaCreacion:"",
                    fechaHistorica:"",
                    fechaHistFormato:"",
                    modificada: false
                }];
            } else {
                $scope.notas.push({
                    nota:"",
                    referencia:"",
                    fechaCreacion:"",
                    fechaHistorica:"",
                    fechaHistFormato:"",
                    modificada: false
                });
            }
            $scope.notasCambios = true;
        }
        $scope.eliminarNota = function(indexNota) {
            if ($scope.notas[indexNota].fechaCreacion != "") {
                $scope.notasAEliminar.push($scope.notas[indexNota]);
            }
            $scope.notas.splice(indexNota,1);
            $scope.notasCambios = true;
        };
        $scope.modificarNota = function(indexNota,nuevaNota) {
            $scope.notas[indexNota].nota = nuevaNota;
            if ($scope.notas[indexNota].fechaCreacion != "") {
                $scope.notas[indexNota].modificada = true;
            };
            $scope.notasCambios = true;
        };
        $scope.modificarReferencia = function(indexNota,nuevaReferencia) {
            $scope.notas[indexNota].referencia = nuevaReferencia;
            if ($scope.notas[indexNota].fechaCreacion != "") {
                $scope.notas[indexNota].modificada = true;
            }
            $scope.notasCambios = true;

        };

        // Para borrar palabras claves
        $scope.borrarSiVacio = function (indexEditada, palabra) {
            if (palabra == "") {
                $scope.datosPrincipales.palabrasClaves.splice(indexEditada,1);
            }
        }
        //Para agregar palabras claves
        $scope.palabraNueva = {mensaje: '+Agregar'};

        $scope.borrarCampo = function () {
            $scope.palabraNueva.mensaje = "";
        }
        $scope.mostrarCampo = function () {
            $scope.palabraNueva.mensaje = "+Agregar";
        }
        $scope.agregarPalabraNueva = function (palabra) {
            if (!$scope.datosPrincipales.palabrasClaves.includes(palabra) && palabra.length != 0) {
                $scope.datosPrincipales.palabrasClaves.push(palabra);
            }
            $scope.palabraNueva.mensaje = "+Agregar";
        }

        //Para guardar borrar y barra
        $scope.ultimaAccion = "";
        // Button functions
        $scope.borrarCambios = function () {
            if (window.confirm("Esta Seguro que quiere borrar los cambios?") === true) {
                init();
            }
        };
        $scope.guardarCambios = function () {
            if($scope.notasCambios) {
                $scope.notasCambios = false;
                $scope.notas.forEach(function (nota) {
                    // Insertamos notas nuevas
                    if (nota.fechaCreacion.length == 0 && nota.nota.length != 0)
                        $http.get('http://monsalvediaz.com:5000/PIMC0.1/Insertar/ArchivosNotas?ArchivoID='+ $scope.archivoID +'&nota="' + nota.nota + '"&referencia="'  + nota.referencia + '"').then(function (data) {
                            console.log(data);
                        });
                    // Modificamos notas viejas
                    if (nota.modificada == true) {
                        $http.get('http://monsalvediaz.com:5000/PIMC0.1/Modificar/ArchivosNotas?idUnico=archivoId&idUnico=notaID&notaID='+ nota.notaID +' &archivoID=' + $scope.archivoID +'&nota="' + nota.nota + '"&referencia="'  + nota.referencia + '"').then(function (data) {
                            console.log(data);
                        });
                    }
                });
                // Eliminamos notas eliminadas
                $scope.notasAEliminar.forEach(function (nota) {
                    $http.get('http://monsalvediaz.com:5000/PIMC0.1/Eliminar/ArchivosNotas?idUnico=archivoId&idUnico=notaID&notaID='+ nota.notaID +' &archivoID=' + $scope.archivoID).then(function (data) {
                            console.log(data);
                        });
                });

            }
            //Revisamos datos principales editados
            if ($scope.datosPrincipales.editado) {

            }
            init();
        };

        // Initialization fucntion
        init();

    }]);
    archivoPerfilControllerApp.run(function (editableOptions,editableThemes) {
        editableThemes.bs3.inputClass = 'input-sm';
        editableThemes.bs3.buttonsClass = 'btn-sm';
        editableOptions.theme = 'bs3';
        editableOptions.buttons = 'no';
    });
})(window.angular);

<|endoftext|>


<commit_before><commit_msg>Fixed mod core attempting to accessing data in old way.<commit_after><|endoftext|>


<commit_before>(function (angular) {
    'use strict';
    var archivoPerfilControllerApp = angular.module('archivoPerfil', ['ngAnimate', 'ngSanitize', 'ui.bootstrap', 'ui.grid', 'ngTouch', 'ui.grid.edit', 'ui.grid.autoResize', 'ui.grid.selection', 'ui.grid.cellNav', 'xeditable'])
    .controller('archivoPerfilController', ['$scope', '$http', '$window', '$location', '$filter', 'uiGridConstants', 'i18nService', '$scope', function ($scope, $http, $window, $location, $filter, i18nService, uiGridConstants) {
        var init = function () {
            $scope.archivoID = $window.localStorage.getItem("archivoID");
            // DATOS PRINCIPALES
            $scope.cargarDatosPrincipales();
            // ANOTACIONES
            screenTop.cargarNotas();
        };

        //Bandera para saber cuando guardar o no
        $scope.datosPrincipales.editado = false;
        $scope.guardarDatos = false;

        //Datos principales
        $scope.archivoDatos = {};
        $scope.datosPrincipales = {};
        $scope.datosPrincipales.archivoTitulo = "";
        $scope.datosPrincipales.archivoNombre = "";
        $scope.datosPrincipales.institucionFondo = "";
        $scope.datosPrincipales.seccion = "";
        $scope.datosPrincipales.numRefDentroFondo = "";
        $scope.datosPrincipales.archivoFecha = "";
        $scope.datosPrincipales.folioInicial = "";
        $scope.datosPrincipales.folioFinal = "";
        $scope.datosPrincipales.legajo = "";
        $scope.datosPrincipales.numOrden = "";
        $scope.datosPrincipales.numPaginas = "";
        $scope.datosPrincipales.palabrasClaves = {};
        $scope.datosPrincipales.disponibilidad = "";

        $scope.cargarDatosPrincipales = function () {
            $http.get('http://monsalvediaz.com:5000/PIMC0.1/ConsultaArchivo?archivoID=' + $scope.archivoID).then(function (data) {
                //Obtener los datos JSON
                $scope.archivoDatos = data.data[0];
                //Log
                console.log($scope.archivoDatos);

                //Llenamos los datos del archivo
                $scope.datosPrincipales.archivoTitulo = $scope.archivoDatos.titulo;
                $scope.datosPrincipales.archivoNombre = $scope.archivoDatos.fondo;
                $scope.datosPrincipales.institucionFondo = $scope.archivoDatos.institucionFondo;
                $scope.datosPrincipales.seccion = $scope.archivoDatos.seccion;
                $scope.datosPrincipales.numRefDentroFondo = $scope.archivoDatos.numRefDentroFondo;
                $scope.datosPrincipales.archivoFecha = $filter('date')(new Date($scope.archivoDatos.fechaInicial), String($scope.archivoDatos.fechaInicialFormato).toLowerCase()) + " - " + $filter('date')(new Date($scope.archivoDatos.fechaFinal), String($scope.archivoDatos.fechaFinalFormato).toLowerCase());
                $scope.datosPrincipales.folioInicial = $scope.archivoDatos.folioInicial;
                $scope.datosPrincipales.folioFinal = $scope.archivoDatos.folioFinal;
                $scope.datosPrincipales.legajo = $scope.archivoDatos.legajo;
                $scope.datosPrincipales.numOrden = $scope.archivoDatos.numOrden;
                $scope.datosPrincipales.numPaginas = $scope.archivoDatos.numPaginas;
                $scope.datosPrincipales.palabrasClaves = $scope.archivoDatos.palabrasClaves.split(",");
                $scope.datosPrincipales.palabrasClaves = $scope.datosPrincipales.palabrasClaves.map(function (e) { return e.trim(); });

                $scope.datosPrincipales.disponibilidad = $scope.archivoDatos.disponibilidad;
                //Limpiamos la bandera de editado
                $scope.datosPrincipales.editado = false;

                //Para palabras claves
                $scope.palabraNueva = {mensaje:"+Agregar"};

            });
        };

        // Anotaciones
        $scope.notas = {};
        $scope.cargarNotas = function () {
            $http.get('http://monsalvediaz.com:5000/PIMC0.1/Consulta/ArchivosNotas?archivoID=' + $scope.archivoID).then(function (data) {
                if (str(data).substr(0, 8) != "[WARNING]") {
                    $scope.notas = data.data;
                    // LOG
                    console.log($scope.notas);
                }
            });

        };
        $scope.agregarNotaVacia = function () {
            $scope.notas.push({
                nota:"",
                referencia:"",
                fechaHistorica:"",
                fechaHistFormato:""
            });

        }

        // Initialization fucntion
        init();

        // Button functions
        $scope.borrarCambios = function () {
            if (window.confirm("Esta Seguro que quiere borrar los cambios?") === true) {
                init();
            }
        };
        $scope.guardarCambios = function () {
            if($scope.guardarDatos) {

                //Revisamos datos principales editados
                if ($scope.datosPrincipales.editado) {

                }
            }
        };

        // Para borrar palabras claves
        $scope.borrarSiVacio = function (indexEditada, palabra) {
            if (palabra == "") {
                $scope.datosPrincipales.palabrasClaves.splice(indexEditada,1);
            }
        }
        //Para agregar palabras claves
        $scope.palabraNueva = {mensaje: '+Agregar'};

        $scope.borrarCampo = function () {
            $scope.palabraNueva.mensaje = "";
        }
        $scope.mostrarCampo = function () {
            $scope.palabraNueva.mensaje = "+Agregar";
            //$scope.;
        }
        $scope.agregarPalabraNueva = function (palabra) {
            if (!$scope.datosPrincipales.palabrasClaves.includes(palabra) && palabra.length != 0) {
                $scope.datosPrincipales.palabrasClaves.push(palabra);
            }
            $scope.palabraNueva.mensaje = "+Agregar";
        }
    }]);
    archivoPerfilControllerApp.run(function (editableOptions,editableThemes) {
        editableThemes.bs3.inputClass = 'input-sm';
        editableThemes.bs3.buttonsClass = 'btn-sm';
        editableOptions.theme = 'bs3';
        editableOptions.buttons = 'no';
    });
})(window.angular);

<commit_msg>agregando notas<commit_after>(function (angular) {
    'use strict';
    var archivoPerfilControllerApp = angular.module('archivoPerfil', ['ngAnimate', 'ngSanitize', 'ui.bootstrap', 'ui.grid', 'ngTouch', 'ui.grid.edit', 'ui.grid.autoResize', 'ui.grid.selection', 'ui.grid.cellNav', 'xeditable'])
    .controller('archivoPerfilController', ['$scope', '$http', '$window', '$location', '$filter', 'uiGridConstants', 'i18nService', '$scope', function ($scope, $http, $window, $location, $filter, i18nService, uiGridConstants) {
        var init = function () {
            $scope.archivoID = $window.localStorage.getItem("archivoID");
            // DATOS PRINCIPALES
            $scope.cargarDatosPrincipales();
            // ANOTACIONES
            screenTop.cargarNotas();
        };

        //Datos principales
        $scope.archivoDatos = {};
        $scope.datosPrincipales = {};
        $scope.datosPrincipales.archivoTitulo = "";
        $scope.datosPrincipales.archivoNombre = "";
        $scope.datosPrincipales.institucionFondo = "";
        $scope.datosPrincipales.seccion = "";
        $scope.datosPrincipales.numRefDentroFondo = "";
        $scope.datosPrincipales.archivoFecha = "";
        $scope.datosPrincipales.folioInicial = "";
        $scope.datosPrincipales.folioFinal = "";
        $scope.datosPrincipales.legajo = "";
        $scope.datosPrincipales.numOrden = "";
        $scope.datosPrincipales.numPaginas = "";
        $scope.datosPrincipales.palabrasClaves = {};
        $scope.datosPrincipales.disponibilidad = "";

        //Bandera para saber cuando guardar o no
        $scope.datosPrincipales.editado = false;

        $scope.cargarDatosPrincipales = function () {
            $http.get('http://monsalvediaz.com:5000/PIMC0.1/ConsultaArchivo?archivoID=' + $scope.archivoID).then(function (data) {
                //Obtener los datos JSON
                $scope.archivoDatos = data.data[0];
                //Log
                console.log($scope.archivoDatos);

                //Llenamos los datos del archivo
                $scope.datosPrincipales.archivoTitulo = $scope.archivoDatos.titulo;
                $scope.datosPrincipales.archivoNombre = $scope.archivoDatos.fondo;
                $scope.datosPrincipales.institucionFondo = $scope.archivoDatos.institucionFondo;
                $scope.datosPrincipales.seccion = $scope.archivoDatos.seccion;
                $scope.datosPrincipales.numRefDentroFondo = $scope.archivoDatos.numRefDentroFondo;
                $scope.datosPrincipales.archivoFecha = $filter('date')(new Date($scope.archivoDatos.fechaInicial), String($scope.archivoDatos.fechaInicialFormato).toLowerCase()) + " - " + $filter('date')(new Date($scope.archivoDatos.fechaFinal), String($scope.archivoDatos.fechaFinalFormato).toLowerCase());
                $scope.datosPrincipales.folioInicial = $scope.archivoDatos.folioInicial;
                $scope.datosPrincipales.folioFinal = $scope.archivoDatos.folioFinal;
                $scope.datosPrincipales.legajo = $scope.archivoDatos.legajo;
                $scope.datosPrincipales.numOrden = $scope.archivoDatos.numOrden;
                $scope.datosPrincipales.numPaginas = $scope.archivoDatos.numPaginas;
                $scope.datosPrincipales.palabrasClaves = $scope.archivoDatos.palabrasClaves.split(",");
                $scope.datosPrincipales.palabrasClaves = $scope.datosPrincipales.palabrasClaves.map(function (e) { return e.trim(); });

                $scope.datosPrincipales.disponibilidad = $scope.archivoDatos.disponibilidad;
                //Limpiamos la bandera de editado
                $scope.datosPrincipales.editado = false;

                //Para palabras claves
                $scope.palabraNueva = {mensaje:"+Agregar"};

            });
        };

        // Anotaciones
        $scope.notas = {};
        $scope.cargarNotas = function () {
            $http.get('http://monsalvediaz.com:5000/PIMC0.1/Consulta/ArchivosNotas?archivoID=' + $scope.archivoID).then(function (data) {
                if (str(data).substr(0, 8) != "[WARNING]") {
                    $scope.notas = data.data;
                    // LOG
                    console.log($scope.notas);
                }
            });

        };
        $scope.agregarNotaVacia = function () {
            $scope.notas.push({
                nota:"",
                referencia:"",
                fechaHistorica:"",
                fechaHistFormato:""
            });

        }

        // Initialization fucntion
        init();

        // Button functions
        $scope.borrarCambios = function () {
            if (window.confirm("Esta Seguro que quiere borrar los cambios?") === true) {
                init();
            }
        };
        $scope.guardarCambios = function () {
            if($scope.guardarDatos) {

                //Revisamos datos principales editados
                if ($scope.datosPrincipales.editado) {

                }
            }
        };

        // Para borrar palabras claves
        $scope.borrarSiVacio = function (indexEditada, palabra) {
            if (palabra == "") {
                $scope.datosPrincipales.palabrasClaves.splice(indexEditada,1);
            }
        }
        //Para agregar palabras claves
        $scope.palabraNueva = {mensaje: '+Agregar'};

        $scope.borrarCampo = function () {
            $scope.palabraNueva.mensaje = "";
        }
        $scope.mostrarCampo = function () {
            $scope.palabraNueva.mensaje = "+Agregar";
        }
        $scope.agregarPalabraNueva = function (palabra) {
            if (!$scope.datosPrincipales.palabrasClaves.includes(palabra) && palabra.length != 0) {
                $scope.datosPrincipales.palabrasClaves.push(palabra);
            }
            $scope.palabraNueva.mensaje = "+Agregar";
        }

        //Para guardar
        $scope.guardarDatos = false;

    }]);
    archivoPerfilControllerApp.run(function (editableOptions,editableThemes) {
        editableThemes.bs3.inputClass = 'input-sm';
        editableThemes.bs3.buttonsClass = 'btn-sm';
        editableOptions.theme = 'bs3';
        editableOptions.buttons = 'no';
    });
})(window.angular);

<|endoftext|>


<commit_before>angular.module("omniControllers")
  .controller("WalletOverviewController",["$scope", "$location" "Account", "Wallet",
    function WalletOverviewController($scope, $location, Account, Wallet) {
      $scope.uuid = Account.uuid;
      $scope.loginLink = $location.protocol() + "://" + $location.host() + "/login/" + $scope.uuid;
      //console.log(Wallet.addresses);
      $scope.firstLogin = Account.firstLogin;
      // HACK: We check for Account.isLoggedIn since this controller is used when not logged in
      $scope.addrList = [];
      $scope.addrListBal = [];
      $scope.maxCurrencies = [];
      $scope.totals = {};

      $scope.addrList =  Wallet.addresses.map(function(e, i, a) {
        return e.address;
      });

      Wallet.addresses.forEach(function(address, index) {
        if (address.balance.length > 0)
          $scope.maxCurrencies = address.balance;

        for (var i = 0; i < address.balance.length; i++) {
          var symbolTotal = $scope.totals[address.balance[i].symbol];
          //          console.log(symbolTotal, address.balance[i].symbol)
          if (!symbolTotal)
            $scope.totals[address.balance[i].symbol] = 0;
          $scope.totals[address.balance[i].symbol] += +address.balance[i].value;
        }
      });
      $scope.disclaimerSeen = Account.settings.disclaimerSeen;
      $scope.$on('$locationChangeSuccess', function(path) {
        Account.settings.disclaimerSeen = true;
      });
    }]);
<commit_msg>Fix typos<commit_after>angular.module("omniControllers")
  .controller("WalletOverviewController", ["$scope","Account","$location","Wallet",
    function WalletOverviewController($scope,Account,$location,Wallet){
      $scope.uuid = Account.uuid;
      $scope.loginLink = $location.protocol() + "://" + $location.host() + "/login/" + $scope.uuid;
      //console.log(Wallet.addresses);
      $scope.firstLogin = Account.firstLogin;
      // HACK: We check for Account.isLoggedIn since this controller is used when not logged in
      $scope.addrList = [];
      $scope.addrListBal = [];
      $scope.maxCurrencies = [];
      $scope.totals = {};

      $scope.addrList =  Wallet.addresses.map(function(e, i, a) {
        return e.address;
      });

      Wallet.addresses.forEach(function(address, index) {
        if (address.balance.length > 0)
          $scope.maxCurrencies = address.balance;

        for (var i = 0; i < address.balance.length; i++) {
          var symbolTotal = $scope.totals[address.balance[i].symbol];
          //          console.log(symbolTotal, address.balance[i].symbol)
          if (!symbolTotal)
            $scope.totals[address.balance[i].symbol] = 0;
          $scope.totals[address.balance[i].symbol] += +address.balance[i].value;
        }
      });
      $scope.disclaimerSeen = Account.settings.disclaimerSeen;
      $scope.$on('$locationChangeSuccess', function(path) {
        Account.settings.disclaimerSeen = true;
      });
    }]);
<|endoftext|>


<commit_before>var kick = function(dbot) {
    var dbot = dbot;

    var commands = {
        // Give the number of times a given user has been kicked and has kicked
        // other people.
        '~kickcount': function(event) {
            var username = event.params[1];

            if(!dbot.db.kicks.hasOwnProperty(username)) {
                var kicks = '0';
            } else {
                var kicks = dbot.db.kicks[username];
            }

            if(!dbot.db.kickers.hasOwnProperty(username)) {
                var kicked = '0';
            } else {
                var kicked = dbot.db.kickers[username];
            }

            event.reply(dbot.t('user_kicks', {'user': username, 'kicks': kicks, 'kicked': kicked}));
        },

        // Output a list of the people who have been kicked the most and those
        // who have kicked other people the most.
        '~kickstats': function(event) {
            var orderedKickLeague = function(list, topWhat) {
                var kickArr = [];
                for(var kickUser in list) {
                    if(list.hasOwnProperty(kickUser)) {
                        kickArr.push([kickUser, list[kickUser]]);
                    }
                }

                kickArr = kickArr.sort(function(a, b) { return a[1] - b[1]; });
                kickArr = kickArr.slice(kickArr.length - 10).reverse();
                var kickString = "Top " + topWhat + ": ";

                for(var i=0;i<kickArr.length;i++) {
                    kickString += kickArr[i][0] + " (" + kickArr[i][1] + "), ";
                }

                return kickString.slice(0, -2);
            };

            event.reply(orderedKickLeague(dbot.db.kicks, 'Kicked'));
            event.reply(orderedKickLeague(dbot.db.kickers, 'Kickers'));
        }
    };

    return {
        'name': 'kick',
        'ignorable': false,
        'commands': commands,

        'listener': function(event) {
           if(event.kickee == dbot.name) {
                dbot.instance.join(event, event.channel);
                event.reply(dbot.t('kicked_dbot', {'botname': dbot.name}));
                dbot.db.kicks[dbot.name] += 1;
            } else {
                if(!dbot.db.kicks.hasOwnProperty(event.kickee)) {
                    dbot.db.kicks[event.kickee] = 1;
                } else {
                    dbot.db.kicks[event.kickee] += 1;
                }

                if(!dbot.db.kickers.hasOwnProperty(event.user)) {
                    dbot.db.kickers[event.user] = 1;
                } else {
                    dbot.db.kickers[event.user] += 1;
                }

                event.reply(event.kickee + '-- (' + dbot.t('user_kicks',
                    {'user': event.kickee, 'kicks': dbot.db.kicks[event.kickee], 'kicked': dbot.db.kickers[event.kickee]}) + ')');
            }
        },
        on: 'KICK'
    };
};

exports.fetch = function(dbot) {
    return kick(dbot);
};
<commit_msg>Change initialisation of kickArr to Object.keys rather than manually filling it...<commit_after>var kick = function(dbot) {
    var dbot = dbot;

    var commands = {
        // Give the number of times a given user has been kicked and has kicked
        // other people.
        '~kickcount': function(event) {
            var username = event.params[1];

            if(!dbot.db.kicks.hasOwnProperty(username)) {
                var kicks = '0';
            } else {
                var kicks = dbot.db.kicks[username];
            }

            if(!dbot.db.kickers.hasOwnProperty(username)) {
                var kicked = '0';
            } else {
                var kicked = dbot.db.kickers[username];
            }

            event.reply(dbot.t('user_kicks', {'user': username, 'kicks': kicks, 'kicked': kicked}));
        },

        // Output a list of the people who have been kicked the most and those
        // who have kicked other people the most.
        '~kickstats': function(event) {
            var orderedKickLeague = function(list, topWhat) {
                var kickArr = Object.keys(list);
                kickArr = kickArr.sort(function(a, b) { return a[1] - b[1]; });
                kickArr = kickArr.slice(kickArr.length - 10).reverse();
                var kickString = "Top " + topWhat + ": ";

                for(var i=0;i<kickArr.length;i++) {
                    kickString += kickArr[i][0] + " (" + kickArr[i][1] + "), ";
                }

                return kickString.slice(0, -2);
            };

            event.reply(orderedKickLeague(dbot.db.kicks, 'Kicked'));
            event.reply(orderedKickLeague(dbot.db.kickers, 'Kickers'));
        }
    };

    return {
        'name': 'kick',
        'ignorable': false,
        'commands': commands,

        'listener': function(event) {
           if(event.kickee == dbot.name) {
                dbot.instance.join(event, event.channel);
                event.reply(dbot.t('kicked_dbot', {'botname': dbot.name}));
                dbot.db.kicks[dbot.name] += 1;
            } else {
                if(!dbot.db.kicks.hasOwnProperty(event.kickee)) {
                    dbot.db.kicks[event.kickee] = 1;
                } else {
                    dbot.db.kicks[event.kickee] += 1;
                }

                if(!dbot.db.kickers.hasOwnProperty(event.user)) {
                    dbot.db.kickers[event.user] = 1;
                } else {
                    dbot.db.kickers[event.user] += 1;
                }

                event.reply(event.kickee + '-- (' + dbot.t('user_kicks',
                    {'user': event.kickee, 'kicks': dbot.db.kicks[event.kickee], 'kicked': dbot.db.kickers[event.kickee]}) + ')');
            }
        },
        on: 'KICK'
    };
};

exports.fetch = function(dbot) {
    return kick(dbot);
};
<|endoftext|>


<commit_before>//Tell jshint (atom package) to stop showing certain irrelevent warnings.
/*jshint esversion: 6 */

var harvesterCapacity = 6;
var upgraderCapacity = 2;

var roleHarvester = require('role.harvester');
var roleUpgrader = require('role.upgrader');
var roleBuilder = require('role.builder');

var clearDeadCreepMemory = function() {
    for(var name in Memory.creeps) {
        if(!Game.creeps[name]) {
            delete Memory.creeps[name];
            console.log('Clearing non-existing creep memory:', name);
        }
    }
};

var getNextSource = function() {
    var harvestSource = 0;
    var sources = Game.spawns.Spawn1.room.find(FIND_SOURCES);
    if (Game.spawns.Spawn1.memory.nextSource === undefined || Game.spawns.Spawn1.memory.nextSource >= sources.length) {
        Game.spawns.Spawn1.memory.nextSource = 0;
    }
    else {
        harvestSource = Game.spawns.Spawn1.memory.nextSource;
        Game.spawns.Spawn1.memory.nextSource += 1;
    }
    return harvestSource;
};

var spawnUpgrader = function() {
    var harvestSource = getNextSource();

    var creepMemory = {role: 'upgrader', source: harvestSource};
    var newName = Game.spawns.Spawn1.createCreep([WORK,CARRY,MOVE,MOVE], undefined, creepMemory);
    if (newName != -6) {
        console.log('Spawning new upgrader: ' + newName);
    }
};

var spawnHarvester = function () {
    var harvestSource = getNextSource();

    var creepMemory = {role: 'harvester', source: harvestSource};
    var newName = Game.spawns.Spawn1.createCreep([WORK,CARRY,MOVE,MOVE], undefined, creepMemory);
    if (newName != -6) {
        console.log('Spawning new harvester: ' + newName);
    }
};

module.exports.loop = function () {

    var tower = Game.getObjectById('519170edb0e79b2eeb360e71');
    if(tower) {
        var closestDamagedStructure = tower.pos.findClosestByRange(FIND_STRUCTURES, {
            filter: (structure) => structure.hits < structure.hitsMax
        });
        if(closestDamagedStructure) {
            tower.repair(closestDamagedStructure);
        }

        var closestHostile = tower.pos.findClosestByRange(FIND_HOSTILE_CREEPS);
        if(closestHostile) {
            tower.attack(closestHostile);
        }
    }

    clearDeadCreepMemory();

    var harvesters = _.filter(Game.creeps, (creep) => creep.memory.role == 'harvester');
    console.log('Harvesters: ' + harvesters.length);

    var upgraders = _.filter(Game.creeps, (creep) => creep.memory.role == 'upgrader');
    console.log('Upgraders: ' + upgraders.length);

    if(harvesters.length < harvesterCapacity) {
        spawnHarvester();
    }

    if(upgraders.length < upgraderCapacity) {
        spawnUpgrader();
    }

    for(var name in Game.creeps) {
        var creep = Game.creeps[name];
        if(creep.memory.role == 'harvester') {
            roleHarvester.run(creep);
        }
        if(creep.memory.role == 'upgrader') {
            roleUpgrader.run(creep);
        }
        if(creep.memory.role == 'builder') {
            roleBuilder.run(creep);
        }
    }
};
<commit_msg>Changed so that building harvesters is prioritized over building upgraders.<commit_after>//Tell jshint (atom package) to stop showing certain irrelevent warnings.
/*jshint esversion: 6 */

var harvesterCapacity = 6;
var upgraderCapacity = 2;

var roleHarvester = require('role.harvester');
var roleUpgrader = require('role.upgrader');
var roleBuilder = require('role.builder');

var clearDeadCreepMemory = function() {
    for(var name in Memory.creeps) {
        if(!Game.creeps[name]) {
            delete Memory.creeps[name];
            console.log('Clearing non-existing creep memory:', name);
        }
    }
};

var getNextSource = function() {
    var harvestSource = 0;
    var sources = Game.spawns.Spawn1.room.find(FIND_SOURCES);
    if (Game.spawns.Spawn1.memory.nextSource === undefined || Game.spawns.Spawn1.memory.nextSource >= sources.length) {
        Game.spawns.Spawn1.memory.nextSource = 0;
    }
    else {
        harvestSource = Game.spawns.Spawn1.memory.nextSource;
        Game.spawns.Spawn1.memory.nextSource += 1;
    }
    return harvestSource;
};

var spawnUpgrader = function() {
    var harvestSource = getNextSource();

    var creepMemory = {role: 'upgrader', source: harvestSource};
    var newName = Game.spawns.Spawn1.createCreep([WORK,CARRY,MOVE,MOVE], undefined, creepMemory);
    if (newName != -6) {
        console.log('Spawning new upgrader: ' + newName);
    }
};

var spawnHarvester = function () {
    var harvestSource = getNextSource();

    var creepMemory = {role: 'harvester', source: harvestSource};
    var newName = Game.spawns.Spawn1.createCreep([WORK,CARRY,MOVE,MOVE], undefined, creepMemory);
    if (newName != -6) {
        console.log('Spawning new harvester: ' + newName);
    }
};

module.exports.loop = function () {

    var tower = Game.getObjectById('519170edb0e79b2eeb360e71');
    if(tower) {
        var closestDamagedStructure = tower.pos.findClosestByRange(FIND_STRUCTURES, {
            filter: (structure) => structure.hits < structure.hitsMax
        });
        if(closestDamagedStructure) {
            tower.repair(closestDamagedStructure);
        }

        var closestHostile = tower.pos.findClosestByRange(FIND_HOSTILE_CREEPS);
        if(closestHostile) {
            tower.attack(closestHostile);
        }
    }

    clearDeadCreepMemory();

    var harvesters = _.filter(Game.creeps, (creep) => creep.memory.role == 'harvester');
    console.log('Harvesters: ' + harvesters.length);

    var upgraders = _.filter(Game.creeps, (creep) => creep.memory.role == 'upgrader');
    console.log('Upgraders: ' + upgraders.length);

    if(upgraders.length < upgraderCapacity) {
        spawnUpgrader();
    }

    if(harvesters.length < harvesterCapacity) {
        spawnHarvester();
    }

    for(var name in Game.creeps) {
        var creep = Game.creeps[name];
        if(creep.memory.role == 'harvester') {
            roleHarvester.run(creep);
        }
        if(creep.memory.role == 'upgrader') {
            roleUpgrader.run(creep);
        }
        if(creep.memory.role == 'builder') {
            roleBuilder.run(creep);
        }
    }
};
<|endoftext|>


<commit_before>function ContainElement(options) {
	var scaleFactor = 1;
	var element = document.getElementById(options.id);
	var elementWidth = options.width || element.offsetWidth;
	var elementHeight = options.height || element.offsetHeight;

	// Apply required attributes to the element and its parents if they aren't already set
	if (element.style.position != 'absolute')
		element.style.position = 'absolute';
	if (element.parentElement.style.overflow != 'hidden')
		element.parentElement.style.overflow = 'hidden';
	if (['relative', 'absolute', 'fixed'].indexOf(element.parentElement.style.position) === -1)
		element.parentElement.style.position = 'relative';

	function updateContain() {
		var parentWidth = element.parentElement.offsetWidth;
		var parentHeight = element.parentElement.offsetHeight;

		// Run the scale/position functionality if able to determine the document width and height
		if ((parentWidth) && (parentHeight)) {
			// Calculate the scale factor
			if (parentWidth > ((parentHeight / (elementHeight * scaleFactor)) * (elementWidth * scaleFactor)))
				scaleFactor = (parentWidth / elementWidth);
			else
				scaleFactor = (parentHeight / elementHeight);

			// Scale the element using the scale factor
			element.style.width = (elementWidth * scaleFactor) + 'px';
			element.style.height = (elementHeight * scaleFactor) + 'px';

			// Anchor the element horizontally to the left/middle/right
			if (parentWidth < (elementWidth * scaleFactor)) {
				switch(options.halign) {
					case 'left':
						// anchor horizontally to the left of the parent element
						element.style.left = 0 + 'px';
						break;
					case 'right':
						// anchor horizontally to the right of the parent element
						element.style.left = (0 - ((elementWidth * scaleFactor) - parentWidth)) + 'px';
						break;
					default:
						// anchor horizontally to the center of the parent element
						element.style.left = (0 - (((elementWidth * scaleFactor) - parentWidth) / 2 )) + 'px';
				}
			} else {
				element.style.left = 0 + 'px';
			}

			// Anchor the element vertically to the top/middle/bottom
			if ((elementHeight * scaleFactor) > parentHeight) {
				switch(options.valign) {
					case 'top':
						// anchor vertically to the top of the parent element
						element.style.top = 0 + 'px';
						break;
					case 'bottom':
						// anchor veritcally to the bottom of the parent element
						element.style.top = (0 - ((elementHeight * scaleFactor) - parentHeight)) + 'px';
						break;
					default:
						// anchor vertically to the center of the parent element
						element.style.top = (0 - (((elementHeight * scaleFactor) - parentHeight) / 2 )) + 'px';
				}
			} else {
				element.style.top = 0 + 'px';
			}
		} else {
			// Try again in 30ms if the document didn't load enough to determine its width and height yet
			window.setTimeout(updateContain, 30);
		}
	}

	// Run the scale function and bind it to various window-size-changing events
	updateContain();

	// Add scale function to the library
	this.update = updateContain;
}

<commit_msg>Fix parent position check before applying relative style if none of the valid positions are used<commit_after>function ContainElement(options) {
	var scaleFactor = 1;
	var element = document.getElementById(options.id);
	var elementWidth = options.width || element.offsetWidth;
	var elementHeight = options.height || element.offsetHeight;

	// Apply required attributes to the element and its parents if they aren't already set
	element.style.position = 'absolute';
	element.parentElement.style.overflow = 'hidden';
	if (['relative', 'absolute', 'fixed'].indexOf(window.getComputedStyle(element.parentElement,null).getPropertyValue('position')) === -1)
		element.parentElement.style.position = 'relative';

	function updateContain() {
		var parentWidth = element.parentElement.offsetWidth;
		var parentHeight = element.parentElement.offsetHeight;

		// Run the scale/position functionality if able to determine the document width and height
		if ((parentWidth) && (parentHeight)) {
			// Calculate the scale factor
			if (parentWidth > ((parentHeight / (elementHeight * scaleFactor)) * (elementWidth * scaleFactor)))
				scaleFactor = (parentWidth / elementWidth);
			else
				scaleFactor = (parentHeight / elementHeight);

			// Scale the element using the scale factor
			element.style.width = (elementWidth * scaleFactor) + 'px';
			element.style.height = (elementHeight * scaleFactor) + 'px';

			// Anchor the element horizontally to the left/middle/right
			if (parentWidth < (elementWidth * scaleFactor)) {
				switch(options.halign) {
					case 'left':
						// anchor horizontally to the left of the parent element
						element.style.left = 0 + 'px';
						break;
					case 'right':
						// anchor horizontally to the right of the parent element
						element.style.left = (0 - ((elementWidth * scaleFactor) - parentWidth)) + 'px';
						break;
					default:
						// anchor horizontally to the center of the parent element
						element.style.left = (0 - (((elementWidth * scaleFactor) - parentWidth) / 2 )) + 'px';
				}
			} else {
				element.style.left = 0 + 'px';
			}

			// Anchor the element vertically to the top/middle/bottom
			if ((elementHeight * scaleFactor) > parentHeight) {
				switch(options.valign) {
					case 'top':
						// anchor vertically to the top of the parent element
						element.style.top = 0 + 'px';
						break;
					case 'bottom':
						// anchor veritcally to the bottom of the parent element
						element.style.top = (0 - ((elementHeight * scaleFactor) - parentHeight)) + 'px';
						break;
					default:
						// anchor vertically to the center of the parent element
						element.style.top = (0 - (((elementHeight * scaleFactor) - parentHeight) / 2 )) + 'px';
				}
			} else {
				element.style.top = 0 + 'px';
			}
		} else {
			// Try again in 30ms if the document didn't load enough to determine its width and height yet
			window.setTimeout(updateContain, 30);
		}
	}

	// Run the scale function and bind it to various window-size-changing events
	updateContain();

	// Add scale function to the library
	this.update = updateContain;
}

<|endoftext|>


<commit_before>/* Setup - Complete - Model */
var CompleteModel = Backbone.Model.extend({
  defaults: {
    copying: [
      '{{_("Dont look now, we are copying things")}}',
      '{{_("Copying your mail, please do not be alarmed!")}}',
      '{{_("Copying mail. This could take a while")}}',
      '{{_("Please be patient, we are copying mail as fast as possible")}}',
      '{{_("Wow, you have a lot of mail")}}',
      '{{_("I hope you dont have a plane to catch or anything")}}',
      '{{_("Copying mail. Put your arms above your head and whistle la cucaracha")}}',
      '{{_("Making a copy of your mail. Putting it in your inbox, all comfy like")}}'
    ],
    nerds: [
      '{{_("Damn kids. Theyre all alike.")}}',
      '{{_("RMS approves!")}}',
      '{{_("Formating your C:\ drive")}}',
      '{{_("Fortifying encryption shields")}}',
      '{{_("Increasing entropy & scrambling bits")}}',
      '{{_("Patching bugs...")}}',
      '{{_("Indexing kittens...")}}',
      '{{_("Reticulating Splines")}}',
      '{{_("Syntax error in line 45 of this e-mail")}}',
      '{{_("Shoveling more coal into the server")}}',
      '{{_("Calibrating flux capacitors")}}',
      '{{_("A few bytes tried to escape, but we caught them")}}',
      '{{_("Deterministically simulating future state")}}',
      '{{_("Embiggening prototypes")}}',
      '{{_("Resolving interdependence")}}',
      '{{_("Spinning violently around the y-axis")}}',
      '{{_("Locating additional gigapixels")}}',
      '{{_("Initializing hamsters")}}',
      '{{_("This is our world now... the world of the electron and the switch")}}',
      '{{_("Uploading ad keywords to advertisers... doh!")}}',
      '{{_("Becoming self-aware")}}',
      '{{_("Looking for heretofore unknown prime numbers")}}',
      '{{_("Re-aligning satellite grid")}}',
      '{{_("Re-routing bitstream")}}',
      '{{_("Warming up particle accelerator")}}',
      '{{_("Time is an illusion. Loading time doubly so")}}',
      '{{_("Verifying local gravitational constant")}}',
      '{{_("This server is powered by a lemon and two electrodes")}}'
    ],
    email: [
      '{{_("Mailpile has an advanced tagging system & search engine at its core")}}',
      '{{_("Do you really need to keep all these Amazon Prime shipping confirmations?")}}',
      '{{_("I am pretty sure email from ThinkGeeks 2011 X-mas sale can be deleted.")}}',
      '{{_("Do you really need an email to know when you have been retweeted?")}}',
      '{{_("Email is the largest internet based social network on the planet")}}',
      '{{_("Which other technology do you use that is 40 years old?")}}',
      '{{_("There are 2.5 billion email users worldwide, thats double the amount of Facebook users!")}}',
      '{{_("Use Mailpile Tags to better organize and search your mail")}}',
      '{{_("Remember getting your first email address? Remember how it felt like something private?")}}',
      '{{_("Email is a decentralized by design, this means no one company or government owns it!")}}',
      '{{_("Over 100 trillion emails are sent per year, wow!")}}',
      '{{_("Email is most widely used direct communication protocol every created by humans")}}',
      '{{_("Email is based on an open standard agreed upon by the entire world and owned by no one")}}'
    ],
    security: [
      '{{_("BCC-ing NSA")}}',
      '{{_("Sending encrypted mail to Snowden")}}',
      '{{_("Decrypting an email from Snowden")}}',
      '{{_("The worlds most powerful governments are conducting mass dragnet surveillance")}}',
      '{{_("Most email can be read by anyone as it travel through the internet")}}',
      '{{_("Encryption ensures that your emails are only read by the intended recipient")}}',
      '{{_("Unencrypted email is more like sending a postcard than sending a letter")}}',
      '{{_("Mailpile uses OpenPGP to encrypt and decrypt your messages securely")}}',
      '{{_("All of your config settings & passwords are encrypted with AES 256")}}',
      '{{_("Encrypting emails means your communication actually stays private")}}',
      '{{_("The more encrypted email you send, the better!")}}',
      '{{_("Make sure you print or save your keys & passphrase somewhere securely")}}',
      '{{_("Mailpile by default encrypts your search index!")}}',
      '{{_("The most common Email password is 123456, hopefully yours is different ;)")}}'
    ],
    jokes: [
      '{{_("Good things come to those who wait")}}',
      '{{_("Make free software and be happy")}}',
      '{{_("Most of Mailpile is made in Iceland, where much of the country believes in elves")}}',
      '{{_("The founders of Mailpile met in a public hot tub in Reykjavík")}}',
      '{{_("We like volcanos, do you like volcanos?")}}',
      '{{_("A million hamsters are spinning their wheels right now")}}',
      '{{_("Tapping earth for more geothermal energy")}}',
      '{{_("Digging moat. Filing with alligators. Fortifying walls")}}',
      '{{_("Indexing lovenotes")}}',
      '{{_("Crossing out swear words...")}}',
      '{{_("Compiling bullshit bingo grid...")}}',
      '{{_("Abandon all hope, ye who enter here")}}',
      '{{_("Welcome to the nine circles of suffering")}}',
      '{{_("Mailing wife about female contacts")}}',
      '{{_("Informing authorities of suspicious activities")}}',
      '{{_("Letting you wait for no apparent reason")}}',
      '{{_("What are you wearing?")}}',
      '{{_("Go put the kettle on, this could be a while")}}',
      '{{_("Go get a cup of tea and some biscuits. This will take approximately 4 custard creams worth of time")}}',
      '{{_("Did you know humans share 50 percent of their DNA with a banana? Perverts")}}',
      '{{_("Estimating chance of astroid hitting Earth")}}',
      '{{_("Reading Terms of Service documents")}}',
      '{{_("Catching up on shows on Netflix")}}',
      '{{_("Oh, you have some very interesting stuff there")}}',
      '{{_("I think I better understand you better now")}}',
      '{{_("Your past is just a story you tell yourself")}}',
      '{{_("Checking emails for stolen Winklevoss ideas")}}',
      '{{_("Applying coupons...")}}',
      '{{_("Licking stamps...")}}',
      '{{_("Self potato")}}',
      '{{_("Yum yum, that one was tasty")}}',
      '{{_("Hey, there is some Nigerian prince here who wants to give you twenty million dollars...")}}',
      '{{_("How rude!")}}',
      '{{_("Now enhancing photos")}}',
      '{{_("Backing up the entire Internet...")}}',
      '{{_("Really? You are still waiting?")}}',
      '{{_("Well... it sure is a beautiful day")}}',
      '{{_("You should probably go outside or something")}}',
      '{{_("Slacking off over here")}}',
      '{{_("Doing nothing")}}',
      '{{_("Making you wait for no reason")}}',
      '{{_("Testing your patience")}}',
      '{{_("Pay no attention to the man behind the curtain")}}',
      '{{_("You are great just the way you are")}}',
      '{{_("Warning: do not think of purple hippos")}}',
      '{{_("Follow the white rabbit")}}',
      '{{_("Wanna see how deep the rabbit hole goes?")}}',
      '{{_("Supplying monkeys with typewriters")}}',
      '{{_("Waiting for Godot.")}}',
      '{{_("Swapping time and space")}}'
    ],
    state: 0
  },
  states: {
    0: 'complete',
    1: 'copying',
    2: 'nerds',
    3: 'email',
    4: 'security',
    5: 'jokes'
  },
  icons: {
    0: 'icon-like',
    1: 'icon-inbox',
    2: ['icon-trophy', 'icon-robot', 'icon-graph'],
    3: ['icon-message', 'icon-tag', 'icon-compose'],
    4: ['icon-privacy', 'icon-lock-closed', 'icon-key'],
    5: ['icon-star', 'icon-lightbulb', 'icon-new']
  }
});

/* Setup - Complete - View */
var CompleteView = Backbone.View.extend({
  initialize: function() {
		this.render();
  },
  render: function(){
    return this;
  },
  events: {
    "click #setup-complete-tour-start": "showTour"
  },
  show: function() {
    if (!StateModel.attributes.complete) {
      Mailpile.API.settings_set_post({ 'web.setup_complete': true }, function(result) {
        $('#setup').html(_.template($('#template-setup-sources-complete').html(), {}));
      });
    } else {
      $('#setup').html(_.template($('#template-setup-sources-complete').html(), {}));
    }
  },
  showTour: function(e) {

    e.preventDefault();

    // Topbar
    $('#header').addClass('animated bounceOutUp');

    setTimeout(function() {
      $('#header').remove();
      var header_html = $('#template-setup-topbar').html();
      $('body').prepend(header_html).find('#header').addClass('animated bounceInDown');
    }, 500);

    // Navigation
    $('#setup-complete-waiting').removeClass('fadeIn').addClass('bounceOutDown');

    setTimeout(function() {
      $('#setup-complete-waiting').remove();
      $('#setup-complete-explore').removeClass('hide').addClass('bounceInUp');
    }, 1000);
  },
  showProcessingMessage: function() {

    // Select Message
    var last = CompleteView.model.get('state');
    var now = 0;

    if (last < 5) {
      now = last;
      now++;
    } else {
      last = 5;
      now = 1;
    }

    CompleteView.model.set({ state: now });

    var state_now = CompleteView.model.states[now];
    var message   = _.sample(CompleteView.model.attributes[state_now]);

    var icon_last = CompleteView.model.icons[last];
    var icon_now  = CompleteView.model.icons[now];

    if (_.isArray(icon_last)) {
      icon_last = icon_last.join(' ');
    }
    if (_.isArray(icon_now)) {
      icon_now = _.sample(icon_now);
    }

    // Update with live data
    var copying = 'Copying [LIVE DATA] Mail';

    $('#setup-complete-icon').removeClass('fadeIn').addClass('bounceOutRight');
    $('#setup-complete-message').removeClass('fadeIn').addClass('bounceOutRight');
    $('#setup-complete-copying').removeClass('fadeIn').addClass('bounceOutRight');

    setTimeout(function() {
      $('#setup-complete-icon').removeClass('bounceOutRight ' + icon_last).addClass('fadeIn ' + icon_now);
      $('#setup-complete-message').html(message).removeClass('bounceOutRight').addClass('fadeIn');
      $('#setup-complete-copying').html(copying).removeClass('bounceOutRight').addClass('fadeIn');
    }, 750);
  }
});<commit_msg>Fixed some more copy details<commit_after>/* Setup - Complete - Model */
var CompleteModel = Backbone.Model.extend({
  defaults: {
    copying: [
      '{{_("Dont look now, we are copying things")}}',
      '{{_("Copying your mail, please do not be alarmed!")}}',
      '{{_("Copying mail. This could take a while")}}',
      '{{_("Please be patient, we are copying mail as fast as possible")}}',
      '{{_("Wow, you have a lot of mail")}}',
      '{{_("I hope you dont have a plane to catch or anything")}}',
      '{{_("Copying mail. Put your arms above your head and whistle la cucaracha")}}',
      '{{_("Making a copy of your mail. Putting it in your inbox, all comfy like")}}'
    ],
    nerds: [
      '{{_("Damn kids. Theyre all alike.")}}',
      '{{_("RMS approves!")}}',
      '{{_("Formating your C:\ drive")}}',
      '{{_("Fortifying encryption shields")}}',
      '{{_("Increasing entropy & scrambling bits")}}',
      '{{_("Patching bugs...")}}',
      '{{_("Indexing kittens...")}}',
      '{{_("Indexing lovenotes")}}',
      '{{_("Reticulating Splines")}}',
      '{{_("Syntax error in line 45 of this e-mail")}}',
      '{{_("Shoveling more coal into the server")}}',
      '{{_("Calibrating flux capacitors")}}',
      '{{_("A few bytes tried to escape, but we caught them")}}',
      '{{_("Deterministically simulating future state")}}',
      '{{_("Embiggening prototypes")}}',
      '{{_("Resolving interdependence")}}',
      '{{_("Spinning violently around the y-axis")}}',
      '{{_("Locating additional gigapixels")}}',
      '{{_("Initializing hamsters")}}',
      '{{_("This is our world now... the world of the electron and the switch")}}',
      '{{_("Uploading ad keywords to advertisers... doh!")}}',
      '{{_("Becoming self-aware")}}',
      '{{_("Looking for heretofore unknown prime numbers")}}',
      '{{_("Re-aligning satellite grid")}}',
      '{{_("Re-routing bitstream")}}',
      '{{_("Warming up particle accelerator")}}',
      '{{_("Time is an illusion. Loading time doubly so")}}',
      '{{_("Verifying local gravitational constant")}}',
      '{{_("This server is powered by a lemon and two electrodes")}}'
    ],
    email: [
      '{{_("Mailpile has an advanced tagging system & search engine at its core")}}',
      '{{_("Do you really need to keep all these Amazon Prime shipping confirmations?")}}',
      '{{_("I am pretty sure email from ThinkGeeks 2011 X-mas sale can be deleted.")}}',
      '{{_("Do you really need an email to know when you have been retweeted?")}}',
      '{{_("Email is the largest internet based social network on the planet")}}',
      '{{_("Which other technology do you use that is 40 years old?")}}',
      '{{_("There are 2.5 billion email users worldwide, thats double the amount of Facebook users!")}}',
      '{{_("Use Mailpile Tags to better organize and search your mail")}}',
      '{{_("Remember getting your first email address? Remember how it felt like something private?")}}',
      '{{_("Email is a decentralized by design, this means no one company or government owns it!")}}',
      '{{_("Over 100 trillion emails are sent per year, wow!")}}',
      '{{_("Email is the most widely used communication protocol ever created by humans")}}',
      '{{_("Email is based on an open standard agreed upon by the entire world and owned by no one")}}'
    ],
    security: [
      '{{_("BCC-ing the NSA and GCHQ")}}',
      '{{_("Sending encrypted mail to Snowden")}}',
      '{{_("Decrypting an email from Snowden")}}',
      '{{_("The worlds most powerful governments are conducting mass dragnet surveillance")}}',
      '{{_("Most email can be read by anyone as it travel through the internet")}}',
      '{{_("Encryption ensures that your emails are only read by the intended recipient")}}',
      '{{_("Unencrypted email is more like sending a postcard than sending a letter")}}',
      '{{_("Mailpile uses OpenPGP to encrypt and decrypt your messages securely")}}',
      '{{_("All of your config settings & passwords are encrypted with AES 256")}}',
      '{{_("Encrypting emails means your communication actually stays private")}}',
      '{{_("The more encrypted email you send, the better!")}}',
      '{{_("Make sure you print or save your keys & passphrase somewhere securely")}}',
      '{{_("Mailpile by default encrypts your search index!")}}',
      '{{_("The most common Email password is 123456, hopefully yours is different")}}'
    ],
    jokes: [
      '{{_("Good things come to those who wait")}}',
      '{{_("Make free software and be happy")}}',
      '{{_("Most of Mailpile was built from cafes in Reykjavík, Iceland")}}'
      '{{_("Many Icelanders believe in elves and magical hidden people")}}',
      '{{_("The founders of Mailpile first met in a public hot tub in Reykjavík")}}',
      '{{_("We like volcanos, do you like volcanos?")}}',
      '{{_("A million hamsters are spinning their wheels right now")}}',
      '{{_("Tapping earth for more geothermal energy")}}',
      '{{_("Digging moat. Filing with alligators. Fortifying walls")}}',
      '{{_("Crossing out swear words...")}}',
      '{{_("Compiling bullshit bingo grid...")}}',
      '{{_("Abandon all hope, ye who enter here")}}',
      '{{_("Welcome to the nine circles of suffering")}}',
      '{{_("Mailing wife about female contacts")}}',
      '{{_("Informing authorities of suspicious activities")}}',
      '{{_("Letting you wait for no apparent reason")}}',
      '{{_("What are you wearing?")}}',
      '{{_("Go put the kettle on, this could be a while")}}',
      '{{_("Go get a cup of tea and some biscuits. This will take approximately 4 custard creams worth of time")}}',
      '{{_("Did you know humans share 50 percent of their DNA with a banana? Perverts")}}',
      '{{_("Estimating chance of astroid hitting Earth")}}',
      '{{_("Reading Terms of Service documents")}}',
      '{{_("Catching up on shows on Netflix")}}',
      '{{_("Oh, you have some very interesting old emails")}}',
      '{{_("I think I better understand you now")}}',
      '{{_("Your past is just a story you tell yourself")}}',
      '{{_("Checking emails for stolen Winklevoss ideas")}}',
      '{{_("Applying coupons...")}}',
      '{{_("Licking stamps...")}}',
      '{{_("Self potato")}}',
      '{{_("Yum yum, that one was tasty")}}',
      '{{_("Hey, there is some Nigerian prince here who wants to give you twenty million dollars...")}}',
      '{{_("How rude!")}}',
      '{{_("Now enhancing photos")}}',
      '{{_("Backing up the entire Internet...")}}',
      '{{_("Really? You are still waiting?")}}',
      '{{_("Well... it sure is a beautiful day")}}',
      '{{_("You should probably go outside or something")}}',
      '{{_("Slacking off over here")}}',
      '{{_("Doing nothing")}}',
      '{{_("Making you wait for no reason")}}',
      '{{_("Testing your patience")}}',
      '{{_("Pay no attention to the man behind the curtain")}}',
      '{{_("You are great just the way you are")}}',
      '{{_("Warning: do not think of purple hippos")}}',
      '{{_("Follow the white rabbit")}}',
      '{{_("Wanna see how deep the rabbit hole goes?")}}',
      '{{_("Supplying monkeys with typewriters")}}',
      '{{_("Waiting for Godot.")}}',
      '{{_("Swapping time and space")}}'
    ],
    state: 0
  },
  states: {
    0: 'complete',
    1: 'copying',
    2: 'nerds',
    3: 'email',
    4: 'security',
    5: 'jokes'
  },
  icons: {
    0: 'icon-like',
    1: 'icon-inbox',
    2: ['icon-trophy', 'icon-robot', 'icon-graph'],
    3: ['icon-message', 'icon-tag', 'icon-compose'],
    4: ['icon-privacy', 'icon-lock-closed', 'icon-key'],
    5: ['icon-star', 'icon-lightbulb', 'icon-new', 'icon-donate']
  }
});

/* Setup - Complete - View */
var CompleteView = Backbone.View.extend({
  initialize: function() {
		this.render();
  },
  render: function(){
    return this;
  },
  events: {
    "click #setup-complete-tour-start": "showTour"
  },
  show: function() {
    if (!StateModel.attributes.complete) {
      Mailpile.API.settings_set_post({ 'web.setup_complete': true }, function(result) {
        $('#setup').html(_.template($('#template-setup-sources-complete').html(), {}));
      });
    } else {
      $('#setup').html(_.template($('#template-setup-sources-complete').html(), {}));
    }
  },
  showTour: function(e) {

    e.preventDefault();

    // Topbar
    $('#header').addClass('animated bounceOutUp');

    setTimeout(function() {
      $('#header').remove();
      var header_html = $('#template-setup-topbar').html();
      $('body').prepend(header_html).find('#header').addClass('animated bounceInDown');
    }, 500);

    // Navigation
    $('#setup-complete-waiting').removeClass('fadeIn').addClass('bounceOutDown');

    setTimeout(function() {
      $('#setup-complete-waiting').remove();
      $('#setup-complete-explore').removeClass('hide').addClass('bounceInUp');
    }, 1000);
  },
  showProcessingMessage: function() {

    // Select Message
    var last = CompleteView.model.get('state');
    var now = 0;

    if (last < 5) {
      now = last;
      now++;
    } else {
      last = 5;
      now = 1;
    }

    CompleteView.model.set({ state: now });

    var state_now = CompleteView.model.states[now];
    var message   = _.sample(CompleteView.model.attributes[state_now]);

    var icon_last = CompleteView.model.icons[last];
    var icon_now  = CompleteView.model.icons[now];

    if (_.isArray(icon_last)) {
      icon_last = icon_last.join(' ');
    }
    if (_.isArray(icon_now)) {
      icon_now = _.sample(icon_now);
    }

    // Update with live data
    var copying = 'Copying [LIVE DATA] Mail';

    $('#setup-complete-icon').removeClass('fadeIn').addClass('bounceOutRight');
    $('#setup-complete-message').removeClass('fadeIn').addClass('bounceOutRight');
    $('#setup-complete-copying').removeClass('fadeIn').addClass('bounceOutRight');

    setTimeout(function() {
      $('#setup-complete-icon').removeClass('bounceOutRight ' + icon_last).addClass('fadeIn ' + icon_now);
      $('#setup-complete-message').html(message).removeClass('bounceOutRight').addClass('fadeIn');
      $('#setup-complete-copying').html(copying).removeClass('bounceOutRight').addClass('fadeIn');
    }, 750);
  }
});<|endoftext|>