<commit_before>Objects = new Meteor.Collection("objects");

if (Meteor.isClient) {
  function getParameterByName(name) {
      name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
      var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
          results = regex.exec(location.search);
      return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
  }

  UI.body.rendered = function () {
    console.log("UI.body.rendered");

    // disable touch to avoid moving scroll view
    document.ontouchstart = function(e) {
      e.preventDefault();
    };

    //this.$('#world-canvas').visualizeTouches();
    
    var id = getParameterByName("id");
    var debug = getParameterByName("debug");
    if (debug == 'undefined')
      debug = false;

    console.log("Client Id: " + id);

    var glyphContainer = this.$('#glyph-container');
    var glyph = this.$('#glyph');
    glyph.css('background-image', 'url(glyphs/' + id + '.png)');

    var windowWidth = $(window).width();
    var windowHeight = $(window).height();

    $worldCanvas = $('#world-canvas');
    var canvasWidth = $worldCanvas.width();
    var canvasHeight = $worldCanvas.height();

    var devicePixelRatio = window.devicePixelRatio || 1.0;
    
    // TEST BEGIN
    /*
    var ratio = 0.22;

    var scaleX = 1 / ((canvasWidth * ratio) / width);

    //var scaleX = 1 / ((canvasWidth * ratio) / width); 

    var angle = 0.0;
    var centerX = 2048;
    var centerY = 1536;
    var tx = 6000;
    var ty = 2000;

    console.log("test: " + scaleX);

    var translateTransform = '';//'translate(-' + tx + 'px,-' + ty + 'px)';
    var rotateTransform = '';//'rotate(' + -(angle) + 'deg)';
    var scaleTransform = 'scale(' + scaleX + ',' + scaleX + ')';

    var transform = translateTransform + ' ' + rotateTransform + ' ' + scaleTransform;
    //var transform = scaleTransform + ' ' + rotateTransform + ' ' + scaleTransform;
    var transformOrigin =  (tx + centerX) + 'px ' + (ty + centerY) + 'px 0'

    
    $worldCanvas.css('-webkit-transform-origin', '0% 0% 0');
    $worldCanvas.css('-webkit-transform', transform);
    */
    /// TEST END

/*
    var $overview = $($worldCanvas.get(0).cloneNode(true));
    //var canvasBackgroundImage = $overview.css('background-image');
    //var canvasBackgroundRepeat = $overview.css('background-repeat');
    //var canvasBackgroundSize = $overview.css('background-size');
    $overview.attr('id', 'world-canvas-copy');
    //$overview.css('-webkit-transform', 'scale(0.03,0.03)');
    $overview.css('height', '100%');
    //$overview.css('background-color', 'green');
    //$overview.css('background-image', canvasBackgroundImage);
    //$overview.css('background-repeat', canvasBackgroundRepeat);
    //$overview.css('background-size', canvasBackgroundSize);
    $('#world-canvas-overview').append($overview);
*/
    var huddle = new Huddle(id, function (data) {
        if (data.Type) {

            if (debug) return;

            switch (data.Type) {
                case 'Proximity':
//                    console.log('proximity data: ' + JSON.stringify(data.Data));

                    var location = data.Data.Location.split(",");
                    var x = location[0];
                    var y = location[1];
                    var angle = data.Data.Orientation;
                    var ratio = data.Data.RgbImageToDisplayRatio;

                    // Indonesien Jakarta
                    //var x = 0.769;
                    //var y = 0.402;

                    console.log(ratio.X);

                    var scaleX = ((ratio.X * windowWidth) / canvasWidth);
                    var scaleY = ((ratio.Y * windowHeight) / canvasHeight);
 
                    //console.log("Rgb Image to Device Ratio: " + ratio.X + "," + ratio.Y);

                    //var ratioPeepholeToWorldX = canvasWidth * ratio.X;
                    //var ratioPeepholeToWorldY = canvasHeight * ratio.Y;

                    //var sx = (1280 / canvasWidth) / ratio.X;
                    //var sy = (720 / canvasHeight) / ratio.Y;

                    //var scaleX = 1 / (canvasWidth * ratio.X) / width;
                    //var scaleY = 1 / (canvasHeight * ratio.Y) / height;

                    //if (id == 9 || id == 12) {
                    //  sx *= 0.38;
                    //  sy *= 0.38;
                    //}

                    //var centerX = parseInt(width / 2);
                    //var centerY = parseInt(height / 2);
                    //var tx = -1 * (x * canvasWidth - (width / 2)) / sx;
                    //var ty = -1 * (y * canvasHeight - (height / 2)) / sy;
                    //var tx = -1 * x * canvasWidth + (width * x / 2);
                    //var ty = -1 * y * canvasHeight + (height * y / 2);

                    var deviceCenterToDeviceLeft = ((windowWidth / ratio.Y) / 2);
                    var deviceCenterToDeviceTop = ((windowHeight / ratio.Y) / 2);

                    var tx = -1 * x * canvasWidth;
                    var ty = -1 * y * canvasHeight;

                    var txd = tx + deviceCenterToDeviceLeft;
                    var tyd = ty + deviceCenterToDeviceTop;

                    
                    var rotateTransform = 'rotate(' + -(angle) + 'deg)';
                    

                    //var transform = translateTransform + ' ' + rotateTransform; + ' ' + scaleTransform;
                    //var transform = translateTransform + ' ' + rotateTransform + ' ' + scaleTransform;
                    var transform = ' scale(' + scaleX + ',' + scaleY + ')';
                    transform += ' translate(' + txd + 'px,' +tyd + 'px)';
                    //transform += ' translate(' + (-1 * tx) + 'px,' + (-1 * ty) + 'px)';
                    //transform += ' scale(' + 0.5 + ',' + 0.5 + ')';
                    //transform += ' translate(' + (1 * tx) + 'px,' + (1 * ty) + 'px)';

                    //console.log('asdf' + transform);
<commit_msg>security commit<commit_after>Objects = new Meteor.Collection("objects");

if (Meteor.isClient) {
  function getParameterByName(name) {
      name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
      var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
          results = regex.exec(location.search);
      return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
  }

  UI.body.rendered = function () {
    console.log("UI.body.rendered");

    // disable touch to avoid moving scroll view
    document.ontouchstart = function(e) {
      e.preventDefault();
    };

    //this.$('#world-canvas').visualizeTouches();
    
    var id = getParameterByName("id");
    var debug = getParameterByName("debug");
    if (debug == 'undefined')
      debug = false;

    console.log("Client Id: " + id);

    var glyphContainer = this.$('#glyph-container');
    var glyph = this.$('#glyph');
    glyph.css('background-image', 'url(glyphs/' + id + '.png)');

    var windowWidth = $(window).width();
    var windowHeight = $(window).height();

    $worldCanvas = $('#world-canvas');
    var canvasWidth = $worldCanvas.width();
    var canvasHeight = $worldCanvas.height();

    var devicePixelRatio = window.devicePixelRatio || 1.0;
    
    // TEST BEGIN
    /*
    var ratio = 0.22;

    var scaleX = 1 / ((canvasWidth * ratio) / width);

    //var scaleX = 1 / ((canvasWidth * ratio) / width); 

    var angle = 0.0;
    var centerX = 2048;
    var centerY = 1536;
    var tx = 6000;
    var ty = 2000;

    console.log("test: " + scaleX);

    var translateTransform = '';//'translate(-' + tx + 'px,-' + ty + 'px)';
    var rotateTransform = '';//'rotate(' + -(angle) + 'deg)';
    var scaleTransform = 'scale(' + scaleX + ',' + scaleX + ')';

    var transform = translateTransform + ' ' + rotateTransform + ' ' + scaleTransform;
    //var transform = scaleTransform + ' ' + rotateTransform + ' ' + scaleTransform;
    var transformOrigin =  (tx + centerX) + 'px ' + (ty + centerY) + 'px 0'

    
    $worldCanvas.css('-webkit-transform-origin', '0% 0% 0');
    $worldCanvas.css('-webkit-transform', transform);
    */
    /// TEST END

/*
    var $overview = $($worldCanvas.get(0).cloneNode(true));
    //var canvasBackgroundImage = $overview.css('background-image');
    //var canvasBackgroundRepeat = $overview.css('background-repeat');
    //var canvasBackgroundSize = $overview.css('background-size');
    $overview.attr('id', 'world-canvas-copy');
    //$overview.css('-webkit-transform', 'scale(0.03,0.03)');
    $overview.css('height', '100%');
    //$overview.css('background-color', 'green');
    //$overview.css('background-image', canvasBackgroundImage);
    //$overview.css('background-repeat', canvasBackgroundRepeat);
    //$overview.css('background-size', canvasBackgroundSize);
    $('#world-canvas-overview').append($overview);
*/
    var huddle = new Huddle(id, function (data) {
        if (data.Type) {

            if (debug) return;

            switch (data.Type) {
                case 'Proximity':
//                    console.log('proximity data: ' + JSON.stringify(data.Data));

                    var location = data.Data.Location.split(",");
                    var x = location[0];
                    var y = location[1];
                    var angle = data.Data.Orientation;
                    var ratio = data.Data.RgbImageToDisplayRatio;

                    // Indonesien Jakarta
                    //var x = 0.769;
                    //var y = 0.402;

                    console.log(ratio.X);

                    var scaleX = ((ratio.X * windowWidth) / canvasWidth);
                    var scaleY = ((ratio.Y * windowHeight) / canvasHeight);
 
                    //console.log("Rgb Image to Device Ratio: " + ratio.X + "," + ratio.Y);

                    //var ratioPeepholeToWorldX = canvasWidth * ratio.X;
                    //var ratioPeepholeToWorldY = canvasHeight * ratio.Y;

                    //var sx = (1280 / canvasWidth) / ratio.X;
                    //var sy = (720 / canvasHeight) / ratio.Y;

                    //var scaleX = 1 / (canvasWidth * ratio.X) / width;
                    //var scaleY = 1 / (canvasHeight * ratio.Y) / height;

                    //if (id == 9 || id == 12) {
                    //  sx *= 0.38;
                    //  sy *= 0.38;
                    //}

                    //var centerX = parseInt(width / 2);
                    //var centerY = parseInt(height / 2);
                    //var tx = -1 * (x * canvasWidth - (width / 2)) / sx;
                    //var ty = -1 * (y * canvasHeight - (height / 2)) / sy;
                    //var tx = -1 * x * canvasWidth + (width * x / 2);
                    //var ty = -1 * y * canvasHeight + (height * y / 2);

                    var deviceCenterToDeviceLeft = ((windowWidth / ratio.Y) / 2);
                    var deviceCenterToDeviceTop = ((windowHeight / ratio.Y) / 2);

                    var tx = -1 * x * canvasWidth;
                    var ty = -1 * y * canvasHeight;

                    var txd = tx + deviceCenterToDeviceLeft;
                    var tyd = ty + deviceCenterToDeviceTop;

                    
                    var rotateTransform = 'rotate(' + -(angle) + 'deg)';
                    

                    //var transform = translateTransform + ' ' + rotateTransform; + ' ' + scaleTransform;
                    //var transform = translateTransform + ' ' + rotateTransform + ' ' + scaleTransform;
                    var transform = ' scale(' + scaleX + ',' + scaleY + ')';
                    transform += ' translate(' + txd + 'px,' +tyd + 'px)';
                    
                    transform += ' translate(' + (-1 * tx) + 'px,' + (-1 * ty) + 'px)';
                    transform += 'rotate(' + -(angle) + 'deg)';
                    transform += ' translate(' + (1 * tx) + 'px,' + (1 * ty) + 'px)';

                    //transform += ' translate(' + (-1 * tx) + 'px,' + (-1 * ty) + 'px)';
                    //transform += ' scale(' + 0.5 + ',' + 0.5 + ')';
                    
                    //console.log('asdf' + transform);

{'fraction_non_alphanumeric': 0.16900478626836113, 'fraction_numerical': 0.015018980029707873, 'mean_word_length': 1.7039268183846497, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4999154', 'n_tokens_mistral': 3744, 'n_tokens_neox': 3406, 'n_words': 805}