<commit_before>/**************************************************
** GAME VARIABLES
**************************************************/
var canvas,			// Canvas DOM element
	ctx,			// Canvas rendering context
	keys,			// Keyboard input
	devOris,		//Device Orientation
	localPlayer,	// Local player
	remotePlayers,	// Remote players
	socket;			// Socket connection
var startColor = randomColor();

var ball   = document.querySelector('.ball');
var garden = document.querySelector('.garden');
var output = document.querySelector('.output');
var button = document.getElementById('bb');

var maxX = garden.clientWidth  - ball.clientWidth;
var maxY = garden.clientHeight - ball.clientHeight;

var serverURL = "http://demo.redline-china.com";
// var serverURL = "http://localhost";
/**************************************************
** GAME INITIALISATION
**************************************************/
function init() {

	// Declare the canvas and rendering context

	// Maximise the canvas
	var canvasWidth = 1024;
	var canvasHeight = 768;

	// Initialise keyboard controls
	// keys = new Keys();

	devOris = new DevOris();

	// Calculate a random start position for the local player
	// The minus 5 (half a player size) stops the player being
	// placed right on the egde of the screen
	var startX = Math.round(Math.random()*(canvasWidth-3-5)),
		startY = Math.round(Math.random()*(canvasHeight-3-5));

	// Initialise the local player

	localPlayer = new Player(startX, startY, startColor);

	// Initialise socket connection
	socket = io.connect(serverURL, {port: 8000, transports: ["websocket"]});

	// Initialise remote players array
	remotePlayers = [];

	// Start listening for events
	setEventHandlers();

	button.addEventListener("touchstart", changeColor);
	button.addEventListener("click", changeColor);

};

function changeColor(e) {
	startColor = randomColor();
	console.log('change color' + startColor);
	localPlayer.setColor(startColor);
	socket.emit("change color player", {color: localPlayer.getColor});

}

function handleOrientation(event) {
	var x = event.beta;  // In degree in the range [-180,180]
	var y = event.gamma; // In degree in the range [-90,90]

	output.innerHTML  = "beta : " + x + "\n";
	output.innerHTML += "gamma: " + y + "\n";

	// Because we don't want to have the device upside down
	// We constrain the x value to the range [-90,90]
	if (x >  90) { x =  90};
	if (x < -90) { x = -90};
	if (y >  90) { y =  90};
	if (y < -90) { y = -90};
	// To make computation easier we shift the range of
	// x and y to [0,180]
	x += 90;
	y += 90;

	// To make computation easier we shift the range of
	// x and y to [0,180]
	// x += 90;
	// y += 90;

	// 10 is half the size of the ball
	// It center the positioning point to the center of the ball
	ball.style.top  = (maxX*x/180 - 10) + "px";
	ball.style.left = (maxY*y/180 - 10) + "px";
	ball.style.background = startColor;

}

/**************************************************
** GAME EVENT HANDLERS
**************************************************/
var setEventHandlers = function() {

	// Device Orientation
	window.addEventListener("deviceorientation", onMove, false);

	// Socket connection successful
	socket.on("connect", onSocketConnected);

	// Socket disconnection
	socket.on("disconnect", onSocketDisconnect);

};

function onMove(e) {
	handleOrientation(e);

	if(localPlayer) {
		devOris.onMove(e);
	}

}

// Socket connected
function onSocketConnected() {
	console.log("Connected to socket server");

	// Send local player data to the game server
	socket.emit("new player", {x: localPlayer.getX(), y: localPlayer.getY(), color:localPlayer.getColor()});
};

// Socket disconnected
function onSocketDisconnect() {
	console.log("Disconnected from socket server");
};

/**************************************************
** GAME ANIMATION LOOP
**************************************************/
function animate() {
	update();
	draw();

	// Request a new animation frame using Paul Irish's shim
	window.requestAnimFrame(animate);
};

/**************************************************
** GAME UPDATE
**************************************************/
function update() {
	// Update local player and check for change
	// if (localPlayer.update(keys)) {
	// 	// Send local player data to the game server
	// 	socket.emit("move player", {x: localPlayer.getX(), y: localPlayer.getY()});
	// };

	if (localPlayer.updateMove(devOris)) {

		socket.emit("move player", {x: localPlayer.getX(), y: localPlayer.getY()});
	};

};

/**************************************************
** GAME DRAW
**************************************************/
function draw() {
	ball.style.background = startColor;
};

/**************************************************
** GAME HELPER FUNCTIONS
**************************************************/

function randomNum(max,min){
  return Math.floor(Math.random()*(max-min+1)+min)
}
function randomColor(){
  var color="#";
  var colorArr=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];
  for(i=0;i<6;i++){
      var cur=randomNum(15,0);
      color+=colorArr[cur];
  }
  function randomNum(max,min){
      return Math.floor(Math.random()*(max-min+1)+min)
  }
  return color;
}<commit_msg>try to add change color button<commit_after>/**************************************************
** GAME VARIABLES
**************************************************/
var canvas,			// Canvas DOM element
	ctx,			// Canvas rendering context
	keys,			// Keyboard input
	devOris,		//Device Orientation
	localPlayer,	// Local player
	remotePlayers,	// Remote players
	socket;			// Socket connection
var startColor = randomColor();

var ball   = document.querySelector('.ball');
var garden = document.querySelector('.garden');
var output = document.querySelector('.output');
var button = document.getElementById('bb');

var maxX = garden.clientWidth  - ball.clientWidth;
var maxY = garden.clientHeight - ball.clientHeight;

var serverURL = "http://demo.redline-china.com";
// var serverURL = "http://localhost";
/**************************************************
** GAME INITIALISATION
**************************************************/
function init() {

	// Declare the canvas and rendering context

	// Maximise the canvas
	var canvasWidth = 1024;
	var canvasHeight = 768;

	// Initialise keyboard controls
	// keys = new Keys();

	devOris = new DevOris();

	// Calculate a random start position for the local player
	// The minus 5 (half a player size) stops the player being
	// placed right on the egde of the screen
	var startX = Math.round(Math.random()*(canvasWidth-3-5)),
		startY = Math.round(Math.random()*(canvasHeight-3-5));

	// Initialise the local player

	localPlayer = new Player(startX, startY, startColor);

	// Initialise socket connection
	socket = io.connect(serverURL, {port: 8000, transports: ["websocket"]});

	// Initialise remote players array
	remotePlayers = [];

	// Start listening for events
	setEventHandlers();

	button.addEventListener("touchstart", changeColor);
	button.addEventListener("click", changeColor);

};

function changeColor(e) {
	startColor = randomColor();
	console.log('change color' + startColor);
	localPlayer.setColor(startColor);
	socket.emit("change color player", {color: localPlayer.getColor()});
	console.log('emit color'+localPlayer.getColor());

}

function handleOrientation(event) {
	var x = event.beta;  // In degree in the range [-180,180]
	var y = event.gamma; // In degree in the range [-90,90]

	output.innerHTML  = "beta : " + x + "\n";
	output.innerHTML += "gamma: " + y + "\n";

	// Because we don't want to have the device upside down
	// We constrain the x value to the range [-90,90]
	if (x >  90) { x =  90};
	if (x < -90) { x = -90};
	if (y >  90) { y =  90};
	if (y < -90) { y = -90};
	// To make computation easier we shift the range of
	// x and y to [0,180]
	x += 90;
	y += 90;

	// To make computation easier we shift the range of
	// x and y to [0,180]
	// x += 90;
	// y += 90;

	// 10 is half the size of the ball
	// It center the positioning point to the center of the ball
	ball.style.top  = (maxX*x/180 - 10) + "px";
	ball.style.left = (maxY*y/180 - 10) + "px";
	ball.style.background = startColor;

}

/**************************************************
** GAME EVENT HANDLERS
**************************************************/
var setEventHandlers = function() {

	// Device Orientation
	window.addEventListener("deviceorientation", onMove, false);

	// Socket connection successful
	socket.on("connect", onSocketConnected);

	// Socket disconnection
	socket.on("disconnect", onSocketDisconnect);

};

function onMove(e) {
	handleOrientation(e);

	if(localPlayer) {
		devOris.onMove(e);
	}

}

// Socket connected
function onSocketConnected() {
	console.log("Connected to socket server");

	// Send local player data to the game server
	socket.emit("new player", {x: localPlayer.getX(), y: localPlayer.getY(), color:localPlayer.getColor()});
};

// Socket disconnected
function onSocketDisconnect() {
	console.log("Disconnected from socket server");
};

/**************************************************
** GAME ANIMATION LOOP
**************************************************/
function animate() {
	update();
	draw();

	// Request a new animation frame using Paul Irish's shim
	window.requestAnimFrame(animate);
};

/**************************************************
** GAME UPDATE
**************************************************/
function update() {
	// Update local player and check for change
	// if (localPlayer.update(keys)) {
	// 	// Send local player data to the game server
	// 	socket.emit("move player", {x: localPlayer.getX(), y: localPlayer.getY()});
	// };

	if (localPlayer.updateMove(devOris)) {

		socket.emit("move player", {x: localPlayer.getX(), y: localPlayer.getY()});
	};

};

/**************************************************
** GAME DRAW
**************************************************/
function draw() {
	ball.style.background = startColor;
};

/**************************************************
** GAME HELPER FUNCTIONS
**************************************************/

function randomNum(max,min){
  return Math.floor(Math.random()*(max-min+1)+min)
}
function randomColor(){
  var color="#";
  var colorArr=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];
  for(i=0;i<6;i++){
      var cur=randomNum(15,0);
      color+=colorArr[cur];
  }
  function randomNum(max,min){
      return Math.floor(Math.random()*(max-min+1)+min)
  }
  return color;
}<|endoftext|>


<commit_before>import { Q, path, fs, config, log, defer, async } from 'azk';
import { net } from 'azk/utils';
var forever = require('forever-monitor');

// TODO: Reaplce forever for a better solution :/
var Balancer = {
  memcached: null,
  hipache  : null,

  start() {
    var self = this;
    return async(function* () {
      if (!self.isRunnig()) {
        var socket = config('paths:memcached_socket');
        yield self.start_memcached(socket);
        yield self.start_hipache(socket);
      }
    });
  },

  start_hipache(socket) {
    var port = config('agent:port');
    var pid  = config("paths:hipache_pid");
    var file = this._check_config(port, socket);
    var cmd = [ 'nvm', 'hipache', '--config', file ];

    log.info("starting hipache");
    return this._start_service(cmd, pid).then((child) => {
      this.hipache = child;
      log.info("hipache started in %s port with file config", port, file);
      child.on('stop', () => {
        log.info('hipache stoped');
      });
      child.on('exit:code', (code) => {
        if (code && code != 0) {
          log.error('hipache exit code: ' + code);
        }
      });
      child.on('stdout', (data) => {
        log.info('hipache: %s', data.toString().trim());
      });
      child.on('stderr', (data) => {
        log.info('hipache: %s', data.toString().trim());
      });
    });
  },

  start_memcached(socket) {
    var pid = config("paths:memcached_pid");
    var cmd = [ 'nvm', 'memcachedjs', '--socket', socket ];

    log.info("starting memcachedjs");
    return this._start_service(cmd, pid).then((child) => {
      this.memcached = child;
      log.info("memcachedjs started in socket: ", socket);
      child.on('stop', () => {
        log.info('memcached stoped');
      });
      child.on('exit:code', (code) => {
        if (code && code != 0) {
          log.error('memcached exit code: ' + code);
        }
      });
      child.on('stdout', (data) => {
        log.info('memcached: %s', data.toString().trim());
      });
      child.on('stderr', (data) => {
        log.info('memcached: %s', data.toString().trim());
      });
    });
  },

  stop() {
    var self = this;
    if (this.isRunnig()) {
      log.debug("call to stop balancer");
      return async(function* () {
        yield defer((resolve) => {
          if (self.hipache.running) {
            self.hipache.on('stop', resolve);
            process.kill(self.hipache.pid);
          } else {
            resolve();
          }
        });
        yield defer((resolve) => {
          if (self.memcached.running) {
            self.memcached.on('stop', resolve);
            process.kill(self.memcached.pid);
          } else {
            resolve();
          }
        });
      });
    } else {
      return Q();
    }
  },

  isRunnig() {
    return (this.hipache && this.hipache.running);
  },

  _start_service(cmd, pid) {
    cmd = [path.join(config('paths:azk_root'), 'bin', 'azk'), ...cmd];
    return defer((resolve, reject, notify) => {
      var child = forever.start(cmd, {
        max : 1,
        silent : true,
        pidFile: pid
      });

      child.on('exit:code', () => {
        reject();
        process.kill(process.pid);
      });
      child.on('start', () => resolve(child));
    });
  },

  _check_config(port, memcached_socket) {
    var file   = config('paths:balancer_file');

    var data = {
      server: {
        accessLog: "./data/logs/hipache_access.log",
        workers: 3,
        maxSockets: 100,
        deadBackendTTL: 30
      },
      http: {
        port: port,
        address: ["127.0.0.1", "::1"]
      },
      driver: ["memcached://" + memcached_socket]
    }

    // set content
    fs.writeFileSync(file, JSON.stringify(data, null, '  '));
    return file;
  }
}

export { Balancer }

<commit_msg>Adding methods to manipulate backends in the balancer.<commit_after>import { _, Q, path, fs, config, log, defer, async } from 'azk';
import { net } from 'azk/utils';
var forever = require('forever-monitor');

var MemcachedDriver = require('memcached');

// TODO: Reaplce forever for a better solution :/
var Balancer = {
  memcached: null,
  hipache  : null,
  mem_client : null,

  get memCached() {
    if (!this.mem_client) {
      var socket = config('paths:memcached_socket');
      this.mem_client = new MemcachedDriver(socket);
    }
    return this.mem_client;
  },

  getBackends(host) {
    var key = 'frontend:' + host;
    return Q.ninvoke(this.memCached, 'get', key).then((entries) => {
      return entries ? entries : [host];
    });
  },

  addBackend(hosts, backend) {
    var self = this;
    return async(function* () {
      for(var host of (_.isArray(hosts) ? hosts : [hosts])) {
        var key = 'frontend:' + host
        var entries = yield self.getBackends(host);
        entries = self._removeEntry(entries, backend);
        entries.push(backend);
        yield Q.ninvoke(self.memCached, 'set', key, entries, 0);
      }
    });
  },

  removeBackend(hosts, backend) {
    var self = this;
    return async(function* () {
      for(var host of (_.isArray(hosts) ? hosts : [hosts])) {
        var key = 'frontend:' + host;
        var entries = yield self.getBackends(host);
        entries = self._removeEntry(entries, backend);
        yield Q.ninvoke(self.memCached, 'set', key, entries, 0);
      }
    });
  },

  _removeEntry(entries, backend) {
    return _.filter(entries, (entry) => { return entry != backend });
  },

  start() {
    var self = this;
    return async(function* () {
      if (!self.isRunnig()) {
        var socket = config('paths:memcached_socket');
        yield self.start_memcached(socket);
        yield self.start_hipache(socket);
      }
    });
  },

  start_hipache(socket) {
    var port = config('agent:port');
    var pid  = config("paths:hipache_pid");
    var file = this._check_config(port, socket);
    var cmd = [ 'nvm', 'hipache', '--config', file ];

    log.info("starting hipache");
    return this._start_service(cmd, pid).then((child) => {
      this.hipache = child;
      log.info("hipache started in %s port with file config", port, file);
      child.on('stop', () => {
        log.info('hipache stoped');
      });
      child.on('exit:code', (code) => {
        if (code && code != 0) {
          log.error('hipache exit code: ' + code);
        }
      });
      child.on('stdout', (data) => {
        log.info('hipache: %s', data.toString().trim());
      });
      child.on('stderr', (data) => {
        log.info('hipache: %s', data.toString().trim());
      });
    });
  },

  start_memcached(socket) {
    var pid = config("paths:memcached_pid");
    var cmd = [ 'nvm', 'memcachedjs', '--socket', socket ];

    log.info("starting memcachedjs");
    return this._start_service(cmd, pid).then((child) => {
      this.memcached = child;
      log.info("memcachedjs started in socket: ", socket);
      child.on('stop', () => {
        log.info('memcached stoped');
      });
      child.on('exit:code', (code) => {
        if (code && code != 0) {
          log.error('memcached exit code: ' + code);
        }
      });
      child.on('stdout', (data) => {
        log.info('memcached: %s', data.toString().trim());
      });
      child.on('stderr', (data) => {
        log.info('memcached: %s', data.toString().trim());
      });
    });
  },

  stop() {
    var self = this;
    if (this.isRunnig()) {
      log.debug("call to stop balancer");
      return async(function* () {
        yield defer((resolve) => {
          if (self.hipache.running) {
            self.hipache.on('stop', resolve);
            process.kill(self.hipache.pid);
          } else {
            resolve();
          }
        });
        yield defer((resolve) => {
          if (self.memcached.running) {
            self.memcached.on('stop', resolve);
            process.kill(self.memcached.pid);
          } else {
            resolve();
          }
        });
      });
    } else {
      return Q();
    }
  },

  isRunnig() {
    return (this.hipache && this.hipache.running);
  },

  _start_service(cmd, pid) {
    cmd = [path.join(config('paths:azk_root'), 'bin', 'azk'), ...cmd];
    return defer((resolve, reject, notify) => {
      var child = forever.start(cmd, {
        max : 1,
        silent : true,
        pidFile: pid
      });

      child.on('exit:code', () => {
        reject();
        process.kill(process.pid);
      });
      child.on('start', () => resolve(child));
    });
  },

  _check_config(port, memcached_socket) {
    var file   = config('paths:balancer_file');

    var data = {
      server: {
        accessLog: "./data/logs/hipache_access.log",
        workers: 3,
        maxSockets: 100,
        deadBackendTTL: 30
      },
      http: {
        port: port,
        address: ["127.0.0.1", "::1"]
      },
      driver: ["memcached://" + memcached_socket]
    }

    // set content
    fs.writeFileSync(file, JSON.stringify(data, null, '  '));
    return file;
  }
}

export { Balancer }

<|endoftext|>


<commit_before>const {app, ipcMain, Menu, shell} = require('electron');

let appMenu = {
	label: app.getName(),
	submenu: [
		{
			role: 'about'
		},
		{
			type: 'separator'
		},
		{
			role: 'services',
			submenu: []
		},
		{
			type: 'separator'
		},
		{
			role: 'hide'
		},
		{
			role: 'hideothers'
		},
		{
			role: 'unhide'
		},
		{
			type: 'separator'
		},
		{
			role: 'quit'
		}
	]
};

let fileMenu = {
	label: 'File',
	submenu: [
		{
			role: 'close'
		}
	]
};

let editMenu = {
	label: 'Edit',
	submenu: [
		{
			role: 'undo'
		},
		{
			role: 'redo'
		},
		{
			type: 'separator'
		},
		{
			role: 'cut'
		},
		{
			role: 'copy'
		},
		{
			role: 'paste'
		},
		{
			role: 'delete'
		},
		{
			role: 'selectall'
		},
		{
			type: 'separator'
		},
		{
			label: 'Speech',
			submenu: [
				{
					role: 'startspeaking'
				},
				{
					role: 'stopspeaking'
				}
			]
		}
	]
};

let viewMenu = {
	label: 'View',
	submenu: [
		{
			role: 'reload'
		},
		{
			role: 'toggledevtools'
		},
		{
			type: 'separator'
		},
		{
			role: 'togglefullscreen'
		}
	]
};

let historyMenu = {
	label: 'History',
	submenu: [
		{
			label: 'Back',
			accelerator: 'Cmd+Left',
			enabled: false,
			click(menuItem, browserWindow, event) {
				browserWindow.webContents.send('navigate.goToOffset', -1);
			}
		},
		{
			label: 'Forward',
			accelerator: 'Cmd+Right',
			enabled: false,
			click(menuItem, browserWindow, event) {
				browserWindow.webContents.send('navigate.goToOffset', 1);
			}
		},
		{
			label: 'Home',
			accelerator: 'Cmd+Shift+H',
			enabled: false,
			click(menuItem, browserWindow, event) {
				browserWindow.webContents.send('navigate.goToURL', {
					url: 'http://devdocs.io/'
				});
			}
		}
	]
};

let windowMenu = {
	role: 'window',
	submenu: [
		{
			role: 'minimize'
		}
	]
};

module.exports = class MainMenu {
	constructor() {
		this.addSubscriptions().build();
	}

	addSubscriptions() {
		ipcMain.on('navigate.update', (event, data) => {
			historyMenu.submenu[0].enabled = data.canGoBack;
			historyMenu.submenu[1].enabled = data.canGoForward;
			historyMenu.submenu[2].enabled = data.canGoHome;

			this.build();
		});

		return this;
	}

	build() {
		Menu.setApplicationMenu(Menu.buildFromTemplate(this.template));

		return this;
	}

	get template() {
		return [appMenu, fileMenu, editMenu, viewMenu, historyMenu, windowMenu];
	}
};
<commit_msg>Add Help menu.<commit_after>const {app, ipcMain, Menu, shell} = require('electron');

const pkg = require('../../package.json');

let appMenu = {
	label: app.getName(),
	submenu: [
		{
			role: 'about'
		},
		{
			type: 'separator'
		},
		{
			role: 'services',
			submenu: []
		},
		{
			type: 'separator'
		},
		{
			role: 'hide'
		},
		{
			role: 'hideothers'
		},
		{
			role: 'unhide'
		},
		{
			type: 'separator'
		},
		{
			role: 'quit'
		}
	]
};

let fileMenu = {
	label: 'File',
	submenu: [
		{
			role: 'close'
		}
	]
};

let editMenu = {
	label: 'Edit',
	submenu: [
		{
			role: 'undo'
		},
		{
			role: 'redo'
		},
		{
			type: 'separator'
		},
		{
			role: 'cut'
		},
		{
			role: 'copy'
		},
		{
			role: 'paste'
		},
		{
			role: 'delete'
		},
		{
			role: 'selectall'
		},
		{
			type: 'separator'
		},
		{
			label: 'Speech',
			submenu: [
				{
					role: 'startspeaking'
				},
				{
					role: 'stopspeaking'
				}
			]
		}
	]
};

let viewMenu = {
	label: 'View',
	submenu: [
		{
			role: 'reload'
		},
		{
			role: 'toggledevtools'
		},
		{
			type: 'separator'
		},
		{
			role: 'togglefullscreen'
		}
	]
};

let historyMenu = {
	label: 'History',
	submenu: [
		{
			label: 'Back',
			accelerator: 'Cmd+Left',
			enabled: false,
			click(menuItem, browserWindow, event) {
				browserWindow.webContents.send('navigate.goToOffset', -1);
			}
		},
		{
			label: 'Forward',
			accelerator: 'Cmd+Right',
			enabled: false,
			click(menuItem, browserWindow, event) {
				browserWindow.webContents.send('navigate.goToOffset', 1);
			}
		},
		{
			label: 'Home',
			accelerator: 'Cmd+Shift+H',
			enabled: false,
			click(menuItem, browserWindow, event) {
				browserWindow.webContents.send('navigate.goToURL', {
					url: 'http://devdocs.io/'
				});
			}
		}
	]
};

let windowMenu = {
	role: 'window',
	submenu: [
		{
			role: 'minimize'
		}
	]
};

let helpMenu = {
	role: 'help',
	submenu: [
		{
			label: 'Report an Issue',
			click() {
				shell.openExternal(pkg.bugs.url);
			}
		},
		{
			label: 'View Project on GitHub',
			click() {
				shell.openExternal(pkg.homepage);
			}
		}
	]
};

module.exports = class MainMenu {
	constructor() {
		this.addSubscriptions().build();
	}

	addSubscriptions() {
		ipcMain.on('navigate.update', (event, data) => {
			historyMenu.submenu[0].enabled = data.canGoBack;
			historyMenu.submenu[1].enabled = data.canGoForward;
			historyMenu.submenu[2].enabled = data.canGoHome;

			this.build();
		});

		return this;
	}

	build() {
		Menu.setApplicationMenu(Menu.buildFromTemplate(this.template));

		return this;
	}

	get template() {
		return [appMenu, fileMenu, editMenu, viewMenu, historyMenu, windowMenu, helpMenu];
	}
};
<|endoftext|>


<commit_before>module.exports = {
	init,
	getMenuItem
};
const electron = require('electron');
const {shell} = require('electron');
const {BrowserWindow} = require('electron');
const path = require('path');
const openAboutWindow = require('about-window').default;

const app = electron.app;
let win;
let menu;

function init() {
	menu = electron.Menu.buildFromTemplate(getMenuTemplate());
	electron.Menu.setApplicationMenu(menu);
	win = BrowserWindow.getAllWindows()[0];
}

function getMenuItem(label) {
	for (let i = 0; i < menu.items.length; i++) {
		const menuItem = menu.items[i].submenu.items.find(item => {
			return item.label === label;
		});
		if (menuItem) {
			return menuItem;
		}
	}
}

function getMenuTemplate() {
	const template = [
		{
			label: 'File',
			submenu: [
				{
					label: 'Homepage',
					click: () => {
						win.loadURL(`file://${__dirname}/../index.html`);
					}
				},
				{
					label: 'Downloader',
					click: () => {
						win.loadURL(`file://${__dirname}/../downloader.html`);
					}
				},
				{
					label: 'Viewer',
					click: () => {
						win.loadURL(`file://${__dirname}/../viewer.html`);
					}
				},
				{
					label: 'Streamer',
					click: () => {
						win.loadURL(`file://${__dirname}/../streamer.html`);
					}
				}
			]
		},
		{
			label: 'Edit',
			submenu: [
				{
					role: 'cut'
				},
				{
					role: 'copy'
				},
				{
					role: 'paste'
				}
			]
		},
		{
			label: 'View',
			submenu: [
				{
					role: 'reload'
				},
				{
					role: 'forcereload'
				},
				{
					type: 'separator'
				},
				{
					type: 'separator'
				},
				{
					role: 'togglefullscreen'
				}
			]
		},
		{
			role: 'window',
			submenu: [
				{
					role: 'minimize'
				},
				{
					role: 'close'
				}
			]
		},
		{
			role: 'help',
			submenu: [
				{
					label: 'Tutorial',
					click() {
						win.loadURL(`file://${__dirname}/../onboard.html`);
					}

				},
				{
					label: 'Learn More about Electron',
					click() {
						shell.openExternal('http://electron.atom.io');
					}

				}, {
					label: 'About',
					click: () => openAboutWindow({
						icon_path: path.join(__dirname, '..', 'icon.png'), // eslint-disable-line camelcase
						bug_report_url: 'https://github.com/willyb321/media_mate/issues', // eslint-disable-line camelcase
						homepage: 'https://github.com/willyb321/media_mate'
					})
				}
			]
		}
	];

	if (process.platform === 'darwin') {
		template.unshift({
			label: app.getName(),
			submenu: [
				{
					role: 'about'
				},
				{
					type: 'separator'
				},
				{
					role: 'services',
					submenu: []
				},
				{
					type: 'separator'
				},
				{
					role: 'hide'
				},
				{
					role: 'hideothers'
				},
				{
					role: 'unhide'
				},
				{
					type: 'separator'
				},
				{
					role: 'quit'
				}
			]
		});
		// Edit menu.
		// Window menu.
		template[3].submenu = [
			{
				label: 'Close',
				accelerator: 'CmdOrCtrl+W',
				role: 'close'
			},
			{
				label: 'Minimize',
				accelerator: 'CmdOrCtrl+M',
				role: 'minimize'
			},
			{
				label: 'Zoom',
				role: 'zoom'
			},
			{
				type: 'separator'
			},
			{
				label: 'Bring All to Front',
				role: 'front'
			}
		];
	}
	return template;
}
<commit_msg>remove double separator<commit_after>module.exports = {
	init,
	getMenuItem
};
const electron = require('electron');
const {shell} = require('electron');
const {BrowserWindow} = require('electron');
const path = require('path');
const openAboutWindow = require('about-window').default;

const app = electron.app;
let win;
let menu;

function init() {
	menu = electron.Menu.buildFromTemplate(getMenuTemplate());
	electron.Menu.setApplicationMenu(menu);
	win = BrowserWindow.getAllWindows()[0];
}

function getMenuItem(label) {
	for (let i = 0; i < menu.items.length; i++) {
		const menuItem = menu.items[i].submenu.items.find(item => {
			return item.label === label;
		});
		if (menuItem) {
			return menuItem;
		}
	}
}

function getMenuTemplate() {
	const template = [
		{
			label: 'File',
			submenu: [
				{
					label: 'Homepage',
					click: () => {
						win.loadURL(`file://${__dirname}/../index.html`);
					}
				},
				{
					label: 'Downloader',
					click: () => {
						win.loadURL(`file://${__dirname}/../downloader.html`);
					}
				},
				{
					label: 'Viewer',
					click: () => {
						win.loadURL(`file://${__dirname}/../viewer.html`);
					}
				},
				{
					label: 'Streamer',
					click: () => {
						win.loadURL(`file://${__dirname}/../streamer.html`);
					}
				}
			]
		},
		{
			label: 'Edit',
			submenu: [
				{
					role: 'cut'
				},
				{
					role: 'copy'
				},
				{
					role: 'paste'
				}
			]
		},
		{
			label: 'View',
			submenu: [
				{
					role: 'reload'
				},
				{
					role: 'forcereload'
				},
				{
					type: 'separator'
				},
				{
					role: 'togglefullscreen'
				}
			]
		},
		{
			role: 'window',
			submenu: [
				{
					role: 'minimize'
				},
				{
					role: 'close'
				}
			]
		},
		{
			role: 'help',
			submenu: [
				{
					label: 'Tutorial',
					click() {
						win.loadURL(`file://${__dirname}/../onboard.html`);
					}

				},
				{
					label: 'Learn More about Electron',
					click() {
						shell.openExternal('http://electron.atom.io');
					}

				}, {
					label: 'About',
					click: () => openAboutWindow({
						icon_path: path.join(__dirname, '..', 'icon.png'), // eslint-disable-line camelcase
						bug_report_url: 'https://github.com/willyb321/media_mate/issues', // eslint-disable-line camelcase
						homepage: 'https://github.com/willyb321/media_mate'
					})
				}
			]
		}
	];

	if (process.platform === 'darwin') {
		template.unshift({
			label: app.getName(),
			submenu: [
				{
					role: 'about'
				},
				{
					type: 'separator'
				},
				{
					role: 'services',
					submenu: []
				},
				{
					type: 'separator'
				},
				{
					role: 'hide'
				},
				{
					role: 'hideothers'
				},
				{
					role: 'unhide'
				},
				{
					type: 'separator'
				},
				{
					role: 'quit'
				}
			]
		});
		// Edit menu.
		// Window menu.
		template[3].submenu = [
			{
				label: 'Close',
				accelerator: 'CmdOrCtrl+W',
				role: 'close'
			},
			{
				label: 'Minimize',
				accelerator: 'CmdOrCtrl+M',
				role: 'minimize'
			},
			{
				label: 'Zoom',
				role: 'zoom'
			},
			{
				type: 'separator'
			},
			{
				label: 'Bring All to Front',
				role: 'front'
			}
		];
	}
	return template;
}
<|endoftext|>


<commit_before>var modelBoxCoreFunction = function($http, modelsCategoriesService, smallImagesService, colorsService) {
	// available model box color
	var colors = colorsService.getAvailableColors();

	return {
		//require: 'ngModel',
		replace: true,
		scope: {
			model: '=ngModel',

			// callbacks (expressions)
			onDelete: '&?',
			onRelocate: '&?',
			onExclude: '&?',
			onInclude: '&?',
			onChoose: '&?',
			onUnChoose: '&?',
			onMakeAvailable: '&?',
			onMakeUnavailable: '&?'
		},
		link: function(scope, element, attributes) {
			scope.defaultImage = 'images/model_silhouette.png';

			// load the category name of the model
			scope.modelCategoryName = '';
			if (scope.model.category && parseInt(scope.model.category) > 0) {
				modelsCategoriesService.load(function(modelsCategories) {
					modelsCategories.forEach(function(modelCategory) {
						if (modelCategory.id == scope.model.category) {
							scope.modelCategoryName = modelCategory.name;
						}
					});
				});
			}

			// indication to display inputs for the notes
			scope.notesEditor = {
				public_notes: false,
				private_notes: false
			};

			scope.getModelTags = function() {
				return scope.model.tags ? scope.model.tags.split(/\s*\,\s*/) : [];
			};

			scope.getSmallImage = function(imageFile) {
				return smallImagesService.getSmall(imageFile);
			};

			scope.getMediumImage = function(imageFile) {
				return smallImagesService.getMedium(imageFile);
			};

			scope.galleryIsOpen = false;

			// set the initial main image
			scope.mainImage = scope.model.images[0] ?
				(scope.$root.IMAGES_BASE_URL + '/' + scope.model.images[0]) :
				scope.defaultImage;

			scope.setMainImage = function(imageNumber) {
				scope.mainImage = scope.$root.IMAGES_BASE_URL + '/' + scope.model.images[imageNumber];
			};

			scope.openGallery = function() {
				scope.galleryIsOpen = !scope.galleryIsOpen;
			};

			// check if "exclude" callback is defined
			scope.showExcludeButton = (typeof(scope.onExclude) == 'function');

			// check if "include" callback is defined
			scope.showIncludeButton = (typeof(scope.onInclude) == 'function');

			// check if "relocate" callback is defined
			scope.showRelocateButton = (typeof(scope.onRelocate) == 'function');

			// check if "delete" callback is defined
			scope.showDeleteButton = (typeof(scope.onDelete) == 'function');

			// check if "Choose" callback is defined
			scope.showChooseButton = (typeof(scope.onChoose) == 'function');

			// check if "UnChoose" callback is defined
			scope.showUnChooseButton = (typeof(scope.onUnChoose) == 'function');

			// check if "UnChoose" callback is defined
			scope.showMakeAvailableButton = (typeof(scope.onMakeAvailable) == 'function');

			// check if "UnChoose" callback is defined
			scope.showMakeUnavailableButton = (typeof(scope.onMakeUnavailable) == 'function');

			// show/hide the "choose color" boxes
			scope.colorPalette = {
				show: false
			};

			// get the color code (e.g. #A23B23) by color name (the list is on the top)
			scope.getColorNumber = colorsService.getColorNumber;

			/**
			 * Choose model's color
			 * @param string newColor
			 */
			scope.chooseModelColor = function(newColor) {
				// set the color locally
				scope.model.color = newColor || null;

				// call the API
				$http({
					method: 'post',
					url: 'api/update_model.php',
					data: {
						model_id: scope.model.id,
						color: newColor || ''
					}
				}).then(function(res) {
					if (res.data && res.data.result == 'ok') {
						return;
					}

					var errorString = res.data.error || 'Saving color failed';
					alert(errorString);
				}, function() {
					alert('Saving color failed');
				}).finally(function() {
					scope.colorPalette.show = false;
				});
			};

			scope.updateModelNote = function(type) {
				var data = {
					model_id: scope.model.id
				};

				if (type == 'public') {
					data['notes'] = scope.model.notes;
				} else {
					data['private_notes'] = scope.model.private_notes;
				}

				// call the API
				$http({
					method: 'post',
					url: 'api/update_model.php',
					data: data
				}).then(function(res) {
					if (res.data && res.data.result == 'ok') {
						// close the editor
						scope.notesEditor[(type == 'public' ? 'public_notes' : 'private_notes')] = false;

						return;
					}

					var errorString = res.data.error || 'Saving color failed';
					alert(errorString);
				}, function() {
					alert('Saving color failed');
				}).finally(function() {
					scope.colorPalette.show = false;
				});
			};

			/**
			 * move the model to the top/bottom of the list
			 * @param int modelId
			 * @param string newLocation - "top" / "bottom"
			 */
			scope.relocateModel = function(modelId, newLocation) {
				// call the API
				$http({
					method: 'post',
					url: 'api/relocate_model.php',
					data: {
						model_id: modelId,
						new_location: newLocation
					}
				}).then(function(res) {
					if (res.data && res.data.result == 'ok') {
						if (typeof(scope.onRelocate) == 'function') {
							scope.onRelocate();
							return;
						}
						return;
					}

					var errorString = res.data.error || 'Relocation failed';
					alert(errorString);
				}, function() {
					alert('Relocation failed - server error');
				});
			};

			/**
			 * delete the model
			 * @param int modelId
			 */
			scope.deleteModel = function(modelId) {
				if (!confirm('Delete the model?')) {
					return;
				}

				// call the API
				$http({
					method: 'post',
					url: 'api/delete_model.php',
					data: {
						model_id: modelId
					}
				}).then(function(res) {
					if (res.data && res.data.result == 'ok') {
						if (typeof(scope.onDelete) == 'function') {
							scope.onDelete();
							return;
						}
						return;
					}

					var errorString = res.data.error || 'Delete failed';
					alert(errorString);
				}, function() {
					alert('Delete failed - server error');
				});
			};

		},
		templateUrl: 'views/directives/model-box.html',
	}
};

webApp.directive('modelBox', ['$http', 'modelsCategoriesService', 'smallImagesService', 'colorsService',
	function($http, modelsCategoriesService, smallImagesService, colorsService) {
	return modelBoxCoreFunction($http, modelsCategoriesService, smallImagesService, colorsService);
}]);

webApp.directive('modelBoxSmall', ['$http', 'modelsCategoriesService', 'smallImagesService', 'colorsService',
	function($http, modelsCategoriesService, smallImagesService, colorsService) {
	var directiveObject = modelBoxCoreFunction($http, modelsCategoriesService, smallImagesService, colorsService);

	// replace the base template with the one for small box
	directiveObject.templateUrl = 'views/directives/model-box-small.html'

	return directiveObject;
}]);
<commit_msg>fix JS error<commit_after>var modelBoxCoreFunction = function($http, modelsCategoriesService, smallImagesService, colorsService) {
	// available model box color
	var colors = colorsService.getAvailableColors();

	return {
		//require: 'ngModel',
		replace: true,
		scope: {
			model: '=ngModel',

			// callbacks (expressions)
			onDelete: '&?',
			onRelocate: '&?',
			onExclude: '&?',
			onInclude: '&?',
			onChoose: '&?',
			onUnChoose: '&?',
			onMakeAvailable: '&?',
			onMakeUnavailable: '&?'
		},
		link: function(scope, element, attributes) {
			scope.defaultImage = 'images/model_silhouette.png';

			// load the category name of the model
			scope.modelCategoryName = '';
			if (scope.model.category && parseInt(scope.model.category) > 0) {
				modelsCategoriesService.load(function(modelsCategories) {
					modelsCategories.forEach(function(modelCategory) {
						if (modelCategory.id == scope.model.category) {
							scope.modelCategoryName = modelCategory.name;
						}
					});
				});
			}

			// indication to display inputs for the notes
			scope.notesEditor = {
				public_notes: false,
				private_notes: false
			};

			scope.getModelTags = function() {
				return scope.model.tags ? scope.model.tags.split(/\s*\,\s*/) : [];
			};

			scope.getSmallImage = function(imageFile) {
				return smallImagesService.getSmall(imageFile);
			};

			scope.getMediumImage = function(imageFile) {
				return smallImagesService.getMedium(imageFile);
			};

			scope.galleryIsOpen = false;

			// set the initial main image
			scope.mainImage = scope.model && scope.model.images[0] ?
				(scope.$root.IMAGES_BASE_URL + '/' + scope.model.images[0]) :
				scope.defaultImage;

			scope.setMainImage = function(imageNumber) {
				scope.mainImage = scope.$root.IMAGES_BASE_URL + '/' + scope.model.images[imageNumber];
			};

			scope.openGallery = function() {
				scope.galleryIsOpen = !scope.galleryIsOpen;
			};

			// check if "exclude" callback is defined
			scope.showExcludeButton = (typeof(scope.onExclude) == 'function');

			// check if "include" callback is defined
			scope.showIncludeButton = (typeof(scope.onInclude) == 'function');

			// check if "relocate" callback is defined
			scope.showRelocateButton = (typeof(scope.onRelocate) == 'function');

			// check if "delete" callback is defined
			scope.showDeleteButton = (typeof(scope.onDelete) == 'function');

			// check if "Choose" callback is defined
			scope.showChooseButton = (typeof(scope.onChoose) == 'function');

			// check if "UnChoose" callback is defined
			scope.showUnChooseButton = (typeof(scope.onUnChoose) == 'function');

			// check if "UnChoose" callback is defined
			scope.showMakeAvailableButton = (typeof(scope.onMakeAvailable) == 'function');

			// check if "UnChoose" callback is defined
			scope.showMakeUnavailableButton = (typeof(scope.onMakeUnavailable) == 'function');

			// show/hide the "choose color" boxes
			scope.colorPalette = {
				show: false
			};

			// get the color code (e.g. #A23B23) by color name (the list is on the top)
			scope.getColorNumber = colorsService.getColorNumber;

			/**
			 * Choose model's color
			 * @param string newColor
			 */
			scope.chooseModelColor = function(newColor) {
				// set the color locally
				scope.model.color = newColor || null;

				// call the API
				$http({
					method: 'post',
					url: 'api/update_model.php',
					data: {
						model_id: scope.model.id,
						color: newColor || ''
					}
				}).then(function(res) {
					if (res.data && res.data.result == 'ok') {
						return;
					}

					var errorString = res.data.error || 'Saving color failed';
					alert(errorString);
				}, function() {
					alert('Saving color failed');
				}).finally(function() {
					scope.colorPalette.show = false;
				});
			};

			scope.updateModelNote = function(type) {
				var data = {
					model_id: scope.model.id
				};

				if (type == 'public') {
					data['notes'] = scope.model.notes;
				} else {
					data['private_notes'] = scope.model.private_notes;
				}

				// call the API
				$http({
					method: 'post',
					url: 'api/update_model.php',
					data: data
				}).then(function(res) {
					if (res.data && res.data.result == 'ok') {
						// close the editor
						scope.notesEditor[(type == 'public' ? 'public_notes' : 'private_notes')] = false;

						return;
					}

					var errorString = res.data.error || 'Saving color failed';
					alert(errorString);
				}, function() {
					alert('Saving color failed');
				}).finally(function() {
					scope.colorPalette.show = false;
				});
			};

			/**
			 * move the model to the top/bottom of the list
			 * @param int modelId
			 * @param string newLocation - "top" / "bottom"
			 */
			scope.relocateModel = function(modelId, newLocation) {
				// call the API
				$http({
					method: 'post',
					url: 'api/relocate_model.php',
					data: {
						model_id: modelId,
						new_location: newLocation
					}
				}).then(function(res) {
					if (res.data && res.data.result == 'ok') {
						if (typeof(scope.onRelocate) == 'function') {
							scope.onRelocate();
							return;
						}
						return;
					}

					var errorString = res.data.error || 'Relocation failed';
					alert(errorString);
				}, function() {
					alert('Relocation failed - server error');
				});
			};

			/**
			 * delete the model
			 * @param int modelId
			 */
			scope.deleteModel = function(modelId) {
				if (!confirm('Delete the model?')) {
					return;
				}

				// call the API
				$http({
					method: 'post',
					url: 'api/delete_model.php',
					data: {
						model_id: modelId
					}
				}).then(function(res) {
					if (res.data && res.data.result == 'ok') {
						if (typeof(scope.onDelete) == 'function') {
							scope.onDelete();
							return;
						}
						return;
					}

					var errorString = res.data.error || 'Delete failed';
					alert(errorString);
				}, function() {
					alert('Delete failed - server error');
				});
			};

		},
		templateUrl: 'views/directives/model-box.html',
	}
};

webApp.directive('modelBox', ['$http', 'modelsCategoriesService', 'smallImagesService', 'colorsService',
	function($http, modelsCategoriesService, smallImagesService, colorsService) {
	return modelBoxCoreFunction($http, modelsCategoriesService, smallImagesService, colorsService);
}]);

webApp.directive('modelBoxSmall', ['$http', 'modelsCategoriesService', 'smallImagesService', 'colorsService',
	function($http, modelsCategoriesService, smallImagesService, colorsService) {
	var directiveObject = modelBoxCoreFunction($http, modelsCategoriesService, smallImagesService, colorsService);

	// replace the base template with the one for small box
	directiveObject.templateUrl = 'views/directives/model-box-small.html'

	return directiveObject;
}]);
<|endoftext|>


<commit_before>tnt.tree_annot = function () {
"use strict";

    var no_track = true;
    var div_id;

    // Defaults
    var tree_conf = {
	tree : undefined,
	track : function () {
	    var t = tnt.track()
		.background_color("#EBF5FF")
		.data(tnt.track.data()
		      .update(tnt.track.retriever.sync()
			      .retriever (function () {
				  return  []
			      })
			     ))
		.display(tnt.track.feature.block()
			 .foreground_color("steelblue")
			 .index(function (d) {
			     return d.start;
			 })
			);

	    return t;
	},
	annotation : undefined,
	ruler : "none",
	key   : undefined
    };

    var tree_annot = function (div) {
	div_id = d3.select(div)
	    .attr("id");

	var group_div = d3.select(div)
	    .append("div")
	    .attr("class", "tnt_groupDiv");

	var tree_div = group_div
	    .append("div")
	    .attr("id", "tnt_tree_container_" + div_id)
	    .attr("class", "tnt_tree_container");

	var annot_div = group_div
	    .append("div")
	    .attr("id", "tnt_annot_container_" + div_id)
	    .attr("class", "tnt_annot_container");

	tree_conf.tree (tree_div.node());

	// tracks
	var leaves = tree_conf.tree.root().get_all_leaves();
	var tracks = [];

	var height = tree_conf.tree.label().height();

	for (var i=0; i<leaves.length; i++) {
            // Block Track1
	    (function  (leaf) {
		tnt.track.id = function () {
		    if (tree_conf.key === undefined) {
			return  leaf.id();
		    }
		    if (typeof (tree_conf.key) === 'function') {
			return tree_conf.key (leaf);
		    }
		    return leaf.property(tree_conf.key);
		};
		var track = tree_conf.track(leaves[i])
		    .height(height);

		tracks.push (track);

	    })(leaves[i]);

        }

	// An axis track
	tnt.track.id = function () {
	    return "axis-top";
	};
	var axis_top = tnt.track()
	    .height(0)
	    .background_color("white")
	    .display(tnt.track.feature.axis()
		     .orientation("top")
		    );

	tnt.track.id = function () {
	    return "axis-bottom";
	};
	var axis = tnt.track()
            .height(18)
            .background_color("white")
            .display(tnt.track.feature.axis()
                     .orientation("bottom")
		    );

	if (tree_conf.ruler === 'both' || tree_conf.ruler === 'top') {
	    tree_conf.annotation
		.add_track(axis_top);
	}

	tree_conf.annotation
	    .add_track(tracks);

	if (tree_conf.ruler === 'both' || tree_conf.ruler === "bottom") {
	    tree_conf.annotation
		.add_track(axis);
	}

	tree_conf.annotation(annot_div.node());
	tree_conf.annotation.start();

	api.method('update', function () {
	    tree_conf.tree.update();
	    var leaves = tree_conf.tree.root().get_all_leaves();
	    var new_tracks = [];

	    if (tree_conf.ruler === 'both' || tree_conf.ruler === 'top') {
		new_tracks.push(axis_top);
	    }

	    for (var i=0; i<leaves.length; i++) {
		// We first see if we have a track for the leaf:
		var id;
		if (tree_conf.key === undefined) {
		    id = leaves[i].id();
		} else if (typeof (tree_conf.key) === 'function') {
		    id = tree_conf.key (leaves[i]);
		} else {
		    id = leaves[i].property(tree_conf.key);
		}
		var curr_track = tree_conf.annotation.find_track_by_id(id);
//		var curr_track = tree_conf.annotation.find_track_by_id(tree_conf.key===undefined ? leaves[i].id() : d3.functor(tree_conf.key) (leaves[i]))//leaves[i].property(tree_conf.key));
		if (curr_track === undefined) {
		    // New leaf -- no track for it
		    (function (leaf) {
			tnt.track.id = function () {
			    if (tree_conf.key === undefined) {
				return leaf.id();
			    }
			    if (typeof (tree_conf.key) === 'function') {
				return tree_conf.key (leaf);
			    }
			    return leaf.property(tree_conf.key);
			};
			curr_track = tree_conf.track(leaves[i])
			    .height(height);
		    })(leaves[i]);
		}
		new_tracks.push(curr_track);
	    }
	    if (tree_conf.ruler === 'both' || tree_conf.ruler === 'bottom') {
		new_tracks.push(axis);
	    }

	    tree_conf.annotation.reorder(new_tracks);
	});

	return tree_annot;
    };

    var api = tnt.utils.api (tree_annot)
	.getset (tree_conf);

    // TODO: Rewrite with the api interface
    tree_annot.track = function (new_track) {
	if (!arguments.length) {
	    return tree_conf.track;
	}

	// First time it is set
	if (no_track) {
	    tree_conf.track = new_track;
	    no_track = false;
	    return tree_annot;
	}

	// If it is reset -- apply the changes
	var tracks = tree_conf.annotation.tracks();
// 	var start_index = (tree_conf.ruler === 'both' || tree_conf.ruler === 'top') ? 1 : 0;
// 	var end_index = (tree_conf.ruler === 'both' || tree_conf.ruler === 'bottom') ? 1 : 0;

	var start_index = 0;
	var n_index = 0;

	if (tree_conf.ruler === "both") {
	    start_index = 1;
	    n_index = 2;
	} else if (tree_conf.ruler === "top") {
	    start_index = 1;
	    n_index = 1;
	} else if (tree_conf.ruler === "bottom") {
	    n_index = 1;
	}

	// Reset top track -- axis
	if (start_index > 0) {
	    tracks[0].display().reset.call(tracks[0]);
	}
	// Reset bottom track -- axis
	if (n_index > start_index) {
	    var n = tracks.length - 1;
	    tracks[n].display().reset.call(tracks[n]);
	}

	for (var i=start_index; i<(tracks.length - n_index); i++) {
	    var t = tracks[i];
	    t.display().reset.call(t);
	    var leaf;
	    tree_conf.tree.root().apply (function (node) {
		if (node.id() === t.id()) {
		    leaf = node;
		}
	    })

	    var n_track;
	    (function (leaf) {
		tnt.track.id = function () {
		    if (tree_conf.key === undefined) {
			return leaf.id();
		    }
		    if (typeof (tree_conf.key === 'function')) {
			return tree_conf.key (leaf);
		    }
		    return leaf.property(tree_conf.key);
		};
		n_track = new_track(leaf.data())
		    .height(tree_conf.tree.label().height());
	    })(leaf);

	    tracks[i] = n_track;
	}

	tree_conf.track = new_track;
	tree_conf.annotation.start();
    };

    return tree_annot;
};
<commit_msg>annotation part is now optional in tree_annot<commit_after>tnt.tree_annot = function () {
"use strict";

    var no_track = true;
    var div_id;

    // Defaults
    var tree_conf = {
	tree : undefined,
	track : function () {
	    var t = tnt.track()
		.background_color("#EBF5FF")
		.data(tnt.track.data()
		      .update(tnt.track.retriever.sync()
			      .retriever (function () {
				  return  []
			      })
			     ))
		.display(tnt.track.feature.block()
			 .foreground_color("steelblue")
			 .index(function (d) {
			     return d.start;
			 })
			);

	    return t;
	},
	annotation : undefined,
	ruler : "none",
	key   : undefined
    };

    var tree_annot = function (div) {
	div_id = d3.select(div)
	    .attr("id");

	var group_div = d3.select(div)
	    .append("div")
	    .attr("class", "tnt_groupDiv");

	var tree_div = group_div
	    .append("div")
	    .attr("id", "tnt_tree_container_" + div_id)
	    .attr("class", "tnt_tree_container");

	var annot_div = group_div
	    .append("div")
	    .attr("id", "tnt_annot_container_" + div_id)
	    .attr("class", "tnt_annot_container");

	tree_conf.tree (tree_div.node());

	// tracks
	var leaves = tree_conf.tree.root().get_all_leaves();
	var tracks = [];

	var height = tree_conf.tree.label().height();

	for (var i=0; i<leaves.length; i++) {
            // Block Track1
	    (function  (leaf) {
		tnt.track.id = function () {
		    if (tree_conf.key === undefined) {
			return  leaf.id();
		    }
		    if (typeof (tree_conf.key) === 'function') {
			return tree_conf.key (leaf);
		    }
		    return leaf.property(tree_conf.key);
		};
		var track = tree_conf.track(leaves[i])
		    .height(height);

		tracks.push (track);

	    })(leaves[i]);

        }

	// An axis track
	tnt.track.id = function () {
	    return "axis-top";
	};
	var axis_top = tnt.track()
	    .height(0)
	    .background_color("white")
	    .display(tnt.track.feature.axis()
		     .orientation("top")
		    );

	tnt.track.id = function () {
	    return "axis-bottom";
	};
	var axis = tnt.track()
            .height(18)
            .background_color("white")
            .display(tnt.track.feature.axis()
                     .orientation("bottom")
		    );

	if (tree_conf.annotation) {
	    if (tree_conf.ruler === 'both' || tree_conf.ruler === 'top') {
		tree_conf.annotation
		    .add_track(axis_top);
	    }

	    tree_conf.annotation
		.add_track(tracks);

	    if (tree_conf.ruler === 'both' || tree_conf.ruler === "bottom") {
		tree_conf.annotation
		    .add_track(axis);
	    }

	    tree_conf.annotation(annot_div.node());
	    tree_conf.annotation.start();
	}

	api.method('update', function () {
	    tree_conf.tree.update();

	    if (tree_conf.annotation) {
		var leaves = tree_conf.tree.root().get_all_leaves();
		var new_tracks = [];

		if (tree_conf.ruler === 'both' || tree_conf.ruler === 'top') {
		    new_tracks.push(axis_top);
		}

		for (var i=0; i<leaves.length; i++) {
		    // We first see if we have a track for the leaf:
		    var id;
		    if (tree_conf.key === undefined) {
			id = leaves[i].id();
		    } else if (typeof (tree_conf.key) === 'function') {
			id = tree_conf.key (leaves[i]);
		    } else {
			id = leaves[i].property(tree_conf.key);
		    }
		    var curr_track = tree_conf.annotation.find_track_by_id(id);
		    //		var curr_track = tree_conf.annotation.find_track_by_id(tree_conf.key===undefined ? leaves[i].id() : d3.functor(tree_conf.key) (leaves[i]))//leaves[i].property(tree_conf.key));
		    if (curr_track === undefined) {
			// New leaf -- no track for it
			(function (leaf) {
			    tnt.track.id = function () {
				if (tree_conf.key === undefined) {
				    return leaf.id();
				}
				if (typeof (tree_conf.key) === 'function') {
				    return tree_conf.key (leaf);
				}
				return leaf.property(tree_conf.key);
			    };
			    curr_track = tree_conf.track(leaves[i])
				.height(height);
			})(leaves[i]);
		    }
		    new_tracks.push(curr_track);
		}
		if (tree_conf.ruler === 'both' || tree_conf.ruler === 'bottom') {
		    new_tracks.push(axis);
		}

		tree_conf.annotation.reorder(new_tracks);
	    }
	});

	return tree_annot;
    };

    var api = tnt.utils.api (tree_annot)
	.getset (tree_conf);

    // TODO: Rewrite with the api interface
    tree_annot.track = function (new_track) {
	if (!arguments.length) {
	    return tree_conf.track;
	}

	// First time it is set
	if (no_track) {
	    tree_conf.track = new_track;
	    no_track = false;
	    return tree_annot;
	}

	// If it is reset -- apply the changes
	var tracks = tree_conf.annotation.tracks();
// 	var start_index = (tree_conf.ruler === 'both' || tree_conf.ruler === 'top') ? 1 : 0;
// 	var end_index = (tree_conf.ruler === 'both' || tree_conf.ruler === 'bottom') ? 1 : 0;

	var start_index = 0;
	var n_index = 0;

	if (tree_conf.ruler === "both") {
	    start_index = 1;
	    n_index = 2;
	} else if (tree_conf.ruler === "top") {
	    start_index = 1;
	    n_index = 1;
	} else if (tree_conf.ruler === "bottom") {
	    n_index = 1;
	}

	// Reset top track -- axis
	if (start_index > 0) {
	    tracks[0].display().reset.call(tracks[0]);
	}
	// Reset bottom track -- axis
	if (n_index > start_index) {
	    var n = tracks.length - 1;
	    tracks[n].display().reset.call(tracks[n]);
	}

	for (var i=start_index; i<=(tracks.length - n_index); i++) {
	    var t = tracks[i];
	    t.display().reset.call(t);
	    var leaf;
	    tree_conf.tree.root().apply (function (node) {
		if (node.id() === t.id()) {
		    leaf = node;
		}
	    })

	    var n_track;
	    (function (leaf) {
		tnt.track.id = function () {
		    if (tree_conf.key === undefined) {
			return leaf.id();
		    }
		    if (typeof (tree_conf.key === 'function')) {
			return tree_conf.key (leaf);
		    }
		    return leaf.property(tree_conf.key);
		};
		n_track = new_track(leaf)
		    .height(tree_conf.tree.label().height());
	    })(leaf);

	    tracks[i] = n_track;
	}

	tree_conf.track = new_track;
	tree_conf.annotation.start();
    };

    return tree_annot;
};
<|endoftext|>


<commit_before>
import { isFunction, isArray, isString, isPlainObject, isUndefined, trim } from 'lodash'
import Expression, { Literal, SubQuery, Column, Table, Escaped } from '../expression'
import Query from '../query'

/**
 * A handler function for template strings
 *
 * @param {String|Array} expr
 * @param {Array} args
 * @returns {Literal}
 */
export function raw(expr, ...args) {
  // handle template strings
  if ( isArray(expr) )
    expr = expr.join('?')

  // parse named parameters
  if ( isPlainObject(args[0]) ) {
    let obj = args[0]
    args = []

    expr = expr.replace(/[:@](\w+)/gi, (match, attr) => {
      // we return the match string in case the attribute is undefined
      if ( isUndefined(obj[attr]) ) return match

      // append the value of the attribute
      args.push(obj[attr])

      // return the basic placeholder
      return '?'
    })
  }

  return new Literal(expr, args)
}

/**
 *
 * @param {Any} value
 * @returns {Expression}
 * @throws {TypeError}
 */
export function sq(value) {
  return createSubQuery(value)
}

/**
 *
 * @param {Any} value
 * @returns {Expression}
 * @throws {TypeError}
 */
export function cte(value) {
  return createSubQuery(value).isCTE()
}

/**
 *
 * @param {String} value
 * @returns {Column}
 */
export function column(value) {
  var alias = ''

  if ( value.indexOf(' as ') > 0 ) {
    [value, alias] = value.split(' as ').map(trim)
  }

  return new Column(value).as(alias)
}

/**
 *
 * @param {String} value
 * @returns {Table}
 */
export function table(value) {
  var alias = ''

  if ( value.indexOf(' as ') > 0 ) {
    [value, alias] = value.split(' as ').map(trim)
  }

  return new Table(value).as(alias)
}

/**
 *
 * @param {Any} value
 * @returns {Escaped}
 */
export function esc(value) {
  return new Escaped(value)
}

/**
 *
 * @param {Any} value
 * @param {String} type
 * @returns {Expression}
 */
export function cast(value, type) {
  return raw(`cast(? as ${type})`, value)
}

/**
 *
 * @param {Any} value
 * @returns {Expression}
 * @throws {TypeError}
 * @private
 */
function createSubQuery(value) {
  // accept a raw query string
  if ( isString(value) )
    value = Literal.from(value)

  // accept a function as a parameter
  if ( isFunction(value) ) {
    let fn = value

    fn(value = new Select())
  }

  // accept a Select query instance
  if ( value instanceof Query || value instanceof Expression )
    value = new SubQuery(value)

  // and finally an instance of SubQuery expression
  if ( value instanceof SubQuery ) return value

  // throws an error for invalid argument
  throw new TypeError("Invalid sub query expression")
}<commit_msg>Add the helper<commit_after>
import { isFunction, isArray, isString, isPlainObject, isUndefined, trim } from 'lodash'
import Expression, { Literal, SubQuery, Column, Table, Escaped, Values } from '../expression'
import Query from '../query'

/**
 * A handler function for template strings
 *
 * @param {String|Array} expr
 * @param {Array} args
 * @returns {Literal}
 */
export function raw(expr, ...args) {
  // handle template strings
  if ( isArray(expr) )
    expr = expr.join('?')

  // parse named parameters
  if ( isPlainObject(args[0]) ) {
    let obj = args[0]
    args = []

    expr = expr.replace(/[:@](\w+)/gi, (match, attr) => {
      // we return the match string in case the attribute is undefined
      if ( isUndefined(obj[attr]) ) return match

      // append the value of the attribute
      args.push(obj[attr])

      // return the basic placeholder
      return '?'
    })
  }

  return new Literal(expr, args)
}

/**
 *
 * @param {Any} value
 * @returns {Expression}
 * @throws {TypeError}
 */
export function sq(value) {
  return createSubQuery(value)
}

/**
 *
 * @param {Any} value
 * @returns {Expression}
 * @throws {TypeError}
 */
export function cte(value) {
  return createSubQuery(value).isCTE()
}

/**
 *
 * @param {String} value
 * @returns {Column}
 */
export function column(value) {
  var alias = ''

  if ( value.indexOf(' as ') > 0 ) {
    [value, alias] = value.split(' as ').map(trim)
  }

  return new Column(value).as(alias)
}

/**
 *
 * @param {String} value
 * @returns {Table}
 */
export function table(value) {
  var alias = ''

  if ( value.indexOf(' as ') > 0 ) {
    [value, alias] = value.split(' as ').map(trim)
  }

  return new Table(value).as(alias)
}

/**
 *
 * @param {Any} value
 * @returns {Escaped}
 */
export function esc(value) {
  return new Escaped(value)
}

/**
 *
 * @param {Any} value
 * @param {String} type
 * @returns {Expression}
 */
export function cast(value, type) {
  return raw(`cast(? as ${type})`, value)
}

/**
 *
 * @param {Array} data
 * @returns {Expression}
 */
export function values (data) {
  return new Values(data)
}

/**
 *
 * @param {Any} value
 * @returns {Expression}
 * @throws {TypeError}
 * @private
 */
function createSubQuery(value) {
  // accept a raw query string
  if ( isString(value) )
    value = Literal.from(value)

  // accept a function as a parameter
  if ( isFunction(value) ) {
    let fn = value

    fn(value = new Select())
  }

  // accept a Select query instance
  if ( value instanceof Query || value instanceof Expression )
    value = new SubQuery(value)

  // and finally an instance of SubQuery expression
  if ( value instanceof SubQuery ) return value

  // throws an error for invalid argument
  throw new TypeError("Invalid sub query expression")
}<|endoftext|>


<commit_before>export default {
  navigatorButton: "[data-test-id='Navigator'] [data-test-id='Button']",
  navigationDrawerLoginButton: "[data-test-id='NavDrawerLoginButton']",
  navigationDrawerEntry: "[data-test-id='NavDrawer'] [data-test-id='Ripple'] span",
  shopLogo: "[data-test-id='Navigator'] img[alt='TestAutomation']",
  imageSliderImage1: "[data-test-id='Slider']:nth-child(2)  img[data-test-id='withoutLink']",
  imageSliderImage2: "[data-test-id='Slider']:nth-child(3)  img[data-test-id='withoutLink']",
  imageWidgetWithLink1: "[data-test-id='imageWidget: /category/3537']",
  productSliderProduct1: "[data-test-id='Slider'] [data-test-id='link: /item/393239']",
  liveShoppingWidgetWithExpectedProduct: "[data-test-id='liveShoppingWidget'] [data-test-id='link: /item/393132']",
  productGridWidgetFirstProduct: "[data-test-id='productGrid'] [data-test-id='link: /item/393939']",
  productListWidgetFirstProduct: "[data-test-id='productList'] [data-test-id='link: /item/393939']",
  categoryListWidgetFirstProduct: "[data-test-id='categoryList'] [data-test-id='link: /category/3537']",
  allProductCategory: "[data-test-id='link: /category/3733']",
  allProductsCategoryTitle: "[data-test-id='title: 4. all products']",
  filterButton: "[data-test-id='filterBar'] [data-test-id='filterButton']",
  backButton: "[data-test-id='backButton']",
  searchButton: "[data-test-id='SearchButton']",
  sortingDropDown: "[data-test-id='sorting']",
  viewSwitch: "[data-test-id='viewSwitch']",
  productWithManyProps4GridViewImage: "[data-test-id='productGrid'] img[alt='Product with many Properties - 4 -']",
  productWithManyProps4GridViewName: "[style='display: block;'] [data-test-id='productGrid'] [data-test-id='Productname: Product with many Properties - 4 -']",
  productWithManyProps4GridViewFavButton: "[data-test-id='link: /item/393939'] [data-test-id='favorites'] [data-test-id='favoriteButton']",
  productWithManyProps4GridViewPrice: "[data-test-id='productGrid'] [data-test-id='link: /item/393939'] [data-test-id='minPrice: 0 price: 199 currency: EUR']",
  productWithManyProps4ListViewImage: "[data-test-id='productList'] img[alt='Product with many Properties - 4 -']",
  productWithManyProps4ListViewName: "[data-test-id='productList'] [data-test-id='Productname: Product with many Properties - 4 -']",
  productWithManyProps4ListViewPrice: "[data-test-id='productList'] [data-test-id='link: /item/393939'] [data-test-id='minPrice: 0 price: 199 currency: EUR']",
  productWithStrikePrice4GridViewStrikePrice: "[data-test-id='productGrid'] [data-test-id='link: /item/31303634'] [data-test-id='strikedPrice: 10']",
  productWithStrikePrice4GridViewDiscountBadge: "[data-test-id='productGrid'] [data-test-id='link: /item/31303634'] [data-test-id='-1%']",
  productWithStrikePrice4GridViewPrice: "[data-test-id='productGrid'] [data-test-id='link: /item/31303634'] [data-test-id='minPrice: 0 price: 9.95 currency: EUR']",
  productWithStrikePrice4listViewStrikePrice: "[data-test-id='productList'] [data-test-id='link: /item/31303634'] [data-test-id='strikedPrice: 10']",
  productWithStrikePrice4ListViewDiscountBadge: "[data-test-id='productList'] [data-test-id='link: /item/31303634'] [data-test-id='-1%']",
  productWithStrikePrice4ListViewPrice: "[data-test-id='productList'] [data-test-id='link: /item/31303634'] [data-test-id='minPrice: 0 price: 9.95 currency: EUR']",
  productWithRating4GridViewRatingStars: "[data-test-id='productGrid'] [data-test-id='link: /item/393430'] [data-test-id='ratedStars: 5']",
  productWithRating4ListViewRatingStars: "[data-test-id='productList'] [data-test-id='link: /item/393430'] [data-test-id='ratedStars: 5']",
  productWithManyProps4ProductPageImage: "[data-test-id='product: Product with many Properties - 4 -'] [data-test-id='image']",
  productWithManyProps4ProductPagName: "[data-test-id='name: Product with many Properties - 4 -']",
  productWithManyProps4ProductPageTitle: "[data-test-id='title: Product with many Properties - 4 -']",
  productWithManyProps4ProductPageAvailabilityText: "[data-test-id='availabilityText: In stock']",
  productWithManufacturerPropManufacturerProp: "[data-test-id='manufacturer: supa dupa Company']",
  productWithManufacturerPropManufacturerPropList: "[data-test-id='property: supa dupa Company']",
  productWithManufacturerPropProductDetailPagePrice: "[data-test-id='minPrice: 0 price: 5 currency: EUR']",
  productWithManufactruerPropProductDetailPageDescription: "[data-test-id='Product with manufacture prop']",
  addToCartButton: "[data-test-id='AddToCartButton']",
  favoriteButton: "[data-test-id='favoriteButton']",
  reviewSection: "[data-test-id='reviewSection']",
  taxDisclaimer: "[data-test-id='taxDisclaimer'] span",
  writeReviewButton: "[data-test-id='writeReview']",
  variantsPicker: "[data-test-id='variantsPicker']",
  variantPickerColor: "[data-test-id='Color']",
  variantPickerShoeSize: "[data-test-id='Shoe size']",
  optionsPicker: "[data-test-id='optionsPicker']",
  optionPickerBallColor: "[data-test-id='Ball color']",
  optionPickerGlow: "[data-test-id='glow']",
  ratingStars: "[data-test-id='ratedStarsAverage']",
  productWithRating3Review1Title: "[data-test-id='reviewTitle: test2']",
  productWithRating3Review2Title: "[data-test-id='reviewTitle: test3']",
  showAllReviewsButton: "[data-test-id='showAllReviewsButton']",
  productWithBasePrice1basePrice: "[data-test-id='priceInfo: €10.00 / 1 kg']",
  productWithStrikePrice4StrikePrice: "[data-test-id='strikedPrice: 10']",
  navDrawerCartButton: "[data-test-id='navDrawerCartButton']",
  emptyCartPlaceHolderString: "[data-test-id='emptyCartPlaceHolderString']",
  cartButton: "[data-test-id='CartButton']",
  productWithManyProps4CartItem: "[data-test-id='cartItem'] [data-test-id='link: /item/393939']",
  contextMenu: "[data-test-id='contextMenu']",
  contextMenuButton: "[data-test-id='contextMenuButton'] span",
  productWithManyProps4CartitemPrice: "[data-test-id='cartItem'] [data-test-id='link: /item/393939'] [data-test-id='minPrice: 0 price: 199 currency: EUR']",
  productWithManyProps4CartSubTotal: "[data-test-id='subTotal: 199']",
  shippingLabel: "[data-test-id='shippingLabel'] span",
  taxDisclaimerFooter: "[data-route-path='/cart'] [data-test-id='taxDisclaimer'] span",
  couponFieldInput: "[data-test-id='couponField'] input",
  couponSubmitButton: "[data-test-id='CouponSubmitButton']",
  searchInput: "[data-test-id='Search'] input",
  loginPageEmailInput: "[data-test-id='LoginPage'] input[id='email']",
  loginPagePasswordInput: "[data-test-id='LoginPage'] input[id='password']",
  forgotPasswordButton: "[data-test-id='forgotPasswordButton']",
  loginButton: "[data-test-id='LoginButton'] ",
  registerButton: "[data-test-id='link: /register']",
  priceRangeSlider: "[data-test-id='priceRangeSlider']",
  filterListItemManufacturer: "[data-test-id='filterListItem'] [data-test-id='link: /filter/manufacturer']",
  filterAttributeManufacturer1: "[data-test-id='filterAttributes'] [data-test-id='kungBirgers']",
  clearAllButton: "[data-test-id='clearAllButton']",
  applyFilterButton: "[data-test-id='applyFilterButton']",
  logOutButtonNavDrawer: "[data-test-id='logoutButtonNavDrawer']",
  reviewsTitle: "[data-test-id='title: Bewertungen']",
  basicDialogOkButton: "[data-test-id='basicDialog'] [data-test-id='Button']",
  writeReviewName: "[data-test-id='reviewForm'] input[id='author']",
  loginWelcomeText: "[data-test-id='NavDrawerLoginButton'] span",
  navDrawerStartPage: "[data-test-id='NavDrawerStartPage']",
  writeReviewTitle: "[data-test-id='reviewForm'] input[id='title']",
  writeReviewTextArea: "[data-test-id='reviewForm'] textarea[id='review']",
  writeReviewRatedStars: "[data-test-id='reviewForm'] [data-test-id='ratedStars: 0']",
  writeReviewCancelButton: "[data-test-id='reviewCancelButton']",
  writeReviewSendButton: "[data-test-id='sendReviewButton']",
  navDrawerFavoritesButton: "[data-test-id='favoritesButton']",
  favoritesPageEmptyFavComponent: "[data-test-id='emptyFavComponent']",
  favoritesPageContinueShoppingButton: "[data-test-id='continueButton']",
  productWithManyProps4Link: "[data-test-id='link: /item/393939']",
  productWithManyProps4FavListPrice: "[data-test-id='minPrice: 0 price: 199 currency: EUR']",
  availabilityTextInStock: "[data-test-id='availabilityText: In stock']",
};
<commit_msg>PWA-527 changed test id<commit_after>export default {
  navigatorButton: "[data-test-id='Navigator'] [data-test-id='Button']",
  navigationDrawerLoginButton: "[data-test-id='NavDrawerLoginButton']",
  navigationDrawerEntry: "[data-test-id='NavDrawer'] [data-test-id='Ripple'] span",
  shopLogo: "[data-test-id='Navigator'] img[alt='TestAutomation']",
  imageSliderImage1: "[data-test-id='Slider']:nth-child(2)  img[data-test-id='withoutLink']",
  imageSliderImage2: "[data-test-id='Slider']:nth-child(3)  img[data-test-id='withoutLink']",
  imageWidgetWithLink1: "[data-test-id='imageWidget: /category/3537']",
  productSliderProduct1: "[data-test-id='Slider'] [data-test-id='link: /item/393239']",
  liveShoppingWidgetWithExpectedProduct: "[data-test-id='liveShoppingWidget'] [data-test-id='link: /item/393132']",
  productGridWidgetFirstProduct: "[data-test-id='productGrid'] [data-test-id='link: /item/393939']",
  productListWidgetFirstProduct: "[data-test-id='productList'] [data-test-id='link: /item/393939']",
  categoryListWidgetFirstProduct: "[data-test-id='categoryList'] [data-test-id='link: /category/3537']",
  allProductCategory: "[data-test-id='link: /category/3733']",
  allProductsCategoryTitle: "[data-test-id='title: 4. all products']",
  filterButton: "[data-test-id='filterBar'] [data-test-id='filterButton']",
  backButton: "[data-test-id='backButton']",
  searchButton: "[data-test-id='SearchButton']",
  sortingDropDown: "[data-test-id='sorting']",
  viewSwitch: "[data-test-id='viewSwitch']",
  productWithManyProps4GridViewImage: "[data-test-id='productGrid'] img[alt='Product with many Properties - 4 -']",
  productWithManyProps4GridViewName: "[style='display: block;'] [data-test-id='productGrid'] [data-test-id='Productname: Product with many Properties - 4 -']",
  productWithManyProps4GridViewFavButton: "[data-test-id='link: /item/393939'] [data-test-id='favorites'] [data-test-id='favoriteButton']",
  productWithManyProps4GridViewPrice: "[data-test-id='productGrid'] [data-test-id='link: /item/393939'] [data-test-id='minPrice: 0 price: 199 currency: EUR']",
  productWithManyProps4ListViewImage: "[data-test-id='productList'] img[alt='Product with many Properties - 4 -']",
  productWithManyProps4ListViewName: "[data-test-id='productList'] [data-test-id='Productname: Product with many Properties - 4 -']",
  productWithManyProps4ListViewPrice: "[data-test-id='productList'] [data-test-id='link: /item/393939'] [data-test-id='minPrice: 0 price: 199 currency: EUR']",
  productWithStrikePrice4GridViewStrikePrice: "[data-test-id='productGrid'] [data-test-id='link: /item/31303634'] [data-test-id='strikedPrice: 10']",
  productWithStrikePrice4GridViewDiscountBadge: "[data-test-id='productGrid'] [data-test-id='link: /item/31303634'] [data-test-id='-1%']",
  productWithStrikePrice4GridViewPrice: "[data-test-id='productGrid'] [data-test-id='link: /item/31303634'] [data-test-id='minPrice: 0 price: 9.95 currency: EUR']",
  productWithStrikePrice4listViewStrikePrice: "[data-test-id='productList'] [data-test-id='link: /item/31303634'] [data-test-id='strikedPrice: 10']",
  productWithStrikePrice4ListViewDiscountBadge: "[data-test-id='productList'] [data-test-id='link: /item/31303634'] [data-test-id='-1%']",
  productWithStrikePrice4ListViewPrice: "[data-test-id='productList'] [data-test-id='link: /item/31303634'] [data-test-id='minPrice: 0 price: 9.95 currency: EUR']",
  productWithRating4GridViewRatingStars: "[data-test-id='productGrid'] [data-test-id='link: /item/393430'] [data-test-id='ratedStars: 5']",
  productWithRating4ListViewRatingStars: "[data-test-id='productList'] [data-test-id='link: /item/393430'] [data-test-id='ratedStars: 5']",
  productWithManyProps4ProductPageImage: "[data-test-id='product: Product with many Properties - 4 -'] [data-test-id='image']",
  productWithManyProps4ProductPagName: "[data-test-id='name: Product with many Properties - 4 -']",
  productWithManyProps4ProductPageTitle: "[data-test-id='title: Product with many Properties - 4 -']",
  productWithManyProps4ProductPageAvailabilityText: "[data-test-id='availabilityText: In stock']",
  productWithManufacturerPropManufacturerProp: "[data-test-id='manufacturer: supa dupa Company']",
  productWithManufacturerPropManufacturerPropList: "[data-test-id='property: supa dupa Company']",
  productWithManufacturerPropProductDetailPagePrice: "[data-test-id='minPrice: 0 price: 5 currency: EUR']",
  productWithManufactruerPropProductDetailPageDescription: "[data-test-id='Product with manufacture prop']",
  addToCartButton: "[data-test-id='addToCartButton']",
  favoriteButton: "[data-test-id='favoriteButton']",
  reviewSection: "[data-test-id='reviewSection']",
  taxDisclaimer: "[data-test-id='taxDisclaimer'] span",
  writeReviewButton: "[data-test-id='writeReview']",
  variantsPicker: "[data-test-id='variantsPicker']",
  variantPickerColor: "[data-test-id='Color']",
  variantPickerShoeSize: "[data-test-id='Shoe size']",
  optionsPicker: "[data-test-id='optionsPicker']",
  optionPickerBallColor: "[data-test-id='Ball color']",
  optionPickerGlow: "[data-test-id='glow']",
  ratingStars: "[data-test-id='ratedStarsAverage']",
  productWithRating3Review1Title: "[data-test-id='reviewTitle: test2']",
  productWithRating3Review2Title: "[data-test-id='reviewTitle: test3']",
  showAllReviewsButton: "[data-test-id='showAllReviewsButton']",
  productWithBasePrice1basePrice: "[data-test-id='priceInfo: €10.00 / 1 kg']",
  productWithStrikePrice4StrikePrice: "[data-test-id='strikedPrice: 10']",
  navDrawerCartButton: "[data-test-id='navDrawerCartButton']",
  emptyCartPlaceHolderString: "[data-test-id='emptyCartPlaceHolderString']",
  cartButton: "[data-test-id='CartButton']",
  productWithManyProps4CartItem: "[data-test-id='cartItem'] [data-test-id='link: /item/393939']",
  contextMenu: "[data-test-id='contextMenu']",
  contextMenuButton: "[data-test-id='contextMenuButton'] span",
  productWithManyProps4CartitemPrice: "[data-test-id='cartItem'] [data-test-id='link: /item/393939'] [data-test-id='minPrice: 0 price: 199 currency: EUR']",
  productWithManyProps4CartSubTotal: "[data-test-id='subTotal: 199']",
  shippingLabel: "[data-test-id='shippingLabel'] span",
  taxDisclaimerFooter: "[data-route-path='/cart'] [data-test-id='taxDisclaimer'] span",
  couponFieldInput: "[data-test-id='couponField'] input",
  couponSubmitButton: "[data-test-id='CouponSubmitButton']",
  searchInput: "[data-test-id='Search'] input",
  loginPageEmailInput: "[data-test-id='LoginPage'] input[id='email']",
  loginPagePasswordInput: "[data-test-id='LoginPage'] input[id='password']",
  forgotPasswordButton: "[data-test-id='forgotPasswordButton']",
  loginButton: "[data-test-id='LoginButton'] ",
  registerButton: "[data-test-id='link: /register']",
  priceRangeSlider: "[data-test-id='priceRangeSlider']",
  filterListItemManufacturer: "[data-test-id='filterListItem'] [data-test-id='link: /filter/manufacturer']",
  filterAttributeManufacturer1: "[data-test-id='filterAttributes'] [data-test-id='kungBirgers']",
  clearAllButton: "[data-test-id='clearAllButton']",
  applyFilterButton: "[data-test-id='applyFilterButton']",
  logOutButtonNavDrawer: "[data-test-id='logoutButtonNavDrawer']",
  reviewsTitle: "[data-test-id='title: Bewertungen']",
  basicDialogOkButton: "[data-test-id='basicDialog'] [data-test-id='Button']",
  writeReviewName: "[data-test-id='reviewForm'] input[id='author']",
  loginWelcomeText: "[data-test-id='NavDrawerLoginButton'] span",
  navDrawerStartPage: "[data-test-id='NavDrawerStartPage']",
  writeReviewTitle: "[data-test-id='reviewForm'] input[id='title']",
  writeReviewTextArea: "[data-test-id='reviewForm'] textarea[id='review']",
  writeReviewRatedStars: "[data-test-id='reviewForm'] [data-test-id='ratedStars: 0']",
  writeReviewCancelButton: "[data-test-id='reviewCancelButton']",
  writeReviewSendButton: "[data-test-id='sendReviewButton']",
  navDrawerFavoritesButton: "[data-test-id='favoritesButton']",
  favoritesPageEmptyFavComponent: "[data-test-id='emptyFavComponent']",
  favoritesPageContinueShoppingButton: "[data-test-id='continueButton']",
  productWithManyProps4Link: "[data-test-id='link: /item/393939']",
  productWithManyProps4FavListPrice: "[data-test-id='minPrice: 0 price: 199 currency: EUR']",
  availabilityTextInStock: "[data-test-id='availabilityText: In stock']",
};
<|endoftext|>


<commit_before>var common = require("./common.js");

describe('import', function() {

    function getSourceOptions() {
        return element(by.id('importSourceSelect')).all(by.css('select option'));
    }

    function getFormatOptions() {
        return element(by.id('importFormatSelect')).all(by.css('select option'));
    }

    beforeEach(function() {
        browser.get('/');
    });

    it('should import a valid iDAI.field JSONL file via HTTP', function() {
        var url = "./test/importer-test-ok.jsonl";

        element(by.id('importButton')).click()
            .then(getSourceOptions)
            .then(function(options) {
                expect(options[1].getAttribute("value")).toEqual("http");
                options[1].click();
            })
            .then(getFormatOptions)
            .then(function(options) {
                expect(options[0].getAttribute("value")).toEqual("native");
                options[0].click();
            })
            .then(common.typeIn(element(by.id('importUrlInput')), url))
            .then(element(by.id('importStartButton')).click())
            .then(function() {
                browser.wait(protractor.ExpectedConditions.presenceOf(element(by.id('message-1'))), 5000);
                expect(element(by.id('message-0')).getText()).toEqual("Starte Import...");
                expect(element(by.id('message-1')).getText()).toEqual("4 Ressourcen wurden erfolgreich importiert.");
            });
    });

});
<commit_msg>fixed import test on jenkins<commit_after>var common = require("./common.js");

describe('import', function() {

    function getSourceOptions() {
        return element(by.id('importSourceSelect')).all(by.css('select option'));
    }

    function getFormatOptions() {
        return element(by.id('importFormatSelect')).all(by.css('select option'));
    }

    beforeEach(function() {
        browser.get('/');
    });

    it('should import a valid iDAI.field JSONL file via HTTP', function() {
        var url = "../test/importer-test-ok.jsonl";

        element(by.id('importButton')).click()
            .then(getSourceOptions)
            .then(function(options) {
                expect(options[1].getAttribute("value")).toEqual("http");
                options[1].click();
            })
            .then(getFormatOptions)
            .then(function(options) {
                expect(options[0].getAttribute("value")).toEqual("native");
                options[0].click();
            })
            .then(common.typeIn(element(by.id('importUrlInput')), url))
            .then(element(by.id('importStartButton')).click())
            .then(function() {
                browser.wait(protractor.ExpectedConditions.presenceOf(element(by.id('message-1'))), 5000);
                expect(element(by.id('message-0')).getText()).toEqual("Starte Import...");
                expect(element(by.id('message-1')).getText()).toEqual("4 Ressourcen wurden erfolgreich importiert.");
            });
    });

});
<|endoftext|>


<commit_before>function render() {
  return (<root>

    <div prop={x ?  : }>

    <div prop={}>

    <div prop={{i++}}>

  </root>);
}
<commit_msg>Test eager attribute and children<commit_after>function render() {
  var test =

        {i++}

;
  return (<root>

    <div prop={x ?  : }>

    <div prop={}>

    <div prop={{i++}}>

  </root>);
}
<|endoftext|>


<commit_before>/*
Copyright 2014 Huawei Technologies Co., Ltd. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 */

let apiUrlConf = {
	"host" : "http://test-1.containerops.sh",
	"pipeline" : {
		"list" : "/pipeline/v1/demo/demo",
		"data" : "/pipeline/v1/demo/demo/{pipelineName}/json?id={pipelineID}",
		"add" : "/pipeline/v1/demo/demo",
		"save" : "/pipeline/v1/demo/demo/{pipelineName}",
		"eventOutput" : "/pipeline/v1/eventJson/github/{eventName}",
		"getEnv" : "/pipeline/v1/demo/demo/{pipelineName}/env?id={pipelineID}",
		"setEnv" : "/pipeline/v1/demo/demo/{pipelineName}/env",
		"changeState" : "/pipeline/v1/demo/demo/{pipelineName}/state",
		"getToken" : "/pipeline/v1/demo/demo/{pipelineName}/token?id={pipelineID}"
	},
	"component" : {
		"list" : "/pipeline/v1/demo/component",
		"data" : "/pipeline/v1/demo/component/{componentName}?id={componentID}",
		"add" : "/pipeline/v1/demo/component",
		"save" : "/pipeline/v1/demo/component/{componentName}"
	},
	"history" : {
		"sequenceList" : "/pipeline/v1/demo/demo/histories",
		"sequenceData" : "/pipeline/v1/demo/demo/{pipelineName}/historyDefine?versionId={versionID}&sequenceId={pipelineSequenceID}",
		"action" : "/pipeline/v1/demo/demo/{pipelineName}/stage/{stageName}/{actionName}/history?actionLogId={actionLogID}",
		"relation" : "/pipeline/v1/demo/demo/{pipelineName}/{pipelineSequenceID}/lineHistory?startActionId={startActionId}&endActionId={endActionId}"
	}
}

// pipeline
export let pipelineApi = {
	"list" : function(){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.list,
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	},
	"data" : function(name,id){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.data.replace(/{pipelineName}/g, name).replace(/{pipelineID}/g, id),
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	},
	"add" : function(name,version){
		var data = JSON.stringify({
				"name":name,
				"version":version
			});
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.add,
	        "type": "POST",
	        "dataType": "json",
	        "data": data
	    });
	    return promise;
	},
	"save" : function(name,reqbody){
		var data = JSON.stringify(reqbody);
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.save.replace(/{pipelineName}/g, name),
	        "type": "PUT",
	        "dataType": "json",
	        "data": data
	    });
	    return promise;
	},
	"eventOutput" : function(name){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.eventOutput.replace(/{eventName}/g, name),
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	},
	"getEnv" : function(name,id){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.getEnv.replace(/{pipelineName}/g, name).replace(/{pipelineID}/g, id),
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	},
	"setEnv" : function(name,reqbody){
		var data = JSON.stringify(reqbody);
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.setEnv.replace(/{pipelineName}/g, name),
	        "type": "PUT",
	        "dataType": "json",
	        "data": data
	    });
	    return promise;
	},
	"changeState" : function(name,reqbody){
		var data = JSON.stringify(reqbody);
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.changeState.replace(/{pipelineName}/g, name),
	        "type": "PUT",
	        "dataType": "json",
	        "data": data
	    });
	    return promise;
	},
	"getToken" : function(name,id){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.getToken.replace(/{pipelineName}/g, name).replace(/{pipelineID}/g, id),
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	}
}

// component
export let componentApi = {
	"list" : function(){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.component.list,
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	},
	"data" : function(name,id){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.component.data.replace(/{componentName}/g, name).replace(/{componentID}/g, id),
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	},
	"add" : function(name,version){
		var data = JSON.stringify({
				"name":name,
				"version":version
			});
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.component.add,
	        "type": "POST",
	        "dataType": "json",
	        "data": data
	    });
	    return promise;
	},
	"save" : function(name,reqbody){
		var data = JSON.stringify(reqbody);
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.component.save.replace(/{componentName}/g, name),
	        "type": "PUT",
	        "dataType": "json",
	        "data": data
	    });
	    return promise;
	}
}

// history
export let historyApi = {
	"sequenceData" : function(pipelineName,versionID,pipelineRunSequenceID){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.history.sequenceData.replace(/{pipelineName}/g, pipelineName).replace(/{versionID}/g, versionID).replace(/{pipelineSequenceID}/g, pipelineRunSequenceID),
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	},
	"sequenceList" : function () {
		var promise = $.ajax({
			"url" : apiUrlConf.host + apiUrlConf.history.sequenceList,
			"type" : "GET",
			"dataType" : "json",
			"cache": false
		});
		return promise;
	},
	"action" : function(pipelineName,stageName,actionName,actionLogID){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.history.action.replace(/{pipelineName}/g, pipelineName).replace(/{stageName}/g, stageName).replace(/{actionName}/g, actionName).replace(/{actionLogID}/g, actionLogID),
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	},
	"relation" : function(pipelineName,pipelineSequenceID,startActionId,endActionId){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.history.relation.replace(/{pipelineName}/g, pipelineName).replace(/{pipelineSequenceID}/g, pipelineSequenceID).replace(/{startActionId}/g, startActionId).replace(/{endActionId}/g, endActionId),
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	}
}
<commit_msg>back to real api server<commit_after>/*
Copyright 2014 Huawei Technologies Co., Ltd. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 */

let apiUrlConf = {
	"host" : "https://test-1.containerops.sh",
	"pipeline" : {
		"list" : "/pipeline/v1/demo/demo",
		"data" : "/pipeline/v1/demo/demo/{pipelineName}/json?id={pipelineID}",
		"add" : "/pipeline/v1/demo/demo",
		"save" : "/pipeline/v1/demo/demo/{pipelineName}",
		"eventOutput" : "/pipeline/v1/eventJson/github/{eventName}",
		"getEnv" : "/pipeline/v1/demo/demo/{pipelineName}/env?id={pipelineID}",
		"setEnv" : "/pipeline/v1/demo/demo/{pipelineName}/env",
		"changeState" : "/pipeline/v1/demo/demo/{pipelineName}/state",
		"getToken" : "/pipeline/v1/demo/demo/{pipelineName}/token?id={pipelineID}"
	},
	"component" : {
		"list" : "/pipeline/v1/demo/component",
		"data" : "/pipeline/v1/demo/component/{componentName}?id={componentID}",
		"add" : "/pipeline/v1/demo/component",
		"save" : "/pipeline/v1/demo/component/{componentName}"
	},
	"history" : {
		"sequenceList" : "/pipeline/v1/demo/demo/histories",
		"sequenceData" : "/pipeline/v1/demo/demo/{pipelineName}/historyDefine?versionId={versionID}&sequenceId={pipelineSequenceID}",
		"action" : "/pipeline/v1/demo/demo/{pipelineName}/stage/{stageName}/{actionName}/history?actionLogId={actionLogID}",
		"relation" : "/pipeline/v1/demo/demo/{pipelineName}/{pipelineSequenceID}/lineHistory?startActionId={startActionId}&endActionId={endActionId}"
	}
}

// pipeline
export let pipelineApi = {
	"list" : function(){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.list,
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	},
	"data" : function(name,id){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.data.replace(/{pipelineName}/g, name).replace(/{pipelineID}/g, id),
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	},
	"add" : function(name,version){
		var data = JSON.stringify({
				"name":name,
				"version":version
			});
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.add,
	        "type": "POST",
	        "dataType": "json",
	        "data": data
	    });
	    return promise;
	},
	"save" : function(name,reqbody){
		var data = JSON.stringify(reqbody);
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.save.replace(/{pipelineName}/g, name),
	        "type": "PUT",
	        "dataType": "json",
	        "data": data
	    });
	    return promise;
	},
	"eventOutput" : function(name){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.eventOutput.replace(/{eventName}/g, name),
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	},
	"getEnv" : function(name,id){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.getEnv.replace(/{pipelineName}/g, name).replace(/{pipelineID}/g, id),
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	},
	"setEnv" : function(name,reqbody){
		var data = JSON.stringify(reqbody);
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.setEnv.replace(/{pipelineName}/g, name),
	        "type": "PUT",
	        "dataType": "json",
	        "data": data
	    });
	    return promise;
	},
	"changeState" : function(name,reqbody){
		var data = JSON.stringify(reqbody);
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.changeState.replace(/{pipelineName}/g, name),
	        "type": "PUT",
	        "dataType": "json",
	        "data": data
	    });
	    return promise;
	},
	"getToken" : function(name,id){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.pipeline.getToken.replace(/{pipelineName}/g, name).replace(/{pipelineID}/g, id),
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	}
}

// component
export let componentApi = {
	"list" : function(){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.component.list,
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	},
	"data" : function(name,id){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.component.data.replace(/{componentName}/g, name).replace(/{componentID}/g, id),
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	},
	"add" : function(name,version){
		var data = JSON.stringify({
				"name":name,
				"version":version
			});
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.component.add,
	        "type": "POST",
	        "dataType": "json",
	        "data": data
	    });
	    return promise;
	},
	"save" : function(name,reqbody){
		var data = JSON.stringify(reqbody);
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.component.save.replace(/{componentName}/g, name),
	        "type": "PUT",
	        "dataType": "json",
	        "data": data
	    });
	    return promise;
	}
}

// history
export let historyApi = {
	"sequenceData" : function(pipelineName,versionID,pipelineRunSequenceID){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.history.sequenceData.replace(/{pipelineName}/g, pipelineName).replace(/{versionID}/g, versionID).replace(/{pipelineSequenceID}/g, pipelineRunSequenceID),
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	},
	"sequenceList" : function () {
		var promise = $.ajax({
			"url" : apiUrlConf.host + apiUrlConf.history.sequenceList,
			"type" : "GET",
			"dataType" : "json",
			"cache": false
		});
		return promise;
	},
	"action" : function(pipelineName,stageName,actionName,actionLogID){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.history.action.replace(/{pipelineName}/g, pipelineName).replace(/{stageName}/g, stageName).replace(/{actionName}/g, actionName).replace(/{actionLogID}/g, actionLogID),
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	},
	"relation" : function(pipelineName,pipelineSequenceID,startActionId,endActionId){
		var promise = $.ajax({
	        "url": apiUrlConf.host + apiUrlConf.history.relation.replace(/{pipelineName}/g, pipelineName).replace(/{pipelineSequenceID}/g, pipelineSequenceID).replace(/{startActionId}/g, startActionId).replace(/{endActionId}/g, endActionId),
	        "type": "GET",
	        "dataType": "json",
	        "cache": false
	    });
	    return promise;
	}
}
<|endoftext|>