<commit_before>// title      : thumb
// author     : Gino Tubaro
// license    : MIT License
// description: just a thumb
// file       : palma.jscad
//!OpenSCAD
//Hay que parametrizara

include('lodash.js');

include("formulas.jscad");

include("node_modules/jscad-utils/jscad-utils.jscad");
include("node_modules/jscad-utils/jscad-utils-color.jscad");

include('node_modules/jscad-utils/jscad-utils-parts.jscad');
include('node_modules/jscad-utils/jscad-boxes.jscad');

include("tornillotuerca.jscad");

var result,xbo;
var long=60;
var alto=10;
var muneca=15;
var pinconector=2;
var tornilloconector=3;
var pulgar =1;
function main()
{
  util.init(CSG);
  var palma = palmagenerator(alto, long, muneca,pulgar);
  return palma;
}

function slider() {

  var o = new Array();
  var g = new Array();
  var e = new Array();
  var largo=20;
  var last=1;
  var long=0;

  o.push(circle({r:10, center:true}).translate([alto,0,0]));
  o.push(circle({r:10, center:true}).translate([-alto,0,0]));
  o.push(square({size: [40,10], center: true}).translate([0, 5, 0]));

  g.push(linear_extrude({ height: 5 }, hull(o)).translate([0, 0, 0]));

  var todo = union(
    Parts.Triangle(5, 50).translate([0, -1, -1]),
    Parts.Triangle(5, 50).translate([5, -1, -1]),
    cube({size: [5, 10, 50], center: [true, true, false]}).translate([2.5, -6, 0])
  );

  todo= union(g).subtract(todo.rotateX(-90).rotateZ(90).snap(union(g), 'x', 'inside-').translate([-1, -1, 0]));
  todo= todo.subtract(cylinder({r: 1, h: 20, center: true}).rotateX(-90).snap(todo, 'x', 'center-').translate([-1,0, 2]));

  return todo;

}

function bajorelieve(height,prof) {

  var h = hull(
    square({size: [30,1], center: true}).translate([0, height,0 ]),
    circle({r: 15, center: true}).translate([0,height/6,0])
  );
  var tapa = linear_extrude({ height: prof }, h);

  return tapa.rotateX(90);

}

function conectores(alto) {
  var o = new Array();
  o.push(cube({size: [100, 2, alto/3], center: [true, true, true]}).translate([0, 2, alto/3]));
  o.push(cube({size: [100, 2, alto/3], center: [true, true, true]}).translate([0, -2, alto/3]));
  o.push(cylinder({r: 2.75, h: alto, center: [true, true, true]}).rotateX(90).rotateZ(90).translate([0, 5, alto-5]));

  return union(o);
}
function contornos(alto) {
  var o = new Array();
  o.push(cylinder({r: 10, h: alto, center: [true, true, true]}).rotateX(90).rotateZ(90).translate([0, -10, alto]));
  o.push(cylinder({r: 15, h: alto, center: [true, true, true]}).rotateX(90).translate([0, -10, alto-5]));
  return union(o);
}
function cuerpito(h,ancho) {
  var o = new Array();
  o.push(circle({r:10, center:true}).translate([ancho,0,0]));
  o.push(circle({r:10, center:true}).translate([-ancho,0,0]));
  o.push(square({size: [40,10], center: true}).translate([0, 5, 0]));
  o.push(square({size:[40,40], center:true}).translate([0, 20, 0]))
  o = linear_extrude({ height: h }, hull(o));

  return o.scale([0.75,0.7,2]);
}

  function palmagenerator(ancho, height,muneca,pulgar) {

    var cag = CAG.fromPoints([
      [-1, -1, 0],
      [1, -1, 0],
      [1, 1, 0]
    ]).expand(1, CSG.defaultResolution2D);

    var flatBottom = CSG.Polygon.createFromPoints(
      cag.getOutlinePaths()[0].points
    );

    var thing = flatBottom.solidFromSlices({
      numslices: height
      ,callback: function(t) {
        var coef = t;
        var o = new Array();
        if (coef < 0.01) coef = 0.01;//must not collapse polygon
        var h = height*t;
        var y = 0;
        //var e = 1/(Math.sqrt(1+(Math.pow(coef*0.01,3)))); //Hay que hacer una parabola para limitar el comienzo y final dl pulgar
        var b = 10+Math.sin(coef*4);
        o.push(circle({r:b, center:true}).translate([ancho,0,0]));
        o.push(circle({r:b, center:true}).translate([-ancho,0,0]));
          if (pulgar) {

            if ((h>=height/7)&&(h<=(height*2/3))){

              var vals = calculate(height/7,height*2/3,height/5,0);
              x = (vals[0]*Math.pow(h,2)) + (vals[1]*h) + vals[2];
              //console.log("h es"+h+" x es"+x+"hola"+((height/6)-(height*2/3)));
              o.push(circle({r: x, center: true}).translate([17, 9, 0]))

            //  o.push(circle({r:y, center:true}).translate([17,9,0]));

            }

            /*
            if ((h>=height/6)&&(h<=(height*2/3))){
              y=(h-height/6)*(h-(height*2/3))*0.6+2;
              o.push(circle({r:y/10, center:true}).translate([17,9,0]));

            };
            */
          }

        o.push(square({size: [40,10], center: true}).translate([0, 5, 0]));

        cag =  hull(o); //.expand(1,CSG.defaultResolution2D)

        var cage = CAG.circle({
          center: [0,0],
          ancho: 3*Math.sin(coef*1.2),
          resolution: 32
        }).expand(1, CSG.defaultResolution2D);

        var cags = CAG.fromPoints([
          [-1, -1, h],
          [1, -1, h],
          [1 , 1, h],
          [-1, 1, h]
        ]).expand(1, CSG.defaultResolution2D);

        return CSG.Polygon.createFromPoints(
          cag.getOutlinePaths()[0].points
        ).translate([0, 0, h]);
      }
    });

    var palma=
    difference(
      union(thing,slider().mirroredZ()).fillet(3,'z+'),
      cuerpito(height,ancho),
      conectores(height),
      contornos(height)

    );
    function oppulgar() {
      var cubo = new Array();

      cubo.push(cube({size: [3.5, 10, 28], center: [true, false, false]})
      .snap(palma,'y','outside-')
      .translate([18, -8, 0])
    );

    return union(cubo);
  }

  //  palma= palma.snap(bajorelieve(height), 'x', 'center-');
  todo= bajorelieve(height,8)
  .snap(palma, 'y', 'outside+')
  .translate([0, 3, height/3]);

  todo=difference(palma,todo,oppulgar());

    todo=
    union(
      difference(
        todo,

        cylinder({r: 3, h: 5, center: [true, true, true]}) //cilindrotapa
        .rotateY(90)
        .rotateZ(90)
        .snap(todo,'y','outside+')
        .translate([0, 4, (height/2.5)+5]),

        cylinder({r: 2.75, h: muneca/2, center: [true, true, true]})
        .rotateY(90)
        .snap(palma,'y','outside-')
        .snap(palma,'x','outside-')
        .translate([-6.25, -9, height/2.5]),

        cube({size: [10, 10, 100], center: [true, false, false]}) //Cubo que "limpia" el borde derecho
        .translate([-20, 10, 0])

      ),
      tornillotuerca(4,2.5)[0]//tuerca de tapa
      .rotateX(90)
      .snap(todo,'y','outside+')
      .translate([0, 4, (height/2.5)+5]),

      tornillotuerca(5,1.75)[0] //tuerca de pulgar
      .rotateY(90)
      .snap(palma,'y','outside-')
      .snap(palma,'x','outside-')
      .translate([-6.25, -9, height/2.5])

    )
    return todo;

  }
<commit_msg>Tornillotuerca escondido<commit_after>// title      : thumb
// author     : Gino Tubaro
// license    : MIT License
// description: just a thumb
// file       : palma.jscad
//!OpenSCAD
//Hay que parametrizara

include('lodash.js');

include("formulas.jscad");

include("node_modules/jscad-utils/jscad-utils.jscad");
include("node_modules/jscad-utils/jscad-utils-color.jscad");

include('node_modules/jscad-utils/jscad-utils-parts.jscad');
include('node_modules/jscad-utils/jscad-boxes.jscad');

include("tornillotuerca.jscad");

var result,xbo;
var long=60;
var alto=10;
var muneca=15;// nada
var pinconector=2;
var tornilloconector=3;
var pulgar =1;
function main()
{
	util.init(CSG);
	var palma = palmagenerator(alto, long, muneca,pulgar);
	return palma;
}

function slider() {

	var o = new Array();
	var g = new Array();
	var e = new Array();
	var largo=20;
	var last=1;
	var long=0;

	o.push(circle({r:10, center:true}).translate([alto,0,0]));
	o.push(circle({r:10, center:true}).translate([-alto,0,0]));
	o.push(square({size: [40,10], center: true}).translate([0, 5, 0]));

	g.push(linear_extrude({ height: 5 }, hull(o)).translate([0, 0, 0]));

	var todo = union(
		Parts.Triangle(5, 50).translate([0, -1, -1]),
		Parts.Triangle(5, 50).translate([5, -1, -1]),
		cube({size: [5, 10, 50], center: [true, true, false]}).translate([2.5, -6, 0])
	);

	todo= union(g).subtract(todo.rotateX(-90).rotateZ(90).snap(union(g), 'x', 'inside-').translate([-1, -1, 0]));
	todo= todo.subtract(cylinder({r: 1, h: 20, center: true}).rotateX(-90).snap(todo, 'x', 'center-').translate([-1,0, 2]));

	return todo;

}

function bajorelieve(height,prof) {

	var h = hull(
		square({size: [30,1], center: true}).translate([0, height,0 ]),
		circle({r: 15, center: true}).translate([0,height/6,0])
	);
	var tapa = linear_extrude({ height: prof }, h);

	return tapa.rotateX(90);

}

function conectores(alto) {
	var o = new Array();
	o.push(cube({size: [100, 2, alto/3], center: [true, true, true]}).translate([0, 2, alto/3]));
	o.push(cube({size: [100, 2, alto/3], center: [true, true, true]}).translate([0, -2, alto/3]));
	o.push(cylinder({r: 2.75, h: alto, center: [true, true, true]}).rotateX(90).rotateZ(90).translate([0, 5, alto-5]));

	return union(o);
}
function contornos(alto) {
	var o = new Array();
	o.push(cylinder({r: 10, h: alto, center: [true, true, true]}).rotateX(90).rotateZ(90).translate([0, -10, alto]));
	o.push(cylinder({r: 15, h: alto, center: [true, true, true]}).rotateX(90).translate([0, -10, alto-5]));
	return union(o);
}
function cuerpito(h,ancho) {
	var o = new Array();
	o.push(circle({r:10, center:true}).translate([ancho,0,0]));
	o.push(circle({r:10, center:true}).translate([-ancho,0,0]));
	o.push(square({size: [40,10], center: true}).translate([0, 5, 0]));
	o.push(square({size:[40,40], center:true}).translate([0, 20, 0]))
	o = linear_extrude({ height: h }, hull(o));

	return o.scale([0.75,0.7,2]);
}

function palmagenerator(ancho, height,muneca,pulgar) {

	var cag = CAG.fromPoints([
		[-1, -1, 0],
		[1, -1, 0],
		[1, 1, 0]
	]).expand(1, CSG.defaultResolution2D);

	var flatBottom = CSG.Polygon.createFromPoints(
		cag.getOutlinePaths()[0].points
	);

	var thing = flatBottom.solidFromSlices({
		numslices: height
		,callback: function(t) {
			var coef = t;
			var o = new Array();
			if (coef < 0.01) coef = 0.01;//must not collapse polygon
			var h = height*t;
			var y = 0;
			//var e = 1/(Math.sqrt(1+(Math.pow(coef*0.01,3)))); //Hay que hacer una parabola para limitar el comienzo y final dl pulgar
			var b = 10+Math.sin(coef*4);
			o.push(circle({r:b, center:true}).translate([ancho,0,0]));
			o.push(circle({r:b, center:true}).translate([-ancho,0,0]));
			if (pulgar) {

				if ((h>=height/7)&&(h<=(height*2/3))){

					var vals = calculate(height/7,height*2/3,height/5,0);
					x = (vals[0]*Math.pow(h,2)) + (vals[1]*h) + vals[2];
					//console.log("h es"+h+" x es"+x+"hola"+((height/6)-(height*2/3)));
					o.push(circle({r: x, center: true}).translate([17, 9, 0]))

					//  o.push(circle({r:y, center:true}).translate([17,9,0]));

				}

				/*
				if ((h>=height/6)&&(h<=(height*2/3))){
				y=(h-height/6)*(h-(height*2/3))*0.6+2;
				o.push(circle({r:y/10, center:true}).translate([17,9,0]));

			};
			*/
		}

		o.push(square({size: [40,10], center: true}).translate([0, 5, 0]));

		cag =  hull(o); //.expand(1,CSG.defaultResolution2D)

		var cage = CAG.circle({
			center: [0,0],
			ancho: 3*Math.sin(coef*1.2),
			resolution: 32
		}).expand(1, CSG.defaultResolution2D);

		var cags = CAG.fromPoints([
			[-1, -1, h],
			[1, -1, h],
			[1 , 1, h],
			[-1, 1, h]
		]).expand(1, CSG.defaultResolution2D);

		return CSG.Polygon.createFromPoints(
			cag.getOutlinePaths()[0].points
		).translate([0, 0, h]);
	}
});

var palma=
difference(
	union(thing,slider().mirroredZ()).fillet(3,'z+'),
	cuerpito(height,ancho),
	conectores(height),
	contornos(height)

);
function oppulgar() {
	var cubo = new Array();

	cubo.push(cube({size: [3.5, 10, 28], center: [true, false, false]})
	.snap(palma,'y','outside-')
	.translate([18, -8, 0])
);

return union(cubo);
}

//  palma= palma.snap(bajorelieve(height), 'x', 'center-');
todo= bajorelieve(height,8)
.snap(palma, 'y', 'outside+')
.translate([0, 3, height/3]);

todo=difference(palma,todo,oppulgar());
var todosin=todo;
todo=
union(
	difference(
		todo,

		cylinder({r: 3, h: 5, center: [true, true, true]}) //cilindrotapa
		.rotateY(90)
		.rotateZ(90)
		.snap(todo,'y','outside+')
		.translate([0, 4, (height/2.5)+5]),

		cylinder({r: 2.75, h: muneca/2, center: [true, true, true]})
		.rotateY(90)
		.snap(palma,'y','outside-')
		.snap(palma,'x','outside-')
		.translate([-6.25, -9, height/2.5]),

		cube({size: [10, 10, 100], center: [true, false, false]}) //Cubo que "limpia" el borde derecho
		.translate([-20, 10, 0])

	),

	tornillotuerca(5,1.75)[0] //tuerca de pulgar
	.rotateY(90)
	.snap(palma,'y','outside-')
	.snap(palma,'x','outside-')
	.translate([-6.25, -9, height/2.5])
)

todosin=
union(
	todosin,
	cylinder({r: 3, h: 5, center: [true, true, true]}) //cilindrotapa
	.rotateY(90)
	.rotateZ(90)
	.snap(todo,'y','outside+')
	.translate([0, 4, (height/2.5)+5]),

	tornillotuerca(4,2.5)[0]//tuerca de tapa
	.rotateX(90)
	.snap(todo,'y','outside+')
	.translate([0, 4, (height/2.5)+5])
);
caca=
difference(cylinder({r:5, h:8, center:[true,true,true]})//tuerca de tapa
.rotateY(90)
.snap(palma,'y','outside-')
.snap(palma,'x','outside-')
.translate([-6.25, -9, height/2.5])
,todosin);
todo =
difference(
	union(
		todo,
		cylinder({r:4, h:2.5, center:[true,true,true]})//tuerca de tapa
		.rotateX(90)
		.snap(todo,'y','outside+')
		.translate([0, 4, (height/2.5)+5])
	),
caca
);

return todo;//difference(todo,difference(todo,todosin));

}
<|endoftext|>


<commit_before>import React, { Component } from 'react';
import classnames from 'classnames';
import { deSig, uxToHex } from '/lib/util';
import { Route, Link } from "react-router-dom";

import { LoadingScreen } from './loading';
import { LinksTabBar } from '/components/lib/links-tabbar';
import SidebarSwitcher from './lib/icons/icon-sidebar-switch';
import { makeRoutePath } from '../lib/util';

export class SettingsScreen extends Component {
  constructor(props) {
    super(props);

    this.state = {
      isLoading: false,
      title: "",
      description: "",
      color: ""
    };

    this.changeTitle = this.changeTitle.bind(this);
    this.changeDescription = this.changeDescription.bind(this);
    this.changeColor = this.changeColor.bind(this);
    this.submitColor = this.submitColor.bind(this);
    this.renderDelete = this.renderDelete.bind(this);
    this.renderMetadataSettings = this.renderMetadataSettings.bind(this);
  }

  componentDidMount() {
    if ((this.props.resource) && ("metadata" in this.props.resource)) {
      this.setState({
        title: this.props.resource.metadata.title,
        description: this.props.resource.metadata.description,
        color: `#${uxToHex(this.props.resource.metadata.color || '0x0')}`
      });
    }
  }

  componentDidUpdate(prevProps, prevState) {
    const { props, state } = this;

    if (!!state.isLoading && !props.resource) {
      this.setState({
        isLoading: false
      }, () => {
        api.setSpinner(false);
        props.history.push('/~link');
      });
    }

    if (((props.resource) && ("metadata" in props.resource))
      && (prevProps !== props)) {
      this.setState({
        title: props.resource.metadata.title,
        description: props.resource.metadata.description,
        color: `#${uxToHex(this.props.resource.metadata.color || '0x0')}`
      });
    }
  }

  changeTitle() {
    this.setState({title: event.target.value})
  }

  changeDescription() {
    this.setState({description: event.target.value});
  }

  changeColor() {
    this.setState({color: event.target.value});
  }

  submitColor() {
    const { props, state } = this;
    const { resource } = props;

    if (!("metadata" in resource)) {
      resource.metadata = {};
    }

    //submit color if valid
    let color = state.color;
    if (color.startsWith("#")) {
      color = state.color.substr(1);
    }
    let hexExp = /([0-9A-Fa-f]{6})/
    let hexTest = hexExp.exec(color);
    let currentColor = "000000";
    if (props.resource && "metadata" in props.resource) {
      currentColor = uxToHex(props.resource.metadata.color);
    }
    if (hexTest && (hexTest[1] !== currentColor)) {
      if (props.amOwner) {
        api.setSpinner(true);
        api.metadataAdd(
          props.resourcePath,
          props.groupPath,
          resource.metadata.title,
          resource.metadata.description,
          resource.metadata['date-created'],
          color
        ).then(() => {
          api.setSpinner(false);
        });
      }
    }
  }

  removeCollection() {
    const { props, state } = this;

    api.setSpinner(true);
    this.setState({
      isLoading: true
    });
    api.removeCollection(props.resourcePath)
    .then(() => {
      this.setState({
        isLoading: false
      });
      api.setSpinner(false);
    });
  }

  deleteCollection() {
    const { props, state } = this;

    api.setSpinner(true);
    this.setState({
      isLoading: true
    });
    api.deleteCollection(props.resourcePath)
    .then(() => {
      this.setState({
        isLoading: false
      });
      api.setSpinner(false);
    });
  }

  markAllAsSeen() {
    api.seenLink(this.props.resourcePath);
  }

  renderRemove() {
    const { props, state } = this;

    return (

Remove Collection

          Remove this collection from your collection list.

          Remove collection

    );
  }

  renderDelete() {
    const { props, state } = this;

    if (!props.amOwner) {
      return null;
    } else {
      return (

Delete Collection

            Delete this collection, for you and all group members.

            Delete collection

      );
    }
  }

  renderMetadataSettings() {
    const { props, state } = this;
    const { resource } = props;

    if (!("metadata" in resource)) {
      resource.metadata = {};
    }

    return(

Rename

Change the name of this collection

          <input
            className={"f8 ba b--gray3 b--gray2-d bg-gray0-d white-d " +
            "focus-b--black focus-b--white-d pa3 db w-100 flex-auto mr3"}
            value={this.state.title}
            disabled={!props.amOwner}
            onChange={this.changeTitle}
            onBlur={() => {
              if (props.amOwner) {
                api.setSpinner(true);
                api.metadataAdd(
                  props.resourcePath,
                  props.groupPath,
                  state.title,
                  resource.metadata.description,
                  resource.metadata['date-created'],
                  uxToHex(resource.metadata.color)
                ).then(() => {
                  api.setSpinner(false);
                });
              }
            }}
          />

Change description

            Change the description of this collection

            <input
              className={"f8 ba b--gray3 b--gray2-d bg-gray0-d white-d " +
                "focus-b--black focus-b--white-d pa3 db w-100 flex-auto mr3"}
              value={this.state.description}
              disabled={!props.amOwner}
              onChange={this.changeDescription}
              onBlur={() => {
                if (props.amOwner) {
                  api.setSpinner(true);
                  api.metadataAdd(
                    props.resourcePath,
                    props.groupPath,
                    resource.metadata.title,
                    state.description,
                    resource['date-created'],
                    uxToHex(resource.color)
                  ).then(() => {
                    api.setSpinner(false);
                  });
                }
              }}
            />

Change color

Give this collection a color when viewing group channels

            <input
              className={"pl7 f8 ba b--gray3 b--gray2-d bg-gray0-d white-d " +
                "focus-b--black focus-b--white-d pa3 db w-100 flex-auto mr3"}
              value={this.state.color}
              disabled={!props.amOwner}
              onChange={this.changeColor}
              onBlur={this.submitColor}
            />

    )
  }

  render() {
    const { props, state } = this;
    const isinPopout = this.props.popout ? "popout/" : "";

    let writeGroup = Array.from(props.group.values());

    if (props.groupPath === undefined) {
      return <LoadingScreen/>;
    }

    if (!!state.isLoading) {
      return (

            <Link to="/~link">{"⟵ All Collections"}</Link>

            <SidebarSwitcher
              sidebarShown={this.props.sidebarShown}
              popout={this.props.popout}
            />
            <Link to={makeRoutePath(props.resourcePath, props.popout)}
            className="pt2 white-d">

                {props.resource.metadata.title}

            </Link>
            <LinksTabBar {...props}/>

Removing...

      );
    }

    return (

          <Link to="/~link">{"⟵ All Collections"}</Link>

          <SidebarSwitcher
            sidebarShown={this.props.sidebarShown}
            popout={this.props.popout}
          />
          <Link to={makeRoutePath(props.resourcePath, props.popout)}
          className="pt2">

              {props.resource.metadata.title}

          </Link>
          <LinksTabBar {...props}/>

Collection Settings

Mark all links as read

Mark all links in this collection as read.

           this.markAllAsSeen}>
              Mark all as read

          {this.renderRemove()}
          {this.renderDelete()}
          {this.renderMetadataSettings()}

    );
  }
}<commit_msg>link: fix api call to change description<commit_after>import React, { Component } from 'react';
import classnames from 'classnames';
import { deSig, uxToHex } from '/lib/util';
import { Route, Link } from "react-router-dom";

import { LoadingScreen } from './loading';
import { LinksTabBar } from '/components/lib/links-tabbar';
import SidebarSwitcher from './lib/icons/icon-sidebar-switch';
import { makeRoutePath } from '../lib/util';

export class SettingsScreen extends Component {
  constructor(props) {
    super(props);

    this.state = {
      isLoading: false,
      title: "",
      description: "",
      color: ""
    };

    this.changeTitle = this.changeTitle.bind(this);
    this.changeDescription = this.changeDescription.bind(this);
    this.changeColor = this.changeColor.bind(this);
    this.submitColor = this.submitColor.bind(this);
    this.renderDelete = this.renderDelete.bind(this);
    this.renderMetadataSettings = this.renderMetadataSettings.bind(this);
  }

  componentDidMount() {
    if ((this.props.resource) && ("metadata" in this.props.resource)) {
      this.setState({
        title: this.props.resource.metadata.title,
        description: this.props.resource.metadata.description,
        color: `#${uxToHex(this.props.resource.metadata.color || '0x0')}`
      });
    }
  }

  componentDidUpdate(prevProps, prevState) {
    const { props, state } = this;

    if (!!state.isLoading && !props.resource) {
      this.setState({
        isLoading: false
      }, () => {
        api.setSpinner(false);
        props.history.push('/~link');
      });
    }

    if (((props.resource) && ("metadata" in props.resource))
      && (prevProps !== props)) {
      this.setState({
        title: props.resource.metadata.title,
        description: props.resource.metadata.description,
        color: `#${uxToHex(this.props.resource.metadata.color || '0x0')}`
      });
    }
  }

  changeTitle() {
    this.setState({title: event.target.value})
  }

  changeDescription() {
    this.setState({description: event.target.value});
  }

  changeColor() {
    this.setState({color: event.target.value});
  }

  submitColor() {
    const { props, state } = this;
    const { resource } = props;

    if (!("metadata" in resource)) {
      resource.metadata = {};
    }

    //submit color if valid
    let color = state.color;
    if (color.startsWith("#")) {
      color = state.color.substr(1);
    }
    let hexExp = /([0-9A-Fa-f]{6})/
    let hexTest = hexExp.exec(color);
    let currentColor = "000000";
    if (props.resource && "metadata" in props.resource) {
      currentColor = uxToHex(props.resource.metadata.color);
    }
    if (hexTest && (hexTest[1] !== currentColor)) {
      if (props.amOwner) {
        api.setSpinner(true);
        api.metadataAdd(
          props.resourcePath,
          props.groupPath,
          resource.metadata.title,
          resource.metadata.description,
          resource.metadata['date-created'],
          color
        ).then(() => {
          api.setSpinner(false);
        });
      }
    }
  }

  removeCollection() {
    const { props, state } = this;

    api.setSpinner(true);
    this.setState({
      isLoading: true
    });
    api.removeCollection(props.resourcePath)
    .then(() => {
      this.setState({
        isLoading: false
      });
      api.setSpinner(false);
    });
  }

  deleteCollection() {
    const { props, state } = this;

    api.setSpinner(true);
    this.setState({
      isLoading: true
    });
    api.deleteCollection(props.resourcePath)
    .then(() => {
      this.setState({
        isLoading: false
      });
      api.setSpinner(false);
    });
  }

  markAllAsSeen() {
    api.seenLink(this.props.resourcePath);
  }

  renderRemove() {
    const { props, state } = this;

    return (

Remove Collection

          Remove this collection from your collection list.

          Remove collection

    );
  }

  renderDelete() {
    const { props, state } = this;

    if (!props.amOwner) {
      return null;
    } else {
      return (

Delete Collection

            Delete this collection, for you and all group members.

            Delete collection

      );
    }
  }

  renderMetadataSettings() {
    const { props, state } = this;
    const { resource } = props;

    if (!("metadata" in resource)) {
      resource.metadata = {};
    }

    return(

Rename

Change the name of this collection

          <input
            className={"f8 ba b--gray3 b--gray2-d bg-gray0-d white-d " +
            "focus-b--black focus-b--white-d pa3 db w-100 flex-auto mr3"}
            value={this.state.title}
            disabled={!props.amOwner}
            onChange={this.changeTitle}
            onBlur={() => {
              if (props.amOwner) {
                api.setSpinner(true);
                api.metadataAdd(
                  props.resourcePath,
                  props.groupPath,
                  state.title,
                  resource.metadata.description,
                  resource.metadata['date-created'],
                  uxToHex(resource.metadata.color)
                ).then(() => {
                  api.setSpinner(false);
                });
              }
            }}
          />

Change description

            Change the description of this collection

            <input
              className={"f8 ba b--gray3 b--gray2-d bg-gray0-d white-d " +
                "focus-b--black focus-b--white-d pa3 db w-100 flex-auto mr3"}
              value={this.state.description}
              disabled={!props.amOwner}
              onChange={this.changeDescription}
              onBlur={() => {
                if (props.amOwner) {
                  api.setSpinner(true);
                  api.metadataAdd(
                    props.resourcePath,
                    props.groupPath,
                    resource.metadata.title,
                    state.description,
                    resource.metadata['date-created'],
                    uxToHex(resource.metadata.color)
                  ).then(() => {
                    api.setSpinner(false);
                  });
                }
              }}
            />

Change color

Give this collection a color when viewing group channels

            <input
              className={"pl7 f8 ba b--gray3 b--gray2-d bg-gray0-d white-d " +
                "focus-b--black focus-b--white-d pa3 db w-100 flex-auto mr3"}
              value={this.state.color}
              disabled={!props.amOwner}
              onChange={this.changeColor}
              onBlur={this.submitColor}
            />

    )
  }

  render() {
    const { props, state } = this;
    const isinPopout = this.props.popout ? "popout/" : "";

    let writeGroup = Array.from(props.group.values());

    if (props.groupPath === undefined) {
      return <LoadingScreen/>;
    }

    if (!!state.isLoading) {
      return (

            <Link to="/~link">{"⟵ All Collections"}</Link>

            <SidebarSwitcher
              sidebarShown={this.props.sidebarShown}
              popout={this.props.popout}
            />
            <Link to={makeRoutePath(props.resourcePath, props.popout)}
            className="pt2 white-d">

                {props.resource.metadata.title}

            </Link>
            <LinksTabBar {...props}/>

Removing...

      );
    }

    return (

          <Link to="/~link">{"⟵ All Collections"}</Link>

          <SidebarSwitcher
            sidebarShown={this.props.sidebarShown}
            popout={this.props.popout}
          />
          <Link to={makeRoutePath(props.resourcePath, props.popout)}
          className="pt2">

              {props.resource.metadata.title}

          </Link>
          <LinksTabBar {...props}/>

Collection Settings

Mark all links as read

Mark all links in this collection as read.

           this.markAllAsSeen}>
              Mark all as read

          {this.renderRemove()}
          {this.renderDelete()}
          {this.renderMetadataSettings()}

    );
  }
}<|endoftext|>


<commit_before>function setUpApp(bootstrapApp) {

	window.stompClient = Stomp.over(new SockJS(appConfig.webService+"/connect", null, {protocols_whitelist: appConfig.sockJsConnectionType}));

	var jwt = getJWT();

	document.getElementsByTagName("base")[0].href = appConfig.base;

	if(!appConfig.stompDebug) {
		window.stompClient.debug = null;
	}

	if(jwt) {
		if(!sessionStorage.token) {
			sessionStorage.token = jwt;
		}

		connect({"jwt": sessionStorage.token});

	} else {
		if(appConfig.allowAnonymous) {
			sessionStorage.role = "ROLE_ANONYMOUS";

			connect({});
		}
		else {
			if(appConfig.mockRole) {
				window.open(appConfig.authService + "/token?referer="+location.href + "&mock=" + appConfig.mockRole, "_self");
			}
			else {
				window.open(appConfig.authService + "/token?referer="+location.href, "_self");
			}
		}
	}

	function connect(headers) {
		angular.element(document).ready(function() {
			window.stompClient.connect(headers, function() {
		  		bootstrapApp();
			});
		});
	}

	function getJWT() {

		if(sessionStorage.token) {
			return sessionStorage.token;
		}

		var queriesString = location.search;

		if(typeof(queriesString) == "undefined") {
			return null;
		}

		var queries = queriesString.substring(1).split("&");

		var jwt = null;

		for(var key in queries) {
			var queryString = queries[key];
			var query = queryString.split("=");
			if(query[0] == "jwt") jwt = query[1];

		}

		if(jwt) {
			var uri = location.toString();
			if (uri.indexOf("?") > 0) {
			    var clean_uri = uri.substring(0, uri.indexOf("?"));
			    history.replaceState({}, document.title, clean_uri);
			}
		}

		return jwt;
	}

}
<commit_msg>Replace deprecated protocol with newer transport.<commit_after>function setUpApp(bootstrapApp) {

	window.stompClient = Stomp.over(new SockJS(appConfig.webService+"/connect", null, {transports: appConfig.sockJsConnectionType}));

	var jwt = getJWT();

	document.getElementsByTagName("base")[0].href = appConfig.base;

	if(!appConfig.stompDebug) {
		window.stompClient.debug = null;
	}

	if(jwt) {
		if(!sessionStorage.token) {
			sessionStorage.token = jwt;
		}

		connect({"jwt": sessionStorage.token});

	} else {
		if(appConfig.allowAnonymous) {
			sessionStorage.role = "ROLE_ANONYMOUS";

			connect({});
		}
		else {
			if(appConfig.mockRole) {
				window.open(appConfig.authService + "/token?referer="+location.href + "&mock=" + appConfig.mockRole, "_self");
			}
			else {
				window.open(appConfig.authService + "/token?referer="+location.href, "_self");
			}
		}
	}

	function connect(headers) {
		angular.element(document).ready(function() {
			window.stompClient.connect(headers, function() {
		  		bootstrapApp();
			});
		});
	}

	function getJWT() {

		if(sessionStorage.token) {
			return sessionStorage.token;
		}

		var queriesString = location.search;

		if(typeof(queriesString) == "undefined") {
			return null;
		}

		var queries = queriesString.substring(1).split("&");

		var jwt = null;

		for(var key in queries) {
			var queryString = queries[key];
			var query = queryString.split("=");
			if(query[0] == "jwt") jwt = query[1];

		}

		if(jwt) {
			var uri = location.toString();
			if (uri.indexOf("?") > 0) {
			    var clean_uri = uri.substring(0, uri.indexOf("?"));
			    history.replaceState({}, document.title, clean_uri);
			}
		}

		return jwt;
	}

}
<|endoftext|>


<commit_before>// View model for the page
function pageViewModel(gvm) {
    // Page specific i18n bindings
    gvm.app  = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("WorksheetNameRapport");}, gvm);
    gvm.title = ko.computed(function (){i18n.setLocale(gvm.lang()); return gvm.app() + ' - ' + i18n.__("HomeRapportTitle");}, gvm);
    gvm.projectname = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("ProjectRapportName");}, gvm);
    gvm.homeManual = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("WorksheetRapportManual");}, gvm);

    gvm.availableCourses = ko.observableArray([]);

    gvm.selectCourse = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("SelectCourse");}, gvm);
    gvm.addBtn = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("AddBtn")}, gvm);
    gvm.tabledata = ko.observableArray([]);

     // Table i18n bindings
    gvm.werkficheID = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("werkficheID");}, gvm);
    gvm.werkficheName = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("werkficheName");}, gvm);
    gvm.werkficheAction = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("werkficheAction");}, gvm);

    gvm.currentCourseId = null;

    gvm.updateCourseRapport = function() {
        $.getJSON('/api/coursedrop', function(data) {
            gvm.availableCourses.removeAll();
            $.each(data, function(i, item) {
                //  Put item in list
                gvm.availableCourses.push(item);

                // Add listener to listitem
                $("#coursebtn-" + item.id).click(function(){
                    gvm.currentCourseId = item.id;
                    $(".btn-courseRapport span:first").text($(this).text());
                    loadTablePage(1);
                });
            });
        });
    };

    gvm.addTableData = function(id, name) {
        // Push data
        var tblOject = {tid: id, tname: name};
        gvm.tabledata.push(tblOject);

        $('#removebtn-' + id).bind('click', function(event, data){
            deleteTableItem(id, tblOject);
            event.stopPropagation();
        });

        $('#editbtn-' + id).bind('click', function(event, data){
            showEditWorksheetModal(id, name);
            event.stopPropagation();
        });

        $('#copybtn-' + id).bind('click', function(event, data){
            copyTableItem(id, tblOject);
            event.stopPropagation();
        });
    }

    gvm.clearTable = function() {
        gvm.tabledata.removeAll();
    }
}

function addNewWorksheet(serialData, courseid, callback) {
    $.ajax({
        url: "/api/addworksheet/" + courseid,
        type: "POST",
        data: serialData,
        success: function(data) {
            /*$.ajax({
                url: "/api/worksheet/" + data['id'] + "/" + data["Name"],
                type: "GET",
                success: function(data) {
                    //loadTablePage(1);
                    callback(true);
                }
            })*/
            console.log(data["id"] + ", " + data["name"]);
        },
        error: function(data) {
            callback(false);
        }
    });
}

function updateWorksheet(id, serialData, callback) {
    $.ajax({
        url: "/api/updateworksheet/" + id,
        type: "PUT",
        data: serialData,
        success: function(data) {
            loadTablePage(1);
            callback(true);
        },
        error: function(data) {
            callback(false);
        }
    });
}

function copyTableItem(id, tblObject) {
    /*showYesNoModal("Bent u zeker dat u dit item wil kopiëren? ", function(val){
        if(val){
            $.ajax({
                url: "/api/coursecopy/" + id,
                type: "post"

            });
        }
    });*/
}

function deleteTableItem(id, tblOject) {
    showYesNoModal("Bent u zeker dat u dit item wil verwijderen? \r\n Let op: verwijderde items blijven in het systeem en kunnen weer actief gezet worden door een administrator. \r\n Gelieve de administrator te contacteren om een vak definitief te verwijderen.", function(val){
        if(val){
            $.ajax({
                url: "/api/deleteworksheet/" + id,
                type: "DELETE",
                success: function() {
                    viewModel.tabledata.remove(tblOject);
                }
            });
        }
    });
}

function showNewWorksheetModal() {
    resetGeneralModal();
    setGeneralModalTitle(i18n.__("AddNewWorksheet"));
    setGeneralModalBody('<form id="newworksheetform"> \

 \
                <input type="text" class="form-control input-lg" placeholder="' + i18n.__('NameTableTitle') + '" " name="name"> \

 \
            </form>' );

    addGeneralModalButton(i18n.__("AddBtn"), function(){
       addNewWorksheet($('#newworksheetform').serialize(), viewModel.currentCourseId, function(result){
            hideModal();
        });
    });

    showGeneralModal();
}

function showEditWorksheetModal(id, name)
{
    resetGeneralModal();
    setGeneralModalTitle(i18n.__("EditWorksheet"));
    setGeneralModalBody('<form id="updateworksheetform"> \

 \
                <input type="text" class="form-control input-lg" placeholder="' + i18n.__('NameTableTitle') + '" " name="name" value="' + name + '"> \

 \
        </form>');
    $.getJSON()

    addGeneralModalButton(i18n.__("SaveBtn"), function(){
        updateWorksheet(id, $('#updateworksheetform').serialize(), function(result){
            hideModal();
        });
    });

    addGeneralModalButton(i18n.__("CancelBtn"), function(){
        hideModal();
    })

    showGeneralModal();
}

function loadTablePage(pagenr)
{
    $.getJSON('/api/worksheets/page/' + pagenr + '/' + viewModel.currentCourseId, function(data){

        /* Clear current table page */
        viewModel.clearTable();

        // Load table data
        $.each(data.data, function(i, item) {
            viewModel.addTableData(item.id, item.Name);
        });

        /* Let previous en next buttons work */
        if(data.prev == "none"){
            $('#pager-prev-btn').addClass('disabled');
        } else {
            $('#pager-prev-btn').removeClass('disabled');
            $('#pager-prev-btn a').click(function(){
                loadTablePage(data.prev);
            });
        }

        if(data.next == "none"){
            $('#pager-next-btn').addClass('disabled');
        } else {
            $('#pager-next-btn').removeClass('disabled');
            $('#pager-next-btn a').click(function(){
                loadTablePage(data.next);
            });
        }

        // Number of pager buttons
        var numItems = $('.pager-nr-btn').length;

        /* Calculate for the pager buttons */
        var lowPage = Math.floor(pagenr/numItems) + 1;

        $('.pager-nr-btn').each(function() {
            /* calculate current page number */
            var thispagenr = lowPage++;

            /* Add the page number */
            $(this).html('' + thispagenr + '');

            /* Add active class to current page */
            if(thispagenr == pagenr) {
                $(this).addClass('active');
            } else {
                $(this).removeClass('active');
            }

            /* Disable inactive classes and bind handlers to active classes */
            if(thispagenr > data.pagecount) {
                $(this).addClass('disabled');
            } else {
                /* Add click listener for button */
                $(this).click(function() {
                    loadTablePage(thispagenr);
                });
            }
        });
    });
}

function initPage() {
    $('#addWorksheetBtn').click(function() {
        showNewWorksheetModal();
    });

    $.getJSON('/api/currentuser', function(data) {
        viewModel.userId = data.id;
        viewModel.updateCourseRapport();
    });
}
<commit_msg>properties van worksheet invullen via formulier<commit_after>// View model for the page
function pageViewModel(gvm) {
    // Page specific i18n bindings
    gvm.app  = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("WorksheetNameRapport");}, gvm);
    gvm.title = ko.computed(function (){i18n.setLocale(gvm.lang()); return gvm.app() + ' - ' + i18n.__("HomeRapportTitle");}, gvm);
    gvm.projectname = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("ProjectRapportName");}, gvm);
    gvm.homeManual = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("WorksheetRapportManual");}, gvm);

    gvm.availableCourses = ko.observableArray([]);

    gvm.selectCourse = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("SelectCourse");}, gvm);
    gvm.addBtn = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("AddBtn")}, gvm);
    gvm.tabledata = ko.observableArray([]);

     // Table i18n bindings
    gvm.werkficheID = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("werkficheID");}, gvm);
    gvm.werkficheName = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("werkficheName");}, gvm);
    gvm.werkficheAction = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("werkficheAction");}, gvm);

    gvm.currentCourseId = null;

    gvm.updateCourseRapport = function() {
        $.getJSON('/api/coursedrop', function(data) {
            gvm.availableCourses.removeAll();
            $.each(data, function(i, item) {
                //  Put item in list
                gvm.availableCourses.push(item);

                // Add listener to listitem
                $("#coursebtn-" + item.id).click(function(){
                    gvm.currentCourseId = item.id;
                    $(".btn-courseRapport span:first").text($(this).text());
                    loadTablePage(1);
                });
            });
        });
    };

    gvm.addTableData = function(id, name) {
        // Push data
        var tblOject = {tid: id, tname: name};
        gvm.tabledata.push(tblOject);

        $('#removebtn-' + id).bind('click', function(event, data){
            deleteTableItem(id, tblOject);
            event.stopPropagation();
        });

        $('#editbtn-' + id).bind('click', function(event, data){
            showEditWorksheetModal(id, name);
            event.stopPropagation();
        });

        $('#copybtn-' + id).bind('click', function(event, data){
            copyTableItem(id, tblOject);
            event.stopPropagation();
        });
    }

    gvm.clearTable = function() {
        gvm.tabledata.removeAll();
    }
}

function addNewWorksheet(serialData, courseid, callback) {
    $.ajax({
        url: "/api/addworksheet/" + courseid,
        type: "POST",
        data: serialData,
        success: function(data) {
            /*$.ajax({
                url: "/api/worksheet/" + data['id'] + "/" + data["Name"],
                type: "GET",
                success: function(data) {
                    //loadTablePage(1);
                    callback(true);
                }
            })*/
            console.log(data);
            console.log(data["id"] + ", " + data["name"]);
        },
        error: function(data) {
            callback(false);
        }
    });
}

function updateWorksheet(id, serialData, callback) {
    $.ajax({
        url: "/api/updateworksheet/" + id,
        type: "PUT",
        data: serialData,
        success: function(data) {
            loadTablePage(1);
            callback(true);
        },
        error: function(data) {
            callback(false);
        }
    });
}

function copyTableItem(id, tblObject) {
    /*showYesNoModal("Bent u zeker dat u dit item wil kopiëren? ", function(val){
        if(val){
            $.ajax({
                url: "/api/coursecopy/" + id,
                type: "post"

            });
        }
    });*/
}

function deleteTableItem(id, tblOject) {
    showYesNoModal("Bent u zeker dat u dit item wil verwijderen? \r\n Let op: verwijderde items blijven in het systeem en kunnen weer actief gezet worden door een administrator. \r\n Gelieve de administrator te contacteren om een vak definitief te verwijderen.", function(val){
        if(val){
            $.ajax({
                url: "/api/deleteworksheet/" + id,
                type: "DELETE",
                success: function() {
                    viewModel.tabledata.remove(tblOject);
                }
            });
        }
    });
}

function showNewWorksheetModal() {
    resetGeneralModal();
    setGeneralModalTitle(i18n.__("AddNewWorksheet"));
    setGeneralModalBody('<form id="newworksheetform"> \

 \
                <input type="text" class="form-control input-lg" placeholder="' + i18n.__('NameTableTitle') + '" " name="name"> \

 \
            </form>' );

    addGeneralModalButton(i18n.__("AddBtn"), function(){
       addNewWorksheet($('#newworksheetform').serialize(), viewModel.currentCourseId, function(result){
            hideModal();
        });
    });

    showGeneralModal();
}

function showEditWorksheetModal(id, name)
{
    resetGeneralModal();
    setGeneralModalTitle(i18n.__("EditWorksheet"));
    setGeneralModalBody('<form id="updateworksheetform"> \

 \
                <input type="text" class="form-control input-lg" placeholder="' + i18n.__('NameTableTitle') + '" " name="name" value="' + name + '"> \

 \
        </form>');
    $.getJSON()

    addGeneralModalButton(i18n.__("SaveBtn"), function(){
        updateWorksheet(id, $('#updateworksheetform').serialize(), function(result){
            hideModal();
        });
    });

    addGeneralModalButton(i18n.__("CancelBtn"), function(){
        hideModal();
    })

    showGeneralModal();
}

function loadTablePage(pagenr)
{
    $.getJSON('/api/worksheets/page/' + pagenr + '/' + viewModel.currentCourseId, function(data){

        /* Clear current table page */
        viewModel.clearTable();

        // Load table data
        $.each(data.data, function(i, item) {
            viewModel.addTableData(item.id, item.Name);
        });

        /* Let previous en next buttons work */
        if(data.prev == "none"){
            $('#pager-prev-btn').addClass('disabled');
        } else {
            $('#pager-prev-btn').removeClass('disabled');
            $('#pager-prev-btn a').click(function(){
                loadTablePage(data.prev);
            });
        }

        if(data.next == "none"){
            $('#pager-next-btn').addClass('disabled');
        } else {
            $('#pager-next-btn').removeClass('disabled');
            $('#pager-next-btn a').click(function(){
                loadTablePage(data.next);
            });
        }

        // Number of pager buttons
        var numItems = $('.pager-nr-btn').length;

        /* Calculate for the pager buttons */
        var lowPage = Math.floor(pagenr/numItems) + 1;

        $('.pager-nr-btn').each(function() {
            /* calculate current page number */
            var thispagenr = lowPage++;

            /* Add the page number */
            $(this).html('' + thispagenr + '');

            /* Add active class to current page */
            if(thispagenr == pagenr) {
                $(this).addClass('active');
            } else {
                $(this).removeClass('active');
            }

            /* Disable inactive classes and bind handlers to active classes */
            if(thispagenr > data.pagecount) {
                $(this).addClass('disabled');
            } else {
                /* Add click listener for button */
                $(this).click(function() {
                    loadTablePage(thispagenr);
                });
            }
        });
    });
}

function initPage() {
    $('#addWorksheetBtn').click(function() {
        showNewWorksheetModal();
    });

    $.getJSON('/api/currentuser', function(data) {
        viewModel.userId = data.id;
        viewModel.updateCourseRapport();
    });
}
<|endoftext|>


<commit_before>/* © Utrecht University and DialogueTrainer */

var Utils;

(function()
{
    "use strict";

    Utils =
    {
        clone: clone,
        ensurePreventDefault: ensurePreventDefault,
        parseDecimalIntWithDefault: parseDecimalIntWithDefault,
        parseBool: parseBool,
        escapeRegex: escapeRegex,
        escapeHTML: escapeHTML,
        unEscapeHTML: unEscapeHTML,
        cssPosition: cssPosition,
        appendChild: appendChild,
        appendChildNS: appendChildNS,
        focusFirstTabindexedDescendant: focusFirstTabindexedDescendant,
        setPreserveSpace: setPreserveSpace,
        attachMarkdownTooltip: attachMarkdownTooltip,
        detachMarkdownTooltip: detachMarkdownTooltip,
        makeSortable: makeSortable,
        confirmDialog: confirmDialog
    };

    // Taken from stackoverflow
    // http: //stackoverflow.com/questions/728360/most-elegant-way-to-clone-a-javascript-object
    function clone(obj)
    {
        return $.extend(true, {}, obj);
    }

    // Ensures the default event trigger is really prevented,
    // because of a bug in firefox it is still triggered,
    // when just calling event.preventDefault()
    // http://stackoverflow.com/questions/14860759/cant-override-ctrls-in-firefox-using-jquery-hotkeys
    function ensurePreventDefault(div, event, eventFunction)
    {
        event.preventDefault();

        div.blur();

        setTimeout(function() { eventFunction(); }, 50);
    }

    function parseDecimalIntWithDefault(string, defaultValue)
    {
        // Make sure radix 10 is used (the default is browser-dependent).
        var value = parseInt(string, 10);
        return isNaN(value) ? defaultValue : value;
    }

    function parseBool(str)
    {
        return str == "true";
    }

    // Taken from https://stackoverflow.com/a/6969486
    function escapeRegex(str)
    {
        return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
    }

    function escapeHTML(str)
    {
        if (str === undefined)
            return str;
        else
        {
            return str
                .replace(/&/g, '&')   // &
                .replace(/</g, '<')  // <
                .replace(/>/g, '>')  // >
                .replace(/\"/g, '"') // "
                .replace(/\'/g, ''')  // '
                .replace(/\n/g, "
"); // \n
        }
    }

    function unEscapeHTML(str)
    {
        if (str === undefined)
            return str;
        else
        {
            return str
                .replace(/&/g, '&') // &
                .replace(/</g, '<') // <
                .replace(/>/g, '>') // >
                .replace(/"/g, '"') // "
                .replace(/'/g, '\'') // '
                .replace(/
/g, "\n"); // \n
        }
    }

    // Gets or sets the "CSS position", which is defined as the combination of
    // the "left" and "top" CSS properties of an element.
    // The values in the argument/return value are expected to be/returned as
    // plain Numbers representing pixels, not strings ending with a unit.
    function cssPosition(elem, newPosition)
    {
        if (newPosition === undefined)
        {
            // "Computed styles of dimensions are almost always pixels"
            // (http://api.jquery.com/css/). We assume this is the case.
            var position = elem.css(['left', 'top']);
            return {
                'left': parseDecimalIntWithDefault(position.left, 0),
                'top': parseDecimalIntWithDefault(position.top, 0)
            };
        }
        else
        {
            return elem.css({
               'left': newPosition.left + 'px',
               'top': newPosition.top + 'px'
            });
        }
    }

    function appendChild(parentXML, name)
    {
        return parentXML.appendChild(document.createElementNS(parentXML.namespaceURI, name));
    }

    function appendChildNS(parentXML, nameSpace, name)
    {
        return parentXML.appendChild(document.createElementNS(nameSpace, name));
    }

    function setPreserveSpace(elem)
    {
        elem.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
    }

    // Focuses on the first descendant that has a non-negative tabindex.
    // This includes elements that are focusable by default, like <input> and <select>.
    function focusFirstTabindexedDescendant(element)
    {
        var descendants = $(element).find('*');
        for (var i = 0; i < descendants.length; i++)
        {
            var toTest = $(descendants[i]);
            if (toTest.prop('tabIndex') >= 0)
            {
                return toTest.focus();
            }
        }
        return $();
    }

    // Attaches a tooltip to an element, only works when the element has a parent
    function attachMarkdownTooltip(elem)
    {
        var tooltipIcon = $('', { class: "markdown-tooltip" });
        tooltipIcon.append($('', { src: editor_url + "svg/icon_markdown.svg" }));
        tooltipIcon.tooltip(
        {
            items: ":hover",
            content: i18next.t('utils:markdown_tooltip'),
            // Taken from: http://stackoverflow.com/a/15014759
            close: function(event, ui)
            {
                ui.tooltip.hover(
                    function ()
                    {
                        $(this).stop(true).fadeIn();
                    },
                    function ()
                    {
                        $(this).fadeOut(function(){ $(this).remove(); });
                    }
                );
            }

        });
        tooltipIcon.insertAfter(elem);
    }

    function detachMarkdownTooltip(elem)
    {
        elem.next('.markdown-tooltip').remove();
    }

    function makeSortable(container)
    {
        container.sortable({
            handle: ".handle",
            axis: "y",
            forceHelperSize: true,
            containment: container,
            start: function(e, ui)
            {
                // Taken from: https://stackoverflow.com/a/36554073
                // Makes the containment area larger so that the element can be sorted into the top and bottom
                var sort = $(this).sortable('instance');
                ui.placeholder.height(ui.helper.height());
                sort.containment[3] += ui.helper.height() * 1.5 - sort.offset.click.top;
                sort.containment[1] -= sort.offset.click.top;
            },
            helper: function(e, helper)
            {
                $(helper).children().each(function()
                {
                    $(this).width($(this).width());
                });
                return helper;
            },
            beforeStop: function(e, ui)
            {
                $(ui.helper).children().each(function()
                {
                    $(this).width("");
                });
            }
        });
    }

    function confirmDialog(content)
    {
        var deferredConfirmation = $.Deferred();
        var container = $('
');
        container.append(content).dialog(
        {
            height: 'auto',
            maxHeight: 768,
            width: 400,
            modal: true,
            buttons: [
            {
                text: i18next.t('common:confirm'),
                click: function()
                {
                    deferredConfirmation.resolve(true);
                    $(this).dialog('close');
                }
            },
            {
                text: i18next.t('common:cancel'),
                click: function()
                {
                    deferredConfirmation.resolve(false);
                    $(this).dialog('close');
                }
            }],
            close: function()
            {
                container.remove();
            }
        });
        return deferredConfirmation;
    }

})();
<commit_msg>Fixed resolving when closing a confirm dialog<commit_after>/* © Utrecht University and DialogueTrainer */

var Utils;

(function()
{
    "use strict";

    Utils =
    {
        clone: clone,
        ensurePreventDefault: ensurePreventDefault,
        parseDecimalIntWithDefault: parseDecimalIntWithDefault,
        parseBool: parseBool,
        escapeRegex: escapeRegex,
        escapeHTML: escapeHTML,
        unEscapeHTML: unEscapeHTML,
        cssPosition: cssPosition,
        appendChild: appendChild,
        appendChildNS: appendChildNS,
        focusFirstTabindexedDescendant: focusFirstTabindexedDescendant,
        setPreserveSpace: setPreserveSpace,
        attachMarkdownTooltip: attachMarkdownTooltip,
        detachMarkdownTooltip: detachMarkdownTooltip,
        makeSortable: makeSortable,
        confirmDialog: confirmDialog
    };

    // Taken from stackoverflow
    // http: //stackoverflow.com/questions/728360/most-elegant-way-to-clone-a-javascript-object
    function clone(obj)
    {
        return $.extend(true, {}, obj);
    }

    // Ensures the default event trigger is really prevented,
    // because of a bug in firefox it is still triggered,
    // when just calling event.preventDefault()
    // http://stackoverflow.com/questions/14860759/cant-override-ctrls-in-firefox-using-jquery-hotkeys
    function ensurePreventDefault(div, event, eventFunction)
    {
        event.preventDefault();

        div.blur();

        setTimeout(function() { eventFunction(); }, 50);
    }

    function parseDecimalIntWithDefault(string, defaultValue)
    {
        // Make sure radix 10 is used (the default is browser-dependent).
        var value = parseInt(string, 10);
        return isNaN(value) ? defaultValue : value;
    }

    function parseBool(str)
    {
        return str == "true";
    }

    // Taken from https://stackoverflow.com/a/6969486
    function escapeRegex(str)
    {
        return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
    }

    function escapeHTML(str)
    {
        if (str === undefined)
            return str;
        else
        {
            return str
                .replace(/&/g, '&')   // &
                .replace(/</g, '<')  // <
                .replace(/>/g, '>')  // >
                .replace(/\"/g, '"') // "
                .replace(/\'/g, ''')  // '
                .replace(/\n/g, "
"); // \n
        }
    }

    function unEscapeHTML(str)
    {
        if (str === undefined)
            return str;
        else
        {
            return str
                .replace(/&/g, '&') // &
                .replace(/</g, '<') // <
                .replace(/>/g, '>') // >
                .replace(/"/g, '"') // "
                .replace(/'/g, '\'') // '
                .replace(/
/g, "\n"); // \n
        }
    }

    // Gets or sets the "CSS position", which is defined as the combination of
    // the "left" and "top" CSS properties of an element.
    // The values in the argument/return value are expected to be/returned as
    // plain Numbers representing pixels, not strings ending with a unit.
    function cssPosition(elem, newPosition)
    {
        if (newPosition === undefined)
        {
            // "Computed styles of dimensions are almost always pixels"
            // (http://api.jquery.com/css/). We assume this is the case.
            var position = elem.css(['left', 'top']);
            return {
                'left': parseDecimalIntWithDefault(position.left, 0),
                'top': parseDecimalIntWithDefault(position.top, 0)
            };
        }
        else
        {
            return elem.css({
               'left': newPosition.left + 'px',
               'top': newPosition.top + 'px'
            });
        }
    }

    function appendChild(parentXML, name)
    {
        return parentXML.appendChild(document.createElementNS(parentXML.namespaceURI, name));
    }

    function appendChildNS(parentXML, nameSpace, name)
    {
        return parentXML.appendChild(document.createElementNS(nameSpace, name));
    }

    function setPreserveSpace(elem)
    {
        elem.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
    }

    // Focuses on the first descendant that has a non-negative tabindex.
    // This includes elements that are focusable by default, like <input> and <select>.
    function focusFirstTabindexedDescendant(element)
    {
        var descendants = $(element).find('*');
        for (var i = 0; i < descendants.length; i++)
        {
            var toTest = $(descendants[i]);
            if (toTest.prop('tabIndex') >= 0)
            {
                return toTest.focus();
            }
        }
        return $();
    }

    // Attaches a tooltip to an element, only works when the element has a parent
    function attachMarkdownTooltip(elem)
    {
        var tooltipIcon = $('', { class: "markdown-tooltip" });
        tooltipIcon.append($('', { src: editor_url + "svg/icon_markdown.svg" }));
        tooltipIcon.tooltip(
        {
            items: ":hover",
            content: i18next.t('utils:markdown_tooltip'),
            // Taken from: http://stackoverflow.com/a/15014759
            close: function(event, ui)
            {
                ui.tooltip.hover(
                    function ()
                    {
                        $(this).stop(true).fadeIn();
                    },
                    function ()
                    {
                        $(this).fadeOut(function(){ $(this).remove(); });
                    }
                );
            }

        });
        tooltipIcon.insertAfter(elem);
    }

    function detachMarkdownTooltip(elem)
    {
        elem.next('.markdown-tooltip').remove();
    }

    function makeSortable(container)
    {
        container.sortable({
            handle: ".handle",
            axis: "y",
            forceHelperSize: true,
            containment: container,
            start: function(e, ui)
            {
                // Taken from: https://stackoverflow.com/a/36554073
                // Makes the containment area larger so that the element can be sorted into the top and bottom
                var sort = $(this).sortable('instance');
                ui.placeholder.height(ui.helper.height());
                sort.containment[3] += ui.helper.height() * 1.5 - sort.offset.click.top;
                sort.containment[1] -= sort.offset.click.top;
            },
            helper: function(e, helper)
            {
                $(helper).children().each(function()
                {
                    $(this).width($(this).width());
                });
                return helper;
            },
            beforeStop: function(e, ui)
            {
                $(ui.helper).children().each(function()
                {
                    $(this).width("");
                });
            }
        });
    }

    function confirmDialog(content)
    {
        var deferredConfirmation = $.Deferred();
        var container = $('
');
        container.append(content).dialog(
        {
            height: 'auto',
            maxHeight: 768,
            width: 400,
            modal: true,
            buttons: [
            {
                text: i18next.t('common:confirm'),
                click: function()
                {
                    deferredConfirmation.resolve(true);
                    $(this).dialog('close');
                }
            },
            {
                text: i18next.t('common:cancel'),
                click: function()
                {
                    $(this).dialog('close');
                }
            }],
            close: function()
            {
                deferredConfirmation.resolve(false);
                container.remove();
            }
        });
        return deferredConfirmation;
    }

})();
<|endoftext|>


<commit_before>// title      : thumb
// author     : Gino Tubaro
// license    : MIT License
// description: just a thumb
// file       : palma.jscad
//!OpenSCAD
//Hay que parametrizara

include('lodash.js');

include("formulas.jscad");

include("node_modules/jscad-utils/jscad-utils.jscad");
include("node_modules/jscad-utils/jscad-utils-color.jscad");

include('node_modules/jscad-utils/jscad-utils-parts.jscad');
include('node_modules/jscad-utils/jscad-boxes.jscad');

include("tornillotuerca.jscad");
// TODO:
// arreglar tapa
// x del pulgar
// agregar texto "Atomic Lab" y el nombre de usuario
// posicion slider
var result,xbo;
var long=50;
var alto=15;

var pinconector=2;
var tornilloconector=3;
var pulgar =1;
function main()
{
	util.init(CSG);
	var palma = palmagenerator(alto, long, pulgar);
	//console.log(palma.getfeatures(['volume']));
	return palma;
}

function slider(alto) { //limpiar

	var o = new Array(); //shape of the palm
	var g = new Array(); //object 3D
	var d = new Array(); //object 3D
	var x = new Array();
	var k = new Array();
	var b = new Array();
	var last=1;
	var long=0;
	x.push(square({size: [alto*4,alto*4]}).center('x'));
	o.push(circle({r:alto, center:true}).translate([alto,0,0]));
	o.push(circle({r:alto, center:true}).translate([-alto,0,0]));
	g.push(linear_extrude({ height: 5 }, hull(o)));
	d.push(linear_extrude({ height: 8 }, hull(x)));
	b.push(union(g).subtract(union(d)));
	///cuerpo sin parteabajoish
	k.push(square({size: [alto*4,10], center: true}).translate([0, 5, 0]));

	b.push(linear_extrude({ height: 5 }, hull(k)));

	var todo = union(
		Parts.Triangle(5, alto*5).translate([0, -1, -1]),
		Parts.Triangle(5, alto*5).translate([5, -1, -1]),
		cube({size: [5, 10, alto*5], center: [true, true, false]}).translate([2.5, -6, 0])
	).translate([(-alto/2)+3, 0, 0]);

	todo= union(b).subtract(todo.rotateX(-90).rotateZ(90).snap(union(b), 'x', 'inside-').translate([-1, -1, 0]));
	todo= todo.subtract(cylinder({r: 1, h: 20, center: true}).rotateX(-90).snap(todo, 'x', 'center-').translate([-1,0, 2]));

	todo=todo.subtract(cube({size: [10, 10, 5], center: [true, true, true]}).snap(todo,'y','outside+').translate([5, 0, 0]) );

	return todo;

}

function bajorelieve(height,prof, alto) { //corregir el cilindro

	var h = hull(
			square({size: [(alto*2)-3,1], center: true}).translate([0,height-alto,0 ]),//alto*4 - thickness
			circle({r: alto/2, center: true}).translate([0,10+alto/2,0])
		);
		h=h.subtract(square({size: [alto*4,alto]}).translate([-alto*2,height-alto,0]));
		var tapa = linear_extrude({ height: prof }, h);

/*	var h = hull(
		square({size: [(alto*4)-10,1], center: true}).translate([0, height-height/4,0 ]),
		circle({r: alto, center: true}).translate([0,-height*0.003125,0])
	);
	var tapa = linear_extrude({ height: prof }, h);
*/

	return tapa.rotateX(90);

}

function conectores(alto) {
	var o = new Array();
	o.push(cube({size: [alto*4, 2, alto/2], center: [true, true, true]}).translate([0, 2, alto/2.5]));
	o.push(cube({size: [alto*4, 2, alto/2], center: [true, true, true]}).translate([0, -2, alto/2.5]));
	o.push(cylinder({r: 2.75, h: alto*4, center: [true, true, true]}).rotateX(90).rotateZ(90).translate([0, 5, alto-5]));

	return union(o);
}
function contornos(alto,ancho) {
	var o = new Array();
	var porc=1-(((alto/2)-5)/alto);
	o.push(cylinder({r: ancho, h: alto*4, center: [true, true, true]}).rotateX(90).rotateZ(90).translate([0, -ancho, alto])); //contorno de conectores
	o.push(cylinder({r: ancho+ancho/4, h: alto, center: [true, true, true]}).scale([1,porc,1]).rotateX(90).translate([0, -ancho, alto-ancho/2])); //contorno de tapa
	return union(o);
}
function cuerpito(h,ancho) {
	var o = new Array();
	var thi=15;
	o.push(circle({r:ancho-thi/2, center:true}).translate([ancho,0,0]));
	o.push(circle({r:ancho-thi/2, center:true}).translate([-ancho,0,0]));
	o.push(square({size: [ancho*4-thi,10], center: true}).translate([0, 5, 0]));
	o.push(square({size:[ancho*4-thi,40], center:true}).translate([0, 20, 0]))

	o = linear_extrude({ height: h }, hull(o));

	return o //o.scale([0.75,0.7,2]);
}

function palmagenerator(ancho, height,pulgar) {

	var cag = CAG.fromPoints([
		[-1, -1, 0],
		[1, -1, 0],
		[1, 1, 0]
	]).expand(1, CSG.defaultResolution2D);
	var flatBottom = CSG.Polygon.createFromPoints(
		cag.getOutlinePaths()[0].points
	);

	var tope;

	var thing = flatBottom.solidFromSlices({
		numslices: height
		,callback: function(t) {
			var coef = t;

			var o = new Array();
			if (coef < 0.01) coef = 0.01;//must not collapse polygon
			var h = height*t;
			var y = 0;
			var b = alto+Math.sin(coef*4);

			o.push(circle({r:b, center:true}).translate([ancho,0,0]).subtract(square({size: [alto*4,alto*4]}).center('x')));
			o.push(circle({r:b, center:true}).translate([-ancho,0,0]).subtract(square({size: [alto*4,alto*4]}).center('x')));
			if (pulgar) {
				//				if ((h>=height/7)&&(h<=(height*2/3))){
				if (height*2/3>=50) { //pongo valor de altura fijo a la curvatura pulgar
					tope = 50;
				}else {
					tope=height*2/3;
				}

				if ((h>=0.1)&&(h<=(tope))){
					var vals = calculate(0.1,tope,alto+4,0);
					x = (vals[0]*Math.pow(h,2)) + (vals[1]*h) + vals[2];
					o.push(circle({r: x/2, center: true}).translate([alto*2, 8, 0]))
				}
			}

			o.push(square({size: [alto*4,10], center: true}).translate([0, 5, 0]));

			cag =  hull(o); //.expand(1,CSG.defaultResolution2D)

			var cage = CAG.circle({
				center: [0,0],
				ancho: 3*Math.sin(coef*1.2),
				resolution: 32
			}).expand(1, CSG.defaultResolution2D);

			var cags = CAG.fromPoints([
				[-1, -1, h],
				[1, -1, h],
				[1 , 1, h],
				[-1, 1, h]
			]).expand(1, CSG.defaultResolution2D);

			return CSG.Polygon.createFromPoints(
				cag.getOutlinePaths()[0].points
			).translate([0, 0, h]);
		}
	});

	var palma=
	difference(
		union(thing,slider(alto).mirroredZ()).fillet(3,'z+'),
		cuerpito(height,ancho),
		conectores(height),
		contornos(height,ancho)

	);
	function oppulgar() { //operacionpulgar
		var cubo;
		var th=3;

		cubo = cube({size: [th, ancho, long/2-4], center: [true, false, false]})
		.snap(palma,'y','outside-')
		.translate([(alto*2)-th, -alto+th, 4])

	return cubo;
}

//  palma= palma.snap(bajorelieve(height), 'x', 'center-');
todo= bajorelieve(height,8,alto)
.snap(palma, 'y', 'outside+')
.translate([0, 3, 0]);

todo=difference(palma,todo,oppulgar());
var todosin=todo;
vals = calculate(0.1,tope,alto+4,0);
x = (vals[0]*Math.pow(tope/2,2)) + (vals[1]*tope/2) + vals[2]; //calculo curva ymax
console.log("x"+x);
todo=
union(
	difference(
		todo,
		cylinder({r: 3, h: alto*4, center: [true, true, true]}) //cilindrotapa
		.rotateX(90)
		.translate([0, 0, (height/2.5)+5]),
		cylinder({r: 3, h: alto, center: [true, true, true]}) //cilindropulgar
		.rotateY(90)
		.translate([(alto*2), x-5, (tope*0.5)])

	),
	tornillotuerca(4,2.5)[0]//tuerca de tapa
	.rotateX(90)
	.snap(todo,'y','outside+')
	.translate([0, 4, (height/2.5)+5]),

	tornillotuerca(alto/2,1.75)[0] //tuerca de pulgar
	.rotateY(90)
	.translate([(alto*2), x-5, (tope*0.5)])
	/*.snap(palma,'y','outside-')
	.snap(palma,'x','outside-')
	.translate([-6.25, -alto, tope*0.5])
*/
)
todo =
difference(
	todo,
	//.translate([(alto*2)+8, x-5, (tope*0.5)]),
		difference(
			cylinder({r:8, h:alto*1.5, center:[true,true,true]})//tuerca de pulgar
			.rotateY(90)
			.translate([(alto*2), x-5, (tope*0.5)]),
			todosin
		)
);

return todo.subtract(
cylinder({r:4.5, h:3, center:[true,true,true]})//bajorelieve de pulgar
.rotateY(90)
.snap(palma,'x','outside-')
.translate([-3, x-5, (tope*0.5)]));//difference(todo,difference(todo,todosin));

}
<commit_msg>Agregado "Atomic Lab" y Nombre de usuario<commit_after>// title      : thumb
// author     : Gino Tubaro
// license    : MIT License
// description: just a thumb
// file       : palma.jscad
//!OpenSCAD
//Hay que parametrizara

include('lodash.js');

include("formulas.jscad");

include("node_modules/jscad-utils/jscad-utils.jscad");
include("node_modules/jscad-utils/jscad-utils-color.jscad");

include('node_modules/jscad-utils/jscad-utils-parts.jscad');
include('node_modules/jscad-utils/jscad-boxes.jscad');

include("tornillotuerca.jscad");
// TODO:
// arreglar tapa
// x del pulgar
// agregar texto "Atomic Lab" y el nombre de usuario
// posicion slider
var result,xbo;
var long=90;
var alto=40;
var nombre= "GT";
var pinconector=2;
var tornilloconector=3;
var pulgar =1;
function main()
{
	util.init(CSG);
	var palma = palmagenerator(alto, long, pulgar,nombre);
	//console.log(palma.getfeatures(['volume']));
	return palma;
}

function slider(alto) { //limpiar

	var o = new Array(); //shape of the palm
	var g = new Array(); //object 3D
	var d = new Array(); //object 3D
	var x = new Array();
	var k = new Array();
	var b = new Array();
	var last=1;
	var long=0;
	x.push(square({size: [alto*4,alto*4]}).center('x'));
	o.push(circle({r:alto, center:true}).translate([alto,0,0]));
	o.push(circle({r:alto, center:true}).translate([-alto,0,0]));
	g.push(linear_extrude({ height: 6 }, hull(o)));
	d.push(linear_extrude({ height: 8 }, hull(x)));
	b.push(union(g).subtract(union(d)));
	///cuerpo sin parteabajoish
	k.push(square({size: [alto*4,10], center: true}).translate([0, 5, 0]));

	b.push(linear_extrude({ height: 6 }, hull(k)));

	var todo = union(
		Parts.Triangle(6, alto*5).translate([0, -1, -1]),
		Parts.Triangle(6, alto*5).translate([5, -1, -1]),
		cube({size: [6, 10, alto*5], center: [true, true, false]}).translate([2.5, -6, 0])
	).translate([(-alto/2)+3, 0, 0]);

	todo= union(b).subtract(todo.rotateX(-90).rotateZ(90).snap(union(b), 'x', 'inside-').translate([-1, -1, 0]));
	todo= todo.subtract(cylinder({r: 1, h: alto*2, center: true}).rotateX(-90).snap(todo, 'x', 'center-').translate([-1,0, 2]));

	todo=todo.subtract(cube({size: [10, 10, 6], center: [true, true, true]}).snap(todo,'y','outside+').translate([6, 0, 0]) );

	return todo;

}

function bajorelieve(height,prof, alto) { //corregir el cilindro

	var h = hull(
			square({size: [(alto*2)-3,1], center: true}).translate([0,height-alto,0 ]),//alto*4 - thickness
			circle({r: alto/2, center: true}).translate([0,10+alto/2,0])
		);
		h=h.subtract(square({size: [alto*4,alto]}).translate([-alto*2,height-alto,0]));
		var tapa = linear_extrude({ height: prof }, h);

/*	var h = hull(
		square({size: [(alto*4)-10,1], center: true}).translate([0, height-height/4,0 ]),
		circle({r: alto, center: true}).translate([0,-height*0.003125,0])
	);
	var tapa = linear_extrude({ height: prof }, h);
*/

	return tapa.rotateX(90);

}

function conectores(alto) {
	var o = new Array();
	o.push(cube({size: [alto*4, 2, alto/2], center: [true, true, true]}).translate([0, 2, alto/2.5]));
	o.push(cube({size: [alto*4, 2, alto/2], center: [true, true, true]}).translate([0, -2, alto/2.5]));
	o.push(cylinder({r: 2.75, h: alto*4, center: [true, true, true]}).rotateX(90).rotateZ(90).translate([0, 5, alto-5]));

	return union(o);
}
function contornos(alto,ancho) {
	var o = new Array();
	var porc=1-(((alto/2)-5)/alto);
	o.push(cylinder({r: ancho, h: alto*4, center: [true, true, true]}).rotateX(90).rotateZ(90).translate([0, -ancho, alto])); //contorno de conectores
	o.push(cylinder({r: ancho+ancho/4, h: alto, center: [true, true, true]}).scale([1,porc,1]).rotateX(90).translate([0, -ancho, alto-ancho/2])); //contorno de tapa
	return union(o);
}
function cuerpito(h,ancho) {
	var o = new Array();
	var thi=15;
	o.push(circle({r:ancho-thi/2, center:true}).translate([ancho,0,0]));
	o.push(circle({r:ancho-thi/2, center:true}).translate([-ancho,0,0]));
	o.push(square({size: [ancho*4-thi,10], center: true}).translate([0, 5, 0]));
	o.push(square({size:[ancho*4-thi,40], center:true}).translate([0, 20, 0]))

	o = linear_extrude({ height: h }, hull(o));

	return o //o.scale([0.75,0.7,2]);
}

function palmagenerator(ancho, height,pulgar) {

	var cag = CAG.fromPoints([
		[-1, -1, 0],
		[1, -1, 0],
		[1, 1, 0]
	]).expand(1, CSG.defaultResolution2D);
	var flatBottom = CSG.Polygon.createFromPoints(
		cag.getOutlinePaths()[0].points
	);

	var tope;

	var thing = flatBottom.solidFromSlices({
		numslices: height
		,callback: function(t) {
			var coef = t;

			var o = new Array();
			if (coef < 0.01) coef = 0.01;//must not collapse polygon
			var h = height*t;
			var y = 0;
			var b = alto+Math.sin(coef*4);

			o.push(circle({r:b, center:true}).translate([ancho,0,0]).subtract(square({size: [alto*4,alto*4]}).center('x')));
			o.push(circle({r:b, center:true}).translate([-ancho,0,0]).subtract(square({size: [alto*4,alto*4]}).center('x')));
			if (pulgar) {
				//				if ((h>=height/7)&&(h<=(height*2/3))){
				if (height*2/3>=50) { //pongo valor de altura fijo a la curvatura pulgar
					tope = 50;
				}else {
					tope=height*2/3;
				}

				if ((h>=0.1)&&(h<=(tope))){
					var vals = calculate(0.1,tope,alto+4,0);
					x = (vals[0]*Math.pow(h,2)) + (vals[1]*h) + vals[2];
					o.push(circle({r: x/2, center: true}).translate([alto*2, 8, 0]))
				}
			}

			o.push(square({size: [alto*4,10], center: true}).translate([0, 5, 0]));

			cag =  hull(o); //.expand(1,CSG.defaultResolution2D)

			var cage = CAG.circle({
				center: [0,0],
				ancho: 3*Math.sin(coef*1.2),
				resolution: 32
			}).expand(1, CSG.defaultResolution2D);

			var cags = CAG.fromPoints([
				[-1, -1, h],
				[1, -1, h],
				[1 , 1, h],
				[-1, 1, h]
			]).expand(1, CSG.defaultResolution2D);

			return CSG.Polygon.createFromPoints(
				cag.getOutlinePaths()[0].points
			).translate([0, 0, h]);
		}
	});

	var palma=
	difference(
		union(thing,slider(alto).mirroredZ()).fillet(3,'z+'),
		cuerpito(height,ancho),
		conectores(height),
		contornos(height,ancho)

	);
	function oppulgar() { //operacionpulgar
		var cubo;
		var th=3;

		cubo = cube({size: [th, ancho, long/2-4], center: [true, false, false]})
		.snap(palma,'y','outside-')
		.translate([(alto*2)-th, -alto+th, 4])

	return cubo;
}

//  palma= palma.snap(bajorelieve(height), 'x', 'center-');
todo= bajorelieve(height,8,alto)
.snap(palma, 'y', 'outside+')
.translate([0, 3, 0]);

todo=difference(palma,todo,oppulgar());
var todosin=todo;
vals = calculate(0.1,tope,alto+4,0);
x = (vals[0]*Math.pow(tope/2,2)) + (vals[1]*tope/2) + vals[2]; //calculo curva ymax
var s = todo.size();
console.log("tamanio"+s);
todo=
union(
	difference(
		todo,
		cylinder({r: 3, h: alto*4, center: [true, true, true]}) //cilindrotapa
		.rotateX(90)
		.translate([0, 0, (height/2.5)+5]),
		cylinder({r: 3, h: alto, center: [true, true, true]}) //cilindropulgar
		.rotateY(90)
		.translate([(alto*2), x-5, (tope*0.5)])

	),
	tornillotuerca(4,2.5)[0]//tuerca de tapa
	.rotateX(90)
	.snap(todo,'y','outside+')
	.translate([0, 4, (height/2.5)+5]),

	tornillotuerca(alto/2,1.75)[0] //tuerca de pulgar
	.rotateY(90)
	.translate([(alto*2), x-5, (tope*0.5)])
	/*.snap(palma,'y','outside-')
	.snap(palma,'x','outside-')
	.translate([-6.25, -alto, tope*0.5])
*/

)

todo =
difference(
	todo,
	//.translate([(alto*2)+8, x-5, (tope*0.5)]),
		difference(
			cylinder({r:8, h:alto*1.5, center:[true,true,true]})//tuerca de pulgar
			.rotateY(90)
			.translate([(alto*2), x-5, (tope*0.5)]),
			todosin
		)
);
todo=difference(
	todo,
	util.label("Atomic Lab") //CC
		.rotateX(90)
		.scale([1,4,1])
		//.align(todo, 'xy')
		//.align(todo, 'xy')
		.fit([s.x - alto*2-10, s.y - alto, s.z-5],true)
		.snap(todo, 'y', 'outside+')
		.translate([0, 2.5, 5])
		.color('red'),

	util.label(nombre+","+alto+","+long) //Nombre + data
		.rotateZ(180)
		.scale([1,1,5])
		//.align(todo, 'xy')
		//.align(todo, 'xy')
		.fit([s.x - alto*2, s.y - alto, s.z-5],true)
		.center('z')
		.translate([0, -alto/2, 0])
		.color('red'),

	cylinder({r:4.5, h:3, center:[true,true,true]})//bajorelieve de pulgar
		.rotateY(90)
		.snap(palma,'x','outside-')
		.translate([-3, x-5, (tope*0.5)])
	);

return todo//difference(todo,difference(todo,todosin));
}
<|endoftext|>


<commit_before>var phrases = [
"No. Your genes are inferior.",
"No. Donate to this website instead.",
"Yes. Lie back and think of England.",
"10/10 fertility gods agree that you should have sex.",
"No. Sex is weird and gross.",
"Yeah girl. Tap that shit.",
"No. Leave it to the professionals.",
"Yeah baby. Call me. 867-5309",
"No. Sex makes Jesus/Mohammed/Budda/Vishnu/etc cry. <picture of crying deity>",
"No. Humans are a cancer on this beautiful earth. Stop the spread.",
"lolololololololol. Oh, you were serious? LOLOLOLOLOLOLOL",
"Oh yes. Please. Mmmmmm.",
"Bow chicka wow wow.",
"Sex is contraindicated in patients with chronic internet use disorder.",
"Nah. Try out this lovely pornography instead.",
"No. Hitler had sex.",
"Have your sex. There are celibate kids in Africa.",
"Zeno's paradox proves that a penis cannot enter a vagina.",
"Yes. Sex is the most full and pure expression of self actualizing humanity possible on this tiny orb hurling through an empty, meaningless cosmos.",
"'should' or 'ought' I have sex is, of course, a moral question, best examined through Kant's dentological ethics. Formulated as universal law - everyone must have sex - we can clearly see a problem. Some people, such as those without genitals, cannot have sex. Therefore, you must not have sex."
];

var response = phrases[Math.floor(Math.random() * phrases.length)];
var elem = document.getElementById("response");
if (elem != null) {
	elem.innerHTML = response;
} else {
	console.log("Did not find response element.");
	document.write("Yes.");
}

<commit_msg>spelling, lol<commit_after>var phrases = [
"No. Your genes are inferior.",
"No. Donate to this website instead.",
"Yes. Lie back and think of England.",
"10/10 fertility gods agree that you should have sex.",
"No. Sex is weird and gross.",
"Yeah girl. Tap that shit.",
"No. Leave it to the professionals.",
"Yeah baby. Call me. 867-5309",
"No. Sex makes Jesus/Mohammed/Budda/Vishnu/etc cry. <picture of crying deity>",
"No. Humans are a cancer on this beautiful earth. Stop the spread.",
"lolololololololol. Oh, you were serious? LOLOLOLOLOLOLOL",
"Oh yes. Please. Mmmmmm.",
"Bow chicka wow wow.",
"Sex is contraindicated in patients with chronic internet use disorder.",
"Nah. Try out this lovely pornography instead.",
"No. Hitler had sex.",
"Have your sex. There are celibate kids in Africa.",
"Zeno's paradox proves that a penis cannot enter a vagina.",
"Yes. Sex is the most full and pure expression of self actualizing humanity possible on this tiny orb hurling through an empty, meaningless cosmos.",
"'should' or 'ought' I have sex is, of course, a moral question, best examined through Kant's deontological ethics. Formulated as universal law - everyone must have sex - we can clearly see a problem. Some people, such as those without genitals, cannot have sex. Therefore, you must not have sex."
];

var response = phrases[Math.floor(Math.random() * phrases.length)];
var elem = document.getElementById("response");
if (elem != null) {
	elem.innerHTML = response;
} else {
	console.log("Did not find response element.");
	document.write("Yes.");
}

<|endoftext|>


<commit_before>"use strict";

function CMathLimitPr()
{
    this.type = LIMIT_LOW;
}

CMathLimitPr.prototype.Set_FromObject = function(Obj)
{
    if (undefined !== Obj.type && null !== Obj.type)
        this.type = Obj.type;
};

CMathLimitPr.prototype.Copy = function()
{
    var NewPr = new CMathLimitPr();
    NewPr.type = this.type;
    return NewPr;
};

CMathLimitPr.prototype.Write_ToBinary = function(Writer)
{
    // Long : type
    Writer.WriteLong(this.type);
};

CMathLimitPr.prototype.Read_FromBinary = function(Reader)
{
    // Long : type
    this.type = Reader.GetLong();
};

function CLimitPrimary(bInside, Type, FName, Iterator)
{
    CLimitPrimary.superclass.constructor.call(this, bInside);

    this.Type = Type;
    this.FName = null;
    this.Iterator = null;

    this.init(FName, Iterator);
}
Asc.extendClass(CLimitPrimary, CMathBase);
CLimitPrimary.prototype.init = function(FName, Iterator)
{
    this.setDimension(2, 1);

    if(this.Type == LIMIT_LOW)
    {
        this.FName  = FName;
        this.Iterator = new CDenominator(Iterator);

        this.elements[0][0] = this.FName;
        this.elements[1][0] = this.Iterator;
    }
    else
    {
        this.Iterator = Iterator;
        this.FName    = FName;

        this.elements[0][0] = this.Iterator;
        this.elements[1][0] = this.FName;
    }
};
CLimitPrimary.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
    this.Parent = Parent;
    this.ParaMath = ParaMath;

    this.Set_CompiledCtrPrp(Parent, ParaMath);

    if(this.bInside == false)
        GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);

    this.FName.PreRecalc(this, ParaMath, ArgSize, RPI);

    var ArgSzIter = ArgSize.Copy();
    ArgSzIter.decrease();

    var NewRPI = RPI.Copy();
    NewRPI.bDecreasedComp = true;

    this.Iterator.PreRecalc(this, ParaMath, ArgSzIter, NewRPI);
};
CLimitPrimary.prototype.Resize = function(oMeasure, RPI)
{
    if(this.Type == LIMIT_LOW)
        this.dH = 0;
    else
        this.dH = 0.06*this.GetTPrpToControlLetter().FontSize;

    this.FName.Resize(oMeasure, RPI);

    this.Iterator.Resize(oMeasure, RPI);

    var SizeFName = this.FName.size,
        SizeIter  = this.Iterator.size;

    var width  = SizeFName.width > SizeIter.width ? SizeFName.width : SizeIter.width,
        height = SizeFName.height + SizeIter.height,
        ascent;

    if(this.Type == LIMIT_LOW)
        ascent = SizeFName.ascent;
    else if(this.Type == LIMIT_UP)
        ascent = SizeIter.height + this.dH + SizeFName.ascent;

    width += this.GapLeft + this.GapRight;

    this.size = {width: width, height: height, ascent: ascent};
};

function CLimit(props)
{
    CLimit.superclass.constructor.call(this);

	this.Id = g_oIdCounter.Get_NewId();

    this.Pr = new CMathLimitPr();

    if(props !== null && typeof(props) !== "undefined")
        this.init(props);

	g_oTableId.Add( this, this.Id );
}
Asc.extendClass(CLimit, CMathBase);

CLimit.prototype.ClassType = historyitem_type_lim;
CLimit.prototype.kind      = MATH_LIMIT;

CLimit.prototype.init = function(props)
{
    this.Fill_LogicalContent(2);

    // посмотреть GetAllFonts
    this.setProperties(props);
    this.fillContent();
};
CLimit.prototype.fillContent = function()
{
};
CLimit.prototype.getFName = function()
{
    return this.Content[0];
};
CLimit.prototype.getIterator = function()
{
    return this.Content[1];
};
CLimit.prototype.ApplyProperties = function(RPI)
{
    if(this.RecalcInfo.bProps == true || RPI.bChangeInline == true)
    {
        this.setDimension(1, 1);

        if(RPI.bInline == true && RPI.bMathFunc == true)
        {
            var props;

            if(this.Pr.type == LIMIT_LOW)
                props = {type:   DEGREE_SUBSCRIPT, ctrPrp: this.CtrPrp};
            else
                props = {type:   DEGREE_SUPERSCRIPT, ctrPrp: this.CtrPrp};

            this.elements[0][0] = new CDegreeBase(props, true);
            this.elements[0][0].setBase(this.getFName());
            this.elements[0][0].setIterator(this.getIterator());
            this.elements[0][0].fillContent();
        }
        else
        {
            this.elements[0][0] = new CLimitPrimary(true, this.Pr.type, this.getFName(), this.getIterator());
        }

        this.RecalcInfo.bProps = false;
    }

};
function CMathFunc(props)
{
    CMathFunc.superclass.constructor.call(this);

	this.Id = g_oIdCounter.Get_NewId();

    this.Pr = new CMathBasePr();

    if(props !== null && typeof(props) !== "undefined")
        this.init(props);

	g_oTableId.Add( this, this.Id );
}
Asc.extendClass(CMathFunc, CMathBase);

CMathFunc.prototype.ClassType = historyitem_type_mathFunc;
CMathFunc.prototype.kind      = MATH_FUNCTION;

CMathFunc.prototype.init = function(props)
{
    this.Fill_LogicalContent(2);

    this.setProperties(props);
    this.fillContent();
};
CMathFunc.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
    var NewRPI = RPI.Copy();
    NewRPI.bMathFunc = true;

    CMathFunc.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, NewRPI, GapsInfo);
};
CMathFunc.prototype.setDistance = function()
{
    this.dW = this.GetTPrpToControlLetter().FontSize/6*g_dKoef_pt_to_mm;
};
CMathFunc.prototype.getFName = function()
{
    return this.Content[0];
};
CMathFunc.prototype.getArgument = function()
{
    return this.Content[1];
};
CMathFunc.prototype.fillContent = function()
{
    this.setDimension(1, 2);
    this.elements[0][0] = this.getFName();
    this.elements[0][1] = this.getArgument();
};

<commit_msg>Поправила высоту итератора в CLimit<commit_after>"use strict";

function CMathLimitPr()
{
    this.type = LIMIT_LOW;
}

CMathLimitPr.prototype.Set_FromObject = function(Obj)
{
    if (undefined !== Obj.type && null !== Obj.type)
        this.type = Obj.type;
};

CMathLimitPr.prototype.Copy = function()
{
    var NewPr = new CMathLimitPr();
    NewPr.type = this.type;
    return NewPr;
};

CMathLimitPr.prototype.Write_ToBinary = function(Writer)
{
    // Long : type
    Writer.WriteLong(this.type);
};

CMathLimitPr.prototype.Read_FromBinary = function(Reader)
{
    // Long : type
    this.type = Reader.GetLong();
};

function CLimitPrimary(bInside, Type, FName, Iterator)
{
    CLimitPrimary.superclass.constructor.call(this, bInside);

    this.Type = Type;
    this.FName = null;
    this.Iterator = null;

    this.init(FName, Iterator);
}
Asc.extendClass(CLimitPrimary, CMathBase);
CLimitPrimary.prototype.init = function(FName, Iterator)
{
    this.setDimension(2, 1);

    if(this.Type == LIMIT_LOW)
    {
        this.FName  = FName;
        this.Iterator = new CDenominator(Iterator);

        this.elements[0][0] = this.FName;
        this.elements[1][0] = this.Iterator;
    }
    else
    {
        this.Iterator = Iterator;
        this.FName    = FName;

        this.elements[0][0] = this.Iterator;
        this.elements[1][0] = this.FName;
    }
};
CLimitPrimary.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
    this.Parent = Parent;
    this.ParaMath = ParaMath;

    this.Set_CompiledCtrPrp(Parent, ParaMath);

    if(this.bInside == false)
        GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);

    this.FName.PreRecalc(this, ParaMath, ArgSize, RPI);

    var ArgSzIter = ArgSize.Copy();
    ArgSzIter.decrease();

    var NewRPI = RPI.Copy();
    NewRPI.bDecreasedComp = true;

    this.Iterator.ArgSize.decrease();
    this.Iterator.PreRecalc(this, ParaMath, ArgSzIter, NewRPI);
};
CLimitPrimary.prototype.Resize = function(oMeasure, RPI)
{
    if(this.Type == LIMIT_LOW)
        this.dH = 0;
    else
        this.dH = 0.06*this.GetTPrpToControlLetter().FontSize;

    this.FName.Resize(oMeasure, RPI);

    this.Iterator.Resize(oMeasure, RPI);

    var SizeFName = this.FName.size,
        SizeIter  = this.Iterator.size;

    var width  = SizeFName.width > SizeIter.width ? SizeFName.width : SizeIter.width,
        height = SizeFName.height + SizeIter.height,
        ascent;

    if(this.Type == LIMIT_LOW)
        ascent = SizeFName.ascent;
    else if(this.Type == LIMIT_UP)
        ascent = SizeIter.height + this.dH + SizeFName.ascent;

    width += this.GapLeft + this.GapRight;

    this.size = {width: width, height: height, ascent: ascent};
};

function CLimit(props)
{
    CLimit.superclass.constructor.call(this);

	this.Id = g_oIdCounter.Get_NewId();

    this.Pr = new CMathLimitPr();

    if(props !== null && typeof(props) !== "undefined")
        this.init(props);

	g_oTableId.Add( this, this.Id );
}
Asc.extendClass(CLimit, CMathBase);

CLimit.prototype.ClassType = historyitem_type_lim;
CLimit.prototype.kind      = MATH_LIMIT;

CLimit.prototype.init = function(props)
{
    this.Fill_LogicalContent(2);

    // посмотреть GetAllFonts
    this.setProperties(props);
    this.fillContent();
};
CLimit.prototype.fillContent = function()
{
};
CLimit.prototype.getFName = function()
{
    return this.Content[0];
};
CLimit.prototype.getIterator = function()
{
    return this.Content[1];
};
CLimit.prototype.ApplyProperties = function(RPI)
{
    if(this.RecalcInfo.bProps == true || RPI.bChangeInline == true)
    {
        this.setDimension(1, 1);

        if(RPI.bInline == true && RPI.bMathFunc == true)
        {
            var props;

            if(this.Pr.type == LIMIT_LOW)
                props = {type:   DEGREE_SUBSCRIPT, ctrPrp: this.CtrPrp};
            else
                props = {type:   DEGREE_SUPERSCRIPT, ctrPrp: this.CtrPrp};

            this.elements[0][0] = new CDegreeBase(props, true);
            this.elements[0][0].setBase(this.getFName());
            this.elements[0][0].setIterator(this.getIterator());
            this.elements[0][0].fillContent();
        }
        else
        {
            this.elements[0][0] = new CLimitPrimary(true, this.Pr.type, this.getFName(), this.getIterator());
        }

        this.RecalcInfo.bProps = false;
    }

};
function CMathFunc(props)
{
    CMathFunc.superclass.constructor.call(this);

	this.Id = g_oIdCounter.Get_NewId();

    this.Pr = new CMathBasePr();

    if(props !== null && typeof(props) !== "undefined")
        this.init(props);

	g_oTableId.Add( this, this.Id );
}
Asc.extendClass(CMathFunc, CMathBase);

CMathFunc.prototype.ClassType = historyitem_type_mathFunc;
CMathFunc.prototype.kind      = MATH_FUNCTION;

CMathFunc.prototype.init = function(props)
{
    this.Fill_LogicalContent(2);

    this.setProperties(props);
    this.fillContent();
};
CMathFunc.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
    var NewRPI = RPI.Copy();
    NewRPI.bMathFunc = true;

    CMathFunc.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, NewRPI, GapsInfo);
};
CMathFunc.prototype.setDistance = function()
{
    this.dW = this.GetTPrpToControlLetter().FontSize/6*g_dKoef_pt_to_mm;
};
CMathFunc.prototype.getFName = function()
{
    return this.Content[0];
};
CMathFunc.prototype.getArgument = function()
{
    return this.Content[1];
};
CMathFunc.prototype.fillContent = function()
{
    this.setDimension(1, 2);
    this.elements[0][0] = this.getFName();
    this.elements[0][1] = this.getArgument();
};

<|endoftext|>


<commit_before>// View model for the page
function pageViewModel(gvm) {
    // Page specific i18n bindings
    gvm.app  = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("WorksheetNameRapport");}, gvm);
    gvm.title = ko.computed(function (){i18n.setLocale(gvm.lang()); return gvm.app() + ' - ' + i18n.__("HomeRapportTitle");}, gvm);
    gvm.projectname = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("WorksheetNameRapport");}, gvm);
    gvm.homeManual = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("WorksheetRapportManual");}, gvm);

    gvm.selectCourse = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("SelectCourse");}, gvm);

    /*/gvm.updateCourseRapport = function() {
        $.getJSON('/api/coursedrop', function(data) {
            gvm.availableCourses.removeAll();
            $.each(data, function(i, item) {
                //  Put item in list
                gvm.availableCourses.push(item);

                // Add listener to listitem
                $("#coursebtn-" + item.id).click(function(){
                    gvm.currentCourseId = item.id;
                    gvm.currentStudentlistId = null;
                    gvm.currentStudentId = null;
                    gvm.updateStudentlists(item.id, gvm.userId);
                    $(".btn-courseRapport span:first").text($(this).text());
                    $(".btn-studentlist span:first").text("Studentlist");
                    $('.btn-student span:first').text("Student");
                    gvm.saveLastSelectedDropdowns();
                });
            });
        });
    };*/

}

function initPage() {

}
<commit_msg>Dropdown worksheet<commit_after>// View model for the page
function pageViewModel(gvm) {
    // Page specific i18n bindings
    gvm.app  = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("WorksheetNameRapport");}, gvm);
    gvm.title = ko.computed(function (){i18n.setLocale(gvm.lang()); return gvm.app() + ' - ' + i18n.__("HomeRapportTitle");}, gvm);
    gvm.projectname = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("WorksheetNameRapport");}, gvm);
    gvm.homeManual = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("WorksheetRapportManual");}, gvm);

    gvm.availableCourses = ko.observableArray([]);

    gvm.selectCourse = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("SelectCourse");}, gvm);

    /*/gvm.updateCourseRapport = function() {
        $.getJSON('/api/coursedrop', function(data) {
            gvm.availableCourses.removeAll();
            $.each(data, function(i, item) {
                //  Put item in list
                gvm.availableCourses.push(item);

                // Add listener to listitem
                $("#coursebtn-" + item.id).click(function(){
                    gvm.currentCourseId = item.id;
                    gvm.currentStudentlistId = null;
                    gvm.currentStudentId = null;
                    gvm.updateStudentlists(item.id, gvm.userId);
                    $(".btn-courseRapport span:first").text($(this).text());
                    $(".btn-studentlist span:first").text("Studentlist");
                    $('.btn-student span:first').text("Student");
                    gvm.saveLastSelectedDropdowns();
                });
            });
        });
    };*/

}

function initPage() {

}
<|endoftext|>