<commit_before>var registered = false;
var datagridData;

function getDateText(obj){
	var str = obj.aData[ obj.iDataColumn ];
	if (str.indexOf(" ") != -1){
		return changeTimePrecision(str.substring(0, str.indexOf(" ")));
	}
	return str;
}

function getTimeText(obj){
	var str = obj.aData[ obj.iDataColumn ];
	if (str.indexOf(" ") != -1){
		return changeTimePrecision(str.substring(str.indexOf(" ")+1));
	}
	return str;
}

function changeTimePrecisionInit(obj){
	var str = obj.aData[ obj.iDataColumn ];
	return changeTimePrecision(str);
}

function changeTimePrecision(str){
	if (str.indexOf(".") != -1){
		if (str.length - str.indexOf(".") > 2)
			var extraLength = str.length - str.indexOf(".") -3;
			return str.substring(0, str.length - extraLength);
	}
	return str;
}

function notifySongEnd(){
	//alert("length " + datagridData.rows.length);
	for (var i=0; i<datagridData.rows.length; i++){
		if (datagridData.rows[i][0] == "c")
			datagridData.rows[i][0] = "p";
		if (datagridData.rows[i][0] == "n"){
			datagridData.rows[i][0] = "c";
			break;
		}
	}

	createDataGrid();
}

function createDataGrid(){

	datagridData.columnHeaders[1]["fnRender"] = getDateText;
	datagridData.columnHeaders[2]["fnRender"] = getTimeText;
	datagridData.columnHeaders[3]["fnRender"] = getTimeText;
	datagridData.columnHeaders[4]["fnRender"] = changeTimePrecisionInit;

	$('#demo').html( '

' );
	$('#nowplayingtable').dataTable( {
		"bSort" : false,
		"bJQueryUI": true,
		"bFilter": false,
		"bInfo": false,
		"bLengthChange": false,
		"aaData": datagridData.rows,
		"aoColumns": datagridData.columnHeaders,
		"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
            if (aData[aData.length-2] != ""){
                $(nRow).attr("style", "background-color:#166622");
            }

            if (aData[0] == "c")
				$(nRow).attr("style", "background-color:#61B329");
			return nRow;
		}
	} );
}

function init2(){
	  $.ajax({ url: "/Nowplaying/get-data-grid-data/format/json", dataType:"json", success:function(data){
		datagridData = data.entries;
		createDataGrid();
	  }});

	  if (typeof registerSongEndListener == 'function' && !registered){
		  registered = true;
		  registerSongEndListener(notifySongEnd);
	  }

	  setTimeout(init2, 5000);
}

$(document).ready(function() {
	init2();
});
<commit_msg>-gaps now show in the now playing data table<commit_after>var registered = false;
var datagridData;

function getDateText(obj){
	var str = obj.aData[ obj.iDataColumn ].toString();
	if (str.indexOf(" ") != -1){
		return changeTimePrecision(str.substring(0, str.indexOf(" ")));
	}
	return str;
}

function getTimeText(obj){
	var str = obj.aData[ obj.iDataColumn ].toString();
	if (str.indexOf(" ") != -1){
		return changeTimePrecision(str.substring(str.indexOf(" ")+1));
	}
	return str;
}

function changeTimePrecisionInit(obj){
	var str = obj.aData[ obj.iDataColumn ].toString();
	return changeTimePrecision(str);
}

function changeTimePrecision(str){
	if (str.indexOf(".") != -1){
		if (str.length - str.indexOf(".") > 2)
			var extraLength = str.length - str.indexOf(".") -3;
			return str.substring(0, str.length - extraLength);
	}
	return str;
}

function notifySongEnd(){
	//alert("length " + datagridData.rows.length);
	for (var i=0; i<datagridData.rows.length; i++){
		if (datagridData.rows[i][0] == "c")
			datagridData.rows[i][0] = "p";
		if (datagridData.rows[i][0] == "n"){
			datagridData.rows[i][0] = "c";
			break;
		}
	}

	createDataGrid();
}

function createDataGrid(){

	datagridData.columnHeaders[1]["fnRender"] = getDateText;
	datagridData.columnHeaders[2]["fnRender"] = getTimeText;
	datagridData.columnHeaders[3]["fnRender"] = getTimeText;
	datagridData.columnHeaders[4]["fnRender"] = changeTimePrecisionInit;

	$('#demo').html( '

' );
	$('#nowplayingtable').dataTable( {
		"bSort" : false,
		"bJQueryUI": true,
		"bFilter": false,
		"bInfo": false,
		"bLengthChange": false,
		"aaData": datagridData.rows,
		"aoColumns": datagridData.columnHeaders,
		"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
            if (aData[aData.length-2] != "")
                $(nRow).attr("style", "background-color:#166622");
            if (aData[0] == "c")
				$(nRow).attr("style", "background-color:#61B329");
            else if (aData[0] == "b")
                $(nRow).attr("style", "background-color:#EE3B3B");
			return nRow;
		}
	} );
}

function init2(){
	  $.ajax({ url: "/Nowplaying/get-data-grid-data/format/json", dataType:"json", success:function(data){
		datagridData = data.entries;
		createDataGrid();
	  }});

	  if (typeof registerSongEndListener == 'function' && !registered){
		  registered = true;
		  registerSongEndListener(notifySongEnd);
	  }

	  setTimeout(init2, 5000);
}

$(document).ready(function() {
	init2();
});
<|endoftext|>


<commit_before>import React, { Component } from 'react'
import { Provider } from 'react-redux'
import configureStore from '../store/configureStore'
import AsyncApp from './AsyncApp'
import ToolboxApp from 'react-toolbox/lib/app'
import Header from '../components/header';

const store = configureStore()

export default class Root extends Component {
  render() {
    return (
      <Provider store={store}>
        <ToolboxApp>
          <Header />
          <AsyncApp />
        </ToolboxApp>
      </Provider>
    )
  }
}
<commit_msg>[CLEAN UP]<commit_after>import React, { Component } from 'react'
import { Provider } from 'react-redux'
import configureStore from '../store/configureStore'
import ToolboxApp from 'react-toolbox/lib/app'
import App from '../App';

const store = configureStore()

export default class Root extends Component {
  render() {
    return (
      <Provider store={store}>
        <ToolboxApp>
          <App />
        </ToolboxApp>
      </Provider>
    )
  }
}
<|endoftext|>


<commit_before>!function(e){var t=function(e,t){var n=[].forEach;if(e instanceof Array||"length"in e){n?n.call(e,t):function(){for(var n=0;n<e.length;n++){t(e[n],n,e)}}()}else(function(){for(i in e){if(e.hasOwnProperty(i))t(e[i],i,e)}})()};var n=e.request=function(e,n){e=e||{};e.url=e.url||"#";e.method=e.method||"GET";e.async=e.async||true;e.body=e.body||null;var r=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");r.onreadystatechange=function(){if(r.readyState===4&&r.status===200)n(null,r.responseText,r);else if(r.readyState===4&&r.status!==0){var e=new Error(r.status);e.body=r.responseText;n(e,undefined,r)}else if(r.readyState==4){}};r.open(e.method,e.url,e.async);r.onerror=function(e){n(e,undefined,r)};if(e.headers)t(e.headers,function(e,t){r.setRequestHeader(t,e)});r.send(e.method==="POST"?e.body:null);return r};n.json=function(t,r){n(t,function(e,t,i){if(e)r(e,t,i);else{var s=n.parseJSON(t);s?r(null,s,i):r(new Error("invalid JSON"),undefined,i)}})};n.jsonp=function(t,n){var r=document.createElement("script");var i="tinyrequest_"+Date.now()+""+Math.random().toString().split(".").pop();r.src=t.url.match(/\?/)?t.url+"&callback="+i:t.url+"?callback="+i;r.onerror=function(e){n(e);r.parentNode.removeChild(r)};window[i]=function(e){n(null,e);r.parentNode.removeChild(r)};var s=document.getElementsByTagName("head")[0];s.appendChild(r)};n.parseJSON=function(t){if(window.JSON&&window.JSON.parse)return JSON.parse(t);if(/^[\],:{}\s]*$/.test(t.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){return(new Function("return "+t))()}return null}}(this)<commit_msg>updated minified file<commit_after>!function(e){var t=function(e,t){var n=[].forEach;if(e instanceof Array||"length"in e){n?n.call(e,t):function(){for(var n=0;n<e.length;n++){t(e[n],n,e)}}()}else(function(){for(var n in e){if(e.hasOwnProperty(n))t(e[n],n,e)}})()};var n=e.request=function(e,n){function i(e,t){var i=new Error(e);i.original=t;n(i,undefined,r)}e=e||{};e.url=e.url||"#";e.method=e.method||"GET";e.async=e.async||true;e.body=e.body||null;var r=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");r.onreadystatechange=function(){if(r.readyState===4&&r.status===200)n(null,r.responseText,r);else if(r.readyState===4&&r.status!==0){if(r.status===12152)i("unknown ajax error",r);else if(r.status>1e4)i("unknown IE error",r);else{i("HTTP error "+r.status,r)}}};r.open(e.method,e.url,e.async);r.onerror=function(e){i("unknown ajax error",e)};if(e.headers)t(e.headers,function(e,t){r.setRequestHeader(t,e)});r.send(e.method==="POST"?e.body:null);return r};n.json=function(t,r){n(t,function(e,t,i){if(e)r(e,t,i);else{try{var s=n.parseJSON(t);r(null,s,i)}catch(o){var e=new Error("invalid JSON");e.original=o;r(e,undefined,i)}}})};n.jsonp=function(t,r){var i=document.createElement("script");var s="tinyrequest_"+Date.now()+""+Math.random().toString().split(".").pop();t.unknownErrors=!!t.unknownErrors;i.src=t.url.match(/\?/)?t.url+"&callback="+s:t.url+"?callback="+s;i.async=false;var o=function(){i.parentNode.removeChild(i);n.removeEvent(window,"error",u)};i.onerror=function(e){r(e);o()};window[s]=function(e){r(null,e);o()};var u=function(e,n,s,u,a){var f=function(){var t=new Error("jsonp scripting error");t.original=e;r(t);o()};if(e.filename===i.src){f()}else if(n===i.src){f()}else if(window.event&&window.event.errorUrl===i.src){window.event=null;f()}else if(t.unknownErrors&&e.target==window&&e.filename===""&&e.message==="Script error."){f()}else if(t.unknownErrors&&e.target===window&&!e.filename){console.log("**I am Firefox, I will offer no help");f()}else if(e.filename&&e.filename!==i.src){}else{o()}};n.addEvent(window,"error",u);var a=document.getElementsByTagName("head")[0];a.appendChild(i)};n.parseJSON=function(t){if(window.JSON&&window.JSON.parse)return JSON.parse(t);if(/^[\],:{}\s]*$/.test(t.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){return(new Function("return "+t))()}return null};n.addEvent=function(t,n,r){if(t.addEventListener)t.addEventListener(n,r,false);else if(t.attachEvent)t.attachEvent("on"+n,r)};n.removeEvent=function(e,t,n){if(e.removeEventListener)e.removeEventListener(t,n,false);else if(e.detachEvent)e.detachEvent("on"+t,n)}}(this)<|endoftext|>


<commit_before>sigma.classes.graph.addMethod('neighbors', function(nodeId) {
  var k, neighbors = {}, index = this.allNeighborsIndex[nodeId] || {};
  for (k in index) neighbors[k] = this.nodesIndex[k];
  return neighbors;
});

// Source Pimp Trizkit https://stackoverflow.com/questions/5560248/programmatically-lighten-or-darken-a-hex-color-or-rgb-and-blend-colors
function shadeBlend(p,c0,c1) {
  var n=p<0?p*-1:p,u=Math.round,w=parseInt;
  if(c0.length>7){
    var f=c0.split(","),t=(c1?c1:p<0?"rgb(0,0,0)":"rgb(255,255,255)").split(","),R=w(f[0].slice(4)),G=w(f[1]),B=w(f[2]);
    return "rgb("+(u((w(t[0].slice(4))-R)*n)+R)+","+(u((w(t[1])-G)*n)+G)+","+(u((w(t[2])-B)*n)+B)+")"
  }else{
    var f=w(c0.slice(1),16),t=w((c1?c1:p<0?"#000000":"#FFFFFF").slice(1),16),R1=f>>16,G1=f>>8&0x00FF,B1=f&0x0000FF;
    return "#"+(0x1000000+(u(((t>>16)-R1)*n)+R1)*0x10000+(u(((t>>8&0x00FF)-G1)*n)+G1)*0x100+(u(((t&0x0000FF)-B1)*n)+B1)).toString(16).slice(1)
  }
}

function group_color(group) {
  switch (group) {
    case "GDR": return "rgb(255,30,30)";
    case "SRC": return "rgb(255,50,190)";
    case "ECOLO": return "rgb(0,230,30)";
    case "RRDP": return "rgb(250,195,132)";
    case "UDI": return "rgb(30,180,255)";
    case "UMP": return "rgb(30,30,200)";
    case "NI": return "rgb(100,100,100)";
    default: return "#555555";
  }
}

function load_data(s, places) {
  $('#menu').hide();
  $('#loader').show();
  $('#layout').removeClass('running');
  $('#layout').addClass('hemicycle');
  $('#layout').text('Cosignatures');
  if (s.isForceAtlas2Running()) {
    s.killForceAtlas2();
  }
  s.graph.clear();
  s.refresh();
  $('#recenter').click();
  var g = {nodes: [], edges: []};
  var loi = $('#loi :selected').val();
  $.getJSON("data/"+loi+".json", function(data) {
    var gpes = {};
    // TODO lighten data => separate parl as json / links as csv
    for (var parl in data['parlementaires']) {
      var place = data['parlementaires'][parl]['p'] || 300;
      var gpe = data['parlementaires'][parl]['g'] || null;
      g.nodes.push({
        id: 'd'+parl,
        label: data['parlementaires'][parl]['n'],
        x: places[place]['x']-285,
        hemx: places[place]['x']-285,
        y: places[place]['y']+150,
        hemy: places[place]['y']+150,
        size: Math.sqrt(data['parlementaires'][parl]['a']),
        color:  shadeBlend(0.2, group_color(gpe)),
        color0: shadeBlend(0.2, group_color(gpe)),
        slug: data['parlementaires'][parl]['s']
      });
      if (gpe) {
        if (gpes[gpe]) {
          gpes[gpe].map(function(dep) {
            g.edges.push({
              id: gpe+'_'+parl+"-"+dep,
              source: "d"+parl,
              target: "d"+dep,
              size: 0,
              weight: 0.1/gpes[gpe].length,
              hidden: true,
              internal: true
            });
          });
        } else {
          gpes[gpe] = [];
        }
        gpes[gpe].push(parl);
      }
    }
    var links = {};
    data['links'].map(function(link) {
      var lid = link['1']+"-"+link['2'];
      if (!links[lid]) {
        links[lid] = {'1': "d"+link['1'], '2': "d"+link['2'], 'w': 0};
      }
      links[lid]['w'] += link['w'];
    });
    for(var link in links) {
      g.edges.push({
        id: link,
        source: links[link]['1'],
        target: links[link]['2'],
        color: '#ccc',
        weight: links[link]['w']
      });
    }
    s.graph.read(g);

    var popUp;
    function showNodeInfo(event) {
      var node = event.data.node;

      popUp && popUp.remove();
      popUp = $(
        ''
      ).attr(
        'id',
        'node-info'
      ).css({
        'display': 'inline-block',
        'width': 55,
        'height': 70,
        'border-radius': 3,
        'padding': 5,
        'background': '#fff',
        'color': '#000',
        'box-shadow': '0 0 4px #666',
        'position': 'absolute',
        'left': (node['cam0:x'] || node['renderer1:x']) - 25,
        'top':  (node['cam0:y'] || node['renderer1:y']) + 15
      });
      $('img',popUp).css('margin','0 0 0 20px');
      $('#sigma').append(popUp);
    }
    function hideNodeInfo(event) {
      popUp && popUp.remove();
      popUp = false;
    }
    s.bind('overNode', showNodeInfo).bind('outNode', hideNodeInfo);

    var selected = null;
    function clickNode(event) {
      var node = event.data.node;
      var bol = (selected == node.id);
      if (selected) unclickNode(event, !bol);
      if (bol) return;
      if (!selected) {
        $("#menu").hide();
        $("#loader").show();
      }
      setTimeout(function(){
        selected = node.id;
        var toKeep = s.graph.neighbors(node.id);
        toKeep[node.id] = node;
        s.graph.nodes().forEach(function(n) {
          if (n.id == node.id)
            n.color = n.color0;
          else if (toKeep[n.id])
            n.color = shadeBlend(0.3, n.color0);
          else n.hidden = true;
        });
        s.graph.edges().forEach(function(e) {
          if (!e.internal &&
              (e.source == node.id && toKeep[e.source]) ||
              (e.target == node.id && toKeep[e.target])) {
            e.color = shadeBlend(0.5, node.color0);
          } else e.hidden = true;
        });
        s.refresh();
        setTimeout(function() {
          $("#loader").hide();
          $("#menu").show();
        }, 0);
      }, 0);
    }
    function unclickNode(event, keepLoadBar) {
      if (!selected) return;
      selected = null;
      $("#menu").hide();
      $("#loader").show();
      setTimeout(function(){
        s.graph.nodes().forEach(function(n) {
          n.color = n.color0;
          n.hidden = false;
          n.selected = false;
        });
        s.graph.edges().forEach(function(e) {
          if (!e.internal) {
            e.color = '#ccc';
            e.hidden = false;
          }
        });
        s.refresh();
        if (!keepLoadBar) {
          setTimeout(function() {
            $("#loader").hide();
            $("#menu").show();
          }, 0);
        }
      }, 0);
    }
    s.bind('clickNode', clickNode).bind('clickStage', unclickNode);

    s.refresh();
    $('#loader').hide();
    setTimeout(function(){
      s.startForceAtlas2({
        edgeWeightInfluence: 0.8,
        strongGravityMode: true,
        gravity: 0.15,
        scalingRatio: 100000,
        slowDown: 2
      });
      $('#menu').show();
      setTimeout(function(){s.killForceAtlas2();}, 5000);
    }, 0);
  });
};

function init() {
  var places = {};
  var s = new sigma('sigma', {
    settings: {
      clone: false,
      immutable: false,
      nodesPowRatio: 0.25,
      edgesPowRatio: 1,
      zoomMin: 0.01,
      zoomMax: 4,
      singleHover: true,
      defaultLabelColor: '#333',
    }
  });
  $.getJSON("data/places.json", function(places) {
    load_data(s, places);
    $('#loi').change(function(){
      load_data(s, places);
    });
    $('#layout').click(function(){
      if ($('#layout').hasClass('running'))
        return;
      $('#recenter').click();
      $('#layout').addClass('running');
      $('#menu').hide();
      var prefix = ($('#layout').hasClass('hemicycle') ? 'fa2' : 'hem');
      sigma.plugins.animate(s, {
        x: prefix + 'x',
        y: prefix + 'y'
      }, {
        duration: 1500,
        onComplete: function(){
          if ($('#layout').hasClass('hemicycle')) {
            $('#layout').removeClass('hemicycle');
            $('#layout').text('Hémicycle');
          } else {
            $('#layout').addClass('hemicycle');
            $('#layout').text('Cosignatures');
          }
          $('#layout').removeClass('running');
          $('#menu').show();
        }
      });
    });
    $('#zoom').click(function() {
      sigma.misc.animation.camera(
        s.camera,
        {ratio: s.camera.ratio / 1.5 },
        {duration: 150 }
      );
    });
    $('#unzoom').click(function() {
      sigma.misc.animation.camera(
        s.camera,
        {ratio: s.camera.ratio * 1.5 },
        {duration: 150 }
      );
    });
    $('#recenter').click(function() {
      sigma.misc.animation.camera(
        s.camera,
        {x: 0, y: 0, ratio: 1},
        {duration: 250, easing: 'cubicInOut'}
      );
    });
  });
}

if (document.addEventListener) {
  document.addEventListener('DOMContentLoaded', init, false);
} else {
  window.onload = init;
}

<commit_msg>fix wrong constructor call<commit_after>sigma.classes.graph.addMethod('neighbors', function(nodeId) {
  var k, neighbors = {}, index = this.allNeighborsIndex[nodeId] || {};
  for (k in index) neighbors[k] = this.nodesIndex[k];
  return neighbors;
});

// Source Pimp Trizkit https://stackoverflow.com/questions/5560248/programmatically-lighten-or-darken-a-hex-color-or-rgb-and-blend-colors
function shadeBlend(p,c0,c1) {
  var n=p<0?p*-1:p,u=Math.round,w=parseInt;
  if(c0.length>7){
    var f=c0.split(","),t=(c1?c1:p<0?"rgb(0,0,0)":"rgb(255,255,255)").split(","),R=w(f[0].slice(4)),G=w(f[1]),B=w(f[2]);
    return "rgb("+(u((w(t[0].slice(4))-R)*n)+R)+","+(u((w(t[1])-G)*n)+G)+","+(u((w(t[2])-B)*n)+B)+")"
  }else{
    var f=w(c0.slice(1),16),t=w((c1?c1:p<0?"#000000":"#FFFFFF").slice(1),16),R1=f>>16,G1=f>>8&0x00FF,B1=f&0x0000FF;
    return "#"+(0x1000000+(u(((t>>16)-R1)*n)+R1)*0x10000+(u(((t>>8&0x00FF)-G1)*n)+G1)*0x100+(u(((t&0x0000FF)-B1)*n)+B1)).toString(16).slice(1)
  }
}

function group_color(group) {
  switch (group) {
    case "GDR": return "rgb(255,30,30)";
    case "SRC": return "rgb(255,50,190)";
    case "ECOLO": return "rgb(0,230,30)";
    case "RRDP": return "rgb(250,195,132)";
    case "UDI": return "rgb(30,180,255)";
    case "UMP": return "rgb(30,30,200)";
    case "NI": return "rgb(100,100,100)";
    default: return "#555555";
  }
}

function load_data(s, places) {
  $('#menu').hide();
  $('#loader').show();
  $('#layout').removeClass('running');
  $('#layout').addClass('hemicycle');
  $('#layout').text('Cosignatures');
  if (s.isForceAtlas2Running()) {
    s.killForceAtlas2();
  }
  s.graph.clear();
  s.refresh();
  $('#recenter').click();
  var g = {nodes: [], edges: []};
  var loi = $('#loi :selected').val();
  $.getJSON("data/"+loi+".json", function(data) {
    var gpes = {};
    // TODO lighten data => separate parl as json / links as csv
    for (var parl in data['parlementaires']) {
      var place = data['parlementaires'][parl]['p'] || 300;
      var gpe = data['parlementaires'][parl]['g'] || null;
      g.nodes.push({
        id: 'd'+parl,
        label: data['parlementaires'][parl]['n'],
        x: places[place]['x']-285,
        hemx: places[place]['x']-285,
        y: places[place]['y']+150,
        hemy: places[place]['y']+150,
        size: Math.sqrt(data['parlementaires'][parl]['a']),
        color:  shadeBlend(0.2, group_color(gpe)),
        color0: shadeBlend(0.2, group_color(gpe)),
        slug: data['parlementaires'][parl]['s']
      });
      if (gpe) {
        if (gpes[gpe]) {
          gpes[gpe].map(function(dep) {
            g.edges.push({
              id: gpe+'_'+parl+"-"+dep,
              source: "d"+parl,
              target: "d"+dep,
              size: 0,
              weight: 0.1/gpes[gpe].length,
              hidden: true,
              internal: true
            });
          });
        } else {
          gpes[gpe] = [];
        }
        gpes[gpe].push(parl);
      }
    }
    var links = {};
    data['links'].map(function(link) {
      var lid = link['1']+"-"+link['2'];
      if (!links[lid]) {
        links[lid] = {'1': "d"+link['1'], '2': "d"+link['2'], 'w': 0};
      }
      links[lid]['w'] += link['w'];
    });
    for(var link in links) {
      g.edges.push({
        id: link,
        source: links[link]['1'],
        target: links[link]['2'],
        color: '#ccc',
        weight: links[link]['w']
      });
    }
    s.graph.read(g);

    var popUp;
    function showNodeInfo(event) {
      var node = event.data.node;

      popUp && popUp.remove();
      popUp = $(
        ''
      ).attr(
        'id',
        'node-info'
      ).css({
        'display': 'inline-block',
        'width': 55,
        'height': 70,
        'border-radius': 3,
        'padding': 5,
        'background': '#fff',
        'color': '#000',
        'box-shadow': '0 0 4px #666',
        'position': 'absolute',
        'left': (node['cam0:x'] || node['renderer1:x']) - 25,
        'top':  (node['cam0:y'] || node['renderer1:y']) + 15
      });
      $('img',popUp).css('margin','0 0 0 20px');
      $('#sigma').append(popUp);
    }
    function hideNodeInfo(event) {
      popUp && popUp.remove();
      popUp = false;
    }
    s.bind('overNode', showNodeInfo).bind('outNode', hideNodeInfo);

    var selected = null;
    function clickNode(event) {
      var node = event.data.node;
      var bol = (selected == node.id);
      if (selected) unclickNode(event, !bol);
      if (bol) return;
      if (!selected) {
        $("#menu").hide();
        $("#loader").show();
      }
      setTimeout(function(){
        selected = node.id;
        var toKeep = s.graph.neighbors(node.id);
        toKeep[node.id] = node;
        s.graph.nodes().forEach(function(n) {
          if (n.id == node.id)
            n.color = n.color0;
          else if (toKeep[n.id])
            n.color = shadeBlend(0.3, n.color0);
          else n.hidden = true;
        });
        s.graph.edges().forEach(function(e) {
          if (!e.internal &&
              (e.source == node.id && toKeep[e.source]) ||
              (e.target == node.id && toKeep[e.target])) {
            e.color = shadeBlend(0.5, node.color0);
          } else e.hidden = true;
        });
        s.refresh();
        setTimeout(function() {
          $("#loader").hide();
          $("#menu").show();
        }, 0);
      }, 0);
    }
    function unclickNode(event, keepLoadBar) {
      if (!selected) return;
      selected = null;
      $("#menu").hide();
      $("#loader").show();
      setTimeout(function(){
        s.graph.nodes().forEach(function(n) {
          n.color = n.color0;
          n.hidden = false;
          n.selected = false;
        });
        s.graph.edges().forEach(function(e) {
          if (!e.internal) {
            e.color = '#ccc';
            e.hidden = false;
          }
        });
        s.refresh();
        if (!keepLoadBar) {
          setTimeout(function() {
            $("#loader").hide();
            $("#menu").show();
          }, 0);
        }
      }, 0);
    }
    s.bind('clickNode', clickNode).bind('clickStage', unclickNode);

    s.refresh();
    $('#loader').hide();
    setTimeout(function(){
      s.startForceAtlas2({
        edgeWeightInfluence: 0.8,
        strongGravityMode: true,
        gravity: 0.15,
        scalingRatio: 100000,
        slowDown: 2
      });
      $('#menu').show();
      setTimeout(function(){s.killForceAtlas2();}, 5000);
    }, 0);
  });
};

function init() {
  var places = {};
  var s = new sigma({
    container: 'sigma',
    settings: {
      clone: false,
      immutable: false,
      nodesPowRatio: 0.25,
      edgesPowRatio: 1,
      zoomMin: 0.01,
      zoomMax: 4,
      singleHover: true,
      defaultLabelColor: '#333',
    }
  });
  $.getJSON("data/places.json", function(places) {
    load_data(s, places);
    $('#loi').change(function(){
      load_data(s, places);
    });
    $('#layout').click(function(){
      if ($('#layout').hasClass('running'))
        return;
      $('#recenter').click();
      $('#layout').addClass('running');
      $('#menu').hide();
      var prefix = ($('#layout').hasClass('hemicycle') ? 'fa2' : 'hem');
      sigma.plugins.animate(s, {
        x: prefix + 'x',
        y: prefix + 'y'
      }, {
        duration: 1500,
        onComplete: function(){
          if ($('#layout').hasClass('hemicycle')) {
            $('#layout').removeClass('hemicycle');
            $('#layout').text('Hémicycle');
          } else {
            $('#layout').addClass('hemicycle');
            $('#layout').text('Cosignatures');
          }
          $('#layout').removeClass('running');
          $('#menu').show();
        }
      });
    });
    $('#zoom').click(function() {
      sigma.misc.animation.camera(
        s.camera,
        {ratio: s.camera.ratio / 1.5 },
        {duration: 150 }
      );
    });
    $('#unzoom').click(function() {
      sigma.misc.animation.camera(
        s.camera,
        {ratio: s.camera.ratio * 1.5 },
        {duration: 150 }
      );
    });
    $('#recenter').click(function() {
      sigma.misc.animation.camera(
        s.camera,
        {x: 0, y: 0, ratio: 1},
        {duration: 250, easing: 'cubicInOut'}
      );
    });
  });
}

if (document.addEventListener) {
  document.addEventListener('DOMContentLoaded', init, false);
} else {
  window.onload = init;
}

<|endoftext|>


<commit_before>function(args) {
/*
created_timestamp(-1)
base_component_id("listApps")
is_app(true)
display_name("App Store")
description('App to list all the apps')
load_once_from_file(true)
*/

    Vue.component('listApps',{

          template: `

{{item.display_name}}

                            Run

`,

          data: function() {
              return {
                          apps: []
                      }},

          mounted: function() {
              this.search()
          },

        methods: {
            search: async function() {
                 this.apps = await callApp({   driver_name: "systemFunctions",  method_name:"get_apps_list"}, { }) }
        }
    })

    return {name: "listApps"}
}
<commit_msg>load the apps correctly<commit_after>function(args) {
/*
created_timestamp(-1)
base_component_id("listApps")
is_app(true)
display_name("App Store")
description('App to list all the apps')
load_once_from_file(true)
*/

    Vue.component('listApps',{

          template: `

{{item.display_name}}

                            Run

`,

          data: function() {
              return {
                          apps: []
                      }},

          mounted: function() {
              this.search()
          },

        methods: {
            search: async function() {
                 this.apps = await callApp({   driver_name: "systemFunctions",  method_name:"get_apps_list"}, { }) }
        }
    })

    return {name: "listApps"}
}
<|endoftext|>


<commit_before>var JS_GAME = {};

JS_GAME.game = (function() {
    var connected = false;
    var disconnectMessage = "Unknown (could be unexpected server shutdown, internet outage, etc.)";
    var isKeyDown = [];
    var mx = 0;
    var my = 0;
    var context;
    var canvas;
    var playerData = {
        name: "",
        x: 0,
        y: 0,
        width: 0,
        height: 0,
        color: "#000000"
    };
    var entityNum = 0;
    var entities;
    var tilesWidth;
    var tilesHeight;
    var tiles;
    var singleTileWidth = 32; //MAGIC NUMBERS (i.e. 32 is width of tile image and draw)
    var frameLength = 1; // in milliseconds
    var gameIP = "167.88.120.57";
    var gamePort = "38734";
    var connectionInfo = "ws:" + gameIP + ":" + gamePort;
    var socket;
    var user = "";
    var pass = "";
    var windowWidth = $(window).innerWidth();
    var windowHeight = $(window).innerHeight();
    var textures = new Object();
    var errs = {
        100: "failedLogin"
    };

    function init() {
        document.body.scroll = "no"; // ie only

        pass = document.getElementById("loginInfo").pass.value;
        user = document.getElementById("loginInfo").user.value;
        if (user.indexOf(",") >= 0 || user.indexOf(":") >= 0) {
            document.getElementById("loginInfo").user.value = "INVALID INPUT";
            return;
        }

        socket = new WebSocket(connectionInfo);

        socket.onopen = function() {
            connected = true;
            var ret = {
                "login": {
                    "user": user,
                    "pass": pass
                }
            };
            socket.send(JSON.stringify(ret));
        }

        socket.onmessage = function(message) {
            var msg = JSON.parse(message.data);
            if ("kicked" in msg) {
                connected = false;
                disconnectMessage = msg.kicked;
            }
            if ("err" in msg && msg.err in errs) {
                msg.err(); //I hope this works!
            }
            if ("validated" in msg) {
                if (msg.validated) {
                    gameInitialize();
                    gameLoop();
                }
            }
            if ("entities" in msg && "enum" in msg) {
                entities = msg.entities;
                entityNum = msg.enum;
            }
            if ("player" in msg) {
                playerData = msg.player;
            }
            if ("level" in msg) {
                tiles = msg.level.tiles;
                tilesWidth = msg.level.width;
                tilesHeight = msg.level.height;
            }
        };

        socket.onclose = function() {
            connected = false;
            $("body").empty();
            $('body').append('
Disconnected

Reason: ' + disconnectMessage);
        };

        socket.onerror = function() {

        };

        window.addEventListener("keydown", keyPress, false);
        window.addEventListener("keyup", keyRelease, false);

        $(window).resize(function() {
            windowWidth = $(window).innerWidth();
            windowHeight = $(window).innerHeight();
            canvasElement.attr({
                width: windowWidth,
                height: windowHeight,
            });
        });
    }

    function gameInitialize() {
        $("body").empty();

        clearInput();

        $('body').append('<canvas id="GameCanvas">');
        canvasElement = $('#GameCanvas');
        canvasElement.attr({
            width: windowWidth,
            height: windowHeight,
            tabIndex: 0,
            onblur: clearInput,
        }).focus();
        window.onblur = clearInput;

        canvas = canvasElement[0];
        context = canvas.getContext('2d');
        context.globalCompositeOperation = "normal";

        function getMousePos(canvas, evt) {
            var rect = canvas.getBoundingClientRect();
            return {
                x: Math.round((evt.clientX - rect.left) / (rect.right - rect.left) * canvas.width),
                y: Math.round((evt.clientY - rect.top) / (rect.bottom - rect.top) * canvas.height)
            };
        }

        canvas.addEventListener("mousemove", function(evt) {
            var mousePos = getMousePos(canvas, evt);
            mx = mousePos.x;
            my = mousePos.y;
        }, false);
    }

    function gameLoop() {
        if (!connected) {
            return;
        }
        var keyData = "";
        try {
            var ret = {
                "keys": isKeyDown
            };
            socket.send(JSON.stringify(ret));
        } catch (err) {}
        context.clearRect(0, 0, windowWidth, windowHeight);
        context.fillStyle = "#FFFFFF";
        context.fillRect(0, 0, windowWidth, windowHeight);
        //draw Tiles
        for (a = 0; a < tilesWidth; a++) {
            for (b = 0; b < tilesHeight; b++) {
                if (tiles[a][b].id >= 0) {
                    drawImageSection("tilesheet", gPIVX(a * singleTileWidth), gPIVY(b * singleTileWidth), tiles[a][b].id, singleTileWidth, singleTileWidth);
                }
            }
        }
        //draw entities
        var entityNameOffsetY = 5;
        for (i = 0; i < entityNum; i++) {
            var e = entities[i];
            context.fillStyle = e.color;
            context.save();
            context.translate(gPIVX(e.x + (e.width / 2)), gPIVY(e.y + (e.height / 2)));
            context.rotate(Math.atan((my - (windowHeight/2)) / (mx - (windowWidth/2))) + ((mx > 0) ? (Math.PI / 2) : (Math.PI / 2)));
            context.translate(-gPIVX(e.x + (e.width / 2)), -gPIVY(e.y + (e.height / 2)));
            drawImageMasked("player", e.color, gPIVX(e.x), gPIVY(e.y), e.width, e.height);
            context.restore();
            context.fillText(e.name, (gPIVX(e.x) - (context.measureText(e.name).width / 2)) + (e.width / 2), gPIVY(e.y) - entityNameOffsetY);
        }
        context.fillText("Pos: (" + playerData.x + ", " + playerData.y + ")", 5, 15);

        setTimeout(gameLoop, frameLength);
    }

    function gPIVX(x) {
        //getPositionInViewportX
        return ((x - (playerData.x + (playerData.width / 2))) + (windowWidth / 2));
    }

    function gPIVY(y) {
        //getPositionInViewportY
        return ((y - (playerData.y + (playerData.height / 2))) + (windowHeight / 2));
    }

    function gPIWX(x) {
        //getPositionInWorldX
        //inverse of gPIVX() (i.e. gPIWX(gPIVX(a)) == a)
        return ((x + (playerData.x + (playerData.width / 2))) - (windowWidth / 2));
    }

    function gPIWY(y) {
        //getPositionInWorldY
        //inverse of gPIVY() (i.e. gPIWY(gPIVY(a)) == a)
        return ((y + (playerData.y + (playerData.height / 2))) - (windowHeight / 2));
    }

    function clearInput() {
        for (i = 0; i < 256; i++) {
            isKeyDown[i] = false;
        }
    }

    function keyPress(e) {
        if (e.keyCode < 265) {
            e.preventDefault();
            isKeyDown[e.keyCode] = true;
        }
        return false;
    }

    function keyRelease(e) {
        if (e.keyCode < 265) {
            e.preventDefault();
            isKeyDown[e.keyCode] = false;
        }
    }

    function isKeyPressed(c) {
        return isKeyDown[c.charCodeAt(0)];
    }

    function drawImageSection(name, x, y, id, spriteWidth, spriteHeight, xSize, ySize) {
        xSize = typeof xSize !== 'undefined' ? xSize : spriteWidth;
        ySize = typeof ySize !== 'undefined' ? ySize : spriteHeight;
        sheetCols = Math.floor(getImage(name).width / (spriteWidth + 2));
        sheetRows = Math.floor(getImage(name).height / (spriteHeight + 2));
        context.drawImage(getImage(name), ((id % sheetCols) * (spriteWidth + 2)) + 1, (Math.floor(id / sheetRows) * (spriteHeight + 2)) + 1, spriteWidth, spriteHeight, x, y, xSize, ySize);
    }

    function drawImage(name, x, y, xSize, ySize) {
        xSize = typeof xSize !== 'undefined' ? xSize : getImage(name).width;
        ySize = typeof ySize !== 'undefined' ? ySize : getImage(name).height;
        context.drawImage(getImage(name), x, y, xSize, ySize);
    }

    function drawImageMasked(name, color, x, y, xSize, ySize) {
        xSize = typeof xSize !== 'undefined' ? xSize : getImage(name).width;
        ySize = typeof ySize !== 'undefined' ? ySize : getImage(name).height;
        context.drawImage(getImageMasked(name, color), x, y, xSize, ySize);
    }

    function getImageData(image) {
        var tempCanv = document.createElement('canvas');
        tempCanv.width = image.width;
        tempCanv.height = image.height;
        var tempCTX = tempCanv.getContext('2d');
        tempCTX.drawImage(image, 0, 0, image.width, image.height);
        return tempCTX.getImageData(0, 0, image.width, image.height);
    }

    function getImageFromData(data) {
        var tempCanv = document.createElement('canvas');
        tempCanv.width = data.width;
        tempCanv.height = data.height;
        var tempCTX = tempCanv.getContext('2d');
        tempCTX.putImageData(data, 0, 0);
        var src = tempCanv.toDataURL("image/png");
        var img = new Image();
        img.src = src;
        return img;
    }

    function getImage(name) {
        if ((name) in textures) {
            return textures[name];
        } else {
            textures[name] = new Image;
            textures[name].src = '/res/tex/' + name + '.png';
            return textures[name];
        }
    }

    function getImageMasked(name, color) {
        if ((name + "-mask" + color) in textures) {
            return textures[name + "-mask" + color];
        }
        var image = getImage(name);
        var mask = getImage(name + "-mask");
        if (image.width == 0 || image.height == 0 || mask.width == 0 || mask.height == 0) {
            return new Image();
        }
        var maskData = getImageData(mask);
        var regex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;
        var colorRGBS = regex.exec(color);
        var colorRGB = [];
        for (i = 0; i < 3; i++) {
            colorRGB[i] = parseInt(colorRGBS[i + 1], 16);
        }
        for (i = 0; i < maskData.data.length; i += 4) {
            maskData.data[i] = colorRGB[0];
            maskData.data[i + 1] = colorRGB[1];
            maskData.data[i + 2] = colorRGB[2];
        }
        var tempCanv = document.createElement('canvas');
        tempCanv.width = image.width;
        tempCanv.height = image.height;
        var tempCTX = tempCanv.getContext("2d");
        tempCTX.drawImage(image, 0, 0, image.width, image.height);
        tempCTX.drawImage(getImageFromData(maskData), 0, 0, maskData.width, maskData.height);
        var ret = new Image();
        ret.src = tempCanv.toDataURL("image/png");
        textures[name + "-mask" + color] = ret;
        return ret;
    }

    function failedLogin() {
        alert("login failed"); //Just testing it out. I'll make it pretty later.
    }

    return {
        init: init,
        textures: textures
    };
})();

$(document).ready(function() {
    $("#loginInfo").submit(function(e) {
        e.preventDefault();
        JS_GAME.game.init();
        return false;
    });
});<commit_msg>nvm I'm just dumb... mx is always > 0<commit_after>var JS_GAME = {};

JS_GAME.game = (function() {
    var connected = false;
    var disconnectMessage = "Unknown (could be unexpected server shutdown, internet outage, etc.)";
    var isKeyDown = [];
    var mx = 0;
    var my = 0;
    var context;
    var canvas;
    var playerData = {
        name: "",
        x: 0,
        y: 0,
        width: 0,
        height: 0,
        color: "#000000"
    };
    var entityNum = 0;
    var entities;
    var tilesWidth;
    var tilesHeight;
    var tiles;
    var singleTileWidth = 32; //MAGIC NUMBERS (i.e. 32 is width of tile image and draw)
    var frameLength = 1; // in milliseconds
    var gameIP = "167.88.120.57";
    var gamePort = "38734";
    var connectionInfo = "ws:" + gameIP + ":" + gamePort;
    var socket;
    var user = "";
    var pass = "";
    var windowWidth = $(window).innerWidth();
    var windowHeight = $(window).innerHeight();
    var textures = new Object();
    var errs = {
        100: "failedLogin"
    };

    function init() {
        document.body.scroll = "no"; // ie only

        pass = document.getElementById("loginInfo").pass.value;
        user = document.getElementById("loginInfo").user.value;
        if (user.indexOf(",") >= 0 || user.indexOf(":") >= 0) {
            document.getElementById("loginInfo").user.value = "INVALID INPUT";
            return;
        }

        socket = new WebSocket(connectionInfo);

        socket.onopen = function() {
            connected = true;
            var ret = {
                "login": {
                    "user": user,
                    "pass": pass
                }
            };
            socket.send(JSON.stringify(ret));
        }

        socket.onmessage = function(message) {
            var msg = JSON.parse(message.data);
            if ("kicked" in msg) {
                connected = false;
                disconnectMessage = msg.kicked;
            }
            if ("err" in msg && msg.err in errs) {
                msg.err(); //I hope this works!
            }
            if ("validated" in msg) {
                if (msg.validated) {
                    gameInitialize();
                    gameLoop();
                }
            }
            if ("entities" in msg && "enum" in msg) {
                entities = msg.entities;
                entityNum = msg.enum;
            }
            if ("player" in msg) {
                playerData = msg.player;
            }
            if ("level" in msg) {
                tiles = msg.level.tiles;
                tilesWidth = msg.level.width;
                tilesHeight = msg.level.height;
            }
        };

        socket.onclose = function() {
            connected = false;
            $("body").empty();
            $('body').append('
Disconnected

Reason: ' + disconnectMessage);
        };

        socket.onerror = function() {

        };

        window.addEventListener("keydown", keyPress, false);
        window.addEventListener("keyup", keyRelease, false);

        $(window).resize(function() {
            windowWidth = $(window).innerWidth();
            windowHeight = $(window).innerHeight();
            canvasElement.attr({
                width: windowWidth,
                height: windowHeight,
            });
        });
    }

    function gameInitialize() {
        $("body").empty();

        clearInput();

        $('body').append('<canvas id="GameCanvas">');
        canvasElement = $('#GameCanvas');
        canvasElement.attr({
            width: windowWidth,
            height: windowHeight,
            tabIndex: 0,
            onblur: clearInput,
        }).focus();
        window.onblur = clearInput;

        canvas = canvasElement[0];
        context = canvas.getContext('2d');
        context.globalCompositeOperation = "normal";

        function getMousePos(canvas, evt) {
            var rect = canvas.getBoundingClientRect();
            return {
                x: Math.round((evt.clientX - rect.left) / (rect.right - rect.left) * canvas.width),
                y: Math.round((evt.clientY - rect.top) / (rect.bottom - rect.top) * canvas.height)
            };
        }

        canvas.addEventListener("mousemove", function(evt) {
            var mousePos = getMousePos(canvas, evt);
            mx = mousePos.x;
            my = mousePos.y;
        }, false);
    }

    function gameLoop() {
        if (!connected) {
            return;
        }
        var keyData = "";
        try {
            var ret = {
                "keys": isKeyDown
            };
            socket.send(JSON.stringify(ret));
        } catch (err) {}
        context.clearRect(0, 0, windowWidth, windowHeight);
        context.fillStyle = "#FFFFFF";
        context.fillRect(0, 0, windowWidth, windowHeight);
        //draw Tiles
        for (a = 0; a < tilesWidth; a++) {
            for (b = 0; b < tilesHeight; b++) {
                if (tiles[a][b].id >= 0) {
                    drawImageSection("tilesheet", gPIVX(a * singleTileWidth), gPIVY(b * singleTileWidth), tiles[a][b].id, singleTileWidth, singleTileWidth);
                }
            }
        }
        //draw entities
        var entityNameOffsetY = 5;
        for (i = 0; i < entityNum; i++) {
            var e = entities[i];
            context.fillStyle = e.color;
            context.save();
            context.translate(gPIVX(e.x + (e.width / 2)), gPIVY(e.y + (e.height / 2)));
            context.rotate(Math.atan((my - (windowHeight/2)) / (mx - (windowWidth/2))) + ((mx > (windowWidth/2)) ? (Math.PI / 2) : (Math.PI / -2)));
            context.translate(-gPIVX(e.x + (e.width / 2)), -gPIVY(e.y + (e.height / 2)));
            drawImageMasked("player", e.color, gPIVX(e.x), gPIVY(e.y), e.width, e.height);
            context.restore();
            context.fillText(e.name, (gPIVX(e.x) - (context.measureText(e.name).width / 2)) + (e.width / 2), gPIVY(e.y) - entityNameOffsetY);
        }
        context.fillText("Pos: (" + playerData.x + ", " + playerData.y + ")", 5, 15);

        setTimeout(gameLoop, frameLength);
    }

    function gPIVX(x) {
        //getPositionInViewportX
        return ((x - (playerData.x + (playerData.width / 2))) + (windowWidth / 2));
    }

    function gPIVY(y) {
        //getPositionInViewportY
        return ((y - (playerData.y + (playerData.height / 2))) + (windowHeight / 2));
    }

    function gPIWX(x) {
        //getPositionInWorldX
        //inverse of gPIVX() (i.e. gPIWX(gPIVX(a)) == a)
        return ((x + (playerData.x + (playerData.width / 2))) - (windowWidth / 2));
    }

    function gPIWY(y) {
        //getPositionInWorldY
        //inverse of gPIVY() (i.e. gPIWY(gPIVY(a)) == a)
        return ((y + (playerData.y + (playerData.height / 2))) - (windowHeight / 2));
    }

    function clearInput() {
        for (i = 0; i < 256; i++) {
            isKeyDown[i] = false;
        }
    }

    function keyPress(e) {
        if (e.keyCode < 265) {
            e.preventDefault();
            isKeyDown[e.keyCode] = true;
        }
        return false;
    }

    function keyRelease(e) {
        if (e.keyCode < 265) {
            e.preventDefault();
            isKeyDown[e.keyCode] = false;
        }
    }

    function isKeyPressed(c) {
        return isKeyDown[c.charCodeAt(0)];
    }

    function drawImageSection(name, x, y, id, spriteWidth, spriteHeight, xSize, ySize) {
        xSize = typeof xSize !== 'undefined' ? xSize : spriteWidth;
        ySize = typeof ySize !== 'undefined' ? ySize : spriteHeight;
        sheetCols = Math.floor(getImage(name).width / (spriteWidth + 2));
        sheetRows = Math.floor(getImage(name).height / (spriteHeight + 2));
        context.drawImage(getImage(name), ((id % sheetCols) * (spriteWidth + 2)) + 1, (Math.floor(id / sheetRows) * (spriteHeight + 2)) + 1, spriteWidth, spriteHeight, x, y, xSize, ySize);
    }

    function drawImage(name, x, y, xSize, ySize) {
        xSize = typeof xSize !== 'undefined' ? xSize : getImage(name).width;
        ySize = typeof ySize !== 'undefined' ? ySize : getImage(name).height;
        context.drawImage(getImage(name), x, y, xSize, ySize);
    }

    function drawImageMasked(name, color, x, y, xSize, ySize) {
        xSize = typeof xSize !== 'undefined' ? xSize : getImage(name).width;
        ySize = typeof ySize !== 'undefined' ? ySize : getImage(name).height;
        context.drawImage(getImageMasked(name, color), x, y, xSize, ySize);
    }

    function getImageData(image) {
        var tempCanv = document.createElement('canvas');
        tempCanv.width = image.width;
        tempCanv.height = image.height;
        var tempCTX = tempCanv.getContext('2d');
        tempCTX.drawImage(image, 0, 0, image.width, image.height);
        return tempCTX.getImageData(0, 0, image.width, image.height);
    }

    function getImageFromData(data) {
        var tempCanv = document.createElement('canvas');
        tempCanv.width = data.width;
        tempCanv.height = data.height;
        var tempCTX = tempCanv.getContext('2d');
        tempCTX.putImageData(data, 0, 0);
        var src = tempCanv.toDataURL("image/png");
        var img = new Image();
        img.src = src;
        return img;
    }

    function getImage(name) {
        if ((name) in textures) {
            return textures[name];
        } else {
            textures[name] = new Image;
            textures[name].src = '/res/tex/' + name + '.png';
            return textures[name];
        }
    }

    function getImageMasked(name, color) {
        if ((name + "-mask" + color) in textures) {
            return textures[name + "-mask" + color];
        }
        var image = getImage(name);
        var mask = getImage(name + "-mask");
        if (image.width == 0 || image.height == 0 || mask.width == 0 || mask.height == 0) {
            return new Image();
        }
        var maskData = getImageData(mask);
        var regex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;
        var colorRGBS = regex.exec(color);
        var colorRGB = [];
        for (i = 0; i < 3; i++) {
            colorRGB[i] = parseInt(colorRGBS[i + 1], 16);
        }
        for (i = 0; i < maskData.data.length; i += 4) {
            maskData.data[i] = colorRGB[0];
            maskData.data[i + 1] = colorRGB[1];
            maskData.data[i + 2] = colorRGB[2];
        }
        var tempCanv = document.createElement('canvas');
        tempCanv.width = image.width;
        tempCanv.height = image.height;
        var tempCTX = tempCanv.getContext("2d");
        tempCTX.drawImage(image, 0, 0, image.width, image.height);
        tempCTX.drawImage(getImageFromData(maskData), 0, 0, maskData.width, maskData.height);
        var ret = new Image();
        ret.src = tempCanv.toDataURL("image/png");
        textures[name + "-mask" + color] = ret;
        return ret;
    }

    function failedLogin() {
        alert("login failed"); //Just testing it out. I'll make it pretty later.
    }

    return {
        init: init,
        textures: textures
    };
})();

$(document).ready(function() {
    $("#loginInfo").submit(function(e) {
        e.preventDefault();
        JS_GAME.game.init();
        return false;
    });
});<|endoftext|>


<commit_before>/* global phantom */
var webpage = require( 'webpage' ),
	currentUrl = phantom.args[ 0 ],
	page;

function renderPage( url ) {
	page = webpage.create();
	page.windowName = 'my-window';
	page.settings.webSecurityEnabled = false;

	// handle redirects
	page.onNavigationRequested = function( url, type, willNavigate, main ) {
		if ( main && url != currentUrl ) {
			currentUrl = url;
			page.close();
			renderPage( url );
		}
	};

	// handle logs
	page.onConsoleMessage = function( msg ) {
		console.log( 'console: ' + msg );
	};

	page.onError = function( msg, trace ) {
		console.log( 'error:', msg );
		trace.forEach( function( item ) {
			console.log( '  ', item.file, ':', item.line );
		} );
	};

	page.open( url, function( status ) {
		if ( status !== 'success' ) {
			phantom.exit( 1 );
		}
	} );
}

renderPage( currentUrl );
<commit_msg>Support PhantomJS 2.0<commit_after>/* global phantom */
var webpage = require( 'webpage' ),
	currentUrl = phantom.args ? phantom.args[ 0 ] : require( 'system' ).args[ 1 ],
	page;

function renderPage( url ) {
	page = webpage.create();
	page.windowName = 'my-window';
	page.settings.webSecurityEnabled = false;

	// handle redirects
	page.onNavigationRequested = function( url, type, willNavigate, main ) {
		if ( main && url != currentUrl ) {
			currentUrl = url;
			page.close();
			renderPage( url );
		}
	};

	// handle logs
	page.onConsoleMessage = function( msg ) {
		console.log( 'console: ' + msg );
	};

	page.onError = function( msg, trace ) {
		console.log( 'error:', msg );
		trace.forEach( function( item ) {
			console.log( '  ', item.file, ':', item.line );
		} );
	};

	page.open( url, function( status ) {
		if ( status !== 'success' ) {
			phantom.exit( 1 );
		}
	} );
}

renderPage( currentUrl );
<|endoftext|>


<commit_before>/*  Copyright (c) 2014 Iain Hamilton

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. */

define([], function() {
  return function () {

    var mapLayers;

    var mapWidth;
    var mapHeight;

    var scaledMapWidth;
    var scaledMapHeight;

    var tileWidth;
    var tileHeight;
    var screenWidth;
    var screenHeight;

    var mapOffsetX;
    var mapOffsetY;

    var curZoom;
    var startX = 0;
    var startY = 0;
    var focusX = 0;
    var focusY = 0;
    var rangeX = 0;
    var rangeY = 0;

    var isometric = false;

    var xyNextPos = {};

    function _setup(layers, mapW, mapH, tileW, tileH, screenW, screenH, curZ) {
      mapLayers = layers;
      mapWidth = mapW;
      mapHeight = mapH;
      tileWidth = tileW;
      tileHeight = tileH;
      curZoom = curZ || 1;
      screenWidth = screenW;
      screenHeight = screenH;
      scaledMapWidth = mapWidth / tileW;
      scaledMapWidth = scaledMapWidth * (tileW * curZoom);
      scaledMapHeight = mapHeight / tileW;
      scaledMapHeight = scaledMapHeight * (tileH * curZoom);
      return {
        startX: startX,
        startY: startY,
        pinFocusX: focusX,
        pinFocusY: focusY
      };
    }

    function _getXYCoords(x, y) {
      var positionY, positionX;
      if (!isometric) {
        positionY = Math.round((y - (tileHeight * curZoom) / 2) / (tileHeight * curZoom));
        positionX = Math.round((x - (tileWidth * curZoom) / 2) / (tileWidth * curZoom));
      }
      else {
        positionY = (2 * (y - mapOffsetY) - x + mapOffsetX) / 2;
        positionX = x + positionY - mapOffsetX - (tileHeight * curZoom);
        positionY = Math.round(positionY / (tileHeight * curZoom));
        positionX = Math.round(positionX / (tileHeight * curZoom));
      }
      return {x: positionX, y: positionY};
    }

    function _setFocus(posX, posY, cameraRangeX, cameraRangeY, setZoom) {
      var xyMapOffset;
      var i;

      if (setZoom && curZoom !== setZoom) {
        curZoom = setZoom;
        scaledMapWidth = mapWidth / tileWidth;
        scaledMapWidth = scaledMapWidth * (tileWidth * curZoom);
        scaledMapHeight = mapHeight / tileHeight;
        scaledMapHeight = scaledMapHeight * (tileHeight * curZoom);
        screenHeight = Math.round(window.innerHeight / (tileHeight * curZoom));
        screenWidth = Math.round(window.innerWidth / (tileWidth * curZoom));
      }
      rangeX = cameraRangeX;
      rangeY = cameraRangeY;

      startX = Math.round(posX - screenWidth / 2);
      startY = Math.round(posY - screenHeight / 2);

      if (screenHeight * (tileHeight * curZoom) > scaledMapHeight) {

        for (i = 0; i < mapLayers.length; i++) {
          mapLayers[i].setOffset(null, Math.round(screenHeight * (tileHeight * curZoom) / 2 - scaledMapHeight / 2));
        }
      }
      else {
        for (i = 0; i < mapLayers.length; i++) {
          if (startY < 0) {

            mapLayers[i].setOffset(null, Math.round(-(tileHeight * curZoom) * posY + (posY * (tileHeight * curZoom))));
          }
          else {
            if (startY + screenHeight > scaledMapHeight / (tileHeight * curZoom)) {

              mapLayers[i].setOffset(null, Math.round(scaledMapHeight / (tileHeight * curZoom)) - (screenHeight * (tileHeight * curZoom)) / 2) ;
            }
            else {

              mapLayers[i].setOffset(null, Math.round(-(tileHeight * curZoom) * posY + (screenHeight / 2 * (tileHeight * curZoom))));
            }
          }
        }
      }
      if (screenWidth * (tileWidth * curZoom) > scaledMapWidth) {
      console.log("here ", 1);

        for (i = 0; i < mapLayers.length; i++) {
          mapLayers[i].setOffset(Math.round(screenWidth * (tileWidth * curZoom) / 2 - scaledMapWidth / 2), Math.round(screenHeight * (tileHeight * curZoom) / 2 - mapHeight / 2));
        }
      }
      else {
        for (i = 0; i < mapLayers.length; i++) {
          if (startX < 0) {
      console.log("here ", 2);
            // mapLayers[i].setOffset(Math.floor(screenWidth * tileWidth / 2 - mapWidth / 2), Math.floor(screenHeight * tileHeight / 2 - mapHeight / 2));
            mapLayers[i].setOffset(Math.floor(screenWidth * (tileWidth * curZoom) / 2 - scaledMapWidth / 2), null);
          }
          else {
            if (startX + screenWidth > scaledMapWidth / (tileWidth * curZoom)) {
      console.log("here ", 3);

              mapLayers[i].setOffset(-(Math.round(scaledMapWidth / (tileWidth * curZoom))  - screenWidth) * (tileWidth * curZoom), null);
            }
            else {
      console.log("here ", 4);

              mapLayers[i].setOffset(Math.round(-(tileWidth * curZoom) * posX + (screenWidth / 2 * (tileHeight * curZoom))), null);
            }
          }
        }
      }
      xyMapOffset = mapLayers[0].getOffset();
      focusX = posX * (curZoom * tileWidth) + xyMapOffset.x;
      focusY = posY * (curZoom * tileHeight) + xyMapOffset.y;
      xyNextPos = _getXYCoords(focusX - xyMapOffset.x, focusY - xyMapOffset.y);
      return {
        startX: Math.floor(xyNextPos.x - rangeX / 2),
        startY: Math.floor(xyNextPos.y - rangeY / 2),
        pinFocusX: Math.floor(focusX),
        pinFocusY: Math.floor(focusY),
        tileX: Math.floor(posX),
        tileY: Math.floor(posY)
      };
    }

    // direction: "up", "down", "left", "right" - distance: int
    function _move(direction, distance) {
      var xyMapOffset = mapLayers[0].getOffset();
      var i = 0;
      xyNextPos = _getXYCoords(focusX - xyMapOffset.x, focusY - xyMapOffset.y);
      switch(direction) {
        case "up":
          if (xyNextPos.y - 1 <= startY + screenHeight / 2 && focusY < (screenHeight / 2 * (tileHeight * curZoom)) && xyMapOffset.y <= 0) {
            for (i = 0; i < mapLayers.length; i++) {
              mapLayers[i].move("up", distance);
            }
          }
          else {
          //  if (xyNextPos.y > rangeY / 2) {
              focusY -= distance;
          //  }
          }
        break;
        case "down":
          if (xyNextPos.y >= screenHeight / 2 && xyMapOffset.y >= -scaledMapHeight + focusY + (screenHeight / 2 * (tileHeight * curZoom))) {
            for (i = 0; i < mapLayers.length; i++) {
              mapLayers[i].move("down", distance);
            }
          }
          else {
          //  if (xyNextPos.y <= Math.round((scaledMapHeight / (tileHeight * curZoom)) - rangeY / 2)) {
              focusY += distance;
          //  }
          }
        break;
        case "left":
          if (xyNextPos.x - 1 <= startX + screenWidth / 2 && focusX < (screenWidth / 2 * (tileWidth * curZoom)) && xyMapOffset.x <= 0) {
            for (i = 0; i < mapLayers.length; i++) {
              mapLayers[i].move("left", distance);
            }
          }
          else {
          //  if (xyNextPos.x > rangeX / 2) {
              focusX -= distance;
          //  }
          }
        break;
        case "right":
          if (xyNextPos.x >= screenWidth / 2 && xyMapOffset.x >= -scaledMapWidth + focusX + (screenWidth / 2 * (tileWidth * curZoom))) {
            for (i = 0; i < mapLayers.length; i++) {
              mapLayers[i].move("right", distance);
            }
          }
          else {
          //  if (xyNextPos.x <= Math.round((scaledMapWidth / (tileWidth * curZoom)) - rangeX / 2)) {
              focusX += distance;
          //  }
          }
        break;
      }
      startX = xyNextPos.x - rangeX / 2;
      startY = xyNextPos.y - rangeY / 2;

      return {
        startX: Math.floor(startX),
        startY: Math.floor(startY),
        pinFocusX: Math.floor(focusX),
        pinFocusY: Math.floor(focusY),
        tileX: Math.floor(xyNextPos.x),
        tileY: Math.floor(xyNextPos.y)
      };
      // Returns where to start drawing the tiles from.
      // pinFocus represents a precise location withn the map.
    }

    return {
      setup: function(mapLayers, mapWidth, mapHeight, tileWidth, tileHeight, screenWidth, screenHeight, curZoom) {
        return _setup(mapLayers, mapWidth, mapHeight, tileWidth, tileHeight, screenWidth, screenHeight, curZoom);
      },

      setFocus: function(posX, posY, rangeX, rangeY, setZoom) {
        return _setFocus(posX, posY, rangeX, rangeY, setZoom);
      },

      setPinFocusY: function(y) {
        focusY = y;
        return {
          startX: Math.floor(startX),
          startY: Math.floor(startY),
          pinFocusX: focusX,
          pinFocusY: focusY,
          tileX: Math.floor(xyNextPos.x),
          tileY: Math.floor(xyNextPos.y)
        };
      },

      setPinFocusX: function(x) {
        focusX = x;
        return {
          startX: Math.floor(startX),
          startY: Math.floor(startY),
          pinFocusX: focusX,
          pinFocusY: focusY,
          tileX: Math.floor(xyNextPos.x),
          tileY: Math.floor(xyNextPos.y)
        };
      },

      getFocus: function() {
        return {
          startX: Math.floor(startX),
          startY: Math.floor(startY),
          pinFocusX: focusX,
          pinFocusY: focusY,
          tileX: Math.floor(xyNextPos.x),
          tileY: Math.floor(xyNextPos.y)
        };
      },

      move: function(direction, distance, setZoom) {
        return _move(direction, distance, setZoom);
      }

    };
  };
});<commit_msg>Removed debug console lines<commit_after>/*  Copyright (c) 2014 Iain Hamilton

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. */

define([], function() {
  return function () {

    var mapLayers;

    var mapWidth;
    var mapHeight;

    var scaledMapWidth;
    var scaledMapHeight;

    var tileWidth;
    var tileHeight;
    var screenWidth;
    var screenHeight;

    var mapOffsetX;
    var mapOffsetY;

    var curZoom;
    var startX = 0;
    var startY = 0;
    var focusX = 0;
    var focusY = 0;
    var rangeX = 0;
    var rangeY = 0;

    var isometric = false;

    var xyNextPos = {};

    function _setup(layers, mapW, mapH, tileW, tileH, screenW, screenH, curZ) {
      mapLayers = layers;
      mapWidth = mapW;
      mapHeight = mapH;
      tileWidth = tileW;
      tileHeight = tileH;
      curZoom = curZ || 1;
      screenWidth = screenW;
      screenHeight = screenH;
      scaledMapWidth = mapWidth / tileW;
      scaledMapWidth = scaledMapWidth * (tileW * curZoom);
      scaledMapHeight = mapHeight / tileW;
      scaledMapHeight = scaledMapHeight * (tileH * curZoom);
      return {
        startX: startX,
        startY: startY,
        pinFocusX: focusX,
        pinFocusY: focusY
      };
    }

    function _getXYCoords(x, y) {
      var positionY, positionX;
      if (!isometric) {
        positionY = Math.round((y - (tileHeight * curZoom) / 2) / (tileHeight * curZoom));
        positionX = Math.round((x - (tileWidth * curZoom) / 2) / (tileWidth * curZoom));
      }
      else {
        positionY = (2 * (y - mapOffsetY) - x + mapOffsetX) / 2;
        positionX = x + positionY - mapOffsetX - (tileHeight * curZoom);
        positionY = Math.round(positionY / (tileHeight * curZoom));
        positionX = Math.round(positionX / (tileHeight * curZoom));
      }
      return {x: positionX, y: positionY};
    }

    function _setFocus(posX, posY, cameraRangeX, cameraRangeY, setZoom) {
      var xyMapOffset;
      var i;

      if (setZoom && curZoom !== setZoom) {
        curZoom = setZoom;
        scaledMapWidth = mapWidth / tileWidth;
        scaledMapWidth = scaledMapWidth * (tileWidth * curZoom);
        scaledMapHeight = mapHeight / tileHeight;
        scaledMapHeight = scaledMapHeight * (tileHeight * curZoom);
        screenHeight = Math.round(window.innerHeight / (tileHeight * curZoom));
        screenWidth = Math.round(window.innerWidth / (tileWidth * curZoom));
      }
      rangeX = cameraRangeX;
      rangeY = cameraRangeY;

      startX = Math.round(posX - screenWidth / 2);
      startY = Math.round(posY - screenHeight / 2);

      if (screenHeight * (tileHeight * curZoom) > scaledMapHeight) {

        for (i = 0; i < mapLayers.length; i++) {
          mapLayers[i].setOffset(null, Math.round(screenHeight * (tileHeight * curZoom) / 2 - scaledMapHeight / 2));
        }
      }
      else {
        for (i = 0; i < mapLayers.length; i++) {
          if (startY < 0) {

            mapLayers[i].setOffset(null, Math.round(-(tileHeight * curZoom) * posY + (posY * (tileHeight * curZoom))));
          }
          else {
            if (startY + screenHeight > scaledMapHeight / (tileHeight * curZoom)) {

              mapLayers[i].setOffset(null, Math.round(scaledMapHeight / (tileHeight * curZoom)) - (screenHeight * (tileHeight * curZoom)) / 2) ;
            }
            else {

              mapLayers[i].setOffset(null, Math.round(-(tileHeight * curZoom) * posY + (screenHeight / 2 * (tileHeight * curZoom))));
            }
          }
        }
      }
      if (screenWidth * (tileWidth * curZoom) > scaledMapWidth) {
        for (i = 0; i < mapLayers.length; i++) {
          mapLayers[i].setOffset(Math.round(screenWidth * (tileWidth * curZoom) / 2 - scaledMapWidth / 2), Math.round(screenHeight * (tileHeight * curZoom) / 2 - mapHeight / 2));
        }
      }
      else {
        for (i = 0; i < mapLayers.length; i++) {
          if (startX < 0) {
            mapLayers[i].setOffset(Math.floor(screenWidth * (tileWidth * curZoom) / 2 - scaledMapWidth / 2), null);
          }
          else {
            if (startX + screenWidth > scaledMapWidth / (tileWidth * curZoom)) {
              mapLayers[i].setOffset(-(Math.round(scaledMapWidth / (tileWidth * curZoom))  - screenWidth) * (tileWidth * curZoom), null);
            }
            else {
              mapLayers[i].setOffset(Math.round(-(tileWidth * curZoom) * posX + (screenWidth / 2 * (tileHeight * curZoom))), null);
            }
          }
        }
      }
      xyMapOffset = mapLayers[0].getOffset();
      focusX = posX * (curZoom * tileWidth) + xyMapOffset.x;
      focusY = posY * (curZoom * tileHeight) + xyMapOffset.y;
      xyNextPos = _getXYCoords(focusX - xyMapOffset.x, focusY - xyMapOffset.y);
      return {
        startX: Math.floor(xyNextPos.x - rangeX / 2),
        startY: Math.floor(xyNextPos.y - rangeY / 2),
        pinFocusX: Math.floor(focusX),
        pinFocusY: Math.floor(focusY),
        tileX: Math.floor(posX),
        tileY: Math.floor(posY)
      };
    }

    // direction: "up", "down", "left", "right" - distance: int
    function _move(direction, distance) {
      var xyMapOffset = mapLayers[0].getOffset();
      var i = 0;
      xyNextPos = _getXYCoords(focusX - xyMapOffset.x, focusY - xyMapOffset.y);
      switch(direction) {
        case "up":
          if (xyNextPos.y - 1 <= startY + screenHeight / 2 && focusY < (screenHeight / 2 * (tileHeight * curZoom)) && xyMapOffset.y <= 0) {
            for (i = 0; i < mapLayers.length; i++) {
              mapLayers[i].move("up", distance);
            }
          }
          else {
          //  if (xyNextPos.y > rangeY / 2) {
              focusY -= distance;
          //  }
          }
        break;
        case "down":
          if (xyNextPos.y >= screenHeight / 2 && xyMapOffset.y >= -scaledMapHeight + focusY + (screenHeight / 2 * (tileHeight * curZoom))) {
            for (i = 0; i < mapLayers.length; i++) {
              mapLayers[i].move("down", distance);
            }
          }
          else {
          //  if (xyNextPos.y <= Math.round((scaledMapHeight / (tileHeight * curZoom)) - rangeY / 2)) {
              focusY += distance;
          //  }
          }
        break;
        case "left":
          if (xyNextPos.x - 1 <= startX + screenWidth / 2 && focusX < (screenWidth / 2 * (tileWidth * curZoom)) && xyMapOffset.x <= 0) {
            for (i = 0; i < mapLayers.length; i++) {
              mapLayers[i].move("left", distance);
            }
          }
          else {
          //  if (xyNextPos.x > rangeX / 2) {
              focusX -= distance;
          //  }
          }
        break;
        case "right":
          if (xyNextPos.x >= screenWidth / 2 && xyMapOffset.x >= -scaledMapWidth + focusX + (screenWidth / 2 * (tileWidth * curZoom))) {
            for (i = 0; i < mapLayers.length; i++) {
              mapLayers[i].move("right", distance);
            }
          }
          else {
          //  if (xyNextPos.x <= Math.round((scaledMapWidth / (tileWidth * curZoom)) - rangeX / 2)) {
              focusX += distance;
          //  }
          }
        break;
      }
      startX = xyNextPos.x - rangeX / 2;
      startY = xyNextPos.y - rangeY / 2;

      return {
        startX: Math.floor(startX),
        startY: Math.floor(startY),
        pinFocusX: Math.floor(focusX),
        pinFocusY: Math.floor(focusY),
        tileX: Math.floor(xyNextPos.x),
        tileY: Math.floor(xyNextPos.y)
      };
      // Returns where to start drawing the tiles from.
      // pinFocus represents a precise location withn the map.
    }

    return {
      setup: function(mapLayers, mapWidth, mapHeight, tileWidth, tileHeight, screenWidth, screenHeight, curZoom) {
        return _setup(mapLayers, mapWidth, mapHeight, tileWidth, tileHeight, screenWidth, screenHeight, curZoom);
      },

      setFocus: function(posX, posY, rangeX, rangeY, setZoom) {
        return _setFocus(posX, posY, rangeX, rangeY, setZoom);
      },

      setPinFocusY: function(y) {
        focusY = y;
        return {
          startX: Math.floor(startX),
          startY: Math.floor(startY),
          pinFocusX: focusX,
          pinFocusY: focusY,
          tileX: Math.floor(xyNextPos.x),
          tileY: Math.floor(xyNextPos.y)
        };
      },

      setPinFocusX: function(x) {
        focusX = x;
        return {
          startX: Math.floor(startX),
          startY: Math.floor(startY),
          pinFocusX: focusX,
          pinFocusY: focusY,
          tileX: Math.floor(xyNextPos.x),
          tileY: Math.floor(xyNextPos.y)
        };
      },

      getFocus: function() {
        return {
          startX: Math.floor(startX),
          startY: Math.floor(startY),
          pinFocusX: focusX,
          pinFocusY: focusY,
          tileX: Math.floor(xyNextPos.x),
          tileY: Math.floor(xyNextPos.y)
        };
      },

      move: function(direction, distance, setZoom) {
        return _move(direction, distance, setZoom);
      }

    };
  };
});<|endoftext|>


<commit_before>export default [
  {
    name: 'Quasar Framework: Cross-Platform Vue JS Vuex & Firebase Apps',
    desc: 'Use Quasar, Vue JS 2, Vuex & Firebase to build a Cross Platform, Single Codebase App for Web, iOS, Android, Mac, Windows',
    author: 'Danny Connell',
    lang: 'English',
    link: 'https://click.linksynergy.com/link?id=V56OaeB17aU&offerid=507388.2305152&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fquasarframework%2F',
    imgUrl: 'https://i.udemycdn.com/course/480x270/2305152_ecfb_5.jpg'
  },

  {
    name: 'Desarrollo de aplicaciones PWA con Vuejs y Quasar Framework',
    desc: 'Aprende a desarrollar una aplicacin web con comportamiento y apariencia mvil que sea capaz de trabajar Offline',
    author: 'Israel Parra',
    lang: 'Spanish',
    link: 'https://click.linksynergy.com/link?id=V56OaeB17aU&offerid=507388.2075016&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Faplicaciones-pwa-con-vuejs-y-quasar-framework%2F',
    imgUrl: 'https://i.udemycdn.com/course/480x270/2075016_4ea3_2.jpg'
  },

  {
    name: 'Getting started with Quasar Framework',
    desc: 'In this video we will see how to get started with Quasar Framework by setting up a development environment and quickly creating a hello world quasar app for both web and desktop.',
    author: 'codeguru',
    lang: 'English',
    link: 'https://www.youtube.com/watch?v=BK66mQTSl7U',
    imgUrl: 'https://i.ytimg.com/vi/BK66mQTSl7U/hqdefault.jpg?sqp=-oaymwEZCNACELwBSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLCG_P7GvHFaoEzScLX83FBKt49sUw'
  },

  {
    name: 'How to create Android and iOS applications using Quasar Framework',
    desc: 'In this video tutorial, codeguru shows you how to create Android and iOS applications using Quasar Framework. He will go in depth in setting up the environments for both Android and iOS applications.',
    author: 'codeguru',
    lang: 'English',
    link: 'https://www.youtube.com/watch?v=As5lzor2NQ8',
    imgUrl: 'https://i.ytimg.com/vi/As5lzor2NQ8/hqdefault.jpg?sqp=-oaymwEZCNACELwBSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLANOzkdmYe6Ng5jdSfPGMSuL7HFlQ'
  },

  {
    name: 'How to Host a Quasar Framework application on AWS in 10 mins using AWS-Amplify',
    desc: 'In this video codeguru discusses hosting a Quasar application on AWS using the aws-amplify framework.',
    author: 'codeguru',
    lang: 'English',
    link: 'https://www.youtube.com/watch?v=1F0SfYmrSbA',
    imgUrl: 'https://i.ytimg.com/vi/1F0SfYmrSbA/hqdefault.jpg?sqp=-oaymwEZCNACELwBSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLA2kGICdkby-h6xUpCKhj763uYSwg'
  },

  {
    name: 'Weather App with Vue.js & Quasar (for Mobile, Desktop & Web)',
    desc: 'Use Vue.js & Quasar to create a Gorgeous Weather App from scratch & get it running & working on 5 different platforms: Android, iOS, Mac, Windows & Web',
    author: 'Danny Connell',
    lang: 'English',
    link: 'https://dannys.link/quasarweather',
    imgUrl: 'https://img-a.udemycdn.com/course/480x270/3180950_e65e_3.jpg'
  }
]
<commit_msg>docs: Added PWA Udemy course to Video Tutorials page. Also updated thumbnail on other Quasar course (#7591)<commit_after>export default [
  {
    name: 'Quasar Framework: Cross-Platform Vue JS Vuex & Firebase Apps',
    desc: 'Use Quasar, Vue JS 2, Vuex & Firebase to build a Cross Platform, Single Codebase App for Web, iOS, Android, Mac, Windows',
    author: 'Danny Connell',
    lang: 'English',
    link: 'https://click.linksynergy.com/link?id=V56OaeB17aU&offerid=507388.2305152&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fquasarframework%2F',
    imgUrl: 'https://img-a.udemycdn.com/course/480x270/2305152_ecfb_6.jpg'
  },

  {
    name: 'Desarrollo de aplicaciones PWA con Vuejs y Quasar Framework',
    desc: 'Aprende a desarrollar una aplicacin web con comportamiento y apariencia mvil que sea capaz de trabajar Offline',
    author: 'Israel Parra',
    lang: 'Spanish',
    link: 'https://click.linksynergy.com/link?id=V56OaeB17aU&offerid=507388.2075016&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Faplicaciones-pwa-con-vuejs-y-quasar-framework%2F',
    imgUrl: 'https://i.udemycdn.com/course/480x270/2075016_4ea3_2.jpg'
  },

  {
    name: 'Getting started with Quasar Framework',
    desc: 'In this video we will see how to get started with Quasar Framework by setting up a development environment and quickly creating a hello world quasar app for both web and desktop.',
    author: 'codeguru',
    lang: 'English',
    link: 'https://www.youtube.com/watch?v=BK66mQTSl7U',
    imgUrl: 'https://i.ytimg.com/vi/BK66mQTSl7U/hqdefault.jpg?sqp=-oaymwEZCNACELwBSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLCG_P7GvHFaoEzScLX83FBKt49sUw'
  },

  {
    name: 'How to create Android and iOS applications using Quasar Framework',
    desc: 'In this video tutorial, codeguru shows you how to create Android and iOS applications using Quasar Framework. He will go in depth in setting up the environments for both Android and iOS applications.',
    author: 'codeguru',
    lang: 'English',
    link: 'https://www.youtube.com/watch?v=As5lzor2NQ8',
    imgUrl: 'https://i.ytimg.com/vi/As5lzor2NQ8/hqdefault.jpg?sqp=-oaymwEZCNACELwBSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLANOzkdmYe6Ng5jdSfPGMSuL7HFlQ'
  },

  {
    name: 'How to Host a Quasar Framework application on AWS in 10 mins using AWS-Amplify',
    desc: 'In this video codeguru discusses hosting a Quasar application on AWS using the aws-amplify framework.',
    author: 'codeguru',
    lang: 'English',
    link: 'https://www.youtube.com/watch?v=1F0SfYmrSbA',
    imgUrl: 'https://i.ytimg.com/vi/1F0SfYmrSbA/hqdefault.jpg?sqp=-oaymwEZCNACELwBSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLA2kGICdkby-h6xUpCKhj763uYSwg'
  },

  {
    name: 'Weather App with Vue.js & Quasar (for Mobile, Desktop & Web)',
    desc: 'Use Vue.js & Quasar to create a Gorgeous Weather App from scratch & get it running & working on 5 different platforms: Android, iOS, Mac, Windows & Web.',
    author: 'Danny Connell',
    lang: 'English',
    link: 'https://dannys.link/quasarweather',
    imgUrl: 'https://img-a.udemycdn.com/course/480x270/3180950_e65e_3.jpg'
  },

  {
    name: 'PWA with Vue JS, Quasar & Firebase (with NodeJS & Express)',
    desc: 'Create a Beautiful Instagram-Style Progressive Web App with Vue, Quasar, Firebase, NodeJS & Express.',
    author: 'Danny Connell',
    lang: 'English',
    link: 'https://dannys.link/quasarpwa',
    imgUrl: 'https://img-a.udemycdn.com/course/750x422/3240810_dedb_2.jpg'
  }
]
<|endoftext|>


<commit_before>var fetchValue = require("./value.js")
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Get array of available text values
//------------------------------------------------------------------------------
module.exports = function(vars,obj,depth) {

  if ( typeof depth !== "number" ) var depth = vars.depth.value

  var key = vars.id.nesting[depth]

  if ( vars.text.nesting && d3plus.object.validate(vars.text.nesting) ) {
    if ( vars.text.nesting[key] ) {
      var textKeys = vars.text.nesting[key]
    }
    else {
      var textKeys = vars.text.nesting[ d3.keys(vars.text.nesting)[0] ]
    }
  }
  else {
    var textKeys = []
    if (vars.text.value) textKeys.push(vars.text.value)
    textKeys.push(key)
  }

  if ( !(textKeys instanceof Array) ) {
    textKeys = [ textKeys ]
  }

  var names = []

  if (d3plus.object.validate(obj) && "d3plus" in obj && obj.d3plus.text) {
    names.push(obj.d3plus.text)
  }
  else {

    textKeys.forEach(function( t ){

      var name = fetchValue( vars , obj , t , key )

      if ( name ) {
        if ( !(name instanceof Array) ) {
          name = vars.format.value(name.toString())
        }
        else {
          name.forEach(function(n){
            n = vars.format.value(n.toString())
          })
        }
        names.push(name)
      }
    })

  }

  return names

}
<commit_msg>fixed issue with grouped legend tooltip titles not displaying proper lists<commit_after>var fetchValue = require("./value.js")
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Get array of available text values
//------------------------------------------------------------------------------
module.exports = function(vars,obj,depth) {

  if ( typeof depth !== "number" ) var depth = vars.depth.value

  var key = vars.id.nesting[depth]

  if ( vars.text.nesting && d3plus.object.validate(vars.text.nesting) ) {
    if ( vars.text.nesting[key] ) {
      var textKeys = vars.text.nesting[key]
    }
    else {
      var textKeys = vars.text.nesting[ d3.keys(vars.text.nesting)[0] ]
    }
  }
  else {
    var textKeys = []
    if (vars.text.value) textKeys.push(vars.text.value)
    textKeys.push(key)
  }

  if ( !(textKeys instanceof Array) ) {
    textKeys = [ textKeys ]
  }

  var names = []

  if (d3plus.object.validate(obj) && "d3plus" in obj && obj.d3plus.text) {
    names.push(obj.d3plus.text)
  }
  else {

    var ids = obj[key]

    if (!(ids instanceof Array)) ids = [ids]

    textKeys.forEach(function( t ){

      var name = []
      ids.forEach(function(i){
        name.push(fetchValue(vars,i,t,key))
      })

      if ( name ) {
        if ( !(name instanceof Array) ) {
          name = vars.format.value(name.toString(),t)
        }
        else {
          name.forEach(function(n){
            if (n) n = vars.format.value(n.toString(),t)
          })
        }
        names.push(name)
      }

    })

  }

  return names

}
<|endoftext|>


<commit_before>define(function() {
    /**
     * @factory
     */
    var AudioElement = function AudioElement(config) {
        config = config || {};

        // TODO: bring in extend() and a read-only defaults JSON
        // config should be a mixin to the defaults.

        function play () {

        }

        return (new function() {
            var sources = config.sources;
            if (typeof sources === "string") sources = [sources];
            var MAX_SOURCES = sources.length;
            var audio = new Audio();
            var source  = null;

            for (var i=0; i<MAX_SOURCES; i++) {
                source = document.createElement("source");
                source.setAttribute("src", sources[i]);
                audio.appendChild(source);
            }

            this.audio = element;
        });
    };

    return AudioElement;
});
<commit_msg>initialize with render<commit_after>define(function() {
    /**
     * @factory
     */
    var AudioElement = function AudioElement(config) {
        config = config || {};

        // TODO: bring in extend() and a read-only defaults JSON
        // config should be a mixin to the defaults.

        function play () {

        }

        function render () {
            var audioContainer = document.createElement("div");
            var playButton = new (function (){
                var circle, triangle, overlay, _play;
                _play    = document.createElement("div");
                circle   = document.createElement("div");
                triangle = document.createElement("div");
                overlay  = document.createElement("div");
                circle.setAttribute("class", "play-button-bg");
                triangle.setAttribute("class", "play-button-triangle");
                overlay.setAttribute("class", "play-button-overlay");
                _play.appendChild(circle);
                _play.appendChild(triangle);
                _play.appendChild(overlay);
                return _play;
            });
            this.playButton = playButton;

            audioContainer.appendChild(this.playButton);

            return audioContainer;
        }

        function parseFileTypes(type) {
            var types = ["mp3", "ogg", "wav"];
            switch(type) {
                case "all":
                    return types;
                default:
                    return types;
            }
        }

        return (new function() {
            var sources;
            if (typeof config.source === "string")  sources = [config.source];
            if (typeof config.sources === "string") sources = [config.sources];
            var MAX_SOURCES = sources.length;
            var audio       = new Audio();
            var source      = null;
            var fileTypes   = config.fileTypes;
            var i,j,buff;
            fileTypes = parseFileTypes(config.fileTypes);

            for (i=0; i<MAX_SOURCES; i++) {
                // handle all or spefific file type extensions.
                if (fileTypes === undefined) {
                    source = document.createElement("source");
                    source.setAttribute("src", sources[i]);
                }
                else {
                    buff=fileTypes.length;
                    for (j=0; j<buff; j++) {
                        source = document.createElement("source");
                        source.setAttribute("src", sources[i]+"."+fileTypes[j]);
                        audio.appendChild(source);
                    }
                }
            }

            this.audio = audio;
            this.render = render;
        });
    };

    return AudioElement;
});
<|endoftext|>


<commit_before>class MediaInfo {

    constructor() {
        this.mimeType = null;
        this.duration = null;

        this.hasAudio = null;
        this.hasVideo = null;
        this.audioCodec = null;
        this.videoCodec = null;
        this.audioBitrate = null;
        this.videoBitrate = null;

        this.audioSampleRate = null;
        this.audioChannelCount = null;

        this.width = null;
        this.height = null;
        this.fps = null;
        this.profile = null;
        this.chromaFormat = null;
        this.sarNum = null;
        this.sarDen = null;

        this.metadata = null;
        this.keyframesIndex = null;
    }

    isComplete() {
        let audioInfoComplete = (this.hasAudio === false) ||
                                (this.hasAudio === true &&
                                 this.audioCodec != null &&
                                 this.audioBitrate != null &&
                                 this.audioSampleRate != null &&
                                 this.audioChannelCount != null);

        let videoInfoComplete = (this.hasVideo === false) ||
                                (this.hasVideo === true &&
                                 this.videoCodec != null &&
                                 this.videoBitrate != null &&
                                 this.width != null &&
                                 this.height != null &&
                                 this.fps != null &&
                                 this.profile != null &&
                                 this.chromaFormat != null &&
                                 this.sarNum != null &&
                                 this.sarDen != null);

        // keyframesIndex may not be present
        return this.mimeType != null &&
               this.duration != null &&
               this.metadata != null &&
               audioInfoComplete &&
               videoInfoComplete;
    }

    isSeekable() {
        return (this.keyframesIndex != null);
    }

    getNearestKeyframePosition(milliseconds) {
        if (this.keyframesIndex == null) {
            return null;
        }

        let keyframeIdx = 0;

        // binary search
        let list = this.keyframesIndex.times;
        let last = list.length - 1;
        let mid = 0;
        let lbound = 0;
        let ubound = last;

        if (milliseconds < list[0]) {
            keyframeIdx = 0;
            lbound = ubound + 1;  // skip search
        }

        while (lbound <= ubound) {
            mid = lbound + Math.floor((ubound - lbound) / 2);
            if (mid === last || (milliseconds >= list[mid] && milliseconds < list[mid + 1])) {
                keyframeIdx = mid;
                break;
            } else if (list[mid] < milliseconds) {
                lbound = mid + 1;
            } else {
                ubound = mid - 1;
            }
        }

        let table = this.keyframesIndex;

        return {
            milliseconds: table.times[keyframeIdx],
            fileposition: table.filepositions[keyframeIdx]
        };
    }

}

export default MediaInfo;<commit_msg>MediaInfo: audioBitrate/videoBitrate may not be present<commit_after>class MediaInfo {

    constructor() {
        this.mimeType = null;
        this.duration = null;

        this.hasAudio = null;
        this.hasVideo = null;
        this.audioCodec = null;
        this.videoCodec = null;
        this.audioBitrate = null;
        this.videoBitrate = null;

        this.audioSampleRate = null;
        this.audioChannelCount = null;

        this.width = null;
        this.height = null;
        this.fps = null;
        this.profile = null;
        this.chromaFormat = null;
        this.sarNum = null;
        this.sarDen = null;

        this.metadata = null;
        this.keyframesIndex = null;
    }

    isComplete() {
        let audioInfoComplete = (this.hasAudio === false) ||
                                (this.hasAudio === true &&
                                 this.audioCodec != null &&
                                 this.audioSampleRate != null &&
                                 this.audioChannelCount != null);

        let videoInfoComplete = (this.hasVideo === false) ||
                                (this.hasVideo === true &&
                                 this.videoCodec != null &&
                                 this.width != null &&
                                 this.height != null &&
                                 this.fps != null &&
                                 this.profile != null &&
                                 this.chromaFormat != null &&
                                 this.sarNum != null &&
                                 this.sarDen != null);

        // keyframesIndex may not be present
        return this.mimeType != null &&
               this.duration != null &&
               this.metadata != null &&
               audioInfoComplete &&
               videoInfoComplete;
    }

    isSeekable() {
        return (this.keyframesIndex != null);
    }

    getNearestKeyframePosition(milliseconds) {
        if (this.keyframesIndex == null) {
            return null;
        }

        let keyframeIdx = 0;

        // binary search
        let list = this.keyframesIndex.times;
        let last = list.length - 1;
        let mid = 0;
        let lbound = 0;
        let ubound = last;

        if (milliseconds < list[0]) {
            keyframeIdx = 0;
            lbound = ubound + 1;  // skip search
        }

        while (lbound <= ubound) {
            mid = lbound + Math.floor((ubound - lbound) / 2);
            if (mid === last || (milliseconds >= list[mid] && milliseconds < list[mid + 1])) {
                keyframeIdx = mid;
                break;
            } else if (list[mid] < milliseconds) {
                lbound = mid + 1;
            } else {
                ubound = mid - 1;
            }
        }

        let table = this.keyframesIndex;

        return {
            milliseconds: table.times[keyframeIdx],
            fileposition: table.filepositions[keyframeIdx]
        };
    }

}

export default MediaInfo;<|endoftext|>


<commit_before>/* File GenericRelatedObjectLookups.js
 * Adds to the any of input.target_id special button, which opens a window with a list of object (kind of an object defined in the corresponding select.target_ct)
 * Author: Maxim Izmaylov (izmaylov.maxim@netcentrum.cz)
 * Copyright: NetCentrum @2007
 * Requirements: jquery.js
 */

$(function(){
	var selects = $('select.target_ct');
	var targets = $('input.target_id');
	for(var x = 0; x < selects.length; x++){
		var nLt = document.getElementById('lookup_' + targets[x].id) || false;
		if(!nLt){
			var newLoupe = document.createElement('img');
			newLoupe.src = adminmediapath + 'img/admin/selector-search.gif';
			newLoupe.style.cssText = 'cursor: pointer;';
			newLoupe.id = 'lookup_' + targets[x].id;
			newLoupe.alt = x;
		} else {
			newLoupe = nLt;
		}
		targets[x].parentNode.appendChild(document.createTextNode(' '));
		targets[x].parentNode.appendChild(newLoupe);
		$('#lookup_' + targets[x].id).click(function(){
			var num = this.alt;
			if(this.className == 'new'){
				selects = $('select.target_ct');
			}
			var objectList = function(id){
				var name = id.replace(/^lookup_/, '').replace(/\./g, '___');
				var path = adminapps[selects[num].value].path.replace('.', '/');
				var prefix = typeof(admin_url) != "undefined" ? admin_url : '../../..';
				var addr = prefix + '/' + path + '/?pop=1';
				var win = window.open(addr, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
				win.focus();
			}
			if(selects[num].selectedIndex > 0){
				objectList(this.id);
			} else {
				try {
					$('#' + this.id.replace(/^lookup_/, '').replace(/\./g, '___').replace('_id', '_ct')).val(defaultId);
					objectList(this.id);
				} catch(e){
					alert('Choose "Target ct"');
				}
			}
		});
	}
});
<commit_msg>fixes addressing problem, refs #1167<commit_after>/* File GenericRelatedObjectLookups.js
 * Adds to the any of input.target_id special button, which opens a window with a list of object (kind of an object defined in the corresponding select.target_ct)
 * Author: Maxim Izmaylov (izmaylov.maxim@netcentrum.cz)
 * Copyright: NetCentrum @2007
 * Requirements: jquery.js
 */

$(function(){
	var selects = $('select.target_ct');
	var targets = $('input.target_id');
	for(var x = 0; x < selects.length; x++){
		var nLt = document.getElementById('lookup_' + targets[x].id) || false;
		if(!nLt){
			var newLoupe = document.createElement('img');
			newLoupe.src = adminmediapath + 'img/admin/selector-search.gif';
			newLoupe.style.cssText = 'cursor: pointer;';
			newLoupe.id = 'lookup_' + targets[x].id;
			newLoupe.alt = x;
		} else {
			newLoupe = nLt;
		}
		targets[x].parentNode.appendChild(document.createTextNode(' '));
		targets[x].parentNode.appendChild(newLoupe);
		$('#lookup_' + targets[x].id).click(function(){
			var num = this.alt;
			if(this.className == 'new'){
				selects = $('select.target_ct');
			}
			var objectList = function(id){
				var name = id.replace(/^lookup_/, '').replace(/\./g, '___');
				var path = adminapps[selects[num].value].path.replace('.', '/');
				var prefix = typeof(admin_url) != "undefined" ? admin_url : '../../../';
				var addr = prefix + path + '/?pop=1';
				var win = window.open(addr, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
				win.focus();
			}
			if(selects[num].selectedIndex > 0){
				objectList(this.id);
			} else {
				try {
					$('#' + this.id.replace(/^lookup_/, '').replace(/\./g, '___').replace('_id', '_ct')).val(defaultId);
					objectList(this.id);
				} catch(e){
					alert('Choose "Target ct"');
				}
			}
		});
	}
});
<|endoftext|>