Commit 071588e2 authored by Clément Fauconnier's avatar Clément Fauconnier

added 3 widgets

parent 24b9d7f1
module.exports = function (grunt) {
var baseSrc = 'js/src';
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.initConfig({
uglify: {
options: {
separator: ';'
},
compile: {
src: [
baseSrc + '/Sankore/klass.js',
baseSrc + '/**/*.js'
],
dest: 'dist/calculator.js'
}
},
watch: {
scripts: {
files: 'js/src/**/*.js',
tasks: ['scripts:dist']
}
}
});
grunt.registerTask('default', ['dist', 'watch']);
grunt.registerTask('dist', ['scripts:dist']);
grunt.registerTask('scripts:dist', ['uglify:compile']);
};
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:ub="http://uniboard.mnemis.com/widgets"
id="http://uniboard.mnemis.com/widgets/calculator"
version="1.1"
width="460"
height="418"
minimum_width="460"
minimum_height="418"
ub:resizable="true"
ub:transparent="true">
<name>Calculator</name>
<content src="index.html"/>
</widget>
* {
margin: 0;
padding: 0;
}
body {
font-size: 12px;
margin:0;
}
.calculator {
-webkit-user-select: none;
font-family: Verdana;
background: -webkit-linear-gradient(top, #f6f6f6 0%, #f7f7f7 25%, #f4f4f4 25%, #e8e8e8 100%);
background: linear-gradient(to bottom, #f6f6f6 0%, #f7f7f7 25%, #f4f4f4 25%, #e8e8e8 100%);
padding: 1em;
width: auto;
border-radius: 0.66em;
border: 1px solid #bbb;
margin: 0.33em;
box-shadow: 0.16em 0.16em 0.46em rgba(0, 0, 0, 0.35), inset 0 0 0.45em rgba(0, 0, 0, 0.3);
}
.calculator .title {
font-weight:bold;
color:#333;
text-shadow:0 1px 1px rgba(0, 0, 0, 0.2);
display:block;
margin-top: -1.1em;
margin-right:25%;
top: 0.4em;
position:relative;
}
.calculator .controls {
float: right;
margin: -1.3em 0.2em 0.25em 0;
}
.calculator .controls button {
background: -webkit-linear-gradient(top, #666666 0%, #444444 100%);
background: linear-gradient(to bottom, #666666 0%, #444444 100%);
padding: 0.12em 0.5em;
border: none;
color: white;
outline: none;
text-shadow: 0 -1px 0 black;
border-radius: 0 0 0.25em 0.25em;
box-shadow: inset 0 -1px 1px #000000, 0 1px 1px rgba(0, 0, 0, 0.5);
}
.calculator .controls button + button {
margin-left:2px;
}
.calculator .controls button:active {
background: -webkit-linear-gradient(bottom, #666666 0%, #444444 100%);
background: linear-gradient(to top, #666666 0%, #444444 100%);
box-shadow: inset 0 -1px 3px #000000;
color: #cccccc;
}
.calculator table {
table-layout: fixed;
line-height:90%;
width: 100%;
border-collapse: separate;
border-spacing: 1px;
}
.calculator .screen td {
height: 1px;
}
.calculator .screen ul {
height: 100%;
cursor: default;
box-sizing: border-box;
margin-bottom: 0.8rem;
padding: 0.4rem;
font-size: 1.5em;
line-height: normal;
text-shadow: 0 1px 1px #ffffff;
color: #444f53;
background: -webkit-linear-gradient(top, #f6f8f9 0%, #d2edf2 70%, #c9e3e7 70%, #d4eff4 100%);
background: linear-gradient(to bottom, #f6f8f9 0%, #d2edf2 70%, #c9e3e7 70%, #d4eff4 100%);
border: 1px solid #d3d3d3;
border-top-color: #d0d0d0;
border-left-color: #d0d0d0;
border-radius: 0.33rem;
box-shadow: 0 0 0.4rem #ffffff, inset 0.15rem 0.15rem 0.4rem rgba(21, 39, 54, 0.5);
}
.calculator .screen li {
list-style-type: none;
}
.calculator .screen .expression-row .caret {
border-left: 1px solid #444f53;
box-sizing: border-box;
margin-right: -1px;
-webkit-animation-name: blinker;
-webkit-animation-duration: 1.2s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
animation-name: blinker;
animation-duration: 1.2s;
animation-timing-function: linear;
animation-iteration-count: infinite;
}
@-webkit-keyframes blinker {
0% {
opacity: 1.0;
}
40% {
opacity: 1.0;
}
50% {
opacity: 0.0;
}
90% {
opacity: 0.0;
}
}
@keyframes blinker {
0% {
opacity: 1.0;
}
40% {
opacity: 1.0;
}
50% {
opacity: 0.0;
}
90% {
opacity: 0.0;
}
}
.calculator .screen .flag-row {
font-size: 0.6em;
min-height: 15px;
overflow: hidden;
}
.calculator .screen .flag-row span {
margin-right:0.3em;
display: inline-block;
}
.calculator .screen .result-row {
min-height: 38px;
font-size: 1.6em;
text-align: right;
}
.calculator .screen .result-row .error {
color: #4b2525;
}
.calculator .screen .euclidean {
font-size: 0.8em;
}
.calculator .screen .euclidean span {
border-bottom: 1px solid #444f53;
position: relative;
margin-bottom: 0.5rem;
display: block;
float: right;
}
.calculator .screen .euclidean .remainder {
margin-left: 0.5em;
}
.calculator .screen .euclidean span:before {
font-size: 0.4em;
display: block;
position: absolute;
bottom: -1em;
width: 100%;
text-align: center;
}
.calculator .screen .euclidean .quotient:before {
content: 'q';
}
.calculator .screen .euclidean .remainder:before {
content: 'r';
}
.calculator .screen .front-screen ul {
overflow: hidden;
}
.calculator .screen .front-screen .expression-row {
min-height: 22px;
max-height: 22px;
white-space: nowrap;
}
.calculator .screen .rear-screen {
width: 50%;
}
.calculator .screen .rear-screen ul {
-webkit-user-select: initial;
height: 103.5%;
margin-right: 0.8rem;
margin-bottom: 0;
font-size: 1.3em;
background: -webkit-linear-gradient(top, #3b474f 0%, #131f21 51%, #0d1516 100%);
background: linear-gradient(to bottom, #3b474f 0%, #131f21 51%, #0d1516 100%);
box-shadow: 0 0 0.4rem #ffffff, inset 0.15rem 0.15rem 0.4rem rgba(21, 39, 54, 0.8);
text-shadow: 0 -1px 1px #000000;
color: #cbe7f4;
overflow-y: scroll;
}
.calculator .screen .rear-screen .expression-row {
word-wrap:break-word;
}
.calculator .screen .rear-screen .euclidian span:before {
font-size: 0.6em;
}
.calculator .edit-area {
height: 100%;
margin-right: 0.8rem;
margin-bottom: 0;
font-size: 1em;
position: relative;
}
.calculator .edit-area hr {
margin: 0.7em 0 0.5em 0;
border: none;
border-top: 1px solid #d0d0d0;
border-bottom: 1px solid #fcfcfc;
}
.calculator .edit-area select {
width: 100%;
}
.calculator .edit-area button.small {
float: right;
width: 9.13%;
height:20px;
padding: 0;
font-size:0;
position:relative;
}
.calculator .edit-area button.small:before {
position: absolute;
display: block;
height:100%;
width: 100%;
font-size:16px;
top: 0;
left: 0;
font-weight:bold;
}
.calculator .edit-area button.small.add:before {
content: '+';
}
.calculator .edit-area button.small.remove:before {
content: '-';
}
.calculator .edit-area button.small + button.small {
margin-right:0.4rem;
}
.calculator .edit-area select.layout-select {
width: 74.77%;
}
.calculator .edit-area label {
width: 100%;
display: block;
color: #555555;
margin: 0.7em 0 0.5em 0;
}
.calculator .edit-area input[type=text],
.calculator .edit-area textarea {
display: block;
box-sizing: border-box;
width: 100%;
border: 1px solid #d0d0d0;
font-size: 1em;
font-family: Verdana;
border-radius: 3px;
padding: 4px 2px;
box-shadow: inset 0.1em 0.1em 0.2em rgba(0, 0, 0, 0.2);
resize: none;
}
.calculator .edit-area input[type=text][disabled],
.calculator .edit-area textarea[disabled] {
background-color: #eeeeee;
color: #555555;
}
.calculator .edit-area .assignation {
margin-top: 1em;
border: 1px solid #d0d0d0;
padding: 0.5em;
box-shadow: inset 0 0 0.5em rgba(255, 255, 255, 1);
border-radius: 3px;
}
.calculator .edit-area .assignation em {
font-size: 1.1em;
line-height: 1.1em;
color: #555555;
text-align: center;
display: block;
}
.calculator .edit-area .assignation label:first-child {
margin-top: 0;
}
.calculator .edit-area .assignation .help {
display: block;
margin-top: 0.3em;
font-size: 0.9em;
color: #777777;
}
.calculator .edit-area .run {
display: block;
width: 100%;
position: absolute;
padding: 0.5em 0;
bottom: 0;
font-weight: bold;
outline: 0;
}
.calculator .buttons td {
padding: 0;
margin: 0;
}
.calculator .buttons button {
outline: 0;
font-family: Verdana;
font-size: 1.2em;
font-weight: 500;
color: #555555;
background: -webkit-linear-gradient(bottom, #eeeeee 0%, #fdfdfd 100%);
background: linear-gradient(to top, #eeeeee 0%, #fdfdfd 100%);
border: 0.4em solid #ffffff;
border-top-width: 0.3em;
border-bottom-width: 0.5em;
border-bottom-color: #eeeeee;
border-right-color: #eeeeee;
border-radius: 0.33rem;
box-shadow: 0.2em 0.2em 0.2em 0.1em rgba(0, 0, 0, 0.2);
box-sizing: border-box;
display: block;
width: 100%;
height: 2.4rem;
padding: 0;
margin: 0;
}
.calculator .buttons button:hover {
color: #29a0b5;
background: -webkit-linear-gradient(bottom, #d0ecf0 0%, #ffffff 100%);
background: linear-gradient(to top, #d0ecf0 0%, #ffffff 100%);
border-bottom-color: #d0ecf0;
border-right-color: #d0ecf0;
}
.calculator .buttons button:active {
font-size: 1.1em;
color: #29a0b5;
border: 1px solid #cccccc;
background: -webkit-linear-gradient(bottom, #d0ecf0 0%, #ffffff 100%);
background: linear-gradient(to top, #d0ecf0 0%, #ffffff 100%);
box-shadow: inset 0 0 0.5em 0.2em rgba(0, 0, 0, 0.1), 0.1em 0.1em 0.2em #ffffff;
}
.calculator .buttons .alt button {
color: #2b8eac;
font-weight: bold;
}
.calculator .buttons .edit button {
border:1px solid #aac3b2;
box-shadow: inset 0 0 1.5em 0.2em rgba(48, 114, 71, 0.3);
color: #678d74;
}
.calculator .buttons .danger button {
font-weight: bold;
}
.calculator .buttons .danger button:hover {
color: #cc5d54;
background: -webkit-linear-gradient(bottom, #f0dad0 0%, #ffffff 100%);
background: linear-gradient(to top, #f0dad0 0%, #ffffff 100%);
border-bottom-color: #f0dad0;
border-right-color: #f0dad0;
}
.calculator .buttons .danger button:active {
color: #cc5d54;
background: -webkit-linear-gradient(bottom, #f0dad0 0%, #ffffff 100%);
background: linear-gradient(to top, #f0dad0 0%, #ffffff 100%);
}
.calculator .buttons button[disabled] {
background: inherit;
box-shadow: 0.1em 0.1em 0.2em #ffffff;
border: 1px solid #cccccc;
color: #cccccc;
}
.calculator .buttons button[disabled]:hover {
background: inherit;
box-shadow: 0.1em 0.1em 0.2em #ffffff;
}
.calculator .buttons button[disabled]:active {
font-size: 1.2em;
}
\ No newline at end of file
!function(){"use strict";Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d&&a?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e}),window.klass={create:function(){var a=Object.create(this);return"function"==typeof a.constructor&&a.constructor.apply(a,arguments),a},extend:function(a){var b=Object.create(this);return a?(Object.keys(a).forEach(function(c){b[c]=a[c]}),b):b},define:function(a,b,c){var d=function(a,b){var c,e=a.split(".");return e.length>0?(c=e.shift(),"undefined"==typeof b[c]&&(b[c]={}),e.length>0?d(e.join("."),b[c]):b[c]):null},e=d(a,window);e[b]=c}}}(),function(){"use strict";klass.define("Sankore","Button",klass.extend({constructor:function(a,b,c,d){this.text=a,this.command=b,this.useLimit="undefined"==typeof c?-1:c,this.editable="undefined"==typeof d?!0:d},isEditable:function(){return this.editable},isUsable:function(){return-1===this.useLimit},isDisabled:function(){return 0===this.useLimit},clone:function(){return Sankore.Button.create(this.text,this.command,this.useLimit,this.editable)}}))}(),function(){"use strict";klass.define("Sankore","Calculator",klass.extend({constructor:function(a,b){Sankore.Util.i18n.load(b.locale||"en"),this.currentLayout=null,this.lastError=null,this.memory=null,this.op=null,this.output=null,this.history=[],this.buttonUseCount={},this.expressionString="",this.unpredictable=b.unpredictableMode||!1,this.eventDispatcher=Sankore.Util.EventDispatcher.create(),this.commands=Sankore.Util.Hash.create(),this.texts=Sankore.Util.Hash.create(),this.calculusEngine=Sankore.Calculus.Engine.create(),this.keystrokeLine=Sankore.KeystrokeLine.create(this.eventDispatcher),this.ui=Sankore.UI.MainInterface.create(a,this.eventDispatcher,this.texts,this.unpredictable),this.editor=Sankore.Editor.Editor.create(this),"undefined"!=typeof b.ready&&this.eventDispatcher.addEventListener("calculator.create",b.ready.bind(this));var c=Sankore.Text.create.bind(Sankore.Text);this.texts.add("id",[c("0","0","0"),c("1","1","1"),c("2","2","2"),c("3","3","3"),c("4","4","4"),c("5","5","5"),c("6","6","6"),c("7","7","7"),c("8","8","8"),c("9","9","9"),c("+","+","+","alt"),c("-","-","-","alt"),c("*","×","×","alt"),c("/","÷","÷","alt"),c(":","⊢","⊢","alt"),c("=","=","=","alt"),c(".",_("text.comma"),_("text.comma")),c("(","(","("),c(")",")",")"),c("op","OP","OP"),c("mr","MR","MR"),c("mc","MC","MC"),c("m+","M+","M+"),c("m-","M-","M-"),c("s","",_("text.del"),"alt",!1),c("l","","←","alt",!1),c("r","","→","alt",!1),c("c","","C","danger",!1)]),c=Sankore.Command.create.bind(Sankore.Command),this.commands.add("id",[c("0",_("command.zero"),function(){this.expressionString+="0"}),c("1",_("command.one"),function(){this.expressionString+="1"}),c("2",_("command.two"),function(){this.expressionString+="2"}),c("3",_("command.three"),function(){this.expressionString+="3"}),c("4",_("command.four"),function(){this.expressionString+="4"}),c("5",_("command.five"),function(){this.expressionString+="5"}),c("6",_("command.six"),function(){this.expressionString+="6"}),c("7",_("command.seven"),function(){this.expressionString+="7"}),c("8",_("command.eight"),function(){this.expressionString+="8"}),c("9",_("command.nine"),function(){this.expressionString+="9"}),c("+",_("command.plus"),function(){this.expressionString+="+"}),c("-",_("command.minus"),function(){this.expressionString+="-"}),c("*",_("command.times"),function(){this.expressionString+="*"}),c("/",_("command.divide"),function(){this.expressionString+="/"}),c(":",_("command.euclidean_divide"),function(){this.expressionString+=":"}),Sankore.InterruptingCommand.create("=",_("command.equal"),function(){this.evaluateStack()}),c(".",_("command.comma"),function(){this.expressionString+="."}),c("(",_("command.open_parenthesis"),function(){this.expressionString+="("}),c(")",_("command.close_parenthesis"),function(){this.expressionString+=")"}),Sankore.InterruptingCommand.create("op",_("command.op"),function(){if(null===this.op){if(this.expressionString.length>1&&-1!=="+-*/:".indexOf(this.expressionString[0]))try{this.calculusEngine.evaluate("(1)"+this.expressionString).getValue(),this.op=this.expressionString,this.eventDispatcher.notify("calculator.op_changed",this.op)}catch(a){}this.expressionString="",this.output=null}else 0===this.expressionString.length&&null!==this.output&&(this.expressionString="("+this.output.toString()+")"),this.expressionString+=this.op,this.execCommand("=")}),Sankore.InterruptingCommand.create("memoryAdd",_("command.memory_add"),function(){this.execCommand("=");try{null===this.memory&&(this.memory=0),this.memory+=this.output.getValue()}catch(a){this.memory=null}this.eventDispatcher.notify("calculator.memory_changed",this.memory)}),Sankore.InterruptingCommand.create("memorySub",_("command.memory_sub"),function(){this.execCommand("=");try{null===this.memory&&(this.memory=0),this.memory-=this.output.getValue()}catch(a){this.memory=null}this.eventDispatcher.notify("calculator.memory_changed",this.memory)}),c("memoryRecall",_("command.memory_recall"),function(){null!==this.memory&&(this.expressionString+="("+this.memory.toString()+")")}),c("memoryClear",_("command.memory_clear"),function(){this.memory=null,this.eventDispatcher.notify("calculator.memory_changed",this.memory)}),Sankore.InternalCommand.create("clear",_("command.clear"),function(){this.reset(),this.eventDispatcher.notify("calculator.memory_changed",this.memory),this.eventDispatcher.notify("calculator.op_changed",this.op),this.eventDispatcher.notify("calculator.output_changed",{output:this.output,error:this.lastError})}),Sankore.InternalCommand.create("left",_("command.left"),function(){this.keystrokeLine.moveCaretLeft()}),Sankore.InternalCommand.create("right",_("command.right"),function(){this.keystrokeLine.moveCaretRight()}),Sankore.InternalCommand.create("del",_("command.del"),function(){var a=this.keystrokeLine.del();a&&this.getButtonUseCount(a.slot)&&(this.buttonUseCount[a.slot]--,this.getButtonUseCount(a.slot)<this.currentLayout.getButton(a.slot).useLimit&&this.eventDispatcher.notify("calculator.button_enabled",a.slot))})]),this.attachEventHandlers(),this.eventDispatcher.notify("calculator.create")},attachEventHandlers:function(){var a=this,b=this.eventDispatcher;this.unpredictable&&(b.addEventListener("editor.show",this.reload.bind(this)),b.addEventListener("editor.hide",this.reload.bind(this))),b.addEventListener("editor.layout_selected",function(b){a.loadLayout(b.id)}),b.addEventListener("main_interface.button_created",function(c){!a.editor.enabled&&c.button.isDisabled()&&b.notify("calculator.button_disabled",c)}),b.addEventListener("main_interface.button_click",function(c){a.editor.enabled||(a.useButton(c.slot),a.keystroke(c.slot,c.button),!c.button.isUsable()&&a.getButtonUseCount(c.slot)>=c.button.useLimit&&b.notify("calculator.button_disabled",c))}),b.addEventListener("main_interface.reset_click",function(){a.reload()})},reset:function(){this.memory=null,this.op=null,this.output=null,this.lastError=null,this.expressionString=[],this.keystrokeLine.reset()},init:function(a){var b=this;this.ui.render(),this.editor.init(a.editor||{}),null!==this.layout&&this.loadLayout(a.layout||"default"),"buttonUseCount"in a&&(this.buttonUseCount=a.buttonUseCount),"keystrokes"in a&&this.keystrokeLine.loadState(a.keystrokes||{}),"output"in a&&a.output&&(this.expressionString=a.output||"",this.evaluateStack()),"error"in a&&a.error&&(this.lastError=Sankore.Util.Error.create(a.error.name,a.error.message),this.eventDispatcher.notify("calculator.output_changed",{output:this.output,error:this.lastError})),"memory"in a&&(this.memory=a.memory,this.eventDispatcher.notify("calculator.memory_changed",this.memory)),"op"in a&&(this.op=a.op,this.eventDispatcher.notify("calculator.op_changed",this.op)),"history"in a&&a.history.length>0&&(this.history=a.history.map(function(a){return{expression:a.expression,output:b.calculusEngine.evaluate(a.output)}}),this.eventDispatcher.notify("calculator.history_changed",this.history)),this.eventDispatcher.notify("calculator.init")},getState:function(){return{layout:this.currentLayout?this.currentLayout.id:null,error:this.lastError,memory:this.memory,op:this.op,output:this.output?this.output.toString():null,buttonUseCount:this.buttonUseCount,editor:this.editor.getState(),keystrokes:this.keystrokeLine.getState(),history:this.history.map(function(a){return{expression:a.expression,output:a.output.toString()}})}},loadLayout:function(a){this.currentLayout=this.editor.layouts.get(a),this.execCommand("clear"),this.buttonUseCount={},this.history=[],this.eventDispatcher.notify("calculator.layout_loaded",this.currentLayout)},reload:function(){this.loadLayout(this.currentLayout.id)},execCommand:function(a,b){var c=this.commands.get(a);c.exec(this,b),this.eventDispatcher.notify("calculator.command_executed",{command:c,args:b})},evaluateStack:function(){try{this.output=this.expressionString.length>0?this.calculusEngine.evaluate(this.expressionString):null,this.lastError=null}catch(a){this.lastError=a,this.output=null}this.expressionString="",this.eventDispatcher.notify("calculator.output_changed",{output:this.output,error:this.lastError})},keystroke:function(a,b){var c=this.commands.get(b.command),d=this.texts.get(b.text);c.isInternal()?this.execCommand(c.id):(c.isInterrupting()&&this.keystrokeLine.moveCaretToEnd(),this.keystrokeLine.hit({slot:a,text:d.screen,command:b.command})),c.isInterrupting()&&this.execute()},execute:function(){var a,b=this.keystrokeLine.count();for(a=0;b>a;a++)this.execCommand(this.keystrokeLine.at(a).command);if(this.eventDispatcher.notify("calculator.executed"),!this.lastError&&this.output)try{this.backup(this.keystrokeLine.getAsText().join(""),this.output)}catch(c){}this.keystrokeLine.reset()},useButton:function(a){"undefined"==typeof this.buttonUseCount[a]&&(this.buttonUseCount[a]=0),this.buttonUseCount[a]++},getButtonUseCount:function(a){return this.buttonUseCount[a]||0},backup:function(a,b){try{b.getValue(),this.history.push({expression:a,output:b}),this.eventDispatcher.notify("calculator.history_changed",this.history)}catch(c){}}}))}(),function(){"use strict";klass.define("Sankore.Calculus","Engine",klass.extend({constructor:function(){this.expressions=[],this.operators=[]},init:function(){this.expressions=[],this.operators=[]},evaluate:function(a){var b,c,d,e=[];a=a.replace(/\s+/g,"");for(var f in a)d=a[f],b=e.length>0?e[e.length-1]:void 0,c=e.length>1?e[e.length-2]:void 0,-1!=="0123456789.".indexOf(d)?isNaN(Number(b))&&"."!==b&&"-."!==b&&("-"!==b||"("!==c&&void 0!==c)?e.push(d):e[e.length-1]+=d:e.push(d);for(var g in e)if(e[g].length>1&&"."===e[g].charAt(e[g].length-1))throw Sankore.Util.Error.create("InvalidExpression","Trailing comma");return this.computeExpression(e)},computeExpression:function(a){var b=function(a,b){for(var c,d=Sankore.Calculus.BinaryOperation.getOperatorPrecedence;;){if(c=a.operators[a.operators.length-1],0===a.operators.length||"("===c||d(b)>d(c))return a.operators.push(b);a.reduce()}};this.init();for(var c in a)switch(a[c]){case"(":this.operators.push(a[c]);break;case")":if(0===this.operators.length)throw Sankore.Util.Error.create("InvalidExpression","Trailing closing brackets");for(;0!==this.operators.length&&"("!==this.operators[this.operators.length-1];)this.reduce();"("===this.operators[this.operators.length-1]&&this.operators.pop();break;case"+":case"-":case"*":case"/":case":":b(this,a[c]);break;default:this.expressions.push(Sankore.Calculus.Operand.create(a[c]))}for(;0!==this.operators.length;)this.reduce();if(1!==this.expressions.length)throw Sankore.Util.Error.create("InvalidExpression",'"'+a.join(" ")+'" is not a valid expression');return this.expressions.pop()},reduce:function(){var a,b=this.expressions.pop(),c=this.expressions.pop(),d=this.operators.pop();if("undefined"==typeof d||"undefined"==typeof c||"undefined"==typeof b)throw Sankore.Util.Error.create("InvalidExpression","Invalid expression");a=":"===d?Sankore.Calculus.EuclideanDivisionOperation.create(c,b):Sankore.Calculus.BinaryOperation.create(c,d,b),this.expressions.push(a)}}))}(),function(){"use strict";klass.define("Sankore.Calculus","Expression",klass.extend({constructor:function(){},getValue:function(){return null},isInteger:function(){try{var a=this.getValue();return a===Math.floor(a)}catch(b){return 0}},toString:function(){return""},isCompound:function(){return!1}})),klass.define("Sankore.Calculus","Operand",Sankore.Calculus.Expression.extend({constructor:function(a){if(this.value=Number(a),isNaN(this.value))throw Sankore.Util.Error.create("InvalidNumber",'"'+String(a)+'" is a not a number')},getValue:function(){return this.value},toString:function(){return String(this.value)}})),klass.define("Sankore.Calculus","Operation",Sankore.Calculus.Expression.extend({constructor:function(a,b){this.operator=a,Sankore.Calculus.Expression.isPrototypeOf(b)||(b=Sankore.Calculus.Operand.create(b)),this.right=b},getPrecedence:function(){return Sankore.Calculus.Operation.getOperatorPrecedence(this.operator)},isLeftAssociative:function(){return!1},isCompound:function(){return!0},getValue:function(){var a=Number(this.right.getValue());return"-"===this.operator&&(a*=-1),a},toString:function(){var a=this.right.toString();return"-"!==this.operator?a:(this.right.isCompound()&&(a="("+a+")"),"-"+a)}})),Sankore.Calculus.Operation.getOperatorPrecedence=function(a){switch(a){case"+":case"-":return 1;case"*":case"/":case":":return 2}},klass.define("Sankore.Calculus","BinaryOperation",Sankore.Calculus.Operation.extend({constructor:function(a,b,c){Sankore.Calculus.Operation.constructor.call(this,b,c),Sankore.Calculus.Expression.isPrototypeOf(a)||(a=Sankore.Calculus.Operand.create(a)),this.left=a},isLeftAssociative:function(){return!0},getValue:function(){var a=this.left.getValue(),b=this.right.getValue();switch(this.operator){case"+":return a+b;case"-":return a-b;case"*":return a*b;case"/":if(0===b)throw Sankore.Util.Error.create("ZeroDivision","Division by zero");return a/b;default:throw Sankore.Util.Error.create("InvalidOperator","This is not a valid operator : "+this.operator)}},toString:function(){if(this.isInteger())return String(this.getValue());var a=this.left.toString(),b=this.right.toString();return Sankore.Calculus.Operation.isPrototypeOf(this.left)&&this.left.getPrecedence()<this.getPrecedence()&&(a="("+a+")"),Sankore.Calculus.Operation.isPrototypeOf(this.right)&&this.right.getPrecedence()<this.getPrecedence()&&(b="("+b+")"),a+String(this.operator)+b}})),klass.define("Sankore.Calculus","EuclideanDivisionOperation",Sankore.Calculus.BinaryOperation.extend({constructor:function(a,b){Sankore.Calculus.BinaryOperation.constructor.call(this,a,":",b)},getValue:function(){var a=this.right.getValue();if(0===a)throw Sankore.Util.Error.create("ZeroDivision","Division by zero");return Math.floor(this.left.getValue()/a)},getRemainder:function(){var a=this.right.getValue();if(0===a)throw Sankore.Util.Error.create("ZeroDivision","Division by zero");return this.left.getValue()%a}}))}(),function(){"use strict";klass.define("Sankore","Command",klass.extend({constructor:function(a,b,c){this.id=a,this.name=b,this.closure=c},getId:function(){return this.id},getName:function(){return this.name},exec:function(a,b){this.closure.call(a,b)},isInterrupting:function(){return!1},isInternal:function(){return!1}})),klass.define("Sankore","InterruptingCommand",Sankore.Command.extend({constructor:function(a,b,c){Sankore.Command.constructor.call(this,a,b,c)},isInterrupting:function(){return!0}})),klass.define("Sankore","InternalCommand",Sankore.Command.extend({constructor:function(a,b,c){Sankore.Command.constructor.call(this,a,b,c)},isInternal:function(){return!0}}))}(),function(){"use strict";klass.define("Sankore.Editor","Editor",klass.extend({constructor:function(a){this.current=null,this.activeButton=null,this.enabled=!1,this.layouts=Sankore.Util.Hash.create({"default":Sankore.Editor.Layout.create({id:"default",name:_("layout.classic_name"),buttonMap:{a1:Sankore.Button.create("mr","memoryRecall"),b1:Sankore.Button.create("mc","memoryClear"),c1:Sankore.Button.create("m+","memoryAdd"),d1:Sankore.Button.create("m-","memorySub"),a2:Sankore.Button.create("op","op"),b2:Sankore.Button.create("(","("),c2:Sankore.Button.create(")",")"),d2:Sankore.Button.create(":",":"),a3:Sankore.Button.create("7","7"),b3:Sankore.Button.create("8","8"),c3:Sankore.Button.create("9","9"),d3:Sankore.Button.create("/","/"),a4:Sankore.Button.create("4","4"),b4:Sankore.Button.create("5","5"),c4:Sankore.Button.create("6","6"),d4:Sankore.Button.create("*","*"),a5:Sankore.Button.create("1","1"),b5:Sankore.Button.create("2","2"),c5:Sankore.Button.create("3","3"),d5:Sankore.Button.create("-","-"),a6:Sankore.Button.create("0","0"),b6:Sankore.Button.create(".","."),c6:Sankore.Button.create("=","="),d6:Sankore.Button.create("+","+")}})}),this.calculator=a,this.ui=Sankore.UI.EditorInterface.create(this,this.calculator.eventDispatcher),this.attachEventHandlers()},attachEventHandlers:function(){var a=this,b=this.calculator.eventDispatcher;b.addEventListener("editor_interface.add_click",function(){var b=a.createLayout();a.setCurrentLayout(b.id)}),b.addEventListener("editor_interface.remove_click",function(){a.removeLayout(a.current),a.setCurrentLayout("default")}),b.addEventListener("editor_interface.run_click",this.runCurrentLayout.bind(this)),b.addEventListener("editor_interface.layout_select",function(b){a.setCurrentLayout(b)}),b.addEventListener("editor_interface.layout_name_change",function(c){a.getCurrentLayout().name!==c&&c.trim().length>0&&(a.getCurrentLayout().name=c,b.notify("editor.layout_changed"))}),b.addEventListener("editor_interface.layout_description_change",function(c){a.getCurrentLayout().description!==c&&(a.getCurrentLayout().description=c,b.notify("editor.layout_changed"))}),b.addEventListener("editor_interface.button_command_change",function(c){a.activeButton&&(a.getCurrentLayout().getButton(a.activeButton).command=c,b.notify("editor.layout_changed"))}),b.addEventListener("editor_interface.button_text_change",function(c){if(a.activeButton){var d=a.getCurrentLayout().getButton(a.activeButton);d.text=c,b.notify("editor.button_renamed",{slot:a.activeButton,button:d}),b.notify("editor.layout_changed")}}),b.addEventListener("editor_interface.button_uselimit_change",function(c){a.activeButton&&(isNaN(Number(c))||(a.getCurrentLayout().getButton(a.activeButton).useLimit=0===c.length?-1:Number(c),b.notify("editor.layout_changed")))}),b.addEventListener("main_interface.button_click",function(b){a.enabled&&a.setActiveButton(b.slot)}),b.addEventListener("main_interface.editor_click",function(){a.enabled?a.runCurrentLayout():a.enable()}),b.addEventListener("main_interface.reset_click",function(){a.enabled&&a.resetActiveButton()})},init:function(a){"layouts"in a&&this.loadLayouts(a.layouts),"enabled"in a&&(this.enabled=a.enabled),this.ui.render(this.calculator.ui),this.setCurrentLayout("current"in a&&a.current?a.current:"default"),this.enabled&&this.enable(),"activeButton"in a&&this.enabled&&this.setActiveButton(a.activeButton)},getState:function(){return{current:this.current,activeButton:this.activeButton,enabled:this.enabled,layouts:this.layouts.map(function(a,b){return b.isEditable()?b:void 0})}},loadLayouts:function(a){var b,c={};for(var d in a){for(var e in a[d].buttonMap)a[d].buttonMap.hasOwnProperty(e)&&(c[e]=Sankore.Button.create(a[d].buttonMap[e].text,a[d].buttonMap[e].command,a[d].buttonMap[e].useLimit));b=Sankore.Editor.Layout.create({id:a[d].id,name:a[d].name,description:a[d].description,buttonMap:c}),b.setEditable(!0),this.layouts.add("id",[b])}},getCurrentLayout:function(){return null===this.current?null:this.layouts.get(this.current)},setCurrentLayout:function(a){this.current=a,this.calculator.eventDispatcher.notify("editor.layout_selected",this.getCurrentLayout()),this.resetActiveButton()},createLayout:function(){var a=this.layouts.get("default").clone();return a.id=this.generateId(),a.name=_("layout.new_name"),a.setEditable(!0),this.layouts.set(a.id,a),this.calculator.eventDispatcher.notify("editor.layout_created"),a},generateId:function(){var a,b="",c=new Date,d=0;for(a=0;a<document.URL.length;a++)b+=String(document.URL.charCodeAt(a)*(c.getMilliseconds()+c.getSeconds()+c.getMinutes()));b=b.match(/.{1,10}/g);for(a in b)d+=Number(b[a]);return d.toString(36)},removeLayout:function(a){confirm(_("editor.remove_alert"))&&(this.layouts.remove(a),this.calculator.eventDispatcher.notify("editor.layout_removed"))},setActiveButton:function(a){if(a&&this.getCurrentLayout().isEditable()){var b=this.getCurrentLayout().getButton(a);b.isEditable()&&(this.calculator.eventDispatcher.notify("editor.button_selected",{slot:a,button:b,previousSlot:this.activeButton}),this.activeButton=a)}else this.resetActiveButton()},resetActiveButton:function(){this.calculator.eventDispatcher.notify("editor.button_selected",{slot:null,button:null,previousSlot:this.activeButton}),this.activeButton=null},enable:function(){this.enabled=!0,this.setActiveButton(null),this.calculator.eventDispatcher.notify("editor.show")},disable:function(){this.enabled=!1,this.setActiveButton(null),this.calculator.eventDispatcher.notify("editor.hide")},getAssignableCommands:function(){return this.calculator.commands.map(function(a,b){return b.isInternal()?void 0:b})},getAssignableTexts:function(){return this.calculator.texts.map(function(a,b){return b.isEditable()?b:void 0})},runCurrentLayout:function(){this.disable()}}))}(),function(){"use strict";klass.define("Sankore.Editor","Layout",klass.extend({constructor:function(a){this.id=a.id||null,this.name=a.name||null,this.description=a.description||null,this.editable=!1,this.buttonMap=a.buttonMap||{}},setEditable:function(a){this.editable=!!a},isEditable:function(){return this.editable},getButton:function(a){return this.buttonMap[a]||null},clone:function(){var a={};for(var b in this.buttonMap)this.buttonMap.hasOwnProperty(b)&&(a[b]=this.buttonMap[b].clone());return Sankore.Editor.Layout.create({id:this.id,name:this.name,description:this.description,editable:this.editable,buttonMap:a})}}))}(),function(){"use strict";klass.define("Sankore","KeystrokeLine",klass.extend({constructor:function(a){this.dispatcher=a,this.keystrokes=[],this.caret=0},notify:function(){this.dispatcher.notify("keystroke_line.changed",this)},hit:function(a){this.keystrokes.splice(this.caret,0,a),this.caret++,this.notify()},del:function(){if(this.caret>0){var a=this.keystrokes.splice(this.caret-1,1)[0];return this.caret--,this.notify(),a}},moveCaretLeft:function(){this.caret>0&&(this.caret--,this.notify())},moveCaretRight:function(){this.caret<this.keystrokes.length&&(this.caret++,this.notify())},moveCaretToEnd:function(){this.caret=this.keystrokes.length,this.notify()},reset:function(){this.caret=0,this.keystrokes=[],this.notify()},count:function(){return this.keystrokes.length},at:function(a){if("undefined"!=typeof this.keystrokes[a])return this.keystrokes[a];throw Sankore.Util.Error.create("OutOfRangeError","No keystroke at index "+a)},getAsText:function(){return[this.getTextAtRange(0,this.caret),this.getTextAtRange(this.caret,this.keystrokes.length)]},getTextAtRange:function(a,b){var c,d="";if(0>a)throw Sankore.Util.Error.create("OutOfRangeError","Cannot get keystroke before index 0");if(a>this.keystrokes.length)throw Sankore.Util.Error.create("OutOfRangeError","Cannot get keystroke after index "+this.keystrokes.length);for(c=a;b>c;c++)d+=this.at(c).text;return d},getState:function(){return{keystrokes:this.keystrokes,caret:this.caret}},loadState:function(a){this.keystrokes=a.keystrokes||{},this.caret=a.caret||0,this.notify()}}))}(),function(){"use strict";klass.define("Sankore","Text",klass.extend({constructor:function(a,b,c,d,e){this.id=a,this.screen=b,this.button=c,this.type="undefined"!=typeof d?d:"normal",this.editable="undefined"!=typeof e?!!e:!0},isEditable:function(){return this.editable},setEditable:function(a){this.editable=!!a}}))}(),function(){"use strict";klass.define("Sankore.UI","EditorInterface",klass.extend({constructor:function(a,b){this.editor=a,this.dispatcher=b,this.hidden=!0,this.editArea=null,this.layoutSelect=null,this.layoutNameInput=null,this.layoutDescriptionInput=null,this.assignationDiv=null,this.runButton=null,this.addButton=null,this.removeButton=null,this.attachEventListeners(),this.rendered=!1},attachEventListeners:function(){var a=this;this.dispatcher.addEventListener("editor.show",this.show.bind(this)),this.dispatcher.addEventListener("editor.hide",this.hide.bind(this)),this.dispatcher.addEventSubscriber({events:["editor.layout_changed","editor.layout_created","editor.layout_removed"],listener:this.updateLayoutSelectElement.bind(this)}),this.dispatcher.addEventListener("editor.layout_selected",function(b){a.loadLayout(b),a.selectLayout(b.id)}),this.dispatcher.addEventListener("editor.button_selected",function(b){var c=b.button;null===c&&a.editor.getCurrentLayout()&&(c=a.editor.getCurrentLayout().isEditable()),a.renderAssignation(c)})},_clearElement:function(a){for(;a.firstChild;)a.removeChild(a.firstChild)},_map:function(a,b){var c,d=[];for(c in a)a.hasOwnProperty(c)&&d.push(b.call(a,a[c],c));return d},render:function(a){var b,c,d=this;this.editArea=document.createElement("div"),this.editArea.classList.add("edit-area"),this.layoutSelect=this.createLayoutSelectElement(),this.editArea.appendChild(this.layoutSelect),this.addButton=document.createElement("button"),this.addButton.className="small",this.addButton.setAttribute("type","button"),this.addButton.addEventListener("click",function(){d.dispatcher.notify("editor_interface.add_click")}),this.removeButton=this.addButton.cloneNode(),this.removeButton.classList.add("remove"),this.removeButton.addEventListener("click",function(){d.dispatcher.notify("editor_interface.remove_click")}),this.addButton.classList.add("add"),this.editArea.appendChild(this.addButton),this.editArea.appendChild(this.removeButton),this.editArea.appendChild(document.createElement("hr")),b=document.createElement("label"),b.appendChild(document.createTextNode(_("editor.layout_name.label"))),this.editArea.appendChild(b),this.layoutNameInput=document.createElement("input"),this.layoutNameInput.setAttribute("name","layout_name"),this.layoutNameInput.setAttribute("type","text"),this.layoutNameInput.setAttribute("maxlength",32),this.layoutNameInput.addEventListener("keyup",function(){d.dispatcher.notify("editor_interface.layout_name_change",this.value)}),this.layoutNameInput.addEventListener("change",function(){0===this.value.trim().length&&(this.value=d.editor.getCurrentLayout().name,d.dispatcher.notify("editor_interface.layout_name_change",this.value))}),this.editArea.appendChild(this.layoutNameInput),c=document.createElement("label"),c.appendChild(document.createTextNode(_("editor.layout_description.label"))),this.editArea.appendChild(c),this.layoutDescriptionInput=document.createElement("textarea"),this.layoutDescriptionInput.setAttribute("name","layout_description"),this.layoutDescriptionInput.setAttribute("maxlength",140),this.layoutDescriptionInput.addEventListener("keyup",function(){d.dispatcher.notify("editor_interface.layout_description_change",this.value)}),this.editArea.appendChild(this.layoutDescriptionInput),this.assignationDiv=document.createElement("div"),this.assignationDiv.classList.add("assignation"),this.editArea.appendChild(this.assignationDiv),this.runButton=document.createElement("button"),this.runButton.classList.add("run"),this.runButton.setAttribute("type","button"),this.runButton.appendChild(document.createTextNode(_("editor.run_button"))),this.runButton.addEventListener("click",function(){d.dispatcher.notify("editor_interface.run_click")}),this.editArea.appendChild(this.runButton),a.rearScreen.parentElement.appendChild(this.editArea),this.rendered=!0,this.hide()},createSelectElement:function(a,b,c,d){var e,f=document.createElement("select");f.setAttribute("name",b),c&&(f.className=c);for(var g in a)e=document.createElement("option"),e.setAttribute("value",a[g].value),"undefined"!=typeof d&&d===a[g].value&&(e.selected=!0),e.appendChild(document.createTextNode(a[g].text)),f.appendChild(e);return f},createLayoutSelectElement:function(){var a=this.createSelectElement(this.editor.layouts.map(function(a,b){return{text:b.name,value:b.id}}),"layouts","layout-select",this.editor.current),b=this;return a.addEventListener("change",function(){b.dispatcher.notify("editor_interface.layout_select",this.value)}),a},updateLayoutSelectElement:function(){var a=this.createLayoutSelectElement();this.editArea.replaceChild(a,this.layoutSelect),this.layoutSelect=a},selectLayout:function(a){this.layoutSelect.value=a},show:function(){this.rendered&&(this.editArea.style.display="block",this.hidden=!1)},hide:function(){this.rendered&&(this.editArea.style.display="none",this.hidden=!0)},loadLayout:function(a){this.layoutNameInput.value=a.name,this.layoutNameInput.disabled=!a.isEditable(),this.layoutDescriptionInput.value=a.description,this.layoutDescriptionInput.disabled=!a.isEditable(),this.removeButton.disabled=!a.isEditable(),this.renderAssignation(a.isEditable())},renderAssignation:function(a){var b,c,d,e,f,g,h,i,j,k=this;!1===a?(b=document.createElement("em"),b.appendChild(document.createTextNode(_("editor.assignation.disabled")))):Sankore.Button.isPrototypeOf(a)?(b=document.createDocumentFragment(),c=document.createElement("label"),c.appendChild(document.createTextNode(_("editor.assignation.text.label"))),b.appendChild(c),j=this.editor.calculator.texts.get(a.text),d=this.createSelectElement(this._map(this.editor.getAssignableTexts(),function(a){return{text:a.button,value:a.id}}),"button_text","",j.id),d.addEventListener("change",function(a){k.dispatcher.notify("editor_interface.button_text_change",a.target.value)}),b.appendChild(d),e=document.createElement("label"),e.appendChild(document.createTextNode(_("editor.assignation.command.label"))),b.appendChild(e),f=this.createSelectElement(this._map(this.editor.getAssignableCommands(),function(a){return{text:a.name,value:a.id}}),"button_command","",a.command),f.addEventListener("change",function(a){k.dispatcher.notify("editor_interface.button_command_change",a.target.value)}),b.appendChild(f),g=document.createElement("label"),g.appendChild(document.createTextNode(_("editor.assignation.use_limit.label"))),b.appendChild(g),h=document.createElement("input"),h.setAttribute("type","text"),h.setAttribute("name","button_count"),h.value=-1===a.useLimit?"":a.useLimit,h.addEventListener("change",function(a){k.dispatcher.notify("editor_interface.button_uselimit_change",a.target.value)}),b.appendChild(h),i=document.createElement("span"),i.className="help",i.appendChild(document.createTextNode(_("editor.assignation.use_limit.help"))),b.appendChild(i)):(b=document.createElement("em"),b.appendChild(document.createTextNode(_("editor.assignation.enabled")))),this._clearElement(this.assignationDiv),this.assignationDiv.appendChild(b)}}))}(),function(){"use strict";klass.define("Sankore.UI","MainInterface",klass.extend({constructor:function(a,b,c,d){this.id=a,this.dispatcher=b,this.texts=c,this.withEditor=d,this.title=null,this.caret=document.createElement("i"),this.caret.className="caret",this.frontScreen=null,this.expressionRow=null,this.resultRow=null,this.flagRow=null,this.flags=[],this.rearScreen=null,this.buttons=Sankore.Util.Hash.create(),this.rendered=!1,this.attachEventListeners()},attachEventListeners:function(){var a=this;this.dispatcher.addEventListener("keystroke_line.changed",function(b){a.updateExpressionRow(b.getAsText())}),this.dispatcher.addEventListener("calculator.memory_changed",function(b){null!==b?a.addFlag("M"):a.removeFlag("M"),a.updateFlagRow()
}),this.dispatcher.addEventListener("calculator.op_changed",function(b){null!==b?a.addFlag("OP"):a.removeFlag("OP"),a.updateFlagRow()}),this.dispatcher.addEventListener("calculator.output_changed",function(b){a.updateResultRow(null!==b.output?b.output:null!==b.error?b.error:"")}),this.dispatcher.addEventListener("calculator.history_changed",this.updateRearScreen.bind(this)),this.dispatcher.addEventListener("calculator.layout_loaded",function(b){a.renderButtons(b.buttonMap),a.changeTitle(b.name),a.clearRearScreen()}),this.dispatcher.addEventListener("calculator.button_disabled",function(b){var c=a.buttons.get(b.slot);c&&(c.disabled=!0)}),this.dispatcher.addEventListener("calculator.button_enabled",function(b){var c=a.buttons.get(b);c&&(c.disabled=!1)}),this.dispatcher.addEventListener("editor.show",this.hideRearScreen.bind(this)),this.dispatcher.addEventListener("editor.hide",this.showRearScreen.bind(this)),this.dispatcher.addEventListener("editor.button_selected",function(b){var c=a.buttons.get(b.slot),d=a.buttons.get(b.previousSlot);d&&d.parentElement.classList.remove("edit"),c&&c.parentElement.classList.add("edit")}),this.dispatcher.addEventListener("editor.button_renamed",function(b){var c,d=a.buttons.get(b.slot),e=a.texts.get(b.button.text);d&&(d.innerText=e.button,c=d.parentElement.classList.contains("edit"),d.parentElement.className=e.type,c&&d.parentElement.classList.add("edit"))})},_clearElement:function(a){for(;a.firstChild;)a.removeChild(a.firstChild)},getRootElement:function(){return document.getElementById(this.id)},render:function(){var a=this.getRootElement();this._clearElement(a),a.classList.contains("calculator")||a.classList.add("calculator"),this.createBaseMarkup(a),this.rearScreen=document.createElement("ul"),a.getElementsByClassName("rear-screen").item(0).appendChild(this.rearScreen),this.frontScreen=document.createElement("ul"),a.getElementsByClassName("front-screen").item(0).appendChild(this.frontScreen),this.expressionRow=document.createElement("li"),this.expressionRow.classList.add("expression-row"),this.frontScreen.appendChild(this.expressionRow),this.flagRow=document.createElement("li"),this.flagRow.classList.add("flag-row"),this.frontScreen.appendChild(this.flagRow),this.resultRow=document.createElement("li"),this.resultRow.classList.add("result-row"),this.frontScreen.appendChild(this.resultRow),this.rendered=!0},renderButtons:function(a){var b,c={},d=document.createDocumentFragment(),e=this.getRootElement().getElementsByClassName("screen").item(0).parentElement;for(var f in a)c[f]=a[f];for(c.a0=Sankore.Button.create("s","del",-1,!1),c.b0=Sankore.Button.create("l","left",-1,!1),c.c0=Sankore.Button.create("r","right",-1,!1),c.d0=Sankore.Button.create("c","clear",-1,!1),b=e.getElementsByClassName("buttons");b.length>0;)e.removeChild(b[0]);b=this.createButtons(c);for(var g in b)d.appendChild(b[g]);e.appendChild(d)},createBaseMarkup:function(a){var b=document.createElement("table"),c=document.createElement("tr"),d=document.createElement("td"),e=document.createElement("td");d.className="rear-screen",d.setAttribute("rowspan","8"),c.appendChild(d),e.className="front-screen",e.setAttribute("colspan","4"),c.appendChild(e),c.className="screen",b.appendChild(c),a.appendChild(this.createTitle()),a.appendChild(this.createControls()),a.appendChild(b)},createTitle:function(){return this.title=document.createElement("span"),this.title.appendChild(document.createTextNode("Chargement...")),this.title.className="title",this.title},createControls:function(){var a=document.createElement("div"),b=document.createElement("button"),c=document.createElement("button"),d=this;return this.withEditor&&(b.setAttribute("type","button"),b.appendChild(document.createTextNode(_("controls.editor"))),b.addEventListener("click",function(){d.dispatcher.notify("main_interface.editor_click")}),a.appendChild(b)),c.setAttribute("type","button"),c.appendChild(document.createTextNode(_("controls.reset"))),c.addEventListener("click",function(){d.dispatcher.notify("main_interface.reset_click")}),a.appendChild(c),a.className="controls",a},createButtons:function(a){var b,c=[];for(b=0;7>b;b++)c.push(this.createButtonRow(b,a));return c},createButtonRow:function(a,b){var c,d=document.createElement("tr");for(d.className="buttons",c="a";"d">=c;c=String.fromCharCode(c.charCodeAt(0)+1))d.appendChild(this.createButton(c+a,b));return d},createButton:function(a,b){var c,d,e=document.createElement("td"),f=this,g=b[a];return e.setAttribute("data-slot",a),e.setAttribute("data-editable",g.isEditable()),"undefined"!=typeof g&&(d=document.createElement("button"),c=this.texts.get(g.text),d.innerText=c.button,"normal"!==c.type&&e.classList.add(c.type),d.addEventListener("mousedown",function(b){f.handleButtonClick(this,b,g,a)}),this.buttons.set(a,d),this.dispatcher.notify("main_interface.button_created",{button:g,slot:a}),e.appendChild(d)),e},handleButtonClick:function(a,b,c,d){this.dispatcher.notify("main_interface.button_click",{button:c,slot:d})},updateFlagRow:function(){var a;this._clearElement(this.flagRow);for(var b in this.flags)a=document.createElement("span"),a.appendChild(document.createTextNode(this.flags[b])),this.flagRow.appendChild(a)},updateExpressionRow:function(a){this._clearElement(this.expressionRow),this.expressionRow.appendChild(document.createTextNode(a[0])),this.expressionRow.appendChild(this.caret),this.expressionRow.appendChild(document.createTextNode(a[1]))},updateResultRow:function(a){this._clearElement(this.resultRow),this.resultRow.appendChild(this.createResultRow(a))},createResultRow:function(a){try{return Sankore.Calculus.EuclideanDivisionOperation.isPrototypeOf(a)?this.createResultRowEuclidean(a.getValue(),a.getRemainder()):Sankore.Calculus.Expression.isPrototypeOf(a)?this.createResultRowExpression(a.getValue()):Sankore.Util.Error.isPrototypeOf(a)?this.createResultRowError(a):this.createResultRowText(String(a))}catch(b){return this.createResultRowError(b)}return null},createResultRowEuclidean:function(a,b){var c=document.createElement("p"),d=document.createElement("span"),e=document.createElement("span");return c.classList.add("euclidean"),e.classList.add("remainder"),e.textContent=this.formatResultValue(b),c.appendChild(e),d.classList.add("quotient"),d.textContent=this.formatResultValue(a),c.appendChild(d),c},createResultRowExpression:function(a){return document.createTextNode(this.formatResultValue(a))},createResultRowText:function(a){return document.createTextNode(a)},createResultRowError:function(a){var b=document.createElement("div"),c=_("error.common");return"ZeroDivision"===a.name&&(c=_("error.zero_division")),b.classList.add("error"),b.appendChild(document.createTextNode(c)),b},formatResultValue:function(a){var b,c=a.toFixed(Math.max(0,10-a.toFixed().length));if(-1!==c.indexOf("."))for(;;){b=c.charAt(c.length-1);{if("0"!==b){"."===b&&(c=c.slice(0,-1));break}c=c.slice(0,-1)}}return Number(c)>1e10-1&&(c=Number(c.substring(0,11)/10).toFixed()),-1!==c.indexOf(".")&&(c=c.replace(".",_("text.comma"))),c},updateRearScreen:function(a){var b,c,d=document.createDocumentFragment();for(var e in a)b=document.createElement("li"),b.className="expression-row",b.appendChild(document.createTextNode(a[e].expression)),d.appendChild(b),c=document.createElement("li"),c.className="result-row",c.appendChild(this.createResultRow(a[e].output)),d.appendChild(c);this.clearRearScreen(),this.rearScreen.appendChild(d),this.rearScreen.lastChild.scrollIntoView()},clearRearScreen:function(){this._clearElement(this.rearScreen)},showRearScreen:function(){this.rearScreen.style.display="block",this.showTitle()},hideRearScreen:function(){this.rearScreen.style.display="none",this.hideTitle()},addFlag:function(a){-1===this.flags.indexOf(a)&&(this.flags.push(a),this.flags.sort())},removeFlag:function(a){var b=this.flags.indexOf(a);-1!==b&&(this.flags.splice(b,1),this.flags.sort())},changeTitle:function(a){this._clearElement(this.title),this.title.appendChild(document.createTextNode(a))},showTitle:function(){this.title.style.visibility="visible"},hideTitle:function(){this.title.style.visibility="hidden"}}))}(),function(){"use strict";klass.define("Sankore.Util","Error",klass.extend({constructor:function(a,b){this.name=a,this.message=b},toString:function(){return this.name+": "+this.message}}))}(),function(){"use strict";klass.define("Sankore.Util","EventDispatcher",klass.extend({constructor:function(){this.eventListeners={}},addEventSubscriber:function(a){for(var b in a.events)this.addEventListener(a.events[b],a.listener);return this},addEventListener:function(a,b,c){return"undefined"==typeof this.eventListeners[a]&&(this.eventListeners[a]=[]),"undefined"==typeof c?this.eventListeners[a].push(b):this.eventListeners[a][c]=b,this},removeEventListener:function(a,b){delete this.eventListeners[a][b]},removeAllEventListeners:function(a){this.eventListeners[a]=[]},notify:function(a,b){var c;for(c in this.eventListeners[a])this.eventListeners[a][c](b)}}))}(),function(){"use strict";klass.define("Sankore.Util","Hash",klass.extend({constructor:function(a){this.elements=a||{}},length:function(){return this.keys().length},keys:function(){return Object.keys(this.elements)},set:function(a,b){this.elements[a]=b},add:function(a,b){for(var c in b)this.set(b[c][a],b[c])},has:function(a){return-1!==this.keys().indexOf(a)},get:function(a,b){return"undefined"!=typeof this.elements[a]?this.elements[a]:"undefined"!=typeof b?b:null},pos:function(a){var b=0;for(var c in this.elements){if(this.elements.hasOwnProperty(c)&&c===a)return b;b++}return null},remove:function(a){return delete this.elements[a]},map:function(a){var b,c=[];for(var d in this.elements)this.elements.hasOwnProperty(d)&&(b=a.call(this,d,this.elements[d]),b&&c.push(b));return c}}))}(),function(){"use strict";klass.define("Sankore.Util","I18N",klass.extend({catalogs:Sankore.Util.Hash.create(),constructor:function(){this.catalog={}},load:function(a){var b=a.split(/-|_/)[0].toLowerCase();Sankore.Util.I18N.catalogs.has(b)||(b="en"),this.catalog=Sankore.Util.I18N.catalogs.get(b,{})},translate:function(a){return a.split(".").reduce(function(a,b){return a&&b in a?a[b]:null},this.catalog)||a}})),Sankore.Util.i18n=Sankore.Util.I18N.create(),window._=function(a){return Sankore.Util.i18n.translate(a)}}(),function(){Sankore.Util.I18N.catalogs.set("en",{layout:{classic_name:"Basic calculator",new_name:"New calculator"},text:{del:"DEL",comma:"."},command:{zero:"0 digit",one:"1 digit",two:"2 digit",three:"3 digit",four:"4 digit",five:"5 digit",six:"6 digit",seven:"7 digit",eight:"8 digit",nine:"9 digit",plus:"Addition",minus:"Subtraction",times:"Multiplication",divide:"Division",euclidean_divide:"Euclidean division",equal:"Equal",comma:"Comma",open_parenthesis:"Open parenthesis",close_parenthesis:"Close parenthesis",op:"Constant operator",memory_add:"Memory addition",memory_sub:"Memory substraction",memory_recall:"Memory recall",memory_clear:"Memory clear",clear:"Clear",left:"Move left",right:"Move right",del:"Delete"},controls:{editor:"Editor",reset:"RST"},editor:{run_button:"Run",remove_alert:"Delete this calculator?",layout_name:{label:"Name"},layout_description:{label:"Description"},assignation:{enabled:"Click on a button to edit it",disabled:"This calculator is not editable",text:{label:"Display text"},command:{label:"Command"},use_limit:{label:"Use limit",help:"0 for disabled, empty for unlimited"}}},error:{common:"Error",zero_division:"Div/0 error"}})}(),function(){Sankore.Util.I18N.catalogs.set("fr",{layout:{classic_name:"Calculatrice standard",new_name:"Nouvelle calculatrice"},text:{del:"EFF",comma:","},command:{zero:"Chiffre 0",one:"Chiffre 1",two:"Chiffre 2",three:"Chiffre 3",four:"Chiffre 4",five:"Chiffre 5",six:"Chiffre 6",seven:"Chiffre 7",eight:"Chiffre 8",nine:"Chiffre 9",plus:"Addition",minus:"Soustraction",times:"Multiplication",divide:"Division",euclidean_divide:"Division euclidienne",equal:"Egalité",comma:"Virgule",open_parenthesis:"Parenthèse ouvrante",close_parenthesis:"Parenthèse fermante",op:"Opérateur constant",memory_add:"Addition mémoire",memory_sub:"Soustraction mémoire",memory_recall:"Rappel mémoire",memory_clear:"R.A.Z. mémoire",clear:"R.A.Z.",left:"Déplacement à gauche",right:"Déplacement à droite",del:"Suppression"},controls:{editor:"Editeur",reset:"RAZ"},editor:{run_button:"Utiliser",remove_alert:"Supprimer cette calculatrice ?",layout_name:{label:"Nom"},layout_description:{label:"Description"},assignation:{enabled:"Cliquez sur une touche pour la modifier",disabled:"Cette calculatrice n'est pas modifiable",text:{label:"Texte à afficher"},command:{label:"Commande"},use_limit:{label:"Nb d'utilisation",help:"0 pour désactiver, vide pour illimité"}}},error:{common:"Erreur",zero_division:"Erreur div/0"}})}();
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Unpredictable Calculator</title>
<script src="js/sankore.js" type="text/javascript"></script>
<script src="dist/calculator.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="css/calculator.css" />
</head>
<body>
<div id="ubwidget"></div>
<script type="text/javascript">
var unpredictable = false;
var c = Sankore.Calculator.create('ubwidget', {
locale: window.sankore ? window.sankore.locale() : 'fr_FR',
unpredictableMode: unpredictable,
ready: function () {
var self = this, state = {}, timer = null;
if (window.sankore) {
try {
state = JSON.parse(window.sankore.preference('state'));
} catch (e) {}
this.eventDispatcher.addEventSubscriber({
events: [
'calculator.output_changed', 'calculator.memory_changed', 'calculator.layout_changed',
'editor.layout_created', 'editor.layout_removed', 'editor.layout_changed', 'editor.button_selected',
'keystroke_line.changed'
],
listener: function () {
if (null !== timer) {
clearTimeout(timer);
}
timer = setTimeout(function() {
window.sankore.setPreference('state', JSON.stringify(self.getState()));
timer = null;
}, 350);
}
});
}
this.init(state);
}
});
</script>
</body>
</html>
/*jshint browser:true, devel:true*/
if (!('sankore' in window)) {
window.sankore = {
preferences: {
state: ''
},
setPreference: function (name, value) {
console.log('Preference "' + name + '" set to : ' + value);
this.preferences[name] = value;
},
preference: function (name) {
console.log('Accessing "' + name + '"');
return this.preferences[name] || '';
},
locale: function () {
return window.navigator.language;
}
};
}
\ No newline at end of file
/*global klass:true, Sankore:true*/
(function() {
"use strict";
klass.define('Sankore', 'Button', klass.extend({
constructor: function (text, command, useLimit, editable) {
this.text = text;
this.command = command;
this.useLimit = typeof useLimit === 'undefined' ? -1 : useLimit;
this.editable = typeof editable === 'undefined' ? true : editable;
},
isEditable: function () {
return this.editable;
},
isUsable: function () {
return this.useLimit === -1;
},
isDisabled: function () {
return this.useLimit === 0;
},
clone: function () {
return Sankore.Button.create(
this.text,
this.command,
this.useLimit,
this.editable
);
}
}));
})();
\ No newline at end of file
/*jshint devel:true, browser:true*/
/*globals klass:true, Sankore:true, _:true */
(function () {
"use strict";
klass.define('Sankore', 'Calculator', klass.extend({
constructor: function (id, options) {
Sankore.Util.i18n.load(options.locale || 'en');
// state attributes
this.currentLayout = null;
this.lastError = null; // last raised error
this.memory = null; // internal memory
this.op = null; // op memory
this.output = null; // last evaluated resut
this.history = []; // operation history
this.buttonUseCount = {}; // button use count
// local attributes
this.expressionString = ''; // current expressionString
this.unpredictable = options.unpredictableMode || false;
// components
this.eventDispatcher = Sankore.Util.EventDispatcher.create();
this.commands = Sankore.Util.Hash.create(); // command hash
this.texts = Sankore.Util.Hash.create(); // text hash
this.calculusEngine = Sankore.Calculus.Engine.create();
this.keystrokeLine = Sankore.KeystrokeLine.create(this.eventDispatcher);
this.ui = Sankore.UI.MainInterface.create(id, this.eventDispatcher, this.texts, this.unpredictable);
this.editor = Sankore.Editor.Editor.create(this);
if (typeof options.ready !== 'undefined') {
this.eventDispatcher.addEventListener('calculator.create', options.ready.bind(this));
}
var c = Sankore.Text.create.bind(Sankore.Text);
this.texts.add('id', [
c('0', '0', '0'),
c('1', '1', '1'),
c('2', '2', '2'),
c('3', '3', '3'),
c('4', '4', '4'),
c('5', '5', '5'),
c('6', '6', '6'),
c('7', '7', '7'),
c('8', '8', '8'),
c('9', '9', '9'),
c('+', '+', '+', 'alt'),
c('-', '-', '-', 'alt'),
c('*', '\u00D7', '\u00D7', 'alt'),
c('/', '\u00F7', '\u00F7', 'alt'),
c(':', '\u22A2', '\u22A2', 'alt'),
c('=', '=', '=', 'alt'),
c('.', _('text.comma'), _('text.comma')),
c('(', '(', '('),
c(')', ')', ')'),
c('op', 'OP', 'OP'),
c('mr', 'MR', 'MR'),
c('mc', 'MC', 'MC'),
c('m+', 'M+', 'M+'),
c('m-', 'M-', 'M-'),
c('s', '', _('text.del'), 'alt', false),
c('l', '', '\u2190', 'alt', false),
c('r', '', '\u2192', 'alt', false),
c('c', '', 'C', 'danger', false)
]);
c = Sankore.Command.create.bind(Sankore.Command);
this.commands.add('id', [
// add 0 to the expression string
c('0', _('command.zero'), function (args) {
this.expressionString += '0';
}),
// add 1 to the expression string
c('1', _('command.one'), function (args) {
this.expressionString += '1';
}),
// add 2 to the expression string
c('2', _('command.two'), function (args) {
this.expressionString += '2';
}),
// add 3 to the expression string
c('3', _('command.three'), function (args) {
this.expressionString += '3';
}),
// add 4 to the expression string
c('4', _('command.four'), function (args) {
this.expressionString += '4';
}),
// add 5 to the expression string
c('5', _('command.five'), function (args) {
this.expressionString += '5';
}),
// add 6 to the expression string
c('6', _('command.six'), function (args) {
this.expressionString += '6';
}),
// add 7 to the expression string
c('7', _('command.seven'), function (args) {
this.expressionString += '7';
}),
// add 8 to the expression string
c('8', _('command.eight'), function (args) {
this.expressionString += '8';
}),
// add 9 to the expression string
c('9', _('command.nine'), function (args) {
this.expressionString += '9';
}),
// add + to the expression string
c('+', _('command.plus'), function (args) {
this.expressionString += '+';
}),
// add - to the expression string
c('-', _('command.minus'), function (args) {
this.expressionString += '-';
}),
// add * to the expression string
c('*', _('command.times'), function (args) {
this.expressionString += '*';
}),
// add / to the expression string
c('/', _('command.divide'), function (args) {
this.expressionString += '/';
}),
// add : to the expression string
c(':', _('command.euclidean_divide'), function (args) {
this.expressionString += ':';
}),
// evaluate the current expression
Sankore.InterruptingCommand.create('=', _('command.equal'), function (args) {
this.evaluateStack();
}),
// add . to the expression string
c('.', _('command.comma'), function (args) {
this.expressionString += '.';
}),
// add ( to the expression string
c('(', _('command.open_parenthesis'), function (args) {
this.expressionString += '(';
}),
// add ) to the expression string
c(')', _('command.close_parenthesis'), function (args) {
this.expressionString += ')';
}),
// store the current (incomplete) expression if not already, else
// call the incomplete expression, append it to the expression string then evaluate
Sankore.InterruptingCommand.create('op', _('command.op'), function (args) {
if (null === this.op) {
if (this.expressionString.length > 1 &&
-1 !== '+-*/:'.indexOf(this.expressionString[0])
) {
try {
// we parse the OP expression with a fake left operand (1)
// if it raised exceptions during parsing or evaluating,
// the expression is not good for an OP operation
this.calculusEngine.evaluate('(1)' + this.expressionString).getValue();
this.op = this.expressionString;
this.eventDispatcher.notify('calculator.op_changed', this.op);
} catch (e) {
}
}
this.expressionString = '';
this.output = null;
} else {
// case : the OP command is called immediately. The previous results is used
// as the left operand
if (0 === this.expressionString.length && null !== this.output) {
this.expressionString = '(' + this.output.toString() + ')';
}
this.expressionString += this.op;
this.execCommand('=');
}
}),
// evaluate the expression string and add it to the memory
Sankore.InterruptingCommand.create('memoryAdd', _('command.memory_add'), function (args) {
this.execCommand('=');
try {
if (null === this.memory) {
this.memory = 0;
}
this.memory += this.output.getValue();
} catch (e) {
this.memory = null;
}
this.eventDispatcher.notify('calculator.memory_changed', this.memory);
}),
// evaluate the expression string and substract it from the memory
Sankore.InterruptingCommand.create('memorySub', _('command.memory_sub'), function (args) {
this.execCommand('=');
try {
if (null === this.memory) {
this.memory = 0;
}
this.memory -= this.output.getValue();
} catch (e) {
this.memory = null;
}
this.eventDispatcher.notify('calculator.memory_changed', this.memory);
}),
// add the current memory value to the expression string
c('memoryRecall', _('command.memory_recall'), function (args) {
if (null !== this.memory) {
this.expressionString += '(' + this.memory.toString() + ')';
}
}),
// clear the memory
c('memoryClear', _('command.memory_clear'), function (args) {
this.memory = null;
this.eventDispatcher.notify('calculator.memory_changed', this.memory);
}),
// clear the output, memory, op and expression string
Sankore.InternalCommand.create('clear', _('command.clear'), function (args) {
this.reset();
this.eventDispatcher.notify('calculator.memory_changed', this.memory);
this.eventDispatcher.notify('calculator.op_changed', this.op);
this.eventDispatcher.notify('calculator.output_changed', {
output: this.output,
error: this.lastError
});
}),
// move the caret left
Sankore.InternalCommand.create('left', _('command.left'), function (args) {
this.keystrokeLine.moveCaretLeft();
}),
// move the caret right
Sankore.InternalCommand.create('right', _('command.right'), function (args) {
this.keystrokeLine.moveCaretRight();
}),
// delete the keystroke before the caret
Sankore.InternalCommand.create('del', _('command.del'), function (args) {
var keystroke = this.keystrokeLine.del();
if (keystroke && this.getButtonUseCount(keystroke.slot)) {
this.buttonUseCount[keystroke.slot]--;
if (this.getButtonUseCount(keystroke.slot) < this.currentLayout.getButton(keystroke.slot).useLimit) {
this.eventDispatcher.notify('calculator.button_enabled', keystroke.slot);
}
}
})
]);
this.attachEventHandlers();
this.eventDispatcher.notify('calculator.create');
},
attachEventHandlers: function () {
var self = this, ed = this.eventDispatcher;
if (this.unpredictable) {
ed.addEventListener('editor.show', this.reload.bind(this));
ed.addEventListener('editor.hide', this.reload.bind(this));
}
ed.addEventListener('editor.layout_selected', function (layout) {
self.loadLayout(layout.id);
});
ed.addEventListener('main_interface.button_created', function (event) {
if (!self.editor.enabled && event.button.isDisabled()) {
ed.notify('calculator.button_disabled', event);
}
});
ed.addEventListener('main_interface.button_click', function (event) {
if (!self.editor.enabled) {
self.useButton(event.slot);
self.keystroke(event.slot, event.button);
if (!event.button.isUsable() && self.getButtonUseCount(event.slot) >= event.button.useLimit) {
ed.notify('calculator.button_disabled', event);
}
}
});
ed.addEventListener('main_interface.reset_click', function () {
self.reload();
});
},
reset: function () {
this.memory = null;
this.op = null;
this.output = null;
this.lastError = null;
this.expressionString = [];
this.keystrokeLine.reset();
},
init: function (state) {
var self = this;
this.ui.render();
this.editor.init(state.editor ||  {});
if (null !== this.layout) {
this.loadLayout(state.layout || 'default');
}
if ('buttonUseCount' in state) {
this.buttonUseCount = state.buttonUseCount;
}
if ('keystrokes' in state) {
this.keystrokeLine.loadState(state.keystrokes || {});
}
if ('output' in state && state.output) {
this.expressionString = state.output || '';
this.evaluateStack();
}
if ('error' in state && state.error) {
this.lastError = Sankore.Util.Error.create(state.error.name, state.error.message);
this.eventDispatcher.notify('calculator.output_changed', {
output: this.output,
error: this.lastError
});
}
if ('memory' in state) {
this.memory = state.memory;
this.eventDispatcher.notify('calculator.memory_changed', this.memory);
}
if ('op' in state) {
this.op = state.op;
this.eventDispatcher.notify('calculator.op_changed', this.op);
}
if ('history' in state && state.history.length > 0) {
this.history = state.history.map(function (log) {
return {
expression: log.expression,
output: self.calculusEngine.evaluate(log.output)
};
});
this.eventDispatcher.notify('calculator.history_changed', this.history);
}
this.eventDispatcher.notify('calculator.init');
},
getState: function () {
return {
layout: this.currentLayout ? this.currentLayout.id : null,
error: this.lastError,
memory: this.memory,
op: this.op,
output: this.output ? this.output.toString() : null,
buttonUseCount: this.buttonUseCount,
editor: this.editor.getState(),
keystrokes: this.keystrokeLine.getState(),
history: this.history.map(function (log) {
return {
expression: log.expression,
output: log.output.toString()
};
})
};
},
loadLayout: function (layoutId) {
this.currentLayout = this.editor.layouts.get(layoutId);
this.execCommand('clear');
this.buttonUseCount = {};
this.history = [];
this.eventDispatcher.notify('calculator.layout_loaded', this.currentLayout);
},
reload: function () {
this.loadLayout(this.currentLayout.id);
},
execCommand: function (name, args) {
var command = this.commands.get(name);
command.exec(this, args);
this.eventDispatcher.notify('calculator.command_executed', {
command: command,
args: args
});
},
evaluateStack: function () {
try {
if (this.expressionString.length > 0) {
this.output = this.calculusEngine.evaluate(this.expressionString);
} else {
this.output = null;
}
this.lastError = null;
} catch (e) {
this.lastError = e;
this.output = null;
}
this.expressionString = '';
this.eventDispatcher.notify('calculator.output_changed', {
output: this.output,
error: this.lastError
});
},
keystroke: function (slot, button) {
var command = this.commands.get(button.command),
text = this.texts.get(button.text);
if (!command.isInternal()) {
if (command.isInterrupting()) {
this.keystrokeLine.moveCaretToEnd();
}
this.keystrokeLine.hit({
slot: slot,
text: text.screen,
command: button.command
});
} else {
this.execCommand(command.id);
}
if (command.isInterrupting()) {
this.execute();
}
},
execute: function () {
var length = this.keystrokeLine.count(),
i;
for (i = 0; i < length; i++) {
this.execCommand(this.keystrokeLine.at(i).command);
}
this.eventDispatcher.notify('calculator.executed');
if (!this.lastError && this.output) {
try {
this.backup(
this.keystrokeLine.getAsText().join(''),
this.output
);
} catch (e) {}
}
this.keystrokeLine.reset();
},
useButton: function (slot) {
if (typeof this.buttonUseCount[slot] === 'undefined') {
this.buttonUseCount[slot] = 0;
}
this.buttonUseCount[slot]++;
},
getButtonUseCount: function (slot) {
return this.buttonUseCount[slot] || 0;
},
backup: function (expression, output) {
try {
// precompute output value for raising potentials exceptions, ugly hack though
output.getValue();
this.history.push({
expression: expression,
output: output
});
this.eventDispatcher.notify('calculator.history_changed', this.history);
} catch (e) {}
}
}));
})();
\ No newline at end of file
/*jshint plusplus: true*/
/*global klass: true, Sankore: true*/
(function () {
"use strict";
klass.define('Sankore.Calculus', 'Engine', klass.extend({
constructor: function () {
this.expressions = [];
this.operators = [];
},
init: function () {
this.expressions = [];
this.operators = [];
},
evaluate: function (expressionString) {
var tokens = [],
lastToken,
penultimateToken,
item;
expressionString = expressionString.replace(/\s+/g, '');
for (var i in expressionString) {
item = expressionString[i];
if (tokens.length > 0) {
lastToken = tokens[tokens.length - 1];
} else {
lastToken = undefined;
}
if (tokens.length > 1) {
penultimateToken = tokens[tokens.length - 2];
} else {
penultimateToken = undefined;
}
if ('0123456789.'.indexOf(item) !== -1) {
if (
!isNaN(Number(lastToken)) ||
lastToken === '.' ||
lastToken === '-.' ||
(
lastToken === '-' &&
(
penultimateToken === '(' ||
penultimateToken === undefined
)
)
) {
tokens[tokens.length - 1] += item;
} else {
tokens.push(item);
}
} else {
tokens.push(item);
}
}
for (var j in tokens) {
if (tokens[j].length > 1 && tokens[j].charAt(tokens[j].length - 1) === '.') {
throw Sankore.Util.Error.create('InvalidExpression', 'Trailing comma');
}
}
return this.computeExpression(tokens);
},
computeExpression: function (tokens) {
var operatorCheck = function (stack, token) {
var prec = Sankore.Calculus.BinaryOperation.getOperatorPrecedence,
top;
while (true) {
top = stack.operators[stack.operators.length - 1];
if (stack.operators.length === 0 || top === '(' || prec(token) > prec(top)) {
return stack.operators.push(token);
}
stack.reduce();
}
};
this.init();
for (var i in tokens) {
switch (tokens[i]) {
case '(':
this.operators.push(tokens[i]);
break;
case ')':
if (this.operators.length === 0) {
throw Sankore.Util.Error.create('InvalidExpression', 'Trailing closing brackets');
}
while (this.operators.length !== 0 && this.operators[this.operators.length - 1] !== '(') {
this.reduce();
}
if (this.operators[this.operators.length - 1] === '(') {
this.operators.pop(); // get rid of the extra paren '('
}
break;
case '+':
case '-':
case '*':
case '/':
case ':':
operatorCheck(this, tokens[i]);
break;
default:
this.expressions.push(Sankore.Calculus.Operand.create(tokens[i]));
}
}
while (this.operators.length !== 0) {
this.reduce();
}
// if there's not one and only one expression in the stack, the expression is invalid
if (this.expressions.length !== 1) {
throw Sankore.Util.Error.create('InvalidExpression', '"' + tokens.join(' ') + '" is not a valid expression');
}
return this.expressions.pop();
},
reduce: function () {
var right = this.expressions.pop(),
left = this.expressions.pop(),
operator = this.operators.pop(),
operation;
if (typeof operator === 'undefined' || typeof left === 'undefined' || typeof right === 'undefined') {
throw Sankore.Util.Error.create('InvalidExpression', 'Invalid expression');
}
if (operator === ':') {
operation = Sankore.Calculus.EuclideanDivisionOperation.create(left, right);
} else {
operation = Sankore.Calculus.BinaryOperation.create(left, operator, right);
}
this.expressions.push(operation);
}
}));
})();
\ No newline at end of file
/*global klass:true, Sankore:true */
(function () {
"use strict";
/**
* Base class for expression
*/
klass.define('Sankore.Calculus', 'Expression', klass.extend({
constructor: function () {
},
getValue: function () {
return null;
},
isInteger: function () {
try {
var value = this.getValue();
return value === Math.floor(value);
} catch (e) {
return 0;
}
},
toString: function () {
return '';
},
isCompound: function () {
return false;
}
}));
/**
* Calculus operand
*/
klass.define('Sankore.Calculus', 'Operand', Sankore.Calculus.Expression.extend({
constructor: function (value) {
this.value = Number(value);
if (isNaN(this.value)) {
throw Sankore.Util.Error.create('InvalidNumber', '"' + String(value) + '" is a not a number');
}
},
getValue: function () {
return this.value;
},
toString: function () {
return String(this.value);
}
}));
/**
* Unary operator (+, -)
*/
klass.define('Sankore.Calculus', 'Operation', Sankore.Calculus.Expression.extend({
constructor: function (operator, right) {
this.operator = operator;
if (!Sankore.Calculus.Expression.isPrototypeOf(right)) {
right = Sankore.Calculus.Operand.create(right);
}
this.right = right;
},
getPrecedence: function () {
return Sankore.Calculus.Operation.getOperatorPrecedence(this.operator);
},
isLeftAssociative: function () {
return false;
},
isCompound: function () {
return true;
},
getValue: function () {
var value = Number(this.right.getValue());
if (this.operator === '-') {
value *= -1;
}
return value;
},
toString: function () {
var string = this.right.toString();
if (this.operator !== '-') {
return string;
}
if (this.right.isCompound()) {
string = '(' + string + ')';
}
return '-' + string;
}
}));
Sankore.Calculus.Operation.getOperatorPrecedence = function (operator) {
switch (operator) {
case '+':
case '-':
return 1;
case '*':
case '/':
case ':':
return 2;
}
};
/**
* Binary operator (+, -, *, /)
*/
klass.define('Sankore.Calculus', 'BinaryOperation', Sankore.Calculus.Operation.extend({
constructor: function (left, operator, right) {
Sankore.Calculus.Operation.constructor.call(this, operator, right);
if (!Sankore.Calculus.Expression.isPrototypeOf(left)) {
left = Sankore.Calculus.Operand.create(left);
}
this.left = left;
},
isLeftAssociative: function () {
return true;
},
getValue: function () {
var leftValue = this.left.getValue(),
rightValue = this.right.getValue();
switch (this.operator) {
case '+':
return leftValue + rightValue;
case '-':
return leftValue - rightValue;
case '*':
return leftValue * rightValue;
case '/':
if (0 === rightValue) {
throw Sankore.Util.Error.create('ZeroDivision', 'Division by zero');
}
return leftValue / rightValue;
default:
throw Sankore.Util.Error.create('InvalidOperator', 'This is not a valid operator : ' + this.operator);
}
},
toString: function () {
if (this.isInteger()) {
return String(this.getValue());
}
var leftString = this.left.toString(),
rightString = this.right.toString(),
string = '';
if (Sankore.Calculus.Operation.isPrototypeOf(this.left)) {
if (this.left.getPrecedence() < this.getPrecedence()) {
leftString = '(' + leftString + ')';
}
}
if (Sankore.Calculus.Operation.isPrototypeOf(this.right)) {
if (this.right.getPrecedence() < this.getPrecedence()) {
rightString = '(' + rightString + ')';
}
}
return leftString + String(this.operator) + rightString;
}
}));
/**
* Euclidean division operator
*/
klass.define('Sankore.Calculus', 'EuclideanDivisionOperation', Sankore.Calculus.BinaryOperation.extend({
constructor: function (left, right) {
Sankore.Calculus.BinaryOperation.constructor.call(this, left, ':', right);
},
getValue: function () {
var rightValue = this.right.getValue();
if (0 === rightValue) {
throw Sankore.Util.Error.create('ZeroDivision', 'Division by zero');
}
return Math.floor(this.left.getValue() / rightValue);
},
getRemainder: function () {
var rightValue = this.right.getValue();
if (0 === rightValue) {
throw Sankore.Util.Error.create('ZeroDivision', 'Division by zero');
}
return this.left.getValue() % rightValue;
}
}));
})();
\ No newline at end of file
/*global klass:true, Sankore:true*/
(function () {
"use strict";
klass.define('Sankore', 'Command', klass.extend({
constructor: function (id, name, closure) {
this.id = id;
this.name = name;
this.closure = closure;
},
getId: function () {
return this.id;
},
getName: function () {
return this.name;
},
exec: function (scope, args) {
this.closure.call(scope, args);
},
isInterrupting: function () {
return false;
},
isInternal: function () {
return false;
}
}));
klass.define('Sankore', 'InterruptingCommand', Sankore.Command.extend({
constructor: function (id, name, closure) {
Sankore.Command.constructor.call(this, id, name, closure);
},
isInterrupting: function () {
return true;
}
}));
klass.define('Sankore', 'InternalCommand', Sankore.Command.extend({
constructor: function (id, name, closure) {
Sankore.Command.constructor.call(this, id, name, closure);
},
isInternal: function () {
return true;
}
}));
})();
\ No newline at end of file
/*jshint browser:true, devel:true */
/*global klass:true, Sankore:true, _:true*/
(function () {
"use strict";
klass.define('Sankore.Editor', 'Editor', klass.extend({
constructor: function (calculator) {
// state attributes
this.current = null;
this.activeButton = null;
this.enabled = false;
this.layouts = Sankore.Util.Hash.create({
'default': Sankore.Editor.Layout.create({
id: 'default',
name: _('layout.classic_name'),
buttonMap: {
a1: Sankore.Button.create('mr', 'memoryRecall'),
b1: Sankore.Button.create('mc', 'memoryClear'),
c1: Sankore.Button.create('m+', 'memoryAdd'),
d1: Sankore.Button.create('m-', 'memorySub'),
a2: Sankore.Button.create('op', 'op'),
b2: Sankore.Button.create('(', '('),
c2: Sankore.Button.create(')', ')'),
d2: Sankore.Button.create(':', ':'),
a3: Sankore.Button.create('7', '7'),
b3: Sankore.Button.create('8', '8'),
c3: Sankore.Button.create('9', '9'),
d3: Sankore.Button.create('/', '/'),
a4: Sankore.Button.create('4', '4'),
b4: Sankore.Button.create('5', '5'),
c4: Sankore.Button.create('6', '6'),
d4: Sankore.Button.create('*', '*'),
a5: Sankore.Button.create('1', '1'),
b5: Sankore.Button.create('2', '2'),
c5: Sankore.Button.create('3', '3'),
d5: Sankore.Button.create('-', '-'),
a6: Sankore.Button.create('0', '0'),
b6: Sankore.Button.create('.', '.'),
c6: Sankore.Button.create('=', '='),
d6: Sankore.Button.create('+', '+')
}
})
});
// components
this.calculator = calculator;
this.ui = Sankore.UI.EditorInterface.create(this, this.calculator.eventDispatcher);
this.attachEventHandlers();
},
attachEventHandlers: function () {
var self = this, ed = this.calculator.eventDispatcher;
// click on Add button
ed.addEventListener('editor_interface.add_click', function () {
var clone = self.createLayout();
self.setCurrentLayout(clone.id);
});
// click on Remove button
ed.addEventListener('editor_interface.remove_click', function () {
self.removeLayout(self.current);
self.setCurrentLayout('default');
});
// click on Run button
ed.addEventListener('editor_interface.run_click', this.runCurrentLayout.bind(this));
// load the new selected layout
ed.addEventListener('editor_interface.layout_select', function (layoutId) {
self.setCurrentLayout(layoutId);
});
// the layout name has changed
ed.addEventListener('editor_interface.layout_name_change', function (name) {
if (self.getCurrentLayout().name !== name && name.trim().length > 0) {
self.getCurrentLayout().name = name;
ed.notify('editor.layout_changed');
}
});
// the layout description has changed
ed.addEventListener('editor_interface.layout_description_change', function (description) {
if (self.getCurrentLayout().description !== description) {
self.getCurrentLayout().description = description;
ed.notify('editor.layout_changed');
}
});
// the command of a button has changed
ed.addEventListener('editor_interface.button_command_change', function (command) {
if (self.activeButton) {
self.getCurrentLayout().getButton(self.activeButton).command = command;
ed.notify('editor.layout_changed');
}
});
// the text of a button has changed
ed.addEventListener('editor_interface.button_text_change', function (text) {
if (self.activeButton) {
var button = self.getCurrentLayout().getButton(self.activeButton);
button.text = text;
ed.notify('editor.button_renamed', {
slot: self.activeButton,
button: button
});
ed.notify('editor.layout_changed');
}
});
// the use limit of a button has changed
ed.addEventListener('editor_interface.button_uselimit_change', function (limit) {
if (self.activeButton) {
if (!isNaN(Number(limit))) {
self.getCurrentLayout().getButton(self.activeButton).useLimit = limit.length === 0 ? -1 : Number(limit);
ed.notify('editor.layout_changed');
}
}
});
// a button is clicked
ed.addEventListener('main_interface.button_click', function (event) {
if (self.enabled) {
self.setActiveButton(event.slot);
}
});
// the editor button is click
ed.addEventListener('main_interface.editor_click', function () {
if (self.enabled) {
self.runCurrentLayout();
} else {
self.enable();
}
});
// the editor button is click
ed.addEventListener('main_interface.reset_click', function () {
if (self.enabled) {
self.resetActiveButton();
}
});
},
init: function (state) {
var self = this;
if ('layouts' in state) {
this.loadLayouts(state.layouts);
}
if ('enabled' in state) {
this.enabled = state.enabled;
}
this.ui.render(this.calculator.ui);
this.setCurrentLayout(('current' in state && state.current) ? state.current : 'default');
if (this.enabled) {
this.enable();
}
if ('activeButton' in state && this.enabled) {
this.setActiveButton(state.activeButton);
}
},
getState: function () {
return {
current: this.current,
activeButton: this.activeButton,
enabled: this.enabled,
layouts: this.layouts.map(function (id, layout) {
if (layout.isEditable()) {
return layout;
}
})
};
},
loadLayouts: function (layouts) {
var buttonMap = {},
layout;
for (var i in layouts) {
for (var slot in layouts[i].buttonMap) {
if (layouts[i].buttonMap.hasOwnProperty(slot)) {
buttonMap[slot] = Sankore.Button.create(
layouts[i].buttonMap[slot].text,
layouts[i].buttonMap[slot].command,
layouts[i].buttonMap[slot].useLimit
);
}
}
layout = Sankore.Editor.Layout.create({
id: layouts[i].id,
name: layouts[i].name,
description: layouts[i].description,
buttonMap: buttonMap
});
layout.setEditable(true);
this.layouts.add('id', [layout]);
}
},
getCurrentLayout: function () {
if (null === this.current) {
return null;
}
return this.layouts.get(this.current);
},
setCurrentLayout: function (id) {
this.current = id;
this.calculator.eventDispatcher.notify('editor.layout_selected', this.getCurrentLayout());
this.resetActiveButton();
},
createLayout: function () {
var clone = this.layouts.get('default').clone();
clone.id = this.generateId();
clone.name = _('layout.new_name');
clone.setEditable(true);
this.layouts.set(clone.id, clone);
this.calculator.eventDispatcher.notify('editor.layout_created');
return clone;
},
/**
* don't try to understand the purpose of this method, it just generates an unique string based upon the current widget url and current time
*/
generateId: function () {
var values = '',
date = new Date(),
id = 0,
i;
for (i = 0; i < document.URL.length; i++) {
values += String(document.URL.charCodeAt(i) * (date.getMilliseconds() + date.getSeconds() + date.getMinutes()));
}
values = values.match(/.{1,10}/g);
for (i in values) {
id += Number(values[i]);
}
return id.toString(36);
},
removeLayout: function (id) {
if (confirm(_('editor.remove_alert'))) {
this.layouts.remove(id);
this.calculator.eventDispatcher.notify('editor.layout_removed');
}
},
setActiveButton: function (slot) {
if (slot && this.getCurrentLayout().isEditable()) {
var button = this.getCurrentLayout().getButton(slot);
if (button.isEditable()) {
this.calculator.eventDispatcher.notify('editor.button_selected', {
slot: slot,
button: button,
previousSlot: this.activeButton
});
this.activeButton = slot;
}
} else {
this.resetActiveButton();
}
},
resetActiveButton: function () {
this.calculator.eventDispatcher.notify('editor.button_selected', {
slot: null,
button: null,
previousSlot: this.activeButton
});
this.activeButton = null;
},
enable: function () {
this.enabled = true;
this.setActiveButton(null);
this.calculator.eventDispatcher.notify('editor.show');
},
disable: function () {
this.enabled = false;
this.setActiveButton(null);
this.calculator.eventDispatcher.notify('editor.hide');
},
getAssignableCommands: function () {
return this.calculator.commands.map(function (k, v) {
if (!v.isInternal()) {
return v;
}
});
},
getAssignableTexts: function () {
return this.calculator.texts.map(function (k, v) {
if (v.isEditable()) {
return v;
}
});
},
runCurrentLayout: function () {
this.disable();
}
}));
})();
\ No newline at end of file
/*global klass:true, Sankore:true*/
(function () {
"use strict";
klass.define('Sankore.Editor', 'Layout', klass.extend({
constructor: function (data) {
this.id = data.id || null;
this.name = data.name || null;
this.description = data.description || null;
this.editable = false;
this.buttonMap = data.buttonMap || {};
},
setEditable: function (editable) {
this.editable = !! editable;
},
isEditable: function () {
return this.editable;
},
getButton: function (slot) {
return this.buttonMap[slot] || null;
},
clone: function () {
var clonedMap = {};
for (var index in this.buttonMap) {
if (this.buttonMap.hasOwnProperty(index)) {
clonedMap[index] = this.buttonMap[index].clone();
}
}
return Sankore.Editor.Layout.create({
id: this.id,
name: this.name,
description: this.description,
editable: this.editable,
buttonMap: clonedMap
});
}
}));
})();
\ No newline at end of file
/*global klass:true, Sankore:true*/
(function () {
"use strict";
klass.define('Sankore', 'KeystrokeLine', klass.extend({
constructor: function (dispatcher) {
this.dispatcher = dispatcher;
this.keystrokes = [];
this.caret = 0;
},
notify: function () {
this.dispatcher.notify('keystroke_line.changed', this);
},
hit: function (keystroke) {
this.keystrokes.splice(this.caret, 0, keystroke);
this.caret++;
this.notify();
},
del: function () {
if (this.caret > 0) {
var deleted = this.keystrokes.splice(this.caret - 1, 1)[0];
this.caret--;
this.notify();
return deleted;
}
},
moveCaretLeft: function () {
if (this.caret > 0) {
this.caret--;
this.notify();
}
},
moveCaretRight: function () {
if (this.caret < this.keystrokes.length) {
this.caret++;
this.notify();
}
},
moveCaretToEnd: function () {
this.caret = this.keystrokes.length;
this.notify();
},
reset: function () {
this.caret = 0;
this.keystrokes = [];
this.notify();
},
count: function () {
return this.keystrokes.length;
},
at: function (index) {
if (typeof this.keystrokes[index] !== 'undefined') {
return this.keystrokes[index];
}
throw Sankore.Util.Error.create('OutOfRangeError', 'No keystroke at index ' + index);
},
getAsText: function () {
return [
this.getTextAtRange(0, this.caret),
this.getTextAtRange(this.caret, this.keystrokes.length)
];
},
getTextAtRange: function (from, to) {
var i, output = '';
if (from < 0) {
throw Sankore.Util.Error.create('OutOfRangeError', 'Cannot get keystroke before index 0');
}
if (from > this.keystrokes.length) {
throw Sankore.Util.Error.create('OutOfRangeError', 'Cannot get keystroke after index ' + this.keystrokes.length);
}
for (i = from; i < to; i++) {
output += this.at(i).text;
}
return output;
},
getState: function () {
return {
keystrokes: this.keystrokes,
caret: this.caret
};
},
loadState: function (state) {
this.keystrokes = state.keystrokes || {};
this.caret = state.caret || 0;
this.notify();
}
}));
})();
\ No newline at end of file
/*globals klass:true, Sankore:true*/
(function() {
"use strict";
klass.define('Sankore', 'Text', klass.extend({
constructor: function (id, screen, button, type, editable) {
this.id = id;
this.screen = screen;
this.button = button;
this.type = typeof type !== 'undefined' ? type : 'normal';
this.editable = typeof editable !== 'undefined' ? !!editable : true;
},
isEditable: function () {
return this.editable;
},
setEditable: function (editable) {
this.editable = !!editable;
}
}));
})();
\ No newline at end of file
/*jshint browser:true*/
/*global klass:true, Sankore: true, _:true*/
(function () {
"use strict";
klass.define('Sankore.UI', 'EditorInterface', klass.extend({
constructor: function (editor, ed) {
this.editor = editor;
this.dispatcher = ed;
this.hidden = true;
this.editArea = null;
this.layoutSelect = null;
this.layoutNameInput = null;
this.layoutDescriptionInput = null;
this.assignationDiv = null;
this.runButton = null;
this.addButton = null;
this.removeButton = null;
this.attachEventListeners();
this.rendered = false;
},
attachEventListeners: function () {
var self = this;
this.dispatcher.addEventListener('editor.show', this.show.bind(this));
this.dispatcher.addEventListener('editor.hide', this.hide.bind(this));
this.dispatcher.addEventSubscriber({
events: ['editor.layout_changed', 'editor.layout_created', 'editor.layout_removed'],
listener: this.updateLayoutSelectElement.bind(this)
});
this.dispatcher.addEventListener('editor.layout_selected', function (layout) {
self.loadLayout(layout);
self.selectLayout(layout.id);
});
this.dispatcher.addEventListener('editor.button_selected', function (e) {
var context = e.button;
if (null === context && self.editor.getCurrentLayout()) {
context = self.editor.getCurrentLayout().isEditable();
}
self.renderAssignation(context);
});
},
_clearElement: function (element) {
while (element.firstChild) {
element.removeChild(element.firstChild);
}
},
_map: function (iterable, callback) {
var mapped = [],
idx;
for (idx in iterable) {
if (iterable.hasOwnProperty(idx)) {
mapped.push(callback.call(iterable, iterable[idx], idx));
}
}
return mapped;
},
render: function (mainInterface) {
var layoutNameLabel,
layoutDescriptionLabel,
assignationDiv,
assignationText,
self = this;
this.editArea = document.createElement('div');
this.editArea.classList.add('edit-area');
this.layoutSelect = this.createLayoutSelectElement();
this.editArea.appendChild(this.layoutSelect);
this.addButton = document.createElement('button');
this.addButton.className = 'small';
this.addButton.setAttribute('type', 'button');
this.addButton.addEventListener('click', function (e) {
self.dispatcher.notify('editor_interface.add_click');
});
this.removeButton = this.addButton.cloneNode();
this.removeButton.classList.add('remove');
this.removeButton.addEventListener('click', function (e) {
self.dispatcher.notify('editor_interface.remove_click');
});
this.addButton.classList.add('add');
this.editArea.appendChild(this.addButton);
this.editArea.appendChild(this.removeButton);
this.editArea.appendChild(document.createElement('hr'));
layoutNameLabel = document.createElement('label');
layoutNameLabel.appendChild(document.createTextNode(_('editor.layout_name.label')));
this.editArea.appendChild(layoutNameLabel);
this.layoutNameInput = document.createElement('input');
this.layoutNameInput.setAttribute('name', 'layout_name');
this.layoutNameInput.setAttribute('type', 'text');
this.layoutNameInput.setAttribute('maxlength', 32);
this.layoutNameInput.addEventListener('keyup', function (e) {
self.dispatcher.notify('editor_interface.layout_name_change', this.value);
});
this.layoutNameInput.addEventListener('change', function (e) {
if (this.value.trim().length === 0) {
this.value = self.editor.getCurrentLayout().name;
self.dispatcher.notify('editor_interface.layout_name_change', this.value);
}
});
this.editArea.appendChild(this.layoutNameInput);
layoutDescriptionLabel = document.createElement('label');
layoutDescriptionLabel.appendChild(document.createTextNode(_('editor.layout_description.label')));
this.editArea.appendChild(layoutDescriptionLabel);
this.layoutDescriptionInput = document.createElement('textarea');
this.layoutDescriptionInput.setAttribute('name', 'layout_description');
this.layoutDescriptionInput.setAttribute('maxlength', 140);
this.layoutDescriptionInput.addEventListener('keyup', function(e) {
self.dispatcher.notify('editor_interface.layout_description_change', this.value);
});
this.editArea.appendChild(this.layoutDescriptionInput);
this.assignationDiv = document.createElement('div');
this.assignationDiv.classList.add('assignation');
this.editArea.appendChild(this.assignationDiv);
this.runButton = document.createElement('button');
this.runButton.classList.add('run');
this.runButton.setAttribute('type', 'button');
this.runButton.appendChild(document.createTextNode(_('editor.run_button')));
this.runButton.addEventListener('click', function (e) {
self.dispatcher.notify('editor_interface.run_click');
});
this.editArea.appendChild(this.runButton);
mainInterface.rearScreen.parentElement.appendChild(this.editArea);
this.rendered = true;
this.hide();
},
createSelectElement: function (data, name, className, selectedValue) {
var select = document.createElement('select'),
option;
select.setAttribute('name', name);
if (className) {
select.className = className;
}
for (var i in data) {
option = document.createElement('option');
option.setAttribute('value', data[i].value);
if (typeof selectedValue !== 'undefined' && selectedValue === data[i].value) {
option.selected = true;
}
option.appendChild(document.createTextNode(data[i].text));
select.appendChild(option);
}
return select;
},
createLayoutSelectElement: function () {
var select = this.createSelectElement(
this.editor.layouts.map(function (k, layout) {
return {
text: layout.name,
value: layout.id
};
}),
'layouts',
'layout-select',
this.editor.current
),
self = this;
select.addEventListener('change', function (e) {
self.dispatcher.notify('editor_interface.layout_select', this.value);
});
return select;
},
updateLayoutSelectElement: function () {
var select = this.createLayoutSelectElement();
this.editArea.replaceChild(select, this.layoutSelect);
this.layoutSelect = select;
},
selectLayout: function (selected) {
this.layoutSelect.value = selected;
},
show: function () {
if (this.rendered) {
this.editArea.style.display = 'block';
this.hidden = false;
}
},
hide: function () {
if (this.rendered) {
this.editArea.style.display = 'none';
this.hidden = true;
}
},
loadLayout: function (layout) {
this.layoutNameInput.value = layout.name;
this.layoutNameInput.disabled = !layout.isEditable();
this.layoutDescriptionInput.value = layout.description;
this.layoutDescriptionInput.disabled = !layout.isEditable();
this.removeButton.disabled = !layout.isEditable();
this.renderAssignation(layout.isEditable());
},
renderAssignation: function (context) {
var innerEl, textLabel, textSelect, commandLabel, commandSelect, useLabel, useInput, useHelp,
text,
self = this;
if (false === context) {
innerEl = document.createElement('em');
innerEl.appendChild(document.createTextNode(_('editor.assignation.disabled')));
} else if (Sankore.Button.isPrototypeOf(context)) {
innerEl = document.createDocumentFragment();
textLabel = document.createElement('label');
textLabel.appendChild(document.createTextNode(_('editor.assignation.text.label')));
innerEl.appendChild(textLabel);
text = this.editor.calculator.texts.get(context.text);
textSelect = this.createSelectElement(
this._map(this.editor.getAssignableTexts(), function (text) {
return {
text: text.button,
value: text.id
};
}),
'button_text',
'',
text.id
);
textSelect.addEventListener('change', function (e) {
self.dispatcher.notify('editor_interface.button_text_change', e.target.value);
});
innerEl.appendChild(textSelect);
commandLabel = document.createElement('label');
commandLabel.appendChild(document.createTextNode(_('editor.assignation.command.label')));
innerEl.appendChild(commandLabel);
commandSelect = this.createSelectElement(
this._map(this.editor.getAssignableCommands(), function (command) {
return {
text: command.name,
value: command.id
};
}),
'button_command',
'',
context.command
);
commandSelect.addEventListener('change', function (e) {
self.dispatcher.notify('editor_interface.button_command_change', e.target.value);
});
innerEl.appendChild(commandSelect);
useLabel = document.createElement('label');
useLabel.appendChild(document.createTextNode(_('editor.assignation.use_limit.label')));
innerEl.appendChild(useLabel);
useInput = document.createElement('input');
useInput.setAttribute('type', 'text');
useInput.setAttribute('name', 'button_count');
useInput.value = (context.useLimit === -1 ? '' : context.useLimit);
useInput.addEventListener('change', function (e) {
self.dispatcher.notify('editor_interface.button_uselimit_change', e.target.value);
});
innerEl.appendChild(useInput);
useHelp = document.createElement('span');
useHelp.className = 'help';
useHelp.appendChild(document.createTextNode(_('editor.assignation.use_limit.help')));
innerEl.appendChild(useHelp);
} else {
innerEl = document.createElement('em');
innerEl.appendChild(document.createTextNode(_('editor.assignation.enabled')));
}
this._clearElement(this.assignationDiv);
this.assignationDiv.appendChild(innerEl);
}
}));
})();
\ No newline at end of file
/*jshint browser:true */
/*global klass:true, Sankore:true, _:true*/
(function () {
"use strict";
klass.define('Sankore.UI', 'MainInterface', klass.extend({
constructor: function (id, ed, texts, withEditor) {
this.id = id;
this.dispatcher = ed;
this.texts = texts;
this.withEditor = withEditor;
this.title = null;
this.caret = document.createElement('i');
this.caret.className = 'caret';
this.frontScreen = null;
this.expressionRow = null;
this.resultRow = null;
this.flagRow = null;
this.flags = [];
this.rearScreen = null;
this.buttons = Sankore.Util.Hash.create();
this.rendered = false;
this.attachEventListeners();
},
attachEventListeners: function () {
var self = this;
// the main screen text has changed
this.dispatcher.addEventListener('keystroke_line.changed', function (keystrokeLine) {
self.updateExpressionRow(keystrokeLine.getAsText());
});
// the internal memory has changed
this.dispatcher.addEventListener('calculator.memory_changed', function (memory) {
if (null !== memory) {
self.addFlag('M');
} else {
self.removeFlag('M');
}
self.updateFlagRow();
});
// the op memory has changed
this.dispatcher.addEventListener('calculator.op_changed', function (op) {
if (null !== op) {
self.addFlag('OP');
} else {
self.removeFlag('OP');
}
self.updateFlagRow();
});
// a new result has been computed
this.dispatcher.addEventListener('calculator.output_changed', function (event) {
if (null !== event.output) {
self.updateResultRow(event.output);
} else if (null !== event.error) {
self.updateResultRow(event.error);
} else {
self.updateResultRow('');
}
});
// the history has changed
this.dispatcher.addEventListener('calculator.history_changed', this.updateRearScreen.bind(this));
// a new layout is loaded
this.dispatcher.addEventListener('calculator.layout_loaded', function (layout) {
self.renderButtons(layout.buttonMap);
self.changeTitle(layout.name);
self.clearRearScreen();
});
// a button has been disabled
this.dispatcher.addEventListener('calculator.button_disabled', function (event) {
var buttonEl = self.buttons.get(event.slot);
if (buttonEl) {
buttonEl.disabled = true;
}
});
// a button has been enabled
this.dispatcher.addEventListener('calculator.button_enabled', function (slot) {
var buttonEl = self.buttons.get(slot);
if (buttonEl) {
buttonEl.disabled = false;
}
});
// the editor is shown/hidden
this.dispatcher.addEventListener('editor.show', this.hideRearScreen.bind(this));
this.dispatcher.addEventListener('editor.hide', this.showRearScreen.bind(this));
// a button has been selected
this.dispatcher.addEventListener('editor.button_selected', function (event) {
var newButtonEl = self.buttons.get(event.slot),
oldButtonEl = self.buttons.get(event.previousSlot);
if (oldButtonEl) {
oldButtonEl.parentElement.classList.remove('edit');
}
if (newButtonEl) {
newButtonEl.parentElement.classList.add('edit');
}
});
// a button has been renamed
this.dispatcher.addEventListener('editor.button_renamed', function (event) {
var buttonEl = self.buttons.get(event.slot),
text = self.texts.get(event.button.text),
hasEditClass;
if (buttonEl) {
buttonEl.innerText = text.button;
hasEditClass = buttonEl.parentElement.classList.contains('edit');
buttonEl.parentElement.className = text.type;
if (hasEditClass) {
buttonEl.parentElement.classList.add('edit');
}
}
});
},
_clearElement: function (element) {
while (element.firstChild) {
element.removeChild(element.firstChild);
}
},
getRootElement: function () {
return document.getElementById(this.id);
},
render: function () {
var root = this.getRootElement();
this._clearElement(root);
if (!root.classList.contains('calculator')) {
root.classList.add('calculator');
}
this.createBaseMarkup(root);
this.rearScreen = document.createElement('ul');
root
.getElementsByClassName('rear-screen')
.item(0)
.appendChild(this.rearScreen);
this.frontScreen = document.createElement('ul');
root
.getElementsByClassName('front-screen')
.item(0)
.appendChild(this.frontScreen);
this.expressionRow = document.createElement('li');
this.expressionRow.classList.add('expression-row');
this.frontScreen.appendChild(this.expressionRow);
this.flagRow = document.createElement('li');
this.flagRow.classList.add('flag-row');
this.frontScreen.appendChild(this.flagRow);
this.resultRow = document.createElement('li');
this.resultRow.classList.add('result-row');
this.frontScreen.appendChild(this.resultRow);
this.rendered = true;
},
renderButtons: function (buttonMap) {
var buttonsTrs,
map = {},
buttons = document.createDocumentFragment(),
rootElement = this
.getRootElement()
.getElementsByClassName('screen')
.item(0)
.parentElement;
// map copy in order to prevent alteration of the original map
for (var slot in buttonMap) {
map[slot] = buttonMap[slot];
}
// adding constant non-editable buttons
map.a0 = Sankore.Button.create('s', 'del', -1, false);
map.b0 = Sankore.Button.create('l', 'left', -1, false);
map.c0 = Sankore.Button.create('r', 'right', -1, false);
map.d0 = Sankore.Button.create('c', 'clear', -1, false);
buttonsTrs = rootElement.getElementsByClassName('buttons');
while (buttonsTrs.length > 0) {
rootElement.removeChild(buttonsTrs[0]);
}
buttonsTrs = this.createButtons(map);
// we use a DocumentFragment to avoid excessive and useless repaints
for (var i in buttonsTrs) {
buttons.appendChild(buttonsTrs[i]);
}
rootElement.appendChild(buttons);
},
createBaseMarkup: function (element) {
var table = document.createElement('table'),
tr = document.createElement('tr'),
rearTd = document.createElement('td'),
frontTd = document.createElement('td');
rearTd.className = 'rear-screen';
rearTd.setAttribute('rowspan', '8');
tr.appendChild(rearTd);
frontTd.className = 'front-screen';
frontTd.setAttribute('colspan', '4');
tr.appendChild(frontTd);
tr.className = 'screen';
table.appendChild(tr);
element.appendChild(this.createTitle());
element.appendChild(this.createControls());
element.appendChild(table);
},
createTitle: function () {
this.title = document.createElement('span');
this.title.appendChild(document.createTextNode('Chargement...'));
this.title.className = 'title';
return this.title;
},
createControls: function () {
var controlsDiv = document.createElement('div'),
editorButton = document.createElement('button'),
resetButton = document.createElement('button'),
self = this;
if (this.withEditor) {
editorButton.setAttribute('type', 'button');
editorButton.appendChild(document.createTextNode(_('controls.editor')));
editorButton.addEventListener('click', function (e) {
self.dispatcher.notify('main_interface.editor_click');
});
controlsDiv.appendChild(editorButton);
}
resetButton.setAttribute('type', 'button');
resetButton.appendChild(document.createTextNode(_('controls.reset')));
resetButton.addEventListener('click', function (e) {
self.dispatcher.notify('main_interface.reset_click');
});
controlsDiv.appendChild(resetButton);
controlsDiv.className = 'controls';
return controlsDiv;
},
createButtons: function (buttonMap) {
var trs = [],
i;
for (i = 0; i < 7; i++) {
trs.push(this.createButtonRow(i, buttonMap));
}
return trs;
},
createButtonRow: function (rowNumber, buttonMap) {
var tr = document.createElement('tr'),
i;
tr.className = 'buttons';
for (i = 'a'; i <= 'd'; i = String.fromCharCode(i.charCodeAt(0) + 1)) {
tr.appendChild(this.createButton(i + rowNumber, buttonMap));
}
return tr;
},
createButton: function (slot, buttonMap) {
var td = document.createElement('td'),
self = this,
text,
buttonEl,
button = buttonMap[slot];
td.setAttribute('data-slot', slot);
td.setAttribute('data-editable', button.isEditable());
if (typeof button !== 'undefined') {
buttonEl = document.createElement('button');
text = this.texts.get(button.text);
buttonEl.innerText = text.button;
if (text.type !== 'normal') {
td.classList.add(text.type);
}
buttonEl.addEventListener('mousedown', function (e) {
self.handleButtonClick(this, e, button, slot);
});
this.buttons.set(slot, buttonEl);
this.dispatcher.notify('main_interface.button_created', {
button: button,
slot: slot
});
td.appendChild(buttonEl);
}
return td;
},
handleButtonClick: function (el, event, button, slot) {
this.dispatcher.notify('main_interface.button_click', {
button: button,
slot: slot
});
},
updateFlagRow: function () {
var span;
this._clearElement(this.flagRow);
for (var i in this.flags) {
span = document.createElement('span');
span.appendChild(document.createTextNode(this.flags[i]));
this.flagRow.appendChild(span);
}
},
updateExpressionRow: function (keystrokeText) {
this._clearElement(this.expressionRow);
this.expressionRow.appendChild(document.createTextNode(keystrokeText[0]));
this.expressionRow.appendChild(this.caret);
this.expressionRow.appendChild(document.createTextNode(keystrokeText[1]));
},
updateResultRow: function (result) {
this._clearElement(this.resultRow);
this.resultRow.appendChild(this.createResultRow(result));
},
createResultRow: function (result) {
try {
if (Sankore.Calculus.EuclideanDivisionOperation.isPrototypeOf(result)) {
return this.createResultRowEuclidean(result.getValue(), result.getRemainder());
} else if (Sankore.Calculus.Expression.isPrototypeOf(result)) {
return this.createResultRowExpression(result.getValue());
} else if (Sankore.Util.Error.isPrototypeOf(result)) {
return this.createResultRowError(result);
} else {
return this.createResultRowText(String(result));
}
} catch (e) {
return this.createResultRowError(e);
}
return null;
},
createResultRowEuclidean: function (quotient, remainder) {
var p = document.createElement('p'),
quotientSpan = document.createElement('span'),
remainderSpan = document.createElement('span');
p.classList.add('euclidean');
remainderSpan.classList.add('remainder');
remainderSpan.textContent = this.formatResultValue(remainder);
p.appendChild(remainderSpan);
quotientSpan.classList.add('quotient');
quotientSpan.textContent = this.formatResultValue(quotient);
p.appendChild(quotientSpan);
return p;
},
createResultRowExpression: function (value) {
return document.createTextNode(this.formatResultValue(value));
},
createResultRowText: function (text) {
return document.createTextNode(text);
},
createResultRowError: function (error) {
var errorDiv = document.createElement('div'),
text = _('error.common');
if (error.name === 'ZeroDivision') {
text = _('error.zero_division');
}
errorDiv.classList.add('error');
errorDiv.appendChild(document.createTextNode(text));
return errorDiv;
},
formatResultValue: function (raw) {
var fixed = raw.toFixed(Math.max(0, 10 - raw.toFixed().length)),
last;
if (fixed.indexOf('.') !== -1) {
while (true) {
last = fixed.charAt(fixed.length - 1);
if (last === "0") {
fixed = fixed.slice(0, -1);
continue;
}
if (last === '.') {
fixed = fixed.slice(0, -1);
}
break;
}
}
// si le nombre de chiffres dépassent 10, on tronque à 10 à droite
// et on arrondit au dernier (wtf)
if (Number(fixed) > (1e10 - 1)) {
fixed = Number(fixed.substring(0, 11) / 10).toFixed();
}
if (fixed.indexOf('.') !== -1) {
fixed = fixed.replace('.', _('text.comma'));
}
return fixed;
},
updateRearScreen: function (history) {
var expressionRow,
resultRow,
rows = document.createDocumentFragment();
for (var i in history) {
expressionRow = document.createElement('li');
expressionRow.className = 'expression-row';
expressionRow.appendChild(document.createTextNode(history[i].expression));
rows.appendChild(expressionRow);
resultRow = document.createElement('li');
resultRow.className = 'result-row';
resultRow.appendChild(this.createResultRow(history[i].output));
rows.appendChild(resultRow);
}
this.clearRearScreen();
this.rearScreen.appendChild(rows);
this.rearScreen.lastChild.scrollIntoView();
},
clearRearScreen: function () {
this._clearElement(this.rearScreen);
},
showRearScreen: function () {
this.rearScreen.style.display = 'block';
this.showTitle();
},
hideRearScreen: function () {
this.rearScreen.style.display = 'none';
this.hideTitle();
},
addFlag: function (flag) {
if (this.flags.indexOf(flag) === -1) {
this.flags.push(flag);
this.flags.sort();
}
},
removeFlag: function (flag) {
var idx = this.flags.indexOf(flag);
if (idx !== -1) {
this.flags.splice(idx, 1);
this.flags.sort();
}
},
changeTitle: function (title) {
this._clearElement(this.title);
this.title.appendChild(document.createTextNode(title));
},
showTitle: function () {
this.title.style.visibility = 'visible';
},
hideTitle: function () {
this.title.style.visibility = 'hidden';
}
}));
})();
\ No newline at end of file
/*globals klass:true Sankore:true*/
(function(){
"use strict";
klass.define('Sankore.Util', 'Error', klass.extend({
constructor: function (name, message) {
this.name = name;
this.message = message;
},
toString: function () {
return this.name + ': ' + this.message;
}
}));
})();
\ No newline at end of file
/*globals klass: true, Sankore:true*/
(function () {
"use strict";
klass.define('Sankore.Util', 'EventDispatcher', klass.extend({
constructor: function () {
this.eventListeners = {};
},
addEventSubscriber: function(subscriber) {
for (var i in subscriber.events) {
this.addEventListener(subscriber.events[i], subscriber.listener);
}
return this;
},
addEventListener: function (event, closure, id) {
if (typeof this.eventListeners[event] === 'undefined') {
this.eventListeners[event] = [];
}
if (typeof id === 'undefined') {
this.eventListeners[event].push(closure);
} else {
this.eventListeners[event][id] = closure;
}
return this;
},
removeEventListener: function (event, id) {
delete this.eventListeners[event][id];
},
removeAllEventListeners: function (event) {
this.eventListeners[event] = [];
},
notify: function (event, obj) {
var closure;
for (closure in this.eventListeners[event]) {
this.eventListeners[event][closure](obj);
}
}
}));
})();
\ No newline at end of file
/*globals klass: true, Sankore: true*/
(function() {
"use strict";
klass.define('Sankore.Util', 'Hash', klass.extend({
constructor: function (elements) {
this.elements = elements || {};
},
length: function () {
return this.keys().length;
},
keys: function () {
return Object.keys(this.elements);
},
set: function (id, value) {
this.elements[id] = value;
},
add: function (id, values) {
for (var i in values) {
this.set(values[i][id], values[i]);
}
},
has: function (id) {
return this.keys().indexOf(id) !== -1;
},
get: function (id, def) {
if (typeof this.elements[id] !== 'undefined') {
return this.elements[id];
}
if (typeof def !== 'undefined') {
return def;
}
return null;
},
pos: function (id) {
var pos = 0;
for (var i in this.elements) {
if (this.elements.hasOwnProperty(i) && i === id) {
return pos;
}
pos++;
}
return null;
},
remove: function (id) {
return delete this.elements[id];
},
map: function (closure) {
var output = [],
called;
for (var id in this.elements) {
if (this.elements.hasOwnProperty(id)) {
called = closure.call(this, id, this.elements[id]);
if (called) {
output.push(called);
}
}
}
return output;
}
}));
})();
\ No newline at end of file
/*jshint devel:true, browser:true*/
/*globals klass:true, Sankore:true*/
(function () {
"use strict";
klass.define('Sankore.Util', 'I18N', klass.extend({
catalogs: Sankore.Util.Hash.create(),
constructor: function () {
this.catalog = {};
},
load: function (locale) {
var localeId = locale.split(/-|_/)[0].toLowerCase();
if (!Sankore.Util.I18N.catalogs.has(localeId)) {
localeId = 'en';
}
this.catalog = Sankore.Util.I18N.catalogs.get(localeId, {});
},
translate: function (id) {
return id.split('.').reduce(
function (root, id) {
if (root && id in root) {
return root[id];
}
return null;
},
this.catalog
) || id;
}
}));
// global instance
Sankore.Util.i18n = Sankore.Util.I18N.create();
// global helper
window._ = function (id) {
return Sankore.Util.i18n.translate(id);
};
})();
\ No newline at end of file
(function() {
Sankore.Util.I18N.catalogs.set('en', {
layout: {
classic_name: 'Basic calculator',
new_name: 'New calculator'
},
text: {
del: 'DEL',
comma: '.'
},
command: {
zero: '0 digit',
one: '1 digit',
two: '2 digit',
three: '3 digit',
four: '4 digit',
five: '5 digit',
six: '6 digit',
seven: '7 digit',
eight: '8 digit',
nine: '9 digit',
plus: 'Addition',
minus: 'Subtraction',
times: 'Multiplication',
divide: 'Division',
euclidean_divide: 'Euclidean division',
equal: 'Equal',
comma: 'Comma',
open_parenthesis: 'Open parenthesis',
close_parenthesis: 'Close parenthesis',
op: 'Constant operator',
memory_add: 'Memory addition',
memory_sub: 'Memory substraction',
memory_recall: 'Memory recall',
memory_clear: 'Memory clear',
clear: 'Clear',
left: 'Move left',
right: 'Move right',
del: 'Delete'
},
controls: {
editor: 'Editor',
reset: 'RST'
},
editor: {
run_button: 'Run',
remove_alert: 'Delete this calculator?',
layout_name: {
label: 'Name'
},
layout_description: {
label: 'Description'
},
assignation: {
enabled: 'Click on a button to edit it',
disabled: 'This calculator is not editable',
text: {
label: 'Display text'
},
command: {
label: 'Command'
},
use_limit: {
label: 'Use limit',
help: '0 for disabled, empty for unlimited'
}
}
},
error: {
common: 'Error',
zero_division: 'Div/0 error'
}
});
})();
\ No newline at end of file
(function() {
Sankore.Util.I18N.catalogs.set('fr', {
layout: {
classic_name: 'Calculatrice standard',
new_name: 'Nouvelle calculatrice'
},
text: {
del: 'EFF',
comma: ','
},
command: {
zero: 'Chiffre 0',
one: 'Chiffre 1',
two: 'Chiffre 2',
three: 'Chiffre 3',
four: 'Chiffre 4',
five: 'Chiffre 5',
six: 'Chiffre 6',
seven: 'Chiffre 7',
eight: 'Chiffre 8',
nine: 'Chiffre 9',
plus: 'Addition',
minus: 'Soustraction',
times: 'Multiplication',
divide: 'Division',
euclidean_divide: 'Division euclidienne',
equal: 'Egalité',
comma: 'Virgule',
open_parenthesis: 'Parenthèse ouvrante',
close_parenthesis: 'Parenthèse fermante',
op: 'Opérateur constant',
memory_add: 'Addition mémoire',
memory_sub: 'Soustraction mémoire',
memory_recall: 'Rappel mémoire',
memory_clear: 'R.A.Z. mémoire',
clear: 'R.A.Z.',
left: 'Déplacement à gauche',
right: 'Déplacement à droite',
del: 'Suppression'
},
controls: {
editor: 'Editeur',
reset: 'RAZ'
},
editor: {
run_button: 'Utiliser',
remove_alert: 'Supprimer cette calculatrice ?',
layout_name: {
label: 'Nom'
},
layout_description: {
label: 'Description'
},
assignation: {
enabled: 'Cliquez sur une touche pour la modifier',
disabled: 'Cette calculatrice n\'est pas modifiable',
text: {
label: 'Texte à afficher'
},
command: {
label: 'Commande'
},
use_limit: {
label: 'Nb d\'utilisation',
help: '0 pour désactiver, vide pour illimité'
}
}
},
error: {
common: 'Erreur',
zero_division: 'Erreur div/0'
}
});
})();
\ No newline at end of file
/*global window:true*/
(function () {
"use strict";
// polyfill
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") {
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fNOP = function () {},
fBound = function () {
return fToBind.apply(this instanceof fNOP && oThis ? this : oThis,
aArgs.concat(Array.prototype.slice.call(arguments)));
};
fNOP.prototype = this.prototype;
fBound.prototype = new fNOP();
return fBound;
};
}
window.klass = {
create: function () {
var self = Object.create(this);
if (typeof self.constructor === "function") {
self.constructor.apply(self, arguments);
}
return self;
},
extend: function (object) {
var self = Object.create(this);
if (!object) {
return self;
}
Object.keys(object).forEach(function (key) {
self[key] = object[key];
});
return self;
},
define: function (namespace, name, object) {
var createNamespace = function (namespace, root) {
var namespaceParts = namespace.split('.'),
first;
if (namespaceParts.length > 0) {
first = namespaceParts.shift();
if (typeof root[first] === 'undefined') {
root[first] = {};
}
if (namespaceParts.length > 0) {
return createNamespace(namespaceParts.join('.'), root[first]);
}
return root[first];
}
return null;
},
ns = createNamespace(namespace, window);
ns[name] = object;
}
};
})();
\ No newline at end of file
* {
margin: 0;
padding: 0;
}
body{
margin:0px;
}
.ubw-container{
float:left;
margin:3px;
margin-right:0px;
margin-top: 2px;
background-image:url(../images/back_small.png);
overflow: hidden;
}
.ubw-body{
margin:5px;
margin-left: 9px;
margin-right: 0px;
}
.ubw-inspector{
position:absolute;
background-color:rgb(252, 252, 252);
border:1px solid #cccccc;
line-height:20px;
font-family:Arial, Helvetica, sans-serif;
font-weight:normal;
font-size:20px;
color:#333333;
}
.ubw-inpubox{
min-width:28px;
min-height:37px;
color:#333333;
background-image: url(../images/button_out.png);
border-left:1px solid rgb(231, 231, 231);
border-right:1px solid rgb(231, 231, 231);
border-bottom:1px solid rgb(221, 221, 221);
border-top:1px solid rgb(241, 241, 241);
}
/*BUTTONS*/
.ubw-button-wrapper{
float:left;
position:relative;
/*border:solid 1px yellow;*/
margin-right:-7px;
z-index:0;
font-family:Arial, Helvetica, sans-serif;
font-weight:normal;
font-size:30px;
overflow:visible;
}
.ubw-button-canvas{
width:auto;
float:left;
position:relative;
overflow:visible;
}
table{
line-height:90%;
}
.ubw-button-body{
position:relative;
float:left;
width:auto;
height:auto;
overflow:visible
text-align:center;
vertical-align:middle;
cursor:pointer;
}
.ubw-button-content{
height:auto;
width:auto;
text-align:center;
overflow:visible;
}
.ubw-button-over{
}
.ubw-button-out{
}
span.colored{
color: #0080ff;
}
\ No newline at end of file
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
function addChar(input, character) {
if(input.value == null || input.value == "0")
input.value = character
else
input.value += character
}
function cos(form) {
form.display.value = Math.cos(form.display.value);
}
function sin(form) {
form.display.value = Math.sin(form.display.value);
}
function tan(form) {
form.display.value = Math.tan(form.display.value);
}
function sqrt(form) {
form.display.value = Math.sqrt(form.display.value);
}
function ln(form) {
form.display.value = Math.log(form.display.value);
}
function exp(form) {
form.display.value = Math.exp(form.display.value);
}
function deleteChar(input) {
input.value = input.value.substring(0, input.value.length - 1)
}
function changeSign(input) {
if(input.value.substring(0, 1) == "-")
input.value = input.value.substring(1, input.value.length)
else
input.value = "-" + input.value
}
function square(form) {
form.display.value = eval(form.display.value) * eval(form.display.value)
}
function checkNum(str) {
for (var i = 0; i < str.length; i++) {
var ch = str.substring(i, i+1)
if (ch < "0" || ch > "9") {
if (ch != "/" && ch != "*" && ch != "+" && ch != "-" && ch != "."
&& ch != "(" && ch!= ")") {
$("#display").text("ERROR");
return false
}
}
}
return true
}
\ No newline at end of file
(function($) {
jQuery.fn.ubwidget = function(options) {
var settings = jQuery.extend({}, jQuery.fn.ubwidget.defaults, options);
$(window)
.bind("blur", function(event){
})
.trigger("focus");
return this.each(function() {
var ubwbody = $(this)
.addClass("ubw-body");
var ubwcontainer = $("<div></div>")
.append(ubwbody)
.addClass("ubw-container")
.css({
width:settings.width,
height:settings.height
})
.disableTextSelect();
$('body').append(ubwcontainer);
});
};
// Default options
jQuery.fn.ubwidget.defaults = {
width:200,
height:250
};
// Shadows
jQuery.fn.ubwshadows = function(settings){
var shadow = $("<div class='ubw-shadow'></div>")
.addClass("ubw-standard-corners")
.css({
backgroundColor:"#333377",
opacity:".1",
filter: "alpha(opacity = 10)",
position:"absolute",
top:settings.t,
left:settings.l,
width:settings.w,
height:settings.h
});
$(this).before(shadow);
};
jQuery.fn.ubwbutton = function(size, arrows) {
var arrows = typeof(arrows) != "undefined" ? arrows = arrows : arrows = {top:0, right:0, bottom:0, left:0};
var button = null;
var scale = 0.20;
var url = "";
var buttonbody;
return this.each(function() {
button = $(this)
.addClass("ubw-button-wrapper")
.css({zIndex:0});
url = $(this).find("img").attr("src");
url = url.split(".");
var buttonContent = $("<table cellpadding='0' cellspacing='0' border='0' width='auto' height='100%'><tr><td height='auto' width='auto' valign='middle' align='center'></td></tr></table>")
.addClass("ubw-button-content");
buttonContent.find("td").html($(this).html());
$(this).empty();
var buttonCanvas = $("<div></div>")
.addClass("ubw-button-canvas")
.appendTo(button)
.html('<table width="auto" height="auto" cellpadding="0" cellspacing="0"><tr><td class="ubw-button-arrowTop" align="center"><img style="visibility:hidden; margin-bottom:-1px" src="images/arrows_out/top.png"></td></tr><tr><td><table width="auto" height="auto" border="0" cellpadding="0" cellspacing="0"><tr><td class="ubw-button-arrowLeft"><img style="visibility:hidden; margin-right:-1px" src="images/arrows_out/left.png"></td><td class="ubw-button-body"></td><td class="ubw-button-arrowRight"><img style="visibility:hidden; margin-left:-1px" src="images/arrows_out/right.png"></td></tr></table></td></tr><tr><td class="ubw-button-arrowBottom" align="center"><img style="visibility:hidden; margin-top:-1px" src="images/arrows_out/bottom.png"></td></tr></table>');
if(arrows.top)buttonCanvas.find(".ubw-button-arrowTop").children("img").css({visibility:"visible"});
if(arrows.right)buttonCanvas.find(".ubw-button-arrowRight").children("img").css({visibility:"visible"});
if(arrows.bottom)buttonCanvas.find(".ubw-button-arrowBottom").children("img").css({visibility:"visible"});
if(arrows.left)buttonCanvas.find(".ubw-button-arrowLeft").children("img").css({visibility:"visible"});
var buttonBody = buttonCanvas.find(".ubw-button-body")
.addClass("ubw-button-out")
.append(buttonContent)
.bind("mouseenter", buttonOverHandler)
.bind("mouseleave", buttonOutHandler)
.bind("mousedown", buttonDownHandler)
.bind("mouseup", buttonUpHandler)
.css({
width:size.w,
height:size.h
});
button.width(size.w+9).height(size.h+2);
buttonbody = buttonBody.find(".ubw-button-content");
});
function buttonOverHandler(e) {
buttonbody.find("img").attr("src", url[0]+"_over.png");
button.css({
zIndex:1
});
};
function buttonOutHandler(e){
buttonbody.find("img").attr("src", url[0]+".png");
button.css({
zIndex:0
});
};
function buttonDownHandler(e){
buttonbody.find("img").attr("src", url[0]+"_over_down.png");
};
function buttonUpHandler(e){
url[0] = url[0].replace("_down", "");
buttonbody.find("img").attr("src", url[0]+"_over.png");
};
};
jQuery.fn.ubwtoggle = function(activated, _firstFunc, _secondFunc) {
var activated = typeof(activated) != "undefined" ? activated = 1 : activated = 0;
return this.each(function(){
var button = $(this);
var buttonBody = button.find(".ubw-button-body");
var img = buttonBody.find("img");
var imgsrc = img.attr("src");
var firstFunc = _firstFunc;
var secondFunc = _secondFunc;
buttonBody
.toggle(
function(){
img.css({visibility:"hidden"});
firstFunc();
},
function(){
img.css({visibility:"visible"});
secondFunc();
}
);
if(activated){
buttonBody.trigger("click");
};
});
};
jQuery.fn.ubwidget.sliderbutton = function() {
};
jQuery.fn.ubwidget.inspector = function(_position, content, button){
var position = {x:_position.x, y:_position.y};
var catcher = $("<div id='ubw-catcher'></div>")
.css({
position:"absolute",
width:"100%",
height:"100%"
})
.mousedown(function(){
inspector.hide();
removeDropShadow();
catcher.hide();
//resizeubcanvas()
});
$("body").append(catcher);
catcher.hide();
var inspector = $("<div class='ubw-inspector'></div>")
.css({
left:position.x,
top:position.y
})
.append(content)
.appendTo($("body"))
.hide()
.disableTextSelect();
var inspectorWidth = inspector.width();
var inspectorHeight = inspector.height();
var windowWidth = $(window).width();
var windowHeight = $(window).height();
$("body").prepend(button);
button.addClass("ubw-rounded")
.click(function(){
catcher.show();
inspector.show();
dropShadow();
resizeubcanvas()
});
function dropShadow (){
inspector.ubwshadows({w:inspectorWidth+23,h:inspectorHeight+22,l:55,t:55})}
function removeDropShadow (){
$(".ubw-shadow").remove()}
// !!
$(".ubw-shadow")
.mousedown(function(){
inspector.hide();
removeDropShadow();
catcher.hide();
resizeubcanvas()
});
function resizeWidget(w, h){
window.resizeTo(w+2, h+2);
$("#indicator").remove();
var indicator = $("<div id='indicator'></div>")
.css({
width:w,
height:h,
position:"absolute",
left:0,
top:0,
border:"1px solid #ff0000"
});
//$("body").prepend(indicator);
}
function resizeubcanvas(){
if(inspector.css("display")=="none"){
resizeWidget(windowWidth, windowHeight);
return 0;
};
var inspectorbottom = inspector.position().top+inspector.height()+40;
var inspectorright = inspector.position().left+inspector.width()+40;
if($(window).height()<inspectorbottom){
resizeWidget($(window).width(), inspectorbottom)};
if($(window).width()<inspectorright){
resizeWidget(inspectorright, $(window).height())};
}
};
})(jQuery);
\ No newline at end of file
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
function init() {
var h = 292;
var w = 160;
var wh = h + 6;
var ww = w + 6;
var clickFlag = false;
var ubwidget = $("#ubwidget").ubwidget({
width: w,
height: h
});
var historyTab = $("<div></div>")
.css({
height: h,
marginRight: 0,
width: 20,
float: "left",
backgroundImage: "url(images/historytab.png)",
backgroundRepeat: "no-repeat"
})
.toggle(
function () {
resizeWidget(370, 294);
historyPanel.show();
$(".ubw-container").css({
backgroundImage: "url(images/back.png)",
width: 328
});
if (window.sankore) {
window.sankore.setPreference('historyTab', "visible");
};
},
function () {
resizeWidget(200, 294);
historyPanel.hide();
$(".ubw-container").css({
backgroundImage: "url(images/back_small.png)",
width: 160
});
if (window.sankore) {
window.sankore.setPreference('historyTab', "hidden");
};
}
)
.hover(
function () {
$(this).css({
backgroundImage: "url(images/historytabOver.png)"
});
},
function () {
$(this).css({
backgroundImage: "url(images/historytab.png)"
});
}
)
.appendTo($("body"));
var space = $("<div></div>");
space.css({
width: 5,
height: 1,
float: "left"
});
var keysPanel = $("<div id='keysPanel'></div>").css({
float: "left"
});
var mode = "standard";
var calc = "";
var displayTrunk = "";
var historyTrunk = "";
var lastHistory = "";
var subtrunk = 0;
var itrunk = 0;
var trunkpos = 0;
var lastchar = {
type: "NaN",
value: "null"
};
var inparenthesis = false;
var erase = false;
var abtn;
var readyToCompute = false;
var lastResult = "0";
var gDecimalSeparator = "";
var gThousandsSeparator = "";
var gDecimalCode = 0;
var gDecimalString = "";
var gError = false;
var historyTxt = "0";
var display = $("<div id='display'>0</div>")
.addClass("ubw-inputbox")
.css({
padding: "12px",
marginLeft: "2px",
marginBottom: "9px",
marginTop: 7,
backgroundImage: "url(images/display.png)",
fontSize: "22px",
fontFamily: "Arial, Helvetica, Sans-serif",
color: "#777788",
width: 118,
height: 28,
overflow: "hidden",
textAlign: "right",
});
var standardPanel = $("<div></div>").css({
float: "left"
});
var cKeySize = {
w: 33,
h: 36
};
var btn7 = $("<div><img src='images/touche7.png'/></div>").ubwbutton({
w: cKeySize.w,
h: cKeySize.h
})
.mousedown(function () {
appendToDisplay("7", 1)
});
var btn8 = $("<div><img src='images/touche8.png'/></div>").ubwbutton({
w: cKeySize.w,
h: cKeySize.h
})
.mousedown(function () {
appendToDisplay("8", 1)
});
var btn9 = $("<div><img src='images/touche9.png'/></div>").ubwbutton({
w: cKeySize.w,
h: cKeySize.h
})
.mousedown(function () {
appendToDisplay("9", 1)
});
var btnDiv = $("<div><img src='images/touchediv.png'/></div>").ubwbutton({
w: cKeySize.w,
h: cKeySize.h
})
.mousedown(function () {
appendToDisplay("/", 0)
});
var btn4 = $("<div><img src='images/touche4.png'/></div>").ubwbutton({
w: cKeySize.w,
h: cKeySize.h
})
.mousedown(function () {
appendToDisplay("4", 1)
});
var btn5 = $("<div><img src='images/touche5.png'/></div>").ubwbutton({
w: cKeySize.w,
h: cKeySize.h
})
.mousedown(function () {
appendToDisplay("5", 1)
});
var btn6 = $("<div><img src='images/touche6.png'/></div>").ubwbutton({
w: cKeySize.w,
h: cKeySize.h
})
.mousedown(function () {
appendToDisplay("6", 1)
});
var btnMul = $("<div><img src='images/touchef.png'/></div>").ubwbutton({
w: cKeySize.w,
h: cKeySize.h
})
.mousedown(function () {
appendToDisplay("*", 0)
});
var btn1 = $("<div><img src='images/touche1.png'/></div>").ubwbutton({
w: cKeySize.w,
h: cKeySize.h
})
.mousedown(function () {
appendToDisplay("1", 1)
});
var btn2 = $("<div><img src='images/touche2.png'/></div>").ubwbutton({
w: cKeySize.w,
h: cKeySize.h
})
.mousedown(function () {
appendToDisplay("2", 1)
});
var btn3 = $("<div><img src='images/touche3.png'/></div>").ubwbutton({
w: cKeySize.w,
h: cKeySize.h
})
.mousedown(function () {
appendToDisplay("3", 1)
});
var btnSou = $("<div><img src='images/touchem.png'/></div>").ubwbutton({
w: 68,
h: 34
})
.mousedown(function () {
appendToDisplay("-", 0)
});
var btn0 = $("<div><img src='images/touche0.png'/></div>").ubwbutton({
w: cKeySize.w,
h: cKeySize.h
})
.mousedown(function () {
appendToDisplay("0", 1)
});
var btnDot = $("<div><img src='images/touchedot.png'/></div>").ubwbutton({
w: cKeySize.w,
h: cKeySize.h
})
.mousedown(function () {
appendToDisplay(".", 1)
});
var btnC = $("<div><img src='images/touchec.png'/></div>").ubwbutton({
w: cKeySize.w,
h: cKeySize.h
})
.mousedown(function () {
reset()
});
var btnAdd = $("<div><img src='images/touchep.png'/></div>").ubwbutton({
w: 68,
h: 34
})
.mousedown(function () {
appendToDisplay("+", 0)
});
var btnPaL = $("<div><img src='images/touchepg.png'/></div>").ubwbutton({
w: cKeySize.w,
h: cKeySize.h
})
.mousedown(function () {
appendToDisplay("(", 1)
});
var btnPaR = $("<div><img src='images/touchepd.png'/></div>").ubwbutton({
w: cKeySize.w,
h: cKeySize.h
})
.mousedown(function () {
appendToDisplay(")", 1)
});
var btnEqu = $("<div><img src='images/toucheeq.png'/></div>").ubwbutton({
w: cKeySize.w,
h: cKeySize.h
})
.mousedown(function () {
compute()
});
var historyPanel = $("<div id='historyPanel'></div>")
.css({
backgroundImage: "url(images/historyback.png)",
width: "auto",
height: "auto",
float: "left",
marginLeft: 3,
marginRight: 2,
marginTop: 6
})
.hide();
var historyBox = $("<textarea id='historyBox'></textarea>")
.css({
padding: 10,
fontSize: "20px",
fontFamily: "Arial, Helvetica, Sans-serif",
width: 143,
height: 236,
backgroundColor: "transparent",
resize: "none",
border: "none",
overlay: "none",
color: "#eeeeee"
})
.val("0");
historyPanel.append(historyBox);
var stop = $("<div></div>");
var sleft = $("<div></div>");
var sright = $("<div></div>");
stop.css({
width: 140
})
.append(btnAdd).append(btnSou)
.append(btn7).append(btn8).append(btn9).append(btnMul)
.append(btn4).append(btn5).append(btn6).append(btnDiv);
sleft.css({
width: 105,
float: "left"
})
.append(btn1).append(btn2).append(btn3)
.append(btn0).append(btnDot).append(btnC);
sright.css({
width: 45,
float: "left"
})
.append(btnEqu);
standardPanel.css({
width: 150
})
.append(stop)
.append(sleft).append(sright);
keysPanel
.append(display)
.append(standardPanel);
ubwidget
.append(historyPanel)
.append(keysPanel);
if (window.sankore) {
historyTxt = window.sankore.preference('historyTxt', historyTxt);
var ht = window.sankore.preference('historyTab', "hidden");
$("#historyBox").val(historyTxt);
if (ht === "visible") {
historyTab.trigger("click");
};
}
function resizeWidget(w, h) {
if (window.sankore) {
window.sankore.resize(w + 2, h + 2);
}
}
function compute() {
var result;
if (calc.length <= 1)
result = eval(calc);
else {
var fNumber, lNumber, operation = "",
fMinus = "";
if (calc.charAt(0) == '-') {
fMinus = "-";
calc = calc.substr(1, calc.length);
}
operation = (calc.indexOf("+", 0) != -1) ? calc.charAt(calc.indexOf("+", 0)) : ((calc.indexOf("*", 0) != -1) ? calc.charAt(calc.indexOf("*", 0)) : ((calc.indexOf("/", 0) != -1) ? calc.charAt(calc.indexOf("/", 0)) : ((calc.indexOf("-", 0) != -1) ? calc.charAt(calc.indexOf("-", 0)) : "")));
fNumber = fMinus + calc.substring(0, calc.indexOf(operation, 0));
lNumber = calc.substring(calc.indexOf(operation, 0) + 1, calc.length);
result = calcIt(fNumber, operation, lNumber);
}
$("#display").text(updateDisplay(result));
lastResult = result;
lastchar.type = "Nan";
lastchar.value = "";
calc = "";
$("#historyBox").val($("#historyBox").val() + historyTrunk + "\n= " + updateDisplay(result) + "\n\n");
$("#historyBox").scrollTop(99999);
displayTrunk = "";
historyTrunk = "";
if (window.sankore) {
window.sankore.setPreference('historyTxt', $("#historyBox").val());
}
lastHistory = $("#historyBox").val();
}
function calcIt(fNumber, operation, lNumber) {
var result, fCount = "",
lCount = "",
length = 0;
fCount = (fNumber.indexOf(".", 0) != -1) ? fNumber.substring(fNumber.indexOf(".", 0) + 1, fNumber.length) : "";
lCount = (lNumber.indexOf(".", 0) != -1) ? lNumber.substring(lNumber.indexOf(".", 0) + 1, lNumber.length) : "";
length = (fCount.length >= lCount.length) ? fCount.length : lCount.length;
length = Math.pow(10, length);
fNumber = Math.round(fNumber * length);
lNumber = Math.round(lNumber * length);
switch (operation) {
case "+":
result = (fNumber + lNumber) / length;
break;
case "-":
result = (fNumber - lNumber) / length;
break;
case "*":
result = (fNumber * lNumber) / Math.pow(length, 2);
break;
case "/":
result = fNumber / lNumber;
break;
}
return result;
}
function reset() {
$("#display").text("0");
calc = "";
lastchar.type = "NaN";
displayTrunk = "";
historyTrunk = "";
$("#historyBox").val(lastHistory);
$("#historyBox").scrollTop(99999);
}
function formatNumberWithDelimiters(number) {
var delimiter = gThousandsSeparator;
var numString = number.toString();
if (!numString)
return "0";
var dot = numString.indexOf(gDecimalSeparator);
if (dot == -1)
dot = numString.length;
var stop = numString.length - dot;
var characteristic = numString.substr(0, dot);
if (!parseInt(characteristic))
return numString;
// see if it's a negative number
var numIsNegative = (parseInt(characteristic) < 0)
var newNumber = "";
var delimiterCount = Math.floor((characteristic.length - 1) / 3);
var extras = characteristic.length % 3;
if (!extras && characteristic.length > 2)
extras = 3;
if (extras)
newNumber = newNumber + characteristic.substr(0, extras);
for (var i = 0; i < delimiterCount; i++) {
if ((0 == i) && numIsNegative && (extras == 1))
newNumber = newNumber + characteristic.substr(extras + (i * 3), 3);
else
newNumber = newNumber + delimiter + characteristic.substr(extras + (i * 3), 3);
}
return (dot ? (newNumber + numString.substr(dot, stop)) : newNumber);
}
function formatNumberWithScientificNotation(number) {
if (number == 0)
return number;
var numString = number.toString();
if (!numString)
return "0";
var num = new Number(numString);
var sci = num.toExponential(5);
if (sci == "NaN")
sci = formatNumberWithDelimiters(numString);
if (!sci)
return "0";
return sci;
}
function updateDisplay(number) {
if (String(number).length > 8) {
number = formatNumberWithScientificNotation(number);
} else {
number = number;
}
return number;
}
function appendToDisplay(_char, v) {
var char = _char;
// Display
if ($("#historyBox").val() === "0") {
$("#historyBox").val("");
};
if (char == "-" && lastchar.type == "NaN") {
char = "m";
};
// char is a number
if (char <= 0 || char > 0 || char == "." || char == "m" || char == "(" || char == ")") {
if (char == "m") {
char = "-";
};
if (lastchar.type == "NaN") {
displayTrunk = "";
};
if (lastchar.value == "." && char == ".") {
calc = calc.substr(0, calc.length - 1);
displayTrunk = displayTrunk.substr(0, displayTrunk.length - 1);
};
if (calc == "0") {
if (char != "0") {
if (char != ".") {
calc = String(char);
displayTrunk = String(char);
historyTrunk = String(char);
lastchar.type = "Number";
} else {
calc += String(char);
displayTrunk += String(char);
historyTrunk += String(char);
lastchar.type = "Number";
}
}
} else {
char = (char == ".") ? ((displayTrunk.indexOf(".", 0) != -1) ? "" : ".") : char;
calc += String(char);
displayTrunk += String(char);
historyTrunk += String(char);
lastchar.type = "Number";
}
}
// char is an operator
else {
if (calc.length === 0) {
var endCalc = calc;
calc = lastResult + endCalc;
historyTrunk = updateDisplay(lastResult);
}
if (lastchar.type == "NaN") {
calc = calc.substr(0, calc.length - 1);
calc += char;
$("#historyBox").val($("#historyBox").val().substr(0, $("#historyBox").val().length - 1));
} else {
try {
calc = eval(calc) + String(char);
} catch (e) {}
}
lastchar.type = "NaN";
try {
displayTrunk = eval(calc.substr(0, calc.length - 1));
} catch (e) {}
$("#historyBox").val($("#historyBox").val() + historyTrunk + char);
$("#historyBox").scrollTop(99999);
historyTrunk = "";
}
lastchar.value = char;
$("#display").text(updateDisplay(displayTrunk));
}
$("#historyBox").click(function () {
if (!clickFlag) {
$(this).select();
clickFlag = true;
} else {
clickFlag = false;
$(this).blur();
}
});
$(document).disableTextSelect();
};
\ No newline at end of file
/*
* jQuery JavaScript Library v1.3.2
* http://jquery.com/
*
* Copyright (c) 2009 John Resig
* Dual licensed under the MIT and GPL licenses.
* http://docs.jquery.com/License
*
* Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
* Revision: 6246
*/
(function(){var l=this,g,y=l.jQuery,p=l.$,o=l.jQuery=l.$=function(E,F){return new o.fn.init(E,F)},D=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,f=/^.[^:#\[\.,]*$/;o.fn=o.prototype={init:function(E,H){E=E||document;if(E.nodeType){this[0]=E;this.length=1;this.context=E;return this}if(typeof E==="string"){var G=D.exec(E);if(G&&(G[1]||!H)){if(G[1]){E=o.clean([G[1]],H)}else{var I=document.getElementById(G[3]);if(I&&I.id!=G[3]){return o().find(E)}var F=o(I||[]);F.context=document;F.selector=E;return F}}else{return o(H).find(E)}}else{if(o.isFunction(E)){return o(document).ready(E)}}if(E.selector&&E.context){this.selector=E.selector;this.context=E.context}return this.setArray(o.isArray(E)?E:o.makeArray(E))},selector:"",jquery:"1.3.2",size:function(){return this.length},get:function(E){return E===g?Array.prototype.slice.call(this):this[E]},pushStack:function(F,H,E){var G=o(F);G.prevObject=this;G.context=this.context;if(H==="find"){G.selector=this.selector+(this.selector?" ":"")+E}else{if(H){G.selector=this.selector+"."+H+"("+E+")"}}return G},setArray:function(E){this.length=0;Array.prototype.push.apply(this,E);return this},each:function(F,E){return o.each(this,F,E)},index:function(E){return o.inArray(E&&E.jquery?E[0]:E,this)},attr:function(F,H,G){var E=F;if(typeof F==="string"){if(H===g){return this[0]&&o[G||"attr"](this[0],F)}else{E={};E[F]=H}}return this.each(function(I){for(F in E){o.attr(G?this.style:this,F,o.prop(this,E[F],G,I,F))}})},css:function(E,F){if((E=="width"||E=="height")&&parseFloat(F)<0){F=g}return this.attr(E,F,"curCSS")},text:function(F){if(typeof F!=="object"&&F!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(F))}var E="";o.each(F||this,function(){o.each(this.childNodes,function(){if(this.nodeType!=8){E+=this.nodeType!=1?this.nodeValue:o.fn.text([this])}})});return E},wrapAll:function(E){if(this[0]){var F=o(E,this[0].ownerDocument).clone();if(this[0].parentNode){F.insertBefore(this[0])}F.map(function(){var G=this;while(G.firstChild){G=G.firstChild}return G}).append(this)}return this},wrapInner:function(E){return this.each(function(){o(this).contents().wrapAll(E)})},wrap:function(E){return this.each(function(){o(this).wrapAll(E)})},append:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.appendChild(E)}})},prepend:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.insertBefore(E,this.firstChild)}})},before:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this)})},after:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this.nextSibling)})},end:function(){return this.prevObject||o([])},push:[].push,sort:[].sort,splice:[].splice,find:function(E){if(this.length===1){var F=this.pushStack([],"find",E);F.length=0;o.find(E,this[0],F);return F}else{return this.pushStack(o.unique(o.map(this,function(G){return o.find(E,G)})),"find",E)}},clone:function(G){var E=this.map(function(){if(!o.support.noCloneEvent&&!o.isXMLDoc(this)){var I=this.outerHTML;if(!I){var J=this.ownerDocument.createElement("div");J.appendChild(this.cloneNode(true));I=J.innerHTML}return o.clean([I.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/^\s*/,"")])[0]}else{return this.cloneNode(true)}});if(G===true){var H=this.find("*").andSelf(),F=0;E.find("*").andSelf().each(function(){if(this.nodeName!==H[F].nodeName){return}var I=o.data(H[F],"events");for(var K in I){for(var J in I[K]){o.event.add(this,K,I[K][J],I[K][J].data)}}F++})}return E},filter:function(E){return this.pushStack(o.isFunction(E)&&o.grep(this,function(G,F){return E.call(G,F)})||o.multiFilter(E,o.grep(this,function(F){return F.nodeType===1})),"filter",E)},closest:function(E){var G=o.expr.match.POS.test(E)?o(E):null,F=0;return this.map(function(){var H=this;while(H&&H.ownerDocument){if(G?G.index(H)>-1:o(H).is(E)){o.data(H,"closest",F);return H}H=H.parentNode;F++}})},not:function(E){if(typeof E==="string"){if(f.test(E)){return this.pushStack(o.multiFilter(E,this,true),"not",E)}else{E=o.multiFilter(E,this)}}var F=E.length&&E[E.length-1]!==g&&!E.nodeType;return this.filter(function(){return F?o.inArray(this,E)<0:this!=E})},add:function(E){return this.pushStack(o.unique(o.merge(this.get(),typeof E==="string"?o(E):o.makeArray(E))))},is:function(E){return !!E&&o.multiFilter(E,this).length>0},hasClass:function(E){return !!E&&this.is("."+E)},val:function(K){if(K===g){var E=this[0];if(E){if(o.nodeName(E,"option")){return(E.attributes.value||{}).specified?E.value:E.text}if(o.nodeName(E,"select")){var I=E.selectedIndex,L=[],M=E.options,H=E.type=="select-one";if(I<0){return null}for(var F=H?I:0,J=H?I+1:M.length;F<J;F++){var G=M[F];if(G.selected){K=o(G).val();if(H){return K}L.push(K)}}return L}return(E.value||"").replace(/\r/g,"")}return g}if(typeof K==="number"){K+=""}return this.each(function(){if(this.nodeType!=1){return}if(o.isArray(K)&&/radio|checkbox/.test(this.type)){this.checked=(o.inArray(this.value,K)>=0||o.inArray(this.name,K)>=0)}else{if(o.nodeName(this,"select")){var N=o.makeArray(K);o("option",this).each(function(){this.selected=(o.inArray(this.value,N)>=0||o.inArray(this.text,N)>=0)});if(!N.length){this.selectedIndex=-1}}else{this.value=K}}})},html:function(E){return E===g?(this[0]?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,""):null):this.empty().append(E)},replaceWith:function(E){return this.after(E).remove()},eq:function(E){return this.slice(E,+E+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments),"slice",Array.prototype.slice.call(arguments).join(","))},map:function(E){return this.pushStack(o.map(this,function(G,F){return E.call(G,F,G)}))},andSelf:function(){return this.add(this.prevObject)},domManip:function(J,M,L){if(this[0]){var I=(this[0].ownerDocument||this[0]).createDocumentFragment(),F=o.clean(J,(this[0].ownerDocument||this[0]),I),H=I.firstChild;if(H){for(var G=0,E=this.length;G<E;G++){L.call(K(this[G],H),this.length>1||G>0?I.cloneNode(true):I)}}if(F){o.each(F,z)}}return this;function K(N,O){return M&&o.nodeName(N,"table")&&o.nodeName(O,"tr")?(N.getElementsByTagName("tbody")[0]||N.appendChild(N.ownerDocument.createElement("tbody"))):N}}};o.fn.init.prototype=o.fn;function z(E,F){if(F.src){o.ajax({url:F.src,async:false,dataType:"script"})}else{o.globalEval(F.text||F.textContent||F.innerHTML||"")}if(F.parentNode){F.parentNode.removeChild(F)}}function e(){return +new Date}o.extend=o.fn.extend=function(){var J=arguments[0]||{},H=1,I=arguments.length,E=false,G;if(typeof J==="boolean"){E=J;J=arguments[1]||{};H=2}if(typeof J!=="object"&&!o.isFunction(J)){J={}}if(I==H){J=this;--H}for(;H<I;H++){if((G=arguments[H])!=null){for(var F in G){var K=J[F],L=G[F];if(J===L){continue}if(E&&L&&typeof L==="object"&&!L.nodeType){J[F]=o.extend(E,K||(L.length!=null?[]:{}),L)}else{if(L!==g){J[F]=L}}}}}return J};var b=/z-?index|font-?weight|opacity|zoom|line-?height/i,q=document.defaultView||{},s=Object.prototype.toString;o.extend({noConflict:function(E){l.$=p;if(E){l.jQuery=y}return o},isFunction:function(E){return s.call(E)==="[object Function]"},isArray:function(E){return s.call(E)==="[object Array]"},isXMLDoc:function(E){return E.nodeType===9&&E.documentElement.nodeName!=="HTML"||!!E.ownerDocument&&o.isXMLDoc(E.ownerDocument)},globalEval:function(G){if(G&&/\S/.test(G)){var F=document.getElementsByTagName("head")[0]||document.documentElement,E=document.createElement("script");E.type="text/javascript";if(o.support.scriptEval){E.appendChild(document.createTextNode(G))}else{E.text=G}F.insertBefore(E,F.firstChild);F.removeChild(E)}},nodeName:function(F,E){return F.nodeName&&F.nodeName.toUpperCase()==E.toUpperCase()},each:function(G,K,F){var E,H=0,I=G.length;if(F){if(I===g){for(E in G){if(K.apply(G[E],F)===false){break}}}else{for(;H<I;){if(K.apply(G[H++],F)===false){break}}}}else{if(I===g){for(E in G){if(K.call(G[E],E,G[E])===false){break}}}else{for(var J=G[0];H<I&&K.call(J,H,J)!==false;J=G[++H]){}}}return G},prop:function(H,I,G,F,E){if(o.isFunction(I)){I=I.call(H,F)}return typeof I==="number"&&G=="curCSS"&&!b.test(E)?I+"px":I},className:{add:function(E,F){o.each((F||"").split(/\s+/),function(G,H){if(E.nodeType==1&&!o.className.has(E.className,H)){E.className+=(E.className?" ":"")+H}})},remove:function(E,F){if(E.nodeType==1){E.className=F!==g?o.grep(E.className.split(/\s+/),function(G){return !o.className.has(F,G)}).join(" "):""}},has:function(F,E){return F&&o.inArray(E,(F.className||F).toString().split(/\s+/))>-1}},swap:function(H,G,I){var E={};for(var F in G){E[F]=H.style[F];H.style[F]=G[F]}I.call(H);for(var F in G){H.style[F]=E[F]}},css:function(H,F,J,E){if(F=="width"||F=="height"){var L,G={position:"absolute",visibility:"hidden",display:"block"},K=F=="width"?["Left","Right"]:["Top","Bottom"];function I(){L=F=="width"?H.offsetWidth:H.offsetHeight;if(E==="border"){return}o.each(K,function(){if(!E){L-=parseFloat(o.curCSS(H,"padding"+this,true))||0}if(E==="margin"){L+=parseFloat(o.curCSS(H,"margin"+this,true))||0}else{L-=parseFloat(o.curCSS(H,"border"+this+"Width",true))||0}})}if(H.offsetWidth!==0){I()}else{o.swap(H,G,I)}return Math.max(0,Math.round(L))}return o.curCSS(H,F,J)},curCSS:function(I,F,G){var L,E=I.style;if(F=="opacity"&&!o.support.opacity){L=o.attr(E,"opacity");return L==""?"1":L}if(F.match(/float/i)){F=w}if(!G&&E&&E[F]){L=E[F]}else{if(q.getComputedStyle){if(F.match(/float/i)){F="float"}F=F.replace(/([A-Z])/g,"-$1").toLowerCase();var M=q.getComputedStyle(I,null);if(M){L=M.getPropertyValue(F)}if(F=="opacity"&&L==""){L="1"}}else{if(I.currentStyle){var J=F.replace(/\-(\w)/g,function(N,O){return O.toUpperCase()});L=I.currentStyle[F]||I.currentStyle[J];if(!/^\d+(px)?$/i.test(L)&&/^\d/.test(L)){var H=E.left,K=I.runtimeStyle.left;I.runtimeStyle.left=I.currentStyle.left;E.left=L||0;L=E.pixelLeft+"px";E.left=H;I.runtimeStyle.left=K}}}}return L},clean:function(F,K,I){K=K||document;if(typeof K.createElement==="undefined"){K=K.ownerDocument||K[0]&&K[0].ownerDocument||document}if(!I&&F.length===1&&typeof F[0]==="string"){var H=/^<(\w+)\s*\/?>$/.exec(F[0]);if(H){return[K.createElement(H[1])]}}var G=[],E=[],L=K.createElement("div");o.each(F,function(P,S){if(typeof S==="number"){S+=""}if(!S){return}if(typeof S==="string"){S=S.replace(/(<(\w+)[^>]*?)\/>/g,function(U,V,T){return T.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?U:V+"></"+T+">"});var O=S.replace(/^\s+/,"").substring(0,10).toLowerCase();var Q=!O.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!O.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||O.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!O.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!O.indexOf("<td")||!O.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!O.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||!o.support.htmlSerialize&&[1,"div<div>","</div>"]||[0,"",""];L.innerHTML=Q[1]+S+Q[2];while(Q[0]--){L=L.lastChild}if(!o.support.tbody){var R=/<tbody/i.test(S),N=!O.indexOf("<table")&&!R?L.firstChild&&L.firstChild.childNodes:Q[1]=="<table>"&&!R?L.childNodes:[];for(var M=N.length-1;M>=0;--M){if(o.nodeName(N[M],"tbody")&&!N[M].childNodes.length){N[M].parentNode.removeChild(N[M])}}}if(!o.support.leadingWhitespace&&/^\s/.test(S)){L.insertBefore(K.createTextNode(S.match(/^\s*/)[0]),L.firstChild)}S=o.makeArray(L.childNodes)}if(S.nodeType){G.push(S)}else{G=o.merge(G,S)}});if(I){for(var J=0;G[J];J++){if(o.nodeName(G[J],"script")&&(!G[J].type||G[J].type.toLowerCase()==="text/javascript")){E.push(G[J].parentNode?G[J].parentNode.removeChild(G[J]):G[J])}else{if(G[J].nodeType===1){G.splice.apply(G,[J+1,0].concat(o.makeArray(G[J].getElementsByTagName("script"))))}I.appendChild(G[J])}}return E}return G},attr:function(J,G,K){if(!J||J.nodeType==3||J.nodeType==8){return g}var H=!o.isXMLDoc(J),L=K!==g;G=H&&o.props[G]||G;if(J.tagName){var F=/href|src|style/.test(G);if(G=="selected"&&J.parentNode){J.parentNode.selectedIndex}if(G in J&&H&&!F){if(L){if(G=="type"&&o.nodeName(J,"input")&&J.parentNode){throw"type property can't be changed"}J[G]=K}if(o.nodeName(J,"form")&&J.getAttributeNode(G)){return J.getAttributeNode(G).nodeValue}if(G=="tabIndex"){var I=J.getAttributeNode("tabIndex");return I&&I.specified?I.value:J.nodeName.match(/(button|input|object|select|textarea)/i)?0:J.nodeName.match(/^(a|area)$/i)&&J.href?0:g}return J[G]}if(!o.support.style&&H&&G=="style"){return o.attr(J.style,"cssText",K)}if(L){J.setAttribute(G,""+K)}var E=!o.support.hrefNormalized&&H&&F?J.getAttribute(G,2):J.getAttribute(G);return E===null?g:E}if(!o.support.opacity&&G=="opacity"){if(L){J.zoom=1;J.filter=(J.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(K)+""=="NaN"?"":"alpha(opacity="+K*100+")")}return J.filter&&J.filter.indexOf("opacity=")>=0?(parseFloat(J.filter.match(/opacity=([^)]*)/)[1])/100)+"":""}G=G.replace(/-([a-z])/ig,function(M,N){return N.toUpperCase()});if(L){J[G]=K}return J[G]},trim:function(E){return(E||"").replace(/^\s+|\s+$/g,"")},makeArray:function(G){var E=[];if(G!=null){var F=G.length;if(F==null||typeof G==="string"||o.isFunction(G)||G.setInterval){E[0]=G}else{while(F){E[--F]=G[F]}}}return E},inArray:function(G,H){for(var E=0,F=H.length;E<F;E++){if(H[E]===G){return E}}return -1},merge:function(H,E){var F=0,G,I=H.length;if(!o.support.getAll){while((G=E[F++])!=null){if(G.nodeType!=8){H[I++]=G}}}else{while((G=E[F++])!=null){H[I++]=G}}return H},unique:function(K){var F=[],E={};try{for(var G=0,H=K.length;G<H;G++){var J=o.data(K[G]);if(!E[J]){E[J]=true;F.push(K[G])}}}catch(I){F=K}return F},grep:function(F,J,E){var G=[];for(var H=0,I=F.length;H<I;H++){if(!E!=!J(F[H],H)){G.push(F[H])}}return G},map:function(E,J){var F=[];for(var G=0,H=E.length;G<H;G++){var I=J(E[G],G);if(I!=null){F[F.length]=I}}return F.concat.apply([],F)}});var C=navigator.userAgent.toLowerCase();o.browser={version:(C.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1],safari:/webkit/.test(C),opera:/opera/.test(C),msie:/msie/.test(C)&&!/opera/.test(C),mozilla:/mozilla/.test(C)&&!/(compatible|webkit)/.test(C)};o.each({parent:function(E){return E.parentNode},parents:function(E){return o.dir(E,"parentNode")},next:function(E){return o.nth(E,2,"nextSibling")},prev:function(E){return o.nth(E,2,"previousSibling")},nextAll:function(E){return o.dir(E,"nextSibling")},prevAll:function(E){return o.dir(E,"previousSibling")},siblings:function(E){return o.sibling(E.parentNode.firstChild,E)},children:function(E){return o.sibling(E.firstChild)},contents:function(E){return o.nodeName(E,"iframe")?E.contentDocument||E.contentWindow.document:o.makeArray(E.childNodes)}},function(E,F){o.fn[E]=function(G){var H=o.map(this,F);if(G&&typeof G=="string"){H=o.multiFilter(G,H)}return this.pushStack(o.unique(H),E,G)}});o.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(E,F){o.fn[E]=function(G){var J=[],L=o(G);for(var K=0,H=L.length;K<H;K++){var I=(K>0?this.clone(true):this).get();o.fn[F].apply(o(L[K]),I);J=J.concat(I)}return this.pushStack(J,E,G)}});o.each({removeAttr:function(E){o.attr(this,E,"");if(this.nodeType==1){this.removeAttribute(E)}},addClass:function(E){o.className.add(this,E)},removeClass:function(E){o.className.remove(this,E)},toggleClass:function(F,E){if(typeof E!=="boolean"){E=!o.className.has(this,F)}o.className[E?"add":"remove"](this,F)},remove:function(E){if(!E||o.filter(E,[this]).length){o("*",this).add([this]).each(function(){o.event.remove(this);o.removeData(this)});if(this.parentNode){this.parentNode.removeChild(this)}}},empty:function(){o(this).children().remove();while(this.firstChild){this.removeChild(this.firstChild)}}},function(E,F){o.fn[E]=function(){return this.each(F,arguments)}});function j(E,F){return E[0]&&parseInt(o.curCSS(E[0],F,true),10)||0}var h="jQuery"+e(),v=0,A={};o.extend({cache:{},data:function(F,E,G){F=F==l?A:F;var H=F[h];if(!H){H=F[h]=++v}if(E&&!o.cache[H]){o.cache[H]={}}if(G!==g){o.cache[H][E]=G}return E?o.cache[H][E]:H},removeData:function(F,E){F=F==l?A:F;var H=F[h];if(E){if(o.cache[H]){delete o.cache[H][E];E="";for(E in o.cache[H]){break}if(!E){o.removeData(F)}}}else{try{delete F[h]}catch(G){if(F.removeAttribute){F.removeAttribute(h)}}delete o.cache[H]}},queue:function(F,E,H){if(F){E=(E||"fx")+"queue";var G=o.data(F,E);if(!G||o.isArray(H)){G=o.data(F,E,o.makeArray(H))}else{if(H){G.push(H)}}}return G},dequeue:function(H,G){var E=o.queue(H,G),F=E.shift();if(!G||G==="fx"){F=E[0]}if(F!==g){F.call(H)}}});o.fn.extend({data:function(E,G){var H=E.split(".");H[1]=H[1]?"."+H[1]:"";if(G===g){var F=this.triggerHandler("getData"+H[1]+"!",[H[0]]);if(F===g&&this.length){F=o.data(this[0],E)}return F===g&&H[1]?this.data(H[0]):F}else{return this.trigger("setData"+H[1]+"!",[H[0],G]).each(function(){o.data(this,E,G)})}},removeData:function(E){return this.each(function(){o.removeData(this,E)})},queue:function(E,F){if(typeof E!=="string"){F=E;E="fx"}if(F===g){return o.queue(this[0],E)}return this.each(function(){var G=o.queue(this,E,F);if(E=="fx"&&G.length==1){G[0].call(this)}})},dequeue:function(E){return this.each(function(){o.dequeue(this,E)})}});
/*
* Sizzle CSS Selector Engine - v0.9.3
* Copyright 2009, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
* More information: http://sizzlejs.com/
*/
(function(){var R=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,L=0,H=Object.prototype.toString;var F=function(Y,U,ab,ac){ab=ab||[];U=U||document;if(U.nodeType!==1&&U.nodeType!==9){return[]}if(!Y||typeof Y!=="string"){return ab}var Z=[],W,af,ai,T,ad,V,X=true;R.lastIndex=0;while((W=R.exec(Y))!==null){Z.push(W[1]);if(W[2]){V=RegExp.rightContext;break}}if(Z.length>1&&M.exec(Y)){if(Z.length===2&&I.relative[Z[0]]){af=J(Z[0]+Z[1],U)}else{af=I.relative[Z[0]]?[U]:F(Z.shift(),U);while(Z.length){Y=Z.shift();if(I.relative[Y]){Y+=Z.shift()}af=J(Y,af)}}}else{var ae=ac?{expr:Z.pop(),set:E(ac)}:F.find(Z.pop(),Z.length===1&&U.parentNode?U.parentNode:U,Q(U));af=F.filter(ae.expr,ae.set);if(Z.length>0){ai=E(af)}else{X=false}while(Z.length){var ah=Z.pop(),ag=ah;if(!I.relative[ah]){ah=""}else{ag=Z.pop()}if(ag==null){ag=U}I.relative[ah](ai,ag,Q(U))}}if(!ai){ai=af}if(!ai){throw"Syntax error, unrecognized expression: "+(ah||Y)}if(H.call(ai)==="[object Array]"){if(!X){ab.push.apply(ab,ai)}else{if(U.nodeType===1){for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&(ai[aa]===true||ai[aa].nodeType===1&&K(U,ai[aa]))){ab.push(af[aa])}}}else{for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&ai[aa].nodeType===1){ab.push(af[aa])}}}}}else{E(ai,ab)}if(V){F(V,U,ab,ac);if(G){hasDuplicate=false;ab.sort(G);if(hasDuplicate){for(var aa=1;aa<ab.length;aa++){if(ab[aa]===ab[aa-1]){ab.splice(aa--,1)}}}}}return ab};F.matches=function(T,U){return F(T,null,null,U)};F.find=function(aa,T,ab){var Z,X;if(!aa){return[]}for(var W=0,V=I.order.length;W<V;W++){var Y=I.order[W],X;if((X=I.match[Y].exec(aa))){var U=RegExp.leftContext;if(U.substr(U.length-1)!=="\\"){X[1]=(X[1]||"").replace(/\\/g,"");Z=I.find[Y](X,T,ab);if(Z!=null){aa=aa.replace(I.match[Y],"");break}}}}if(!Z){Z=T.getElementsByTagName("*")}return{set:Z,expr:aa}};F.filter=function(ad,ac,ag,W){var V=ad,ai=[],aa=ac,Y,T,Z=ac&&ac[0]&&Q(ac[0]);while(ad&&ac.length){for(var ab in I.filter){if((Y=I.match[ab].exec(ad))!=null){var U=I.filter[ab],ah,af;T=false;if(aa==ai){ai=[]}if(I.preFilter[ab]){Y=I.preFilter[ab](Y,aa,ag,ai,W,Z);if(!Y){T=ah=true}else{if(Y===true){continue}}}if(Y){for(var X=0;(af=aa[X])!=null;X++){if(af){ah=U(af,Y,X,aa);var ae=W^!!ah;if(ag&&ah!=null){if(ae){T=true}else{aa[X]=false}}else{if(ae){ai.push(af);T=true}}}}}if(ah!==g){if(!ag){aa=ai}ad=ad.replace(I.match[ab],"");if(!T){return[]}break}}}if(ad==V){if(T==null){throw"Syntax error, unrecognized expression: "+ad}else{break}}V=ad}return aa};var I=F.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(T){return T.getAttribute("href")}},relative:{"+":function(aa,T,Z){var X=typeof T==="string",ab=X&&!/\W/.test(T),Y=X&&!ab;if(ab&&!Z){T=T.toUpperCase()}for(var W=0,V=aa.length,U;W<V;W++){if((U=aa[W])){while((U=U.previousSibling)&&U.nodeType!==1){}aa[W]=Y||U&&U.nodeName===T?U||false:U===T}}if(Y){F.filter(T,aa,true)}},">":function(Z,U,aa){var X=typeof U==="string";if(X&&!/\W/.test(U)){U=aa?U:U.toUpperCase();for(var V=0,T=Z.length;V<T;V++){var Y=Z[V];if(Y){var W=Y.parentNode;Z[V]=W.nodeName===U?W:false}}}else{for(var V=0,T=Z.length;V<T;V++){var Y=Z[V];if(Y){Z[V]=X?Y.parentNode:Y.parentNode===U}}if(X){F.filter(U,Z,true)}}},"":function(W,U,Y){var V=L++,T=S;if(!U.match(/\W/)){var X=U=Y?U:U.toUpperCase();T=P}T("parentNode",U,V,W,X,Y)},"~":function(W,U,Y){var V=L++,T=S;if(typeof U==="string"&&!U.match(/\W/)){var X=U=Y?U:U.toUpperCase();T=P}T("previousSibling",U,V,W,X,Y)}},find:{ID:function(U,V,W){if(typeof V.getElementById!=="undefined"&&!W){var T=V.getElementById(U[1]);return T?[T]:[]}},NAME:function(V,Y,Z){if(typeof Y.getElementsByName!=="undefined"){var U=[],X=Y.getElementsByName(V[1]);for(var W=0,T=X.length;W<T;W++){if(X[W].getAttribute("name")===V[1]){U.push(X[W])}}return U.length===0?null:U}},TAG:function(T,U){return U.getElementsByTagName(T[1])}},preFilter:{CLASS:function(W,U,V,T,Z,aa){W=" "+W[1].replace(/\\/g,"")+" ";if(aa){return W}for(var X=0,Y;(Y=U[X])!=null;X++){if(Y){if(Z^(Y.className&&(" "+Y.className+" ").indexOf(W)>=0)){if(!V){T.push(Y)}}else{if(V){U[X]=false}}}}return false},ID:function(T){return T[1].replace(/\\/g,"")},TAG:function(U,T){for(var V=0;T[V]===false;V++){}return T[V]&&Q(T[V])?U[1]:U[1].toUpperCase()},CHILD:function(T){if(T[1]=="nth"){var U=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(T[2]=="even"&&"2n"||T[2]=="odd"&&"2n+1"||!/\D/.test(T[2])&&"0n+"+T[2]||T[2]);T[2]=(U[1]+(U[2]||1))-0;T[3]=U[3]-0}T[0]=L++;return T},ATTR:function(X,U,V,T,Y,Z){var W=X[1].replace(/\\/g,"");if(!Z&&I.attrMap[W]){X[1]=I.attrMap[W]}if(X[2]==="~="){X[4]=" "+X[4]+" "}return X},PSEUDO:function(X,U,V,T,Y){if(X[1]==="not"){if(X[3].match(R).length>1||/^\w/.test(X[3])){X[3]=F(X[3],null,null,U)}else{var W=F.filter(X[3],U,V,true^Y);if(!V){T.push.apply(T,W)}return false}}else{if(I.match.POS.test(X[0])||I.match.CHILD.test(X[0])){return true}}return X},POS:function(T){T.unshift(true);return T}},filters:{enabled:function(T){return T.disabled===false&&T.type!=="hidden"},disabled:function(T){return T.disabled===true},checked:function(T){return T.checked===true},selected:function(T){T.parentNode.selectedIndex;return T.selected===true},parent:function(T){return !!T.firstChild},empty:function(T){return !T.firstChild},has:function(V,U,T){return !!F(T[3],V).length},header:function(T){return/h\d/i.test(T.nodeName)},text:function(T){return"text"===T.type},radio:function(T){return"radio"===T.type},checkbox:function(T){return"checkbox"===T.type},file:function(T){return"file"===T.type},password:function(T){return"password"===T.type},submit:function(T){return"submit"===T.type},image:function(T){return"image"===T.type},reset:function(T){return"reset"===T.type},button:function(T){return"button"===T.type||T.nodeName.toUpperCase()==="BUTTON"},input:function(T){return/input|select|textarea|button/i.test(T.nodeName)}},setFilters:{first:function(U,T){return T===0},last:function(V,U,T,W){return U===W.length-1},even:function(U,T){return T%2===0},odd:function(U,T){return T%2===1},lt:function(V,U,T){return U<T[3]-0},gt:function(V,U,T){return U>T[3]-0},nth:function(V,U,T){return T[3]-0==U},eq:function(V,U,T){return T[3]-0==U}},filter:{PSEUDO:function(Z,V,W,aa){var U=V[1],X=I.filters[U];if(X){return X(Z,W,V,aa)}else{if(U==="contains"){return(Z.textContent||Z.innerText||"").indexOf(V[3])>=0}else{if(U==="not"){var Y=V[3];for(var W=0,T=Y.length;W<T;W++){if(Y[W]===Z){return false}}return true}}}},CHILD:function(T,W){var Z=W[1],U=T;switch(Z){case"only":case"first":while(U=U.previousSibling){if(U.nodeType===1){return false}}if(Z=="first"){return true}U=T;case"last":while(U=U.nextSibling){if(U.nodeType===1){return false}}return true;case"nth":var V=W[2],ac=W[3];if(V==1&&ac==0){return true}var Y=W[0],ab=T.parentNode;if(ab&&(ab.sizcache!==Y||!T.nodeIndex)){var X=0;for(U=ab.firstChild;U;U=U.nextSibling){if(U.nodeType===1){U.nodeIndex=++X}}ab.sizcache=Y}var aa=T.nodeIndex-ac;if(V==0){return aa==0}else{return(aa%V==0&&aa/V>=0)}}},ID:function(U,T){return U.nodeType===1&&U.getAttribute("id")===T},TAG:function(U,T){return(T==="*"&&U.nodeType===1)||U.nodeName===T},CLASS:function(U,T){return(" "+(U.className||U.getAttribute("class"))+" ").indexOf(T)>-1},ATTR:function(Y,W){var V=W[1],T=I.attrHandle[V]?I.attrHandle[V](Y):Y[V]!=null?Y[V]:Y.getAttribute(V),Z=T+"",X=W[2],U=W[4];return T==null?X==="!=":X==="="?Z===U:X==="*="?Z.indexOf(U)>=0:X==="~="?(" "+Z+" ").indexOf(U)>=0:!U?Z&&T!==false:X==="!="?Z!=U:X==="^="?Z.indexOf(U)===0:X==="$="?Z.substr(Z.length-U.length)===U:X==="|="?Z===U||Z.substr(0,U.length+1)===U+"-":false},POS:function(X,U,V,Y){var T=U[2],W=I.setFilters[T];if(W){return W(X,V,U,Y)}}}};var M=I.match.POS;for(var O in I.match){I.match[O]=RegExp(I.match[O].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var E=function(U,T){U=Array.prototype.slice.call(U);if(T){T.push.apply(T,U);return T}return U};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(N){E=function(X,W){var U=W||[];if(H.call(X)==="[object Array]"){Array.prototype.push.apply(U,X)}else{if(typeof X.length==="number"){for(var V=0,T=X.length;V<T;V++){U.push(X[V])}}else{for(var V=0;X[V];V++){U.push(X[V])}}}return U}}var G;if(document.documentElement.compareDocumentPosition){G=function(U,T){var V=U.compareDocumentPosition(T)&4?-1:U===T?0:1;if(V===0){hasDuplicate=true}return V}}else{if("sourceIndex" in document.documentElement){G=function(U,T){var V=U.sourceIndex-T.sourceIndex;if(V===0){hasDuplicate=true}return V}}else{if(document.createRange){G=function(W,U){var V=W.ownerDocument.createRange(),T=U.ownerDocument.createRange();V.selectNode(W);V.collapse(true);T.selectNode(U);T.collapse(true);var X=V.compareBoundaryPoints(Range.START_TO_END,T);if(X===0){hasDuplicate=true}return X}}}}(function(){var U=document.createElement("form"),V="script"+(new Date).getTime();U.innerHTML="<input name='"+V+"'/>";var T=document.documentElement;T.insertBefore(U,T.firstChild);if(!!document.getElementById(V)){I.find.ID=function(X,Y,Z){if(typeof Y.getElementById!=="undefined"&&!Z){var W=Y.getElementById(X[1]);return W?W.id===X[1]||typeof W.getAttributeNode!=="undefined"&&W.getAttributeNode("id").nodeValue===X[1]?[W]:g:[]}};I.filter.ID=function(Y,W){var X=typeof Y.getAttributeNode!=="undefined"&&Y.getAttributeNode("id");return Y.nodeType===1&&X&&X.nodeValue===W}}T.removeChild(U)})();(function(){var T=document.createElement("div");T.appendChild(document.createComment(""));if(T.getElementsByTagName("*").length>0){I.find.TAG=function(U,Y){var X=Y.getElementsByTagName(U[1]);if(U[1]==="*"){var W=[];for(var V=0;X[V];V++){if(X[V].nodeType===1){W.push(X[V])}}X=W}return X}}T.innerHTML="<a href='#'></a>";if(T.firstChild&&typeof T.firstChild.getAttribute!=="undefined"&&T.firstChild.getAttribute("href")!=="#"){I.attrHandle.href=function(U){return U.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var T=F,U=document.createElement("div");U.innerHTML="<p class='TEST'></p>";if(U.querySelectorAll&&U.querySelectorAll(".TEST").length===0){return}F=function(Y,X,V,W){X=X||document;if(!W&&X.nodeType===9&&!Q(X)){try{return E(X.querySelectorAll(Y),V)}catch(Z){}}return T(Y,X,V,W)};F.find=T.find;F.filter=T.filter;F.selectors=T.selectors;F.matches=T.matches})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var T=document.createElement("div");T.innerHTML="<div class='test e'></div><div class='test'></div>";if(T.getElementsByClassName("e").length===0){return}T.lastChild.className="e";if(T.getElementsByClassName("e").length===1){return}I.order.splice(1,0,"CLASS");I.find.CLASS=function(U,V,W){if(typeof V.getElementsByClassName!=="undefined"&&!W){return V.getElementsByClassName(U[1])}}})()}function P(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W<V;W++){var T=ad[W];if(T){if(ab&&T.nodeType===1){T.sizcache=Y;T.sizset=W}T=T[U];var X=false;while(T){if(T.sizcache===Y){X=ad[T.sizset];break}if(T.nodeType===1&&!ac){T.sizcache=Y;T.sizset=W}if(T.nodeName===Z){X=T;break}T=T[U]}ad[W]=X}}}function S(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W<V;W++){var T=ad[W];if(T){if(ab&&T.nodeType===1){T.sizcache=Y;T.sizset=W}T=T[U];var X=false;while(T){if(T.sizcache===Y){X=ad[T.sizset];break}if(T.nodeType===1){if(!ac){T.sizcache=Y;T.sizset=W}if(typeof Z!=="string"){if(T===Z){X=true;break}}else{if(F.filter(Z,[T]).length>0){X=T;break}}}T=T[U]}ad[W]=X}}}var K=document.compareDocumentPosition?function(U,T){return U.compareDocumentPosition(T)&16}:function(U,T){return U!==T&&(U.contains?U.contains(T):true)};var Q=function(T){return T.nodeType===9&&T.documentElement.nodeName!=="HTML"||!!T.ownerDocument&&Q(T.ownerDocument)};var J=function(T,aa){var W=[],X="",Y,V=aa.nodeType?[aa]:aa;while((Y=I.match.PSEUDO.exec(T))){X+=Y[0];T=T.replace(I.match.PSEUDO,"")}T=I.relative[T]?T+"*":T;for(var Z=0,U=V.length;Z<U;Z++){F(T,V[Z],W)}return F.filter(X,W)};o.find=F;o.filter=F.filter;o.expr=F.selectors;o.expr[":"]=o.expr.filters;F.selectors.filters.hidden=function(T){return T.offsetWidth===0||T.offsetHeight===0};F.selectors.filters.visible=function(T){return T.offsetWidth>0||T.offsetHeight>0};F.selectors.filters.animated=function(T){return o.grep(o.timers,function(U){return T===U.elem}).length};o.multiFilter=function(V,T,U){if(U){V=":not("+V+")"}return F.matches(V,T)};o.dir=function(V,U){var T=[],W=V[U];while(W&&W!=document){if(W.nodeType==1){T.push(W)}W=W[U]}return T};o.nth=function(X,T,V,W){T=T||1;var U=0;for(;X;X=X[V]){if(X.nodeType==1&&++U==T){break}}return X};o.sibling=function(V,U){var T=[];for(;V;V=V.nextSibling){if(V.nodeType==1&&V!=U){T.push(V)}}return T};return;l.Sizzle=F})();o.event={add:function(I,F,H,K){if(I.nodeType==3||I.nodeType==8){return}if(I.setInterval&&I!=l){I=l}if(!H.guid){H.guid=this.guid++}if(K!==g){var G=H;H=this.proxy(G);H.data=K}var E=o.data(I,"events")||o.data(I,"events",{}),J=o.data(I,"handle")||o.data(I,"handle",function(){return typeof o!=="undefined"&&!o.event.triggered?o.event.handle.apply(arguments.callee.elem,arguments):g});J.elem=I;o.each(F.split(/\s+/),function(M,N){var O=N.split(".");N=O.shift();H.type=O.slice().sort().join(".");var L=E[N];if(o.event.specialAll[N]){o.event.specialAll[N].setup.call(I,K,O)}if(!L){L=E[N]={};if(!o.event.special[N]||o.event.special[N].setup.call(I,K,O)===false){if(I.addEventListener){I.addEventListener(N,J,false)}else{if(I.attachEvent){I.attachEvent("on"+N,J)}}}}L[H.guid]=H;o.event.global[N]=true});I=null},guid:1,global:{},remove:function(K,H,J){if(K.nodeType==3||K.nodeType==8){return}var G=o.data(K,"events"),F,E;if(G){if(H===g||(typeof H==="string"&&H.charAt(0)==".")){for(var I in G){this.remove(K,I+(H||""))}}else{if(H.type){J=H.handler;H=H.type}o.each(H.split(/\s+/),function(M,O){var Q=O.split(".");O=Q.shift();var N=RegExp("(^|\\.)"+Q.slice().sort().join(".*\\.")+"(\\.|$)");if(G[O]){if(J){delete G[O][J.guid]}else{for(var P in G[O]){if(N.test(G[O][P].type)){delete G[O][P]}}}if(o.event.specialAll[O]){o.event.specialAll[O].teardown.call(K,Q)}for(F in G[O]){break}if(!F){if(!o.event.special[O]||o.event.special[O].teardown.call(K,Q)===false){if(K.removeEventListener){K.removeEventListener(O,o.data(K,"handle"),false)}else{if(K.detachEvent){K.detachEvent("on"+O,o.data(K,"handle"))}}}F=null;delete G[O]}}})}for(F in G){break}if(!F){var L=o.data(K,"handle");if(L){L.elem=null}o.removeData(K,"events");o.removeData(K,"handle")}}},trigger:function(I,K,H,E){var G=I.type||I;if(!E){I=typeof I==="object"?I[h]?I:o.extend(o.Event(G),I):o.Event(G);if(G.indexOf("!")>=0){I.type=G=G.slice(0,-1);I.exclusive=true}if(!H){I.stopPropagation();if(this.global[G]){o.each(o.cache,function(){if(this.events&&this.events[G]){o.event.trigger(I,K,this.handle.elem)}})}}if(!H||H.nodeType==3||H.nodeType==8){return g}I.result=g;I.target=H;K=o.makeArray(K);K.unshift(I)}I.currentTarget=H;var J=o.data(H,"handle");if(J){J.apply(H,K)}if((!H[G]||(o.nodeName(H,"a")&&G=="click"))&&H["on"+G]&&H["on"+G].apply(H,K)===false){I.result=false}if(!E&&H[G]&&!I.isDefaultPrevented()&&!(o.nodeName(H,"a")&&G=="click")){this.triggered=true;try{H[G]()}catch(L){}}this.triggered=false;if(!I.isPropagationStopped()){var F=H.parentNode||H.ownerDocument;if(F){o.event.trigger(I,K,F,true)}}},handle:function(K){var J,E;K=arguments[0]=o.event.fix(K||l.event);K.currentTarget=this;var L=K.type.split(".");K.type=L.shift();J=!L.length&&!K.exclusive;var I=RegExp("(^|\\.)"+L.slice().sort().join(".*\\.")+"(\\.|$)");E=(o.data(this,"events")||{})[K.type];for(var G in E){var H=E[G];if(J||I.test(H.type)){K.handler=H;K.data=H.data;var F=H.apply(this,arguments);if(F!==g){K.result=F;if(F===false){K.preventDefault();K.stopPropagation()}}if(K.isImmediatePropagationStopped()){break}}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(H){if(H[h]){return H}var F=H;H=o.Event(F);for(var G=this.props.length,J;G;){J=this.props[--G];H[J]=F[J]}if(!H.target){H.target=H.srcElement||document}if(H.target.nodeType==3){H.target=H.target.parentNode}if(!H.relatedTarget&&H.fromElement){H.relatedTarget=H.fromElement==H.target?H.toElement:H.fromElement}if(H.pageX==null&&H.clientX!=null){var I=document.documentElement,E=document.body;H.pageX=H.clientX+(I&&I.scrollLeft||E&&E.scrollLeft||0)-(I.clientLeft||0);H.pageY=H.clientY+(I&&I.scrollTop||E&&E.scrollTop||0)-(I.clientTop||0)}if(!H.which&&((H.charCode||H.charCode===0)?H.charCode:H.keyCode)){H.which=H.charCode||H.keyCode}if(!H.metaKey&&H.ctrlKey){H.metaKey=H.ctrlKey}if(!H.which&&H.button){H.which=(H.button&1?1:(H.button&2?3:(H.button&4?2:0)))}return H},proxy:function(F,E){E=E||function(){return F.apply(this,arguments)};E.guid=F.guid=F.guid||E.guid||this.guid++;return E},special:{ready:{setup:B,teardown:function(){}}},specialAll:{live:{setup:function(E,F){o.event.add(this,F[0],c)},teardown:function(G){if(G.length){var E=0,F=RegExp("(^|\\.)"+G[0]+"(\\.|$)");o.each((o.data(this,"events").live||{}),function(){if(F.test(this.type)){E++}});if(E<1){o.event.remove(this,G[0],c)}}}}}};o.Event=function(E){if(!this.preventDefault){return new o.Event(E)}if(E&&E.type){this.originalEvent=E;this.type=E.type}else{this.type=E}this.timeStamp=e();this[h]=true};function k(){return false}function u(){return true}o.Event.prototype={preventDefault:function(){this.isDefaultPrevented=u;var E=this.originalEvent;if(!E){return}if(E.preventDefault){E.preventDefault()}E.returnValue=false},stopPropagation:function(){this.isPropagationStopped=u;var E=this.originalEvent;if(!E){return}if(E.stopPropagation){E.stopPropagation()}E.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=u;this.stopPropagation()},isDefaultPrevented:k,isPropagationStopped:k,isImmediatePropagationStopped:k};var a=function(F){var E=F.relatedTarget;while(E&&E!=this){try{E=E.parentNode}catch(G){E=this}}if(E!=this){F.type=F.data;o.event.handle.apply(this,arguments)}};o.each({mouseover:"mouseenter",mouseout:"mouseleave"},function(F,E){o.event.special[E]={setup:function(){o.event.add(this,F,a,E)},teardown:function(){o.event.remove(this,F,a)}}});o.fn.extend({bind:function(F,G,E){return F=="unload"?this.one(F,G,E):this.each(function(){o.event.add(this,F,E||G,E&&G)})},one:function(G,H,F){var E=o.event.proxy(F||H,function(I){o(this).unbind(I,E);return(F||H).apply(this,arguments)});return this.each(function(){o.event.add(this,G,E,F&&H)})},unbind:function(F,E){return this.each(function(){o.event.remove(this,F,E)})},trigger:function(E,F){return this.each(function(){o.event.trigger(E,F,this)})},triggerHandler:function(E,G){if(this[0]){var F=o.Event(E);F.preventDefault();F.stopPropagation();o.event.trigger(F,G,this[0]);return F.result}},toggle:function(G){var E=arguments,F=1;while(F<E.length){o.event.proxy(G,E[F++])}return this.click(o.event.proxy(G,function(H){this.lastToggle=(this.lastToggle||0)%F;H.preventDefault();return E[this.lastToggle++].apply(this,arguments)||false}))},hover:function(E,F){return this.mouseenter(E).mouseleave(F)},ready:function(E){B();if(o.isReady){E.call(document,o)}else{o.readyList.push(E)}return this},live:function(G,F){var E=o.event.proxy(F);E.guid+=this.selector+G;o(document).bind(i(G,this.selector),this.selector,E);return this},die:function(F,E){o(document).unbind(i(F,this.selector),E?{guid:E.guid+this.selector+F}:null);return this}});function c(H){var E=RegExp("(^|\\.)"+H.type+"(\\.|$)"),G=true,F=[];o.each(o.data(this,"events").live||[],function(I,J){if(E.test(J.type)){var K=o(H.target).closest(J.data)[0];if(K){F.push({elem:K,fn:J})}}});F.sort(function(J,I){return o.data(J.elem,"closest")-o.data(I.elem,"closest")});o.each(F,function(){if(this.fn.call(this.elem,H,this.fn.data)===false){return(G=false)}});return G}function i(F,E){return["live",F,E.replace(/\./g,"`").replace(/ /g,"|")].join(".")}o.extend({isReady:false,readyList:[],ready:function(){if(!o.isReady){o.isReady=true;if(o.readyList){o.each(o.readyList,function(){this.call(document,o)});o.readyList=null}o(document).triggerHandler("ready")}}});var x=false;function B(){if(x){return}x=true;if(document.addEventListener){document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,false);o.ready()},false)}else{if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);o.ready()}});if(document.documentElement.doScroll&&l==l.top){(function(){if(o.isReady){return}try{document.documentElement.doScroll("left")}catch(E){setTimeout(arguments.callee,0);return}o.ready()})()}}}o.event.add(l,"load",o.ready)}o.each(("blur,focus,load,resize,scroll,unload,click,dblclick,mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave,change,select,submit,keydown,keypress,keyup,error").split(","),function(F,E){o.fn[E]=function(G){return G?this.bind(E,G):this.trigger(E)}});o(l).bind("unload",function(){for(var E in o.cache){if(E!=1&&o.cache[E].handle){o.event.remove(o.cache[E].handle.elem)}}});(function(){o.support={};var F=document.documentElement,G=document.createElement("script"),K=document.createElement("div"),J="script"+(new Date).getTime();K.style.display="none";K.innerHTML=' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>';var H=K.getElementsByTagName("*"),E=K.getElementsByTagName("a")[0];if(!H||!H.length||!E){return}o.support={leadingWhitespace:K.firstChild.nodeType==3,tbody:!K.getElementsByTagName("tbody").length,objectAll:!!K.getElementsByTagName("object")[0].getElementsByTagName("*").length,htmlSerialize:!!K.getElementsByTagName("link").length,style:/red/.test(E.getAttribute("style")),hrefNormalized:E.getAttribute("href")==="/a",opacity:E.style.opacity==="0.5",cssFloat:!!E.style.cssFloat,scriptEval:false,noCloneEvent:true,boxModel:null};G.type="text/javascript";try{G.appendChild(document.createTextNode("window."+J+"=1;"))}catch(I){}F.insertBefore(G,F.firstChild);if(l[J]){o.support.scriptEval=true;delete l[J]}F.removeChild(G);if(K.attachEvent&&K.fireEvent){K.attachEvent("onclick",function(){o.support.noCloneEvent=false;K.detachEvent("onclick",arguments.callee)});K.cloneNode(true).fireEvent("onclick")}o(function(){var L=document.createElement("div");L.style.width=L.style.paddingLeft="1px";document.body.appendChild(L);o.boxModel=o.support.boxModel=L.offsetWidth===2;document.body.removeChild(L).style.display="none"})})();var w=o.support.cssFloat?"cssFloat":"styleFloat";o.props={"for":"htmlFor","class":"className","float":w,cssFloat:w,styleFloat:w,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",tabindex:"tabIndex"};o.fn.extend({_load:o.fn.load,load:function(G,J,K){if(typeof G!=="string"){return this._load(G)}var I=G.indexOf(" ");if(I>=0){var E=G.slice(I,G.length);G=G.slice(0,I)}var H="GET";if(J){if(o.isFunction(J)){K=J;J=null}else{if(typeof J==="object"){J=o.param(J);H="POST"}}}var F=this;o.ajax({url:G,type:H,dataType:"html",data:J,complete:function(M,L){if(L=="success"||L=="notmodified"){F.html(E?o("<div/>").append(M.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(E):M.responseText)}if(K){F.each(K,[M.responseText,L,M])}}});return this},serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?o.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password|search/i.test(this.type))}).map(function(E,F){var G=o(this).val();return G==null?null:o.isArray(G)?o.map(G,function(I,H){return{name:F.name,value:I}}):{name:F.name,value:G}}).get()}});o.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(E,F){o.fn[F]=function(G){return this.bind(F,G)}});var r=e();o.extend({get:function(E,G,H,F){if(o.isFunction(G)){H=G;G=null}return o.ajax({type:"GET",url:E,data:G,success:H,dataType:F})},getScript:function(E,F){return o.get(E,null,F,"script")},getJSON:function(E,F,G){return o.get(E,F,G,"json")},post:function(E,G,H,F){if(o.isFunction(G)){H=G;G={}}return o.ajax({type:"POST",url:E,data:G,success:H,dataType:F})},ajaxSetup:function(E){o.extend(o.ajaxSettings,E)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return l.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest()},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(M){M=o.extend(true,M,o.extend(true,{},o.ajaxSettings,M));var W,F=/=\?(&|$)/g,R,V,G=M.type.toUpperCase();if(M.data&&M.processData&&typeof M.data!=="string"){M.data=o.param(M.data)}if(M.dataType=="jsonp"){if(G=="GET"){if(!M.url.match(F)){M.url+=(M.url.match(/\?/)?"&":"?")+(M.jsonp||"callback")+"=?"}}else{if(!M.data||!M.data.match(F)){M.data=(M.data?M.data+"&":"")+(M.jsonp||"callback")+"=?"}}M.dataType="json"}if(M.dataType=="json"&&(M.data&&M.data.match(F)||M.url.match(F))){W="jsonp"+r++;if(M.data){M.data=(M.data+"").replace(F,"="+W+"$1")}M.url=M.url.replace(F,"="+W+"$1");M.dataType="script";l[W]=function(X){V=X;I();L();l[W]=g;try{delete l[W]}catch(Y){}if(H){H.removeChild(T)}}}if(M.dataType=="script"&&M.cache==null){M.cache=false}if(M.cache===false&&G=="GET"){var E=e();var U=M.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+E+"$2");M.url=U+((U==M.url)?(M.url.match(/\?/)?"&":"?")+"_="+E:"")}if(M.data&&G=="GET"){M.url+=(M.url.match(/\?/)?"&":"?")+M.data;M.data=null}if(M.global&&!o.active++){o.event.trigger("ajaxStart")}var Q=/^(\w+:)?\/\/([^\/?#]+)/.exec(M.url);if(M.dataType=="script"&&G=="GET"&&Q&&(Q[1]&&Q[1]!=location.protocol||Q[2]!=location.host)){var H=document.getElementsByTagName("head")[0];var T=document.createElement("script");T.src=M.url;if(M.scriptCharset){T.charset=M.scriptCharset}if(!W){var O=false;T.onload=T.onreadystatechange=function(){if(!O&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){O=true;I();L();T.onload=T.onreadystatechange=null;H.removeChild(T)}}}H.appendChild(T);return g}var K=false;var J=M.xhr();if(M.username){J.open(G,M.url,M.async,M.username,M.password)}else{J.open(G,M.url,M.async)}try{if(M.data){J.setRequestHeader("Content-Type",M.contentType)}if(M.ifModified){J.setRequestHeader("If-Modified-Since",o.lastModified[M.url]||"Thu, 01 Jan 1970 00:00:00 GMT")}J.setRequestHeader("X-Requested-With","XMLHttpRequest");J.setRequestHeader("Accept",M.dataType&&M.accepts[M.dataType]?M.accepts[M.dataType]+", */*":M.accepts._default)}catch(S){}if(M.beforeSend&&M.beforeSend(J,M)===false){if(M.global&&!--o.active){o.event.trigger("ajaxStop")}J.abort();return false}if(M.global){o.event.trigger("ajaxSend",[J,M])}var N=function(X){if(J.readyState==0){if(P){clearInterval(P);P=null;if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}}else{if(!K&&J&&(J.readyState==4||X=="timeout")){K=true;if(P){clearInterval(P);P=null}R=X=="timeout"?"timeout":!o.httpSuccess(J)?"error":M.ifModified&&o.httpNotModified(J,M.url)?"notmodified":"success";if(R=="success"){try{V=o.httpData(J,M.dataType,M)}catch(Z){R="parsererror"}}if(R=="success"){var Y;try{Y=J.getResponseHeader("Last-Modified")}catch(Z){}if(M.ifModified&&Y){o.lastModified[M.url]=Y}if(!W){I()}}else{o.handleError(M,J,R)}L();if(X){J.abort()}if(M.async){J=null}}}};if(M.async){var P=setInterval(N,13);if(M.timeout>0){setTimeout(function(){if(J&&!K){N("timeout")}},M.timeout)}}try{J.send(M.data)}catch(S){o.handleError(M,J,null,S)}if(!M.async){N()}function I(){if(M.success){M.success(V,R)}if(M.global){o.event.trigger("ajaxSuccess",[J,M])}}function L(){if(M.complete){M.complete(J,R)}if(M.global){o.event.trigger("ajaxComplete",[J,M])}if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}return J},handleError:function(F,H,E,G){if(F.error){F.error(H,E,G)}if(F.global){o.event.trigger("ajaxError",[H,F,G])}},active:0,httpSuccess:function(F){try{return !F.status&&location.protocol=="file:"||(F.status>=200&&F.status<300)||F.status==304||F.status==1223}catch(E){}return false},httpNotModified:function(G,E){try{var H=G.getResponseHeader("Last-Modified");return G.status==304||H==o.lastModified[E]}catch(F){}return false},httpData:function(J,H,G){var F=J.getResponseHeader("content-type"),E=H=="xml"||!H&&F&&F.indexOf("xml")>=0,I=E?J.responseXML:J.responseText;if(E&&I.documentElement.tagName=="parsererror"){throw"parsererror"}if(G&&G.dataFilter){I=G.dataFilter(I,H)}if(typeof I==="string"){if(H=="script"){o.globalEval(I)}if(H=="json"){I=l["eval"]("("+I+")")}}return I},param:function(E){var G=[];function H(I,J){G[G.length]=encodeURIComponent(I)+"="+encodeURIComponent(J)}if(o.isArray(E)||E.jquery){o.each(E,function(){H(this.name,this.value)})}else{for(var F in E){if(o.isArray(E[F])){o.each(E[F],function(){H(F,this)})}else{H(F,o.isFunction(E[F])?E[F]():E[F])}}}return G.join("&").replace(/%20/g,"+")}});var m={},n,d=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];function t(F,E){var G={};o.each(d.concat.apply([],d.slice(0,E)),function(){G[this]=F});return G}o.fn.extend({show:function(J,L){if(J){return this.animate(t("show",3),J,L)}else{for(var H=0,F=this.length;H<F;H++){var E=o.data(this[H],"olddisplay");this[H].style.display=E||"";if(o.css(this[H],"display")==="none"){var G=this[H].tagName,K;if(m[G]){K=m[G]}else{var I=o("<"+G+" />").appendTo("body");K=I.css("display");if(K==="none"){K="block"}I.remove();m[G]=K}o.data(this[H],"olddisplay",K)}}for(var H=0,F=this.length;H<F;H++){this[H].style.display=o.data(this[H],"olddisplay")||""}return this}},hide:function(H,I){if(H){return this.animate(t("hide",3),H,I)}else{for(var G=0,F=this.length;G<F;G++){var E=o.data(this[G],"olddisplay");if(!E&&E!=="none"){o.data(this[G],"olddisplay",o.css(this[G],"display"))}}for(var G=0,F=this.length;G<F;G++){this[G].style.display="none"}return this}},_toggle:o.fn.toggle,toggle:function(G,F){var E=typeof G==="boolean";return o.isFunction(G)&&o.isFunction(F)?this._toggle.apply(this,arguments):G==null||E?this.each(function(){var H=E?G:o(this).is(":hidden");o(this)[H?"show":"hide"]()}):this.animate(t("toggle",3),G,F)},fadeTo:function(E,G,F){return this.animate({opacity:G},E,F)},animate:function(I,F,H,G){var E=o.speed(F,H,G);return this[E.queue===false?"each":"queue"](function(){var K=o.extend({},E),M,L=this.nodeType==1&&o(this).is(":hidden"),J=this;for(M in I){if(I[M]=="hide"&&L||I[M]=="show"&&!L){return K.complete.call(this)}if((M=="height"||M=="width")&&this.style){K.display=o.css(this,"display");K.overflow=this.style.overflow}}if(K.overflow!=null){this.style.overflow="hidden"}K.curAnim=o.extend({},I);o.each(I,function(O,S){var R=new o.fx(J,K,O);if(/toggle|show|hide/.test(S)){R[S=="toggle"?L?"show":"hide":S](I)}else{var Q=S.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),T=R.cur(true)||0;if(Q){var N=parseFloat(Q[2]),P=Q[3]||"px";if(P!="px"){J.style[O]=(N||1)+P;T=((N||1)/R.cur(true))*T;J.style[O]=T+P}if(Q[1]){N=((Q[1]=="-="?-1:1)*N)+T}R.custom(T,N,P)}else{R.custom(T,S,"")}}});return true})},stop:function(F,E){var G=o.timers;if(F){this.queue([])}this.each(function(){for(var H=G.length-1;H>=0;H--){if(G[H].elem==this){if(E){G[H](true)}G.splice(H,1)}}});if(!E){this.dequeue()}return this}});o.each({slideDown:t("show",1),slideUp:t("hide",1),slideToggle:t("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(E,F){o.fn[E]=function(G,H){return this.animate(F,G,H)}});o.extend({speed:function(G,H,F){var E=typeof G==="object"?G:{complete:F||!F&&H||o.isFunction(G)&&G,duration:G,easing:F&&H||H&&!o.isFunction(H)&&H};E.duration=o.fx.off?0:typeof E.duration==="number"?E.duration:o.fx.speeds[E.duration]||o.fx.speeds._default;E.old=E.complete;E.complete=function(){if(E.queue!==false){o(this).dequeue()}if(o.isFunction(E.old)){E.old.call(this)}};return E},easing:{linear:function(G,H,E,F){return E+F*G},swing:function(G,H,E,F){return((-Math.cos(G*Math.PI)/2)+0.5)*F+E}},timers:[],fx:function(F,E,G){this.options=E;this.elem=F;this.prop=G;if(!E.orig){E.orig={}}}});o.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(o.fx.step[this.prop]||o.fx.step._default)(this);if((this.prop=="height"||this.prop=="width")&&this.elem.style){this.elem.style.display="block"}},cur:function(F){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var E=parseFloat(o.css(this.elem,this.prop,F));return E&&E>-10000?E:parseFloat(o.curCSS(this.elem,this.prop))||0},custom:function(I,H,G){this.startTime=e();this.start=I;this.end=H;this.unit=G||this.unit||"px";this.now=this.start;this.pos=this.state=0;var E=this;function F(J){return E.step(J)}F.elem=this.elem;if(F()&&o.timers.push(F)&&!n){n=setInterval(function(){var K=o.timers;for(var J=0;J<K.length;J++){if(!K[J]()){K.splice(J--,1)}}if(!K.length){clearInterval(n);n=g}},13)}},show:function(){this.options.orig[this.prop]=o.attr(this.elem.style,this.prop);this.options.show=true;this.custom(this.prop=="width"||this.prop=="height"?1:0,this.cur());o(this.elem).show()},hide:function(){this.options.orig[this.prop]=o.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(H){var G=e();if(H||G>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var E=true;for(var F in this.options.curAnim){if(this.options.curAnim[F]!==true){E=false}}if(E){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(o.css(this.elem,"display")=="none"){this.elem.style.display="block"}}if(this.options.hide){o(this.elem).hide()}if(this.options.hide||this.options.show){for(var I in this.options.curAnim){o.attr(this.elem.style,I,this.options.orig[I])}}this.options.complete.call(this.elem)}return false}else{var J=G-this.startTime;this.state=J/this.options.duration;this.pos=o.easing[this.options.easing||(o.easing.swing?"swing":"linear")](this.state,J,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};o.extend(o.fx,{speeds:{slow:600,fast:200,_default:400},step:{opacity:function(E){o.attr(E.elem.style,"opacity",E.now)},_default:function(E){if(E.elem.style&&E.elem.style[E.prop]!=null){E.elem.style[E.prop]=E.now+E.unit}else{E.elem[E.prop]=E.now}}}});if(document.documentElement.getBoundingClientRect){o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}var G=this[0].getBoundingClientRect(),J=this[0].ownerDocument,F=J.body,E=J.documentElement,L=E.clientTop||F.clientTop||0,K=E.clientLeft||F.clientLeft||0,I=G.top+(self.pageYOffset||o.boxModel&&E.scrollTop||F.scrollTop)-L,H=G.left+(self.pageXOffset||o.boxModel&&E.scrollLeft||F.scrollLeft)-K;return{top:I,left:H}}}else{o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}o.offset.initialized||o.offset.initialize();var J=this[0],G=J.offsetParent,F=J,O=J.ownerDocument,M,H=O.documentElement,K=O.body,L=O.defaultView,E=L.getComputedStyle(J,null),N=J.offsetTop,I=J.offsetLeft;while((J=J.parentNode)&&J!==K&&J!==H){M=L.getComputedStyle(J,null);N-=J.scrollTop,I-=J.scrollLeft;if(J===G){N+=J.offsetTop,I+=J.offsetLeft;if(o.offset.doesNotAddBorder&&!(o.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(J.tagName))){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}F=G,G=J.offsetParent}if(o.offset.subtractsBorderForOverflowNotVisible&&M.overflow!=="visible"){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}E=M}if(E.position==="relative"||E.position==="static"){N+=K.offsetTop,I+=K.offsetLeft}if(E.position==="fixed"){N+=Math.max(H.scrollTop,K.scrollTop),I+=Math.max(H.scrollLeft,K.scrollLeft)}return{top:N,left:I}}}o.offset={initialize:function(){if(this.initialized){return}var L=document.body,F=document.createElement("div"),H,G,N,I,M,E,J=L.style.marginTop,K='<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>';M={position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"};for(E in M){F.style[E]=M[E]}F.innerHTML=K;L.insertBefore(F,L.firstChild);H=F.firstChild,G=H.firstChild,I=H.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(G.offsetTop!==5);this.doesAddBorderForTableAndCells=(I.offsetTop===5);H.style.overflow="hidden",H.style.position="relative";this.subtractsBorderForOverflowNotVisible=(G.offsetTop===-5);L.style.marginTop="1px";this.doesNotIncludeMarginInBodyOffset=(L.offsetTop===0);L.style.marginTop=J;L.removeChild(F);this.initialized=true},bodyOffset:function(E){o.offset.initialized||o.offset.initialize();var G=E.offsetTop,F=E.offsetLeft;if(o.offset.doesNotIncludeMarginInBodyOffset){G+=parseInt(o.curCSS(E,"marginTop",true),10)||0,F+=parseInt(o.curCSS(E,"marginLeft",true),10)||0}return{top:G,left:F}}};o.fn.extend({position:function(){var I=0,H=0,F;if(this[0]){var G=this.offsetParent(),J=this.offset(),E=/^body|html$/i.test(G[0].tagName)?{top:0,left:0}:G.offset();J.top-=j(this,"marginTop");J.left-=j(this,"marginLeft");E.top+=j(G,"borderTopWidth");E.left+=j(G,"borderLeftWidth");F={top:J.top-E.top,left:J.left-E.left}}return F},offsetParent:function(){var E=this[0].offsetParent||document.body;while(E&&(!/^body|html$/i.test(E.tagName)&&o.css(E,"position")=="static")){E=E.offsetParent}return o(E)}});o.each(["Left","Top"],function(F,E){var G="scroll"+E;o.fn[G]=function(H){if(!this[0]){return null}return H!==g?this.each(function(){this==l||this==document?l.scrollTo(!F?H:o(l).scrollLeft(),F?H:o(l).scrollTop()):this[G]=H}):this[0]==l||this[0]==document?self[F?"pageYOffset":"pageXOffset"]||o.boxModel&&document.documentElement[G]||document.body[G]:this[0][G]}});o.each(["Height","Width"],function(I,G){var E=I?"Left":"Top",H=I?"Right":"Bottom",F=G.toLowerCase();o.fn["inner"+G]=function(){return this[0]?o.css(this[0],F,false,"padding"):null};o.fn["outer"+G]=function(K){return this[0]?o.css(this[0],F,false,K?"margin":"border"):null};var J=G.toLowerCase();o.fn[J]=function(K){return this[0]==l?document.compatMode=="CSS1Compat"&&document.documentElement["client"+G]||document.body["client"+G]:this[0]==document?Math.max(document.documentElement["client"+G],document.body["scroll"+G],document.documentElement["scroll"+G],document.body["offset"+G],document.documentElement["offset"+G]):K===g?(this.length?o.css(this[0],J):null):this.css(J,typeof K==="string"?K:K+"px")}})})();
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* .disableTextSelect - Disable Text Select Plugin
*
* Version: 1.1
* Updated: 2007-11-28
*
* Used to stop users from selecting text
*
* Copyright (c) 2007 James Dempster (letssurf@gmail.com, http://www.jdempster.com/category/jquery/disabletextselect/)
*
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
**/
/**
* Requirements:
* - jQuery (John Resig, http://www.jquery.com/)
**/
(function($) {
if ($.browser.mozilla) {
$.fn.disableTextSelect = function() {
return this.each(function() {
$(this).css({
'MozUserSelect' : 'none'
});
});
};
$.fn.enableTextSelect = function() {
return this.each(function() {
$(this).css({
'MozUserSelect' : ''
});
});
};
} else if ($.browser.msie) {
$.fn.disableTextSelect = function() {
return this.each(function() {
$(this).bind('selectstart.disableTextSelect', function() {
return false;
});
});
};
$.fn.enableTextSelect = function() {
return this.each(function() {
$(this).unbind('selectstart.disableTextSelect');
});
};
} else {
$.fn.disableTextSelect = function() {
return this.each(function() {
$(this).bind('mousedown.disableTextSelect', function() {
return false;
});
});
};
$.fn.enableTextSelect = function() {
return this.each(function() {
$(this).unbind('mousedown.disableTextSelect');
});
};
}
})(jQuery);
\ No newline at end of file
/*
* jQuery EasIng v1.1.2 - http://gsgd.co.uk/sandbox/jquery.easIng.php
*
* Uses the built In easIng capabilities added In jQuery 1.1
* to offer multiple easIng options
*
* Copyright (c) 2007 George Smith
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*/
// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.extend( jQuery.easing,
{
easeInQuad: function (x, t, b, c, d) {
return c*(t/=d)*t + b;
},
easeOutQuad: function (x, t, b, c, d) {
return -c *(t/=d)*(t-2) + b;
},
easeInOutQuad: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return c/2*t*t + b;
return -c/2 * ((--t)*(t-2) - 1) + b;
},
easeInCubic: function (x, t, b, c, d) {
return c*(t/=d)*t*t + b;
},
easeOutCubic: function (x, t, b, c, d) {
return c*((t=t/d-1)*t*t + 1) + b;
},
easeInOutCubic: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return c/2*t*t*t + b;
return c/2*((t-=2)*t*t + 2) + b;
},
easeInQuart: function (x, t, b, c, d) {
return c*(t/=d)*t*t*t + b;
},
easeOutQuart: function (x, t, b, c, d) {
return -c * ((t=t/d-1)*t*t*t - 1) + b;
},
easeInOutQuart: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
return -c/2 * ((t-=2)*t*t*t - 2) + b;
},
easeInQuint: function (x, t, b, c, d) {
return c*(t/=d)*t*t*t*t + b;
},
easeOutQuint: function (x, t, b, c, d) {
return c*((t=t/d-1)*t*t*t*t + 1) + b;
},
easeInOutQuint: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
return c/2*((t-=2)*t*t*t*t + 2) + b;
},
easeInSine: function (x, t, b, c, d) {
return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
},
easeOutSine: function (x, t, b, c, d) {
return c * Math.sin(t/d * (Math.PI/2)) + b;
},
easeInOutSine: function (x, t, b, c, d) {
return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
},
easeInExpo: function (x, t, b, c, d) {
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
},
easeOutExpo: function (x, t, b, c, d) {
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
},
easeInOutExpo: function (x, t, b, c, d) {
if (t==0) return b;
if (t==d) return b+c;
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
},
easeInCirc: function (x, t, b, c, d) {
return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
},
easeOutCirc: function (x, t, b, c, d) {
return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
},
easeInOutCirc: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
},
easeInElastic: function (x, t, b, c, d) {
var s=1.70158;var p=0;var a=c;
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
if (a < Math.abs(c)) { a=c; var s=p/4; }
else var s = p/(2*Math.PI) * Math.asin (c/a);
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
},
easeOutElastic: function (x, t, b, c, d) {
var s=1.70158;var p=0;var a=c;
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
if (a < Math.abs(c)) { a=c; var s=p/4; }
else var s = p/(2*Math.PI) * Math.asin (c/a);
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
},
easeInOutElastic: function (x, t, b, c, d) {
var s=1.70158;var p=0;var a=c;
if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
if (a < Math.abs(c)) { a=c; var s=p/4; }
else var s = p/(2*Math.PI) * Math.asin (c/a);
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
},
easeInBack: function (x, t, b, c, d, s) {
if (s == undefined) s = 1.70158;
return c*(t/=d)*t*((s+1)*t - s) + b;
},
easeOutBack: function (x, t, b, c, d, s) {
if (s == undefined) s = 1.70158;
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
},
easeInOutBack: function (x, t, b, c, d, s) {
if (s == undefined) s = 1.70158;
if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
},
easeInBounce: function (x, t, b, c, d) {
return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
},
easeOutBounce: function (x, t, b, c, d) {
if ((t/=d) < (1/2.75)) {
return c*(7.5625*t*t) + b;
} else if (t < (2/2.75)) {
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
} else if (t < (2.5/2.75)) {
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
} else {
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
}
},
easeInOutBounce: function (x, t, b, c, d) {
if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
}
});
\ No newline at end of file
{
"author": "Alti-TCS",
"name": "Calculatrice.wgt",
"version": "2.3.0RC-32-g426c891",
"repository": {
"type": "git",
"url": "ssh://devalti@VM-REPO/home/devalti/projets/opensankore/Sankore-3.1.git"
},
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.3.2",
"grunt-contrib-watch": "~0.5.3"
},
"optionalDependencies": {},
"engines": {
"node": "*"
}
}
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<meta name="description" content="Traceur de fonctions mathématiques en JavaScript"/>
<meta name="author" content="Yannick Vessaz"/>
<meta name="revised" content="2018/06/04"/>
<title>GraphMe</title>
<link rel="shortcut icon" type="image/png" href="Images/mini_icon.png"/>
<link rel="stylesheet" type="text/css" href="Style/ColorPicker.css"/>
<link rel="stylesheet" type="text/css" href="Style/Haut.css"/>
<link rel="stylesheet" type="text/css" href="Style/Menus.css"/>
<link rel="stylesheet" type="text/css" href="Style/Widget.css"/>
<script type="text/javascript" src="JavaScript/Affichage.js"></script>
<script type="text/javascript" src="JavaScript/Affichage3D.js"></script>
<script type="text/javascript" src="JavaScript/AffichageUniboard.js"></script>
<script type="text/javascript" src="JavaScript/ColorPicker.js"></script>
<script type="text/javascript" src="JavaScript/Editeur.js"></script>
<script type="text/javascript" src="JavaScript/Etudes.js"></script>
<script type="text/javascript" src="JavaScript/CartesianFunction.js"></script>
<script type="text/javascript" src="JavaScript/Fonction.js"></script>
<script type="text/javascript" src="JavaScript/ImplicitFunction.js"></script>
<script type="text/javascript" src="JavaScript/Interface.js"></script>
<script type="text/javascript" src="JavaScript/Languages.js"></script>
<script type="text/javascript" src="JavaScript/Outils.js"></script>
<script type="text/javascript" src="JavaScript/ParametricFunction.js"></script>
<script type="text/javascript" src="JavaScript/PolarFunction.js"></script>
<script type="text/javascript" src="JavaScript/Sauvegardes.js"></script>
<script type="text/javascript" src="JavaScript/Souris.js"></script>
<script type="text/javascript" src="JavaScript/Utils.js"></script>
<script type="text/javascript" src="JavaScript/Widget.js"></script>
</head>
<body onload="widget.init()" onresize="widget.resize()" onkeypress="keyPress(event)">
<table id="background">
<tr class="background-border-x">
<td id="background-top-left" class="background-border-y"></td>
<td id="background-top"></td>
<td id="background-top-right" class="background-border-y"></td>
</tr>
<tr>
<td id="background-left" class="background-border-y"></td>
<td id="background-center">
<!-- ..... Haut du Widget ..... -->
<!-- Onglets -->
<div id="haut">
<div id="ongletsHaut">
<span class="ongletHaut premierOngletHaut" onclick="afficherMenu('menuGraphMe')">
<img src="Images/mini_icon.png" style="width:18px; vertical-align:top;"/>
<span id="graphMeButton">
GraphMe
</span>
</span>
<span class="ongletHaut" onclick="if(fonction3D){afficherMenu('menuFonctions3D')}else{afficherMenu('menuFonctions');if(fct.list[editeur.idFct]){editeur.setOptions()}}">
<span id="functionsButton">
Functions
</span>
</span>
<span class="ongletHaut" onclick="if(fonction3D){afficherMenu('menuAffichage3D')}else{afficherMenu('menuAffichage')}">
<span id="displayButton">
Display
</span>
</span>
<span class="ongletHaut" onclick="afficherMenu('menuAide')">
<span id="helpButton">
Help
</span>
</span>
</div>
<!-- Onglet3D -->
<div id="onglet3D" onclick="activer3D()">
3D
</div>
<!-- Mini-boutons -->
<div id="topRightButtons">
<div id="boutonSaveGraph" title="Save" class="miniBouton" onclick="afficherMenu('menuSaveGraph')">S</div>
<div id="boutonAgrandir" title="Full screen" class="miniBouton" onclick="agrandirAffichage()">^</div>
<!--<div id="miniMax" onclick="miniMax()">-</div> ▶▼ -->
</div>
</div>
<!-- ..... Millieu du Widget ..... -->
<div id="widgetCenter">
<!-- Zone d'affichage -->
<div id="eventAffichage" onmousedown="souris.down(event)" onmouseup="souris.up()" onmousemove="souris.move(event)" onmouseout="souris.out(event)" ondblclick="souris.dblClick(event)">
<div id="affichage"></div>
<div id="affichageOutils"></div>
</div>
<div id="divInputRapide">
f(x) =
<input type="text" id="inputRapide" onkeypress="if(event.keyCode == 13) widget.addStartFunction()"/>
<input id="inputRapideButton" type="button" value="Display" onclick="widget.addStartFunction()"/>
</div>
<div id="zoneJoystick">
<div id="joystick" onclick="">
<table>
<tr>
<td></td>
<td onclick="if(fonction3D){display3D.zoom(1.25)}else{affichage.deplacerY(1)}"></td>
<td></td>
</tr>
<tr>
<td onclick="affichage.deplacerX(-1)"></td>
<td onclick="affichage.centrer();"></td>
<td onclick="affichage.deplacerX(1)"></td>
</tr>
<tr>
<td></td>
<td onclick="if(fonction3D){display3D.zoom(0.8)}else{affichage.deplacerY(-1)}"></td>
<td></td>
</tr>
</table>
</div>
<div id="boutonJoystick" onclick=""></div>
</div>
<div id="zoomButtons">
<div id="zoomOut" class="toolButton zoomButton" onclick="affichage.zoom(1.25)">-</div><div id="zoomIn" class="toolButton zoomButton" onclick="affichage.zoom(0.8)">+</div>
</div>
<div id="toolButtons">
<div id="pointTool" title="Point tool" class="toolButton selectedTool" onclick="outil.choisir('point')">·</div>
<div id="moveTool" title="Move tool" class="toolButton" onclick="outil.choisir('deplacement')"><div class="icon"></div></div>
<div id="tangentTool" title="Tangent tool" class="toolButton" onclick="outil.choisir('tangente')"><div class="icon"></div></div>
</div>
<!-- ..... Menus ..... -->
<!-- Menu d'exemple -->
<div id="menuExemple" class="menu">
<div class="contenuMenu"></div>
<div class="barreBasMenu"><div><div>
<input id="menuExempleCloseButton" type="button" onclick="cacherMenu()" value="Close"/>
</div></div></div>
</div>
<!-- GraphMe -->
<div id="menuGraphMe" class="menu">
<div class="ongletMenu deuxOnglets">
<span id="menuGraphMeOptionsTab" class="ongletMenuActuel" onclick='afficherMenu("menuGraphMe")'>Options</span>
<span id="menuGraphMeAboutTab" onclick='afficherMenu("menuCredits")'>About</span>
</div>
<div class="contenuMenu avecBordures">
<h3 id="widgetOptions">Widget options</h3>
<span id="widgetTheme">Widget theme</span> : <select id="selectTheme" onchange="changerTheme(this.value)">
<option id="selectThemeDarkBlue" value="darkblue">Dark blue</option>
<option id="selectThemeBlack" value="black">Black</option>
<option id="selectThemeBlue" value="blue">Blue</option>
<option id="selectThemeWhite" value="white">White</option>
</select><br/>
<br/><br/>
<input type="button" onclick='widget.reset()' id="resetWidgetButton" value="Reset widget" style=" height:32px;"/>
<!-- TODO option to resize widget on OpenBoard / Sankore -->
<!--<span class="gras">Options :</span><br/>
<input type="button" class="boutonSauvegarde" onclick="saveOptions()" value="Save"/><input type="button" class="boutonSauvegarde" onclick="loadOptions()" value="Load"/> <input class="boutonSauvegarde2" type="button" onclick="delOptions()" value="Remove"/><input class="boutonSauvegarde2" type="button" onclick="alertOptions()" value="Display"/><br/>
<span class="texteSecondaire">Save widget preferences in cookies, load preferences from cookies or delete preferences in cookies.</span>
<br/><br/>
<label for="checkMaJ">Update widget at startup</label> <input type="checkbox" id="checkMaJ" onclick="checkboxMaJ()"/>
<br/>
<div id="cacheCookies"><br/><br/><h1>Cookies are disabled. You cannot save preferences...</h1></div>
<div id="cacheMaJ">You are using the latest version of this widget.</div>-->
</div>
<div class="barreBasMenu"><div><div>
<input type="button" id="menuGraphMeCloseButton" class="bouton" onclick="cacherMenu(); actualiserGraph()" value="Close"/>
</div></div></div>
</div>
<!-- Cookies alert -->
<div id="menuAlertCookies" class="miniMenu">
<h1> Preferences saved :</h1>
<div id="divAlertCookies"></div>
<br/>
<input type="button" onclick="afficherMenu(dernierMenu)" value="Ok"/>
</div>
<!-- Crédits -->
<div id="menuCredits" class="menu">
<div class="ongletMenu deuxOnglets">
<span id="menuCreditsOptionsTab" onclick='afficherMenu("menuGraphMe")'>Options</span>
<span id="menuCreditsAboutTab" class="ongletMenuActuel" onclick='afficherMenu("menuCredits")'>About</span>
</div>
<div class="contenuMenu avecBordures" style="text-align:justify;">
<table id="credits">
<tr>
<td>
<img src="icon.png"/>
<h3 id="widgetDevelopedBy">Widget developed by</h3>
Yannick Vessaz <br/>
<a href='mailto:yannick.vessaz@gmail.com'>yannick.vessaz@gmail.com</a><br/>
<a href='https://yannick.vessaz.net/GraphMe'>https://yannick.vessaz.net/GraphMe</a>
</td>
</tr>
</table>
<span class="texteSecondaire">
<br/>
<span id="widgetContactInfo">If you want to report a bug, make a proposal or just ask questions about this widget, you can contact me at the following e-mail</span> : <a href='mailto:yannick.vessaz@gmail.com'>yannick.vessaz@gmail.com</a>.
<br/><br/>
<span id="widgetBackgroundSource">Background images come from the KDE desktop environment</span>.
</span>
</div>
<div class="barreBasMenu"><div><div>
<input type="button" id="menuCreditsCloseButton" class="bouton" onclick="cacherMenu()" value="Close"/>
<span id="version" class="texteSecondaire" style="position:absolute;bottom:10px;left:15px;">
version 2.1.0 (2018-06-04)
(<span id="changelogButton" style="color: rgb(0,128,255); text-decoration: underline; cursor: pointer;" onclick="afficherMenu('menuChangelog')">changelog</span>)
<input type="button" id="checkForUpdateButton" onclick='miseAjour()' value="Check for updates"/>
</span>
</div></div></div>
</div>
<!-- Changelog -->
<div id="menuChangelog" class="menu">
<div class="ongletMenu deuxOnglets">
<span id="changelogTitle" class="ongletMenuActuel">Changelog</span>
</div>
<iframe id="versionIframe" src="version.txt" style="display:none" onload="document.getElementById('versionFileContent').innerHTML = this.contentWindow.document.body.innerHTML"></iframe>
<div id="versionFileContent" class="contenuMenu">
</div>
<div class="barreBasMenu"><div><div>
<input type="button" id="menuChangelogBackButton" class="bouton" onclick="afficherMenu('menuCredits')" value="Back"/>
<input type="button" id="menuChangelogCloseButton" class="bouton" onclick="cacherMenu()" value="Close"/>
</div></div></div>
</div>
<!-- Affichage -->
<div id="menuAffichage" class="menu">
<div class="ongletMenu deuxOnglets">
<span id="menuAffichageDisplayParametersTab" class="ongletMenuActuel" onclick='afficherMenu("menuAffichage")'>Display parameters</span>
<span id="menuAffichageFunctionsParametersTab" onclick='afficherMenu("menuFunctionParameters")'>Functions parameters</span>
</div>
<div class="contenuMenu">
<table class="colonnes">
<tr>
<td class="premiereColonne" style="width: 30%;">
<!--<h4>Souris</h4>
<select id="selectSouris" onchange="outil.choisir(this.value)" style="width: 100%;">
<option value="point">Point</option>
<option value="deplacement">Déplacement</option>
<option value="tangente">Tangente</option>
</select>-->
<h4 id="plotRange">Plot range</h4>
<span id="xAxis">X-axis</span>: <br/>
<input id="borneXGauche" class="mediumInput" value="-5" onkeypress="if(event.keyCode==13) actualiserGraph()"/> <span id="xAxisTo">to</span> <input id="borneXDroite" class="mediumInput" value="5" onkeypress="if(event.keyCode==13) actualiserGraph()"/> <br/>
<span id="yAxis">Y-axis</span>: <br/>
<input id="borneYGauche" class="mediumInput" value="-5" onkeypress="if(event.keyCode==13) actualiserGraph()"/> <span id="yAxisTo">to</span> <input id="borneYDroite" class="mediumInput" value="5" onkeypress="if(event.keyCode==13) actualiserGraph()"/>
<br/>
<br/>Zoom: <br/>
<input type="button" class="bouton" style="width:30px;" onclick='affichage.zoom(1.25)' value="-"/><input type="button" class="bouton" style="width:30px; position:relative; left: 9px;" onclick='affichage.zoom(0.8)' value="+"/><br/>
<br/>
<span id="defaultZoom">Default zoom</span> :
<input value="3.7" class="smallInput" id="zoomDefaut"/>
<input type="button" id="defaultDisplayParameters" onclick="affichage.initZoom2(document.getElementById('zoomDefaut').value)" value="Default display parameters"/>
<br/><br/><br/><br/>
</td>
<td>
<h4 id="displayOptions">Options</h4>
<span id="displayMethod">Display method</span> : <select id="selectMethodeAffichage" onchange="affichage.getOptions()">
<option value="canvas">canvas</option>
<option value="svg">svg</option>
<option value="uniboard">uniboard</option>
</select> <br/>
<br/>
<input type="checkbox" id="checkGrille" checked="true" onclick="actualiserGraph()"/><label for="checkGrille"> <span id="showGrid">Show grid</span></label> <br/>
<input type="checkbox" id="checkAxes" checked="true" onclick="actualiserGraph()"/><label for="checkAxes"> <span id="showAxis">Show axis</span></label> <br/>
<input type="checkbox" id="checkEchelle" checked="true" onclick="actualiserGraph()"/><label for="checkEchelle"> <span id="showScale">Show scale</span></label> <br/>
<br/>
<span id="graphAccuracy">Graph accuracy, computed points</span> : <input value="100" class="smallInput" id="inputPrecision" onchange="affichage.calculer()"/>
<div class="boutonPlus" type="button" onclick="boutonPlus('inputPrecision', 20); affichage.calculer();">+</div><div class="boutonMoins" type="button" onclick="boutonMoins('inputPrecision', 20); affichage.calculer();">-</div> <br/>
<input type="checkbox" id="checkPrecision" onclick="actualiserGraph()"/><label for="checkPrecision"> <span id="improveAccuracy">Improve accuracy on zoom (can be slower)</span>.</label> <br/>
<br/><br/>
</td>
</tr>
</table>
</div>
<div class="barreBasMenu"><div><div>
<input type="button" id="menuAffichageOkButton" class="bouton" onclick='cacherMenu(); actualiserGraph()' value="Ok"/>
</div></div></div>
</div>
<div id="menuFunctionParameters" class="menu">
<div class="ongletMenu deuxOnglets">
<span id="menuFunctionParametersDisplayParametersTab" onclick='afficherMenu("menuAffichage")'>Display parameters</span>
<span id="menuFunctionParametersFunctionsParametersTab" class="ongletMenuActuel" onclick='afficherMenu("menuFunctionParameters")'>Functions parameters</span>
</div>
<div class="contenuMenu">
<h3 id="defaultFunctionParameters">Default functions parameters</h3>
<span id="thickness">Thickness</span> : <input id="inputTaille" class="smallInput" value="3" onkeypress="if(event.keyCode==13) actualiserGraph()"/>
<div class="boutonPlus" type="button" onclick="boutonPlus('inputTaille', 1); actualiserGraph()">+</div><div class="boutonMoins" type="button" onclick="boutonMoins('inputTaille', 1); actualiserGraph()">-</div>
<br/><br/>
<span id="drawDerivativeAndPrimitive">Draw derivatives and primitives</span> :<br/>
<label for="checkDerivee1"> f'(x) </label><input type="checkbox" id="checkDerivee1" onchange="actualiserGraph()"/><label for="checkDerivee2"> f''(x) </label><input type="checkbox" id="checkDerivee2" onchange="actualiserGraph()"/><label for="checkPrimitive1"> F(x) </label><input type="checkbox" id="checkPrimitive1" onchange="actualiserGraph()"/>
<br/><br/>
<input type="checkbox" id="checkAire" onchange="actualiserGraph()"/><label for="checkAire"> <span id="drawArea">Draw area under function</span></label><br/>
<br/>
<span id="lineStyle">Line style</span> :
<select id="selectStyle" onchange="actualiserGraph()">
<option id="selectStyleLine" value="continu">line</option>
<option id="selectStyleDotted" value="points">dotted</option>
<option id="selectStyleDashed" value="traits">dashed</option>
</select> <br/>
</div>
<div class="barreBasMenu"><div><div>
<input type="button" id="menuFunctionParametersCloseButton" class="bouton" onclick="cacherMenu()" value="Close"/>
</div></div></div>
</div>
<div id="menuAffichage3D" class="menu">
<div class="ongletMenu deuxOnglets">
<span id="display3D" class="ongletMenuActuel">3D Display</span>
</div>
<div class="contenuMenu">
<span id="displayStyle">Display style</span> :
<select id="selectAffichage3D" onchange="actualiserGraph()">
<option id="displayStyleSurfaces" value="surfaces">surfaces</option>
<option id="displayStyleDotted" value="points">dotted</option>
</select> <input type="button" id="resetDisplay3D" onclick="display3D.initZoom()" value="Reset display"/> <br/>
<br/>
<span id="graphAccuracy3D">Graph accuracy</span> : <input value="0.2" class="smallInput" id="inputPrecision3D" onchange="display3D.functionPrecision = parseFloat(this.value); actualiserGraph();"/>
<div class="boutonPlus" type="button" onclick="boutonPlus('inputPrecision3D', 0.1); display3D.functionPrecision = parseFloat(document.getElementById('inputPrecision3D').value); actualiserGraph()">+</div><div class="boutonMoins" type="button" onclick="boutonMoins('inputPrecision3D', 0.1); display3D.functionPrecision = parseFloat(document.getElementById('inputPrecision3D').value); actualiserGraph()">-</div> <br/>
<br/>
<span id="colorsConfig">Colors configuration</span><br/>
<span id="useRedFor">use red for</span>:
<select onchange="display3D.checkCouleurs3D()" id="selectRouge3D">
<option id="redPositive" value="plus">positive values</option>
<option id="redNegative" value="moins">negative values</option>
<option id="redAlways" value="tout">always</option>
</select>
<br/>
<span id="useGreenFor">use green for</span>:
<select onchange="display3D.checkCouleurs3D()" id="selectVert3D">
<option id="greenPositive" value="moins">negative values</option>
<option id="greenNegative" value="plus">positive values</option>
<option id="greenAlways" value="tout">always</option>
</select>
<br/>
<span id="useBlueFor">use blue for</span>:
<select onchange="display3D.checkCouleurs3D()" id="selectBleu3D">
<option id="bluePositive" value="tout">always</option>
<option id="blueNegative" value="plus">positive values</option>
<option id="blueAlways" value="moins">negative values</option>
</select>
<br/>
<span id="globalValue">General value</span> : <input class="smallInput" id="couleur3Dgenerale" type="texte" value="0" onkeyup="display3D.checkCouleurs3D()"/> <span id="globalValueRange">(between 0 and 255)</span>
<br/>
<span id="apercuCouleur3D"></span>
</div>
<div class="barreBasMenu"><div><div>
<input type="button" id="menuAffichage3dOk" class="bouton" onclick='cacherMenu(); actualiserGraph()' value="Ok"/>
</div></div></div>
</div>
<!-- Aide -->
<div id="menuAide" class="menu">
<div class="ongletMenu deuxOnglets">
<span id="menuAideUsageTab" class="ongletMenuActuel" onclick='afficherMenu("menuAide")'>Usage</span>
<span id="menuAideExamplesTab" onclick='afficherMenu("menuAideExemples")'>Exemples</span>
</div>
<div class="contenuMenu avecBordures">
<h1 id="howItWorks">How it works</h1>
<p id="howItWorksText">
This widget allow to draw mathematical function.
Enter function in the field in the top part of widget and press "Show".
Open the "Fonctions" menu to modify the current function or add a new function.
</p>
<p><span id="availableFunctionsText">You can enter following mathematical functions</span> : <br/>
<h2 id="basicOperations">Basic operations</h2>
<ul>
<li><span id="plus">Plus</span> -> <span class="gras">+</span></li>
<li><span id="minus">Minus</span> -> <span class="gras">-</span></li>
<li><span id="multiplication">Multiplication</span> -> <span class="gras">*</span></li>
<li><span id="division">Division</span> -> <span class="gras">/</span></li>
<li><span id="modulus">Modulus</span> -> <span class="gras">%</span></li>
</ul>
<h2 id="trigonometricFunctions">Trigonometric functions</h2>
<ul>
<li><span id="sine">Sine</span> -> <span class="gras">sin(x)</span></li>
<li><span id="cosine">Cosine</span> -> <span class="gras">cos(x)</span></li>
<li><span id="tangent">Tangent</span> -> <span class="gras">tan(x)</span></li>
<li><span id="cotangent">Cotangent</span> -> <span class="gras">cot(x)</span></li>
<li><span id="secant">Secant</span> -> <span class="gras">sec(x)</span></li>
<li><span id="cosecant">Cosecant</span> -> <span class="gras">csc(x)</span></li>
</ul>
<ul>
<li><span id="arcSine">Arc sine</span> -> <span class="gras">arcsin(x)</span> or <span class="gras">asin(x)</span></li>
<li><span id="arcCosine">Arc cosine</span> -> <span class="gras">arccos(x)</span> or <span class="gras">acos(x)</span></li>
<li><span id="arcTangent">Arc tangent</span> -> <span class="gras">arctan(x)</span> or <span class="gras">atan(x)</span></li>
<li><span id="arcCotangent">Arc cotangent</span> -> <span class="gras">arccot(x)</span> or <span class="gras">acot(x)</span></li>
</ul>
<h2 id="hyperbolicFunctions">Hyperbolic functions</h2>
<ul>
<li><span id="hypSine">Hyperbolic sine</span> -> <span class="gras">sinh(x)</span></li>
<li><span id="hypCosine">Hyperbolic cosine</span> -> <span class="gras">cosh(x)</span></li>
<li><span id="hypTangent">Hyperbolic tangent</span> -> <span class="gras">tanh(x)</span></li>
<li><span id="hypCotangent">Hyperbolic cotangent</span> -> <span class="gras">coth(x)</span></li>
<li><span id="hypSecant">Hyperbolic secant</span> -> <span class="gras">sech(x)</span></li>
<li><span id="hypCosecant">Hyperbolic cosecant</span> -> <span class="gras">csch(x)</span></li>
</ul>
<ul>
<li><span id="hypArcSine">Hyperbolic arc sine</span> -> <span class="gras">arcsinh(x)</span> or <span class="gras">asinh(x)</span></li>
<li><span id="hypArcCosine">Hyperbolic arc cosine</span> -> <span class="gras">arccosh(x)</span> or <span class="gras">acosh(x)</span></li>
<li><span id="hypArcTangent">Hyperbolic arc tangent</span> -> <span class="gras">arctanh(x)</span> or <span class="gras">atanh(x)</span></li>
<li><span id="hypArcCotangent">Hyperbolic arc cotangent</span> -> <span class="gras">arccoth(x)</span> or <span class="gras">acoth(x)</span></li>
</ul>
<h2 id="powerAndRoot">Power and root</h2>
<ul>
<li><span id="squareRoot">Square root</span> -> <span class="gras">sqrt(x)</span></li>
<li><span id="power">Power</span> -> <span class="gras">pow(x, y)</span> <span id="xPowY" class="texteSecondaire">Élève x à la puissance y</span></li>
<li><span id="root">Root</span> -> <span class="gras">root(x, y)</span> <span id="rootText" class="texteSecondaire">Root y de x</span></li>
</ul>
<h2 id="expAndLog">Exponential and logarithm</h2>
<ul>
<li>e<span style="vertical-align:super;">x</span> -> <span class="gras">exp(x)</span></li>
<li><span id="naturalLog">Natural logarithm</span> -> <span class="gras">ln(x)</span></li>
<li><span id="decimalLog">Decimal logarithm</span> -> <span class="gras">log(x)</span></li>
</ul>
<h2 id="absValue">Absolute value</h2>
<ul>
<li>|x| -> <span class="gras">abs(x)</span></li>
</ul>
<h2 id="rounding">Rounding</h2>
<ul>
<li><span class="gras">round(x)</span> -> <span id="roundText">round to the nearest integer</span></li>
<li><span class="gras">ceil(x)</span> -> <span id="ceilText">round to the first integer bigger than x</span></li>
<li><span class="gras">floor(x)</span> -> <span id="floorText">round to the first integer lower than x</span></li>
</ul>
</p> <br/>
<hr/>
<h1 id="constants">Constants</h1>
<p>
<span id="constantsText">Some constants are also available</span> : <br/>
<ul>
<li><span class="gras">pi</span> = 4 * atan(1) ≈ 3,141592653589793</li>
<li><span class="gras">e</span> = exp(1) ≈ 2.718281828459045</li>
</ul>
</p>
<br/>
<hr/>
<h1 id="keyboardShortcuts">Keyboard shortcuts</h1>
<p style="font-size:90%;">
ctrl + <span>left arrow</span> -> <span id="moveLeft">graph will be moved left</span><br/>
ctrl + <span>top arrow</span> -> <span id="moveTop">graph will be moved top</span><br/>
ctrl + <span>right arrow</span> -> <span id="moveRight">graph will be moved right</span><br/>
ctrl + <span>bottom arrow</span> -> <span id="moveBottom">graph will be moved bottom</span><br/>
<br/>
</p>
</div>
<div class="barreBasMenu"><div><div>
<input type="button" id="menuAideCloseButton" class="bouton" onclick="cacherMenu()" value="Close"/>
<!-- <input type="button" id="usersGuideButton" class="bouton" value="User's guide" onclick="navigateur('Guide_Utilisateur.html')" style="position:absolute;bottom:0px;left:0px;"/> -->
</div></div></div>
</div>
<div id="menuAideExemples" class="menu">
<div class="ongletMenu deuxOnglets">
<span id="menuAideExemplesUsageTab" onclick='afficherMenu("menuAide")'>Usage</span>
<span id="menuAideExemplesExamplesTab" class="ongletMenuActuel" onclick='afficherMenu("menuAideExemples")'>Exemples</span>
</div>
<div class="contenuMenu avecBordures">
<span id="examplesText" class="texteSecondaire">(You can click on an example to view it. Do not forget to set accuracy in options if necessary.)</span>
<br/><br/>
<hr/>
<h1 id="functions2d">2D Fonctions</h1>
<p>
<span class="survol" onclick="fct.addCartesian('0.5*x+1')">f(x) = 0.5*x+1</span> <br/>
<span class="survol" onclick="fct.addCartesian('pow(x,2)-3')">f(x) = pow(x,2)-3</span> <br/>
<span class="survol" onclick="fct.addCartesian('1/x')">f(x) = 1/x</span> <br/>
<span class="survol" onclick="fct.addCartesian('atan(x)')">f(x) = atan(x)</span> <br/>
<span class="survol" onclick="fct.addCartesian('(x+1/x)/1.2')">f(x) = (x+1/x)/1.2</span> <br/>
<span class="survol" onclick="fct.addCartesian('sin(10*x*x)*0.5')">f(x) = sin(10*x*x)*0.5</span> <br/>
<span class="survol" onclick="fct.addCartesian('log(pow(x-2,2))')">f(x) = log(pow(x-2,2))</span> <br/>
<span class="survol" onclick="fct.addCartesian('(x*x-5*x+5)*exp(x)/5')">f(x) = (x*x-5*x+5)*exp(x)/5</span> <br/>
<span class="survol" onclick="fct.addCartesian('random()')">f(x) = random()</span> <br/>
</p>
<br/><br/>
<hr/>
<h1 id="functions3d">3D Fonctions</h1>
<p>
<span class="survol" onclick="document.getElementById('input3D').value = 'sin(x)+cos(y)'; display3D.draw()">f(x,y) = sin(x)+cos(y)</span> <br/>
<span class="survol" onclick="document.getElementById('input3D').value = 'sqrt(10-x*x)'; display3D.draw()">f(x,y) = sqrt(10-x*x)</span> <br/>
<span class="survol" onclick="document.getElementById('input3D').value = 'atan(x)+atan(y)'; display3D.draw()">f(x,y) = atan(x)+atan(y)</span> <br/>
</p>
<br/>
</div>
<div class="barreBasMenu"><div><div>
<input type="button" id="menuAideExemplesCloseButton" class="bouton" onclick="cacherMenu()" value="Close"/>
</div></div></div>
</div>
<!--<div id="menuAideAutres" class="menu">
<div class="ongletMenu troisOnglets">
<span id="menuAideAutreUsageTab" onclick='afficherMenu("menuAide")'>Usage</span>
<span id="menuAideAutreExamplesTab" onclick='afficherMenu("menuAideExemples")'>Exemples</span>
<span id="menuAideAutreOtherTab" class="ongletMenuActuel" onclick='afficherMenu("menuAideAutres")'>Other</span>
</div>
<div class="contenuMenu avecBordures">
<h4 id="saveGraph">Save graph</h4>
<span id="saveGraphText">You can save the graph by clicking on the "S" button in the top right corner.
In some webbrowsers, it is impossible to save in JPEG format. The PNG format should be selected in preference.
Inside Sankore or Uniboard, the graph image is opened in a new web page. You can save it with right click on it. The image will be saved on desktop and you can't modify its name. Use your favourite folder explorer to rename it "image.png".</span>
<br/><br/>
<h4 id="openBoardOrSankore">OpenBoard or Sankore</h4>
<span id="openBoardOrSankoreText">If you use the widget in OpenBoard or Sankore, you can draw functions directly on the white page. For that, you can use the "uniboard" display method in preferences menu.
With this method, the graph will be displayed at the center of the page on top of existing content. To delete the graph, you have to use the erase tool of OpenBoard or Sankore.</span>
</div>
<div class="barreBasMenu"><div><div>
<input type="button" id="menuAideAutreCloseButton" class="bouton" onclick="cacherMenu()" value="Close"/>
</div></div></div>
</div>-->
<!--Etude de fonction -->
<div id="menuEtude" class="menu">
<div class="ongletMenu deuxOnglets">
<span id="functionStudyTitle" class="ongletMenuActuel">Function study</span>
</div>
<div class="contenuMenu">
<p class="gras">
f(x) = <span id="etudeFdeX">...</span>
</p>
<p><span id="domainOfDefinition" class="gras">Domain of definition</span> :
<span id="etudeEDF">...</span>
</p>
<p><span id="symmetry" class="gras">Symmetry</span> :
<span id="etudeParite">...</span>
</p>
<p><span id="zeros" class="gras">Zeros</span> :
<span id="etudeZeros">...</span>
</p>
<p><span id="sign" class="gras">Sign</span> :<table id="etudeSigne">
<tr id="etudeSigneRow">
</tr>
</table></p>
<p><span id="asymptotes" class="gras">Asymptotes</span> : <br/>
<span id="etudeA">...</span>
</p>
<p><span id="extremums" class="gras">Extremums</span> : <br/>
<span id="etudeMinMax">...</span>
</p>
<p><span id="inflexionPoints" class="gras">Inflexion points</span> : <br/>
<span id="etudeI">...</span> <br/>
</p>
<br/>
<span id="functionStudyText" class="texteSecondaire" style="font-size:10px;">The tool for function analysis is not 100% reliable. Don't forget to check the results before any usage.</span>
<br/>
<br/>
</div>
<div class="barreBasMenu"><div><div>
<!-- <input type="button" class="bouton" onclick="etude.etudier(document.getElementById('input').value)" value="Actualiser" style="position:relative;right:310px;"/> -->
<input type="button" id="menuEtudeBackButton" class="bouton" onclick="afficherMenu(dernierMenu)" style="position: absolute; left: 0px;" value="Back"/>
<input type="button" id="menuEtudeCloseButton" class="bouton" onclick="cacherMenu()" value="Close"/>
</div></div></div>
</div>
<!-- Fonctions 2D -->
<div id="menuFonctions" class="menu">
<div class="ongletMenu deuxOnglets">
<span id="menuFonctionsFunctionsTab" class="ongletMenuActuel" onclick='afficherMenu("menuFonctions")'>Functions</span>
<span id="menuFonctionsHistoryTab" onclick='afficherMenu("menuHistorique")'>History</span>
</div>
<div class="contenuMenu avecBordures">
<div id="functionMenuRight">
<div id="editeurFonction" style="visibility: hidden">
<div id="editeurPageModifier">
<div class="editeurOnglets">
<span id="editorEditPageEditTab" class="ongletActuel">Edit</span>
<span id="editorEditPageToolsTab" onclick="document.getElementById('editeurPageModifier').style.display='none';document.getElementById('editeurPageOutils').style.display='block';">Tools</span>
</div>
<br/>
<canvas id="editeurApercu" width="100" height="80"></canvas>
<br/>
<div id="editeurFctDiv">
<span id="editeurFctPrefix">f(x) = </span>
<input id="editeurInput" style="width: 75%;" onchange="editeur.getOptions()"/>
<br/>
</div>
<div id="editeurFctXYDiv" style="display:none">
x(t) = <input id="editeurFctX" style="width: 75%;" onchange="editeur.getOptions()"/>
<br/>
y(t) = <input id="editeurFctY" style="width: 75%;" onchange="editeur.getOptions()"/>
<br/>
</div>
<div id="editeurRangeDiv" style="display:none">
"t" <span id="editorRangeFrom">from</span> <input id="editeurFrom" class="smallInput" onchange="editeur.getOptions()"/>
<span id="editorRangeTo">to</span> <input id="editeurTo" class="smallInput" onchange="editeur.getOptions()"/>
<br/>
</div>
<br/>
<span id="editorThickness">Thickness</span> : <input class="smallInput" id="editeurWidth" onchange="editeur.getOptions()" value="3"/>
&nbsp;&nbsp;
<span id="editorColor">Color</span> : <span id="editeurCouleur" title="editeur.fct.couleur" class="boutonCouleur" onclick="editeur.couleur(this.id)" style="background-color: rgba(0,128,255,1)"></span>
<br/>
<div id="editeurDeriveesDiv">
<span id="editorDerivatives">Derivatives</span> : <label for="editeurD1"> f'(x)</label><input type="checkbox" id="editeurD1" onchange="editeur.getOptions()"/><span id="editeurCouleurD1" title="editeur.fct.couleurD1" class="miniCouleur" onclick="editeur.couleur(this.id)" style="background-color: rgba(0,128,255,1)"></span>
&nbsp;&nbsp;
<label for="editeurD2"> f''(x)</label><input type="checkbox" id="editeurD2" onchange="editeur.getOptions()"/><span id="editeurCouleurD2" title="editeur.fct.couleurD2" class="miniCouleur" onclick="editeur.couleur(this.id)" style="background-color: rgba(0,128,255,1)"></span>
<br/>
<span id="editorPrimitive">Primitive</span> : <label for="editeurP1"> F(x)</label><input type="checkbox" id="editeurP1" onchange="editeur.getOptions()"/><span id="editeurCouleurP1" title="editeur.fct.couleurP1" class="miniCouleur" onclick="editeur.couleur(this.id)" style="background-color: rgba(0,128,255,1)"></span>
<span id="editeurTexteConditionInitiale"> F(0) = </span><input id="editeurConditionInitiale" onchange="editeur.getOptions()" value="0" style="width:20px"/>
<br/>
</div>
<div id="editeurStyleDiv">
<span id="editorLineStyle">Style</span> :
<select id="editeurStyle" onchange="editeur.getOptions()">
<option id="editorStyleLine" value="continu">line</option>
<option id="editorStyleDotted" value="points">dotted</option>
<option id="editorStyleDashed" value="traits">dashed</option>
</select>
<br/>
</div>
<div id="editeurAireDiv">
<label for="editeurAire"><span id="editorDrawArea">Area under function</span> : </label><input type="checkbox" id="editeurAire" onchange="editeur.getOptions()"/>
<br/>
</div>
<br/>
<div style="text-align:right;">
<input type="button" id="editorDuplicate" class="bouton" value="Duplicate" onclick="editeur.dupliquer()"/>
<input type="button" id="editorRemove" class="bouton" value="Remove" onclick="editeur.supprimer()"/>
</div>
</div>
<div id="editeurPageOutils" style="display: none;">
<div class="editeurOnglets">
<span id="editorToolsPageEditTab" onclick="document.getElementById('editeurPageOutils').style.display='none';document.getElementById('editeurPageModifier').style.display='block';">Edit</span>
<span id="editorToolsPageToolsTab" class="ongletActuel">Tools</span>
</div>
<br/>
<span id="computePoint">Compute a point on the fonction</span> :<br/>
x=<input value="0" class="smallInput" id="inputX" onkeypress="if(event.keyCode==13) calculerPoint()"/>
<input type="button" id="computePointButton" onclick="calculerPoint()" value="Compute"/><br/>
<span id="outputX"> </span>
<br/><br/>
<span id="computeArea">Compute area under the function</span> :<br/>
<span id="areaFrom">De</span> <input value="-5" class="smallInput" id="aireG"/> <span id="areaTo">à</span> <input value="5" class="smallInput" id="aireD"/> <input type="button" id="computeAreaButton" onclick='calculerAire()' value="Compute"/><br/>
<span id="outputAire"> </span>
<br/><br/>
<span id="functionStudy">Function study</span> : <br/>
<input type="button" id="functionStudyButton" class="bouton" value="Start study" onclick="editeur.etudier()"/><br/>
<br/><br/>
<div style="text-align:right;">
<input type="button" id="editorToolsDuplicate" class="bouton" value="Duplicate" onclick="editeur.dupliquer()"/>
<input type="button" id="editorToolsRemove" class="bouton" value="Remove" onclick="editeur.supprimer()"/>
</div>
</div>
</div>
</div>
<div id="functionMenuLeft">
<span id="newFunction">New function</span> :
<select id="functionType" onchange="fct.changeType(this.value)">
<option id="functionTypeCartesian" value="cartesian">Cartesian</option>
<option id="functionTypePolar" value="polar">Polar</option>
<option id="functionTypeParametric" value="parametric">Parametric</option>
<option id="functionTypeImplicit" value="implicit">Implicit</option>
</select>
<br/>
<span id="cartesianDiv">
f(x) =
<input id="input" placeholder="sin(x)" style="width:220px; position:relative; right:2px;" onkeypress="if(event.keyCode == 13) fct.ajouter()"/>
</span>
<span id="implicitDiv" style="display:none">
<input id="implicitInput" placeholder="x^2 + y^2 = 9" style="width:220px; position:relative; right:2px;" onkeypress="if(event.keyCode == 13) fct.ajouter()"/>
</span>
<span id="polarDiv" style="display:none">
r(t) =
<input id="polarInput" placeholder="t" style="width:220px; position:relative; right:2px;" onkeypress="if(event.keyCode == 13) fct.ajouter()"/>
</span>
<span id="parametricDiv" style="display:none">
x(t) =
<input id="parametricInputX" placeholder="cos(t)" style="width:220px; position:relative; right:2px;" onkeypress="if(event.keyCode == 13) document.getElementById('parametricInputY').focus()"/>
<br/>
y(t) =
<input id="parametricInputY" placeholder="sin(t)" style="width:220px; position:relative; right:2px;" onkeypress="if(event.keyCode == 13) fct.ajouter()"/>
</span>
<input type="button" id="addFunctionButton" value="Add" onclick="fct.ajouter();"/>
<br/>
<br/>
<span id="functionsListText">Functions list</span> :
<div id="fonctionsSupp"></div>
</div>
</div>
<div class="barreBasMenu"><div><div>
<input type="button" id="menuFonctionsCloseButton" class="bouton" onclick="cacherMenu()" value="Close"/>
</div></div></div>
</div>
<!-- Fonctions 3D -->
<div id="menuFonctions3D" style="display:none;">
f(x,y) =
<input type="text" id="input3D" onkeypress="if(event.keyCode == 13) display3D.draw();saveOptions();"/>
<input type="button" id="input3dDisplayButton" value="Display" onclick="display3D.draw();saveOptions();"/>
</div>
<!-- Historique -->
<div id="menuHistorique" class="menu">
<div class="ongletMenu deuxOnglets">
<span id="menuHistoriqueFunctionsTab" onclick='afficherMenu("menuFonctions")'>Functions</span>
<span id="menuHistoriqueHistoryTab" class="ongletMenuActuel" onclick='afficherMenu("menuHistorique")'>History</span>
</div>
<div class="contenuMenu avecBordures" id="divHistorique">
<h3 id="latestDisplayedFunctions">Latest displayed functions</h3>
<span id="spanHistorique"></span>
</div>
<div class="barreBasMenu"><div><div>
<input type="button" id="menuHistoriqueCloseButton" class="bouton" onclick="cacherMenu()" value="Close"/>
</div></div></div>
</div>
<!-- Couleur -->
<div id="menuCouleur" class="menu" onmouseup="colorPicker.sourisUp()">
<div class="ongletMenu deuxOnglets">
<span id="chooseColor" class="ongletMenuActuel">Color picker</span>
</div>
<div class="contenuMenu">
<br/>
<canvas id="canvasSV" onmousemove="colorPicker.moveSV(event)" onmousedown="colorPicker.sourisClick(this.id); colorPicker.moveSV(event)" onmouseup="colorPicker.sourisUp()" onmouseover="colorPicker.sourisOver(this.id)" onmouseout="colorPicker.sourisOut()"></canvas>
<canvas id="canvasT" onmousemove="colorPicker.moveT(event)" onmousedown="colorPicker.sourisClick(this.id); colorPicker.moveT(event)" onmouseup="colorPicker.sourisUp()" onmouseover="colorPicker.sourisOver(this.id)" onmouseout="colorPicker.sourisOut()"></canvas>
<table id="colorValues">
<tr>
<td><span id="colorPickerColor">Color</span> : </td><td><input id="inputTeinte" class="smallInput" value="0" onchange="colorPicker.recupererInputs()"/></td>
</tr><tr>
<td><span id="colorPickerValue">Value</span> : </td><td><input id="inputValeur" class="smallInput" value="0" onchange="colorPicker.recupererInputs()"/></td>
</tr><tr>
<td><span id="colorPickerSaturation">Saturation</span> : </td><td><input id="inputSaturation" class="smallInput" value="0" onchange="colorPicker.recupererInputs()"/></td>
</tr><tr>
<td><span id="colorPickerRed">Red</span> : </td><td><input id="inputRouge" class="smallInput" value="255" onchange="colorPicker.recupererInputs2()"/></td>
</tr><tr>
<td><span id="colorPickerGreen">Green</span> : </td><td><input id="inputVert" class="smallInput" value="0" onchange="colorPicker.recupererInputs2()"/></td>
</tr><tr>
<td><span id="colorPickerBlue">Blue</span> : </td><td><input id="inputBleu" class="smallInput" value="0" onchange="colorPicker.recupererInputs2()"/></td>
</tr><tr>
<td><span id="colorPickerOpacity">Opacity</span> : </td><td><input id="inputOpacity" class="smallInput" value="1" onchange="colorPicker.recupererInputs()"/></td>
</tr><!--<tr>
<td><input id="inputCouleur" style="width: 70%" value="cyan" onkeypress="fct.couleur = this.value; if(event.keyCode==13) actualiserGraph()"/></td>
</tr>-->
</table>
<div id="apercuCouleur" title="New color"></div><div id="apercuCouleur2" title="Old color"></div>
<br/>
<canvas id="canvasO" onmousemove="colorPicker.moveO(event)" onmousedown="colorPicker.sourisClick(this.id); colorPicker.moveO(event)" onmouseup="colorPicker.sourisUp()" onmouseover="colorPicker.sourisOver(this.id)" onmouseout="colorPicker.sourisOut()"></canvas>
</div>
<div class="barreBasMenu"><div><div>
<input type="button" id="colorPickerCancelButton" class="bouton" onclick="cacherMenu()" value="Cancel"/><input type="button" id="colorPickerOkButton" class="bouton" onclick="colorPicker.fermer()" value="Ok"/>
</div></div></div>
</div>
<!-- Save image -->
<div id="menuSaveImage" class="menu">
<div class="ongletMenu deuxOnglets">
<span id="saveImageTitle" class="ongletMenuActuel">Save image</span>
</div>
<div class="contenuMenu">
<p id="saveImageText">
You can right click on the image and select "Save image". It is also possible to choose "Copy image" and past it into another application.
</p>
<div id="saveImageContent"></div>
</div>
<div class="barreBasMenu"><div><div>
<input id="menuSaveImageCloseButton" type="button" onclick="cacherMenu()" value="Close"/>
</div></div></div>
</div>
<!-- Erreurs Fonctions interdites -->
<div id="fctInterdite" class="miniMenu">
<br/>
<h1>------- <span id="blackListError">Error</span> -------</h1>
<br/>
<span id="cannotDrawFunction">Cannot draw function</span> ...
<br/><br/>
<span id="invalidExpression">Invalid character or expression</span> : <br/>
<span id="spanFctInterdite" style="font-style:italic;"></span>
<br/><br/>
<input type="button" id="blackListErrorOkButton" onclick="cacherMenu()" value="Ok"/>
</div>
<!-- Autres erreurs -->
<div id="erreurFct" class="miniMenu">
<h4>------- <span id="fctError">Error</span> -------</h4>
<span id="checkTheFunction">Check the function and try to draw it again</span>.
<br/><br/>
<span id="errorMessage">Error message</span> : <span id="spanErreurFct"></span>.
<br/><br/>
<span id="youCanFindExamples">You can find examples of various drawable functions in the help menu</span>.
<br/>
<input type="button" id="fctErrorHelpButton" onclick="afficherMenu('menuAide')" value="Help"/>
<input type="button" id="fctErrorOkButton" onclick="cacherMenu()" value="Ok"/>
</div>
<!-- Sauvegarder le graphique-->
<div id="menuSaveGraph" class="miniMenu">
<h1 id="menuSaveGraphTitle">Save graph</h1>
<span id="saveWidthText">Width</span> : <input id="saveWidth" class="smallInput" type="text" value="800"/><br/>
<span id="saveHeightText">Height</span> : <input id="saveHeight" class="smallInput" type="text" value="600"/><br/>
<br/>
<span id="saveBackgroundColor">Background color</span> : <span id="boutonBackgroundSauvegarde" class="boutonCouleur" title="backgroundSauvegarde" onclick="colorPicker.init(this.id); afficherMenu('menuCouleur')" style="background-color: rgba(0,0,0,0.5);"></span><br/>
<br/>
<span id="imageFormat">Image format</span> :
<select id="selectSaveType">
<option value="png">PNG</option>
<option value="jpg">JPG</option>
</select>
<br/><br/>
<input type="button" id="menuSaveGraphCancelButton" onclick="cacherMenu()" value="Cancel"/>
<input type="button" id="menuSaveGraphOkButton" onclick="saveGraph()" value="Ok"/>
</div>
<!-- Menu des mises à jour -->
<div id="mAj" class="menu">
<div class="ongletMenu deuxOnglets">
<span id="updateTitle" class="ongletMenuActuel">Updates</span>
</div>
<div class="contenuMenu">
<br/>
<span id="currentVersion">Current version</span> : <br/><span id="thisVersion"></span><br/><br/>
<span id="latestVersionAvailable">Latest version available online</span> : <br/><span id="newVersion"></span><br/>
<br/><br/>
<!--<span id="useLatestVersionText">You can replace the current version with an online version.
This will only affect the current session. You have to do it again after next startup.</span><br/>
<br/>
<input type="button" id="useLatestVersion" onclick="majAccept()" value="Use latest version"/><br/>-->
<!-- <input type="button" onclick="cacherMenu()" value="Keep my version"/> -->
</div>
<div class="barreBasMenu"><div><div>
<input type="button" id="updateBackButton" class="bouton" onclick="afficherMenu('menuCredits')" value="Back"/>
<input type="button" id="updateOkButton" class="bouton" onclick="cacherMenu()" value="Ok"/>
</div></div></div>
</div>
<!-- Erreur mise à jour -->
<div id="erreurMaJ" class="miniMenu">
<br/>
<h1>------- <span id="updateErrorTitle">Error</span> -------</h1>
<br/><br/>
<span id="updateErrorText">Update to latest version is not available because you already use the latest version</span>.
<br/><br/><br/>
<input type="button" id="updateErrorOkButton" onclick="cacherMenu()" value="Ok"/>
</div>
<!-- Info options sauvegardées -->
<div id="infoSauvegarde" class="alertMenu">
<br/>
<h1>Preferences saved!</h1>
<br/>
<input type="button" onclick="document.getElementById('infoSauvegarde').style.display = 'none'" value="Ok"/>
</div>
<!-- Demande mise à jour auto -->
<div id="demandeMaJ" class="miniMenu">
<br/>
<h1>Automatic update</h1>
<br/><br/>
Do you really want to use the latest online widget version ?
<br/><br/><br/>
<input type="button" onclick="afficherMenu(dernierMenu)" value="No"/>
<input type="button" onclick="majAccept()" value="Yes"/>
</div>
<!-- ..... Flèches de déplacement ..... -->
<div class="flecheDeplacement" id="flecheHaut" onclick="if(fonction3D){display3D.zoom(1.25)}else{affichage.deplacerY(1)}" onmousemove="souris.move(event)"></div>
<div class="flecheDeplacement" id="flecheGauche" onclick="affichage.deplacerX(-1)" onmousemove="souris.move(event)"></div>
<div class="flecheDeplacement" id="flecheBas" onclick="if(fonction3D){display3D.zoom(0.8)}else{affichage.deplacerY(-1)}" onmousemove="souris.move(event)"></div>
<div class="flecheDeplacement" id="flecheDroite" onclick="affichage.deplacerX(1)" onmousemove="souris.move(event)"></div>
<!-- .... Add SVG display script .... -->
<embed id="embedSVG" src="JavaScript/AffichageSVG.svg" type="image/svg+xml" style="position:absolute; display:none; z-index: -1;"/>
</div>
</td>
<td id="background-right" class="background-border-y"></td>
</tr>
<tr class="background-border-x">
<td id="background-bottom-left" class="background-border-y"></td>
<td id="background-bottom"></td>
<td id="background-bottom-right" class="background-border-y"></td>
</tr>
</table>
<!-- Menu clique droite sur le graphique -->
<div id="ctxMenu">
<h1 id="ctxMenuDisplay">Display</h1>
<input type="checkbox" id="ctxAxes" checked="checked" onchange="affichage.axes = this.checked ? true : false ; affichage.dessiner()"/>
<label for="ctxAxes" id="ctxMenuAxes">Axes</label>
<div class="miniCouleur" id="ctxCouleurAxes" style="background-color:rgba(0,0,0,0.5)" title="affichage.couleurAxes" onclick="colorPicker.init(this.id); afficherMenu('menuCouleur'); ctxMenu.fermer()"></div>
<br/>
<input type="checkbox" id="ctxEchelle" checked="checked" onchange="affichage.echelle = this.checked ? true : false ; affichage.dessiner()"/>
<label for="ctxEchelle" id="ctxMenuScale">Scale</label>
<div class="miniCouleur" id="ctxCouleurEchelle" style="background-color:rgba(255,255,255,1)" title="affichage.couleurEchelle" onclick="colorPicker.init(this.id); afficherMenu('menuCouleur'); ctxMenu.fermer()"></div>
<br/>
<input type="checkbox" id="ctxGrille" checked="checked" onchange="affichage.grille = this.checked ? true : false ; affichage.dessiner()"/>
<label for="ctxGrille" id="ctxMenuGrid">Grid</label>
<div class="miniCouleur" id="ctxCouleurGrille" style="background-color:rgba(255,255,255,0.1)" title="affichage.couleurGrille" onclick="colorPicker.init(this.id); afficherMenu('menuCouleur'); ctxMenu.fermer()"></div>
<br/>
<input type="button" id="ctxMenuReset" class="bouton" value="Reset" onclick="affichage.initZoom2(document.getElementById('zoomDefaut').value); ctxMenu.fermer()"/>
<br/>
<input type="button" id="ctxMenuSave" class="bouton" value="Save" onclick="afficherMenu('menuSaveGraph'); ctxMenu.fermer()"/>
<div class="fermer" onclick="ctxMenu.fermer();">x</div>
</div>
<!-- Boutons de suppression des points et des ronds ajoutés -->
<span id="divSuppOutil"></span>
<!-- Messages d'aide -->
<div id="divMessages"></div>
<!-- .... Setup translations .... -->
<script type="text/javascript">languages.init();</script>
</body>
<!-- Widget made by Yannick Vessaz -->
<!-- E-mail: yannick.vessaz@gmail.com -->
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>GraphMe - Guide utilisateur</title>
<link rel="stylesheet" type="text/css" href="Style/Guide_Utilisateur.css"/>
</head>
<body>
<h1>GraphMe</h1>
<img src="Images/GraphMe.png"/>
<h1>Guide d'utilisation</h1>
<ol id="Sommaire">
<li><a href="#Introduction">Introduction</a></li>
<li><a href="#Installation">Installation</a></li>
<li><a href="#AfficherLeWidget">Afficher le widget</a></li>
<li><a href="#PresentationAffichage">Présentation de l'affichage</a></li>
<li><a href="#DessinerFonction">Dessiner une fonction</a></li>
<li><a href="#DeplacerAffichage">Se déplacer à travers la fonction</a></li>
<li><a href="#MenuOptions">Le menu des options</a></li>
<li><a href="#MenuOutils">Le menu des outils</a></li>
<li><a href="#PlusieursFonctions">Dessiner plusieurs fonctions</a></li>
<li><a href="#MaJ">Mettre à jour GraphMe</a></li>
<li><a href="#Contact">Contact</a></li>
</ol>
<h2 id="Introduction">1. Introduction</h2>
<p>
GraphMe est un traceur de fonctions mathématiques que j'ai programmé dans le cadre du travail de maturité gymnasiale. Il est codé en HTML, CSS et JavaScript. Ce grapheur est disponible sur un cd-rom accompagnant mon travail de maturité ainsi que sur internet à la page <a href="http://gyb.educanet2.ch/tm-widgets/.ws_gen/?15">http://gyb.educanet2.ch/tm-widgets/.ws_gen/?15</a>. Ce document a pour but d'expliquer comment utiliser GraphMe. Il présente ses différentes fonctions ainsi que quelques astuces utiles à l'utilisateur.
</p>
<h2 id="Installation">2. Installation</h2>
<p>
Le widget que vous pouvez télécharger sur internet est compressé au format zip. Avant de l'utiliser, il est nécessaire de le décompresser. Si vous n'avez aucuns programmes permettant d'ouvrir les fichiers zip, vous pouvez télécharger 7zip sur <a href="http://www.7-zip.org/">http://www.7-zip.org/</a>. GraphMe a été conçu pour s'utiliser dans un navigateur internet ou s'intégrer à Uniboard. Pour l'ajouter aux widgets d'Uniboard, il faut copier le dossier « GraphMe.wgt » dans « library/interactive/ ». Par exemple, sous Windows, le widget doit être dans : « C:/Program Files/Uniboard 4/library/interactive/GraphMe.wgt ». Si vous n'avez pas Uniboard, vous pouvez l'obtenir sur <a href="http://getuniboard.com">http://getuniboard.com/</a>.
</p>
<h2 id="AfficherLeWidget">3. Afficher le widget</h2>
<div class="droite"><img src="Images/Guide_Navigateur.png"/>Image de GraphMe dans un navigateur internet</div>
<p>
A) Pour afficher le widget dans un navigateur, il faut simplement ouvrir le fichier « Grapheur.xhtml » qui se trouve dans le dossier « GraphMe.wgt » avec votre navigateur internet. Toutefois, certains navigateurs n'arrivent pas à afficher le widget. La liste suivante contient les navigateurs sur lesquels le widget a été testé :
</p>
<ul>
<li>Mozilla Firefox (3.5) : tout fonctionne très bien.</li>
<li>Internet Explorer (8.0) : impossible d'ouvrir le widget, le format .xhtml n'est pas reconnu.</li>
<li>Internet Explorer (pré-version 9.0) : le widget est ouvrable mais seul l'affichage utilisant SVG fonctionne, « canvas » n'est toujours pas supporté.</li>
<li>Konqueror (4.3.4) : le widget s'ouvre mais il y a quelques problèmes d'affichage. Il est quand même utilisable en sélectionnant la méthode d'affichage « canvas » dans les options.</li>
<li>Rekonq (0.5) : le widget fonctionne très bien avec « canvas » mais est un peut lent en utilisant SVG.</li>
<li>Opera (10.51) : le widget est parfaitement utilisable</li>
<li>Google Chrome (4.1) : tout fonctionne également. L'affichage 3D est même très rapide comparé à d'autres navigateurs.</li>
</ul>
<p>
B) Pour ouvrir le widget dans Uniboard, il faut tout d'abord cliquer sur le bouton « Bibliothèque » en haut de la fenêtre. Ensuite, allez dans l'onglet « Interactif » ou autrement, selon les version d'Uniboard, dans l'onglet « Applications ». Cliquez sur l'icône correspondant à « Traceur de fonctions mathématiques » et finalement sur « Ajouter à la page ».
</p>
<div class="gauche"><img src="Images/Guide_Uniboard.png"/>Image de GraphMe dans Uniboard</div>
<img src="Images/Guide_AjouterWidget.png"/>
<h2 id="PresentationAffichage">4. Présentation de l'affichage</h2>
<ol>
<li>Champ permettant de définir la fonction à afficher.</li>
<li>Bouton affichant la fonction.</li>
<li>Bouton servant à ajouter une nouvelle fonction ou à accéder à l'historique des fonctions.</li>
<li>Zone d'affichage.</li>
<li>Options d'affichage permettant de définir la partie de la fonction à afficher.</li>
<li>Boutons de zoom.</li>
<li>Bouton servant à changer la couleur.</li>
<li>Boutons accédant aux différents menus.</li>
<li>Onglet choisissant entre les fonctions 2D et 3D.</li>
<li>Bouton de maximisation du widget.</li>
</ol>
<img src="Images/Guide_Presentation.png"/>
<h2 id="DessinerFonction">5. Dessiner une fonction</h2>
<p>
Pour dessiner une fonction mathématique, il suffit d'entrer celle-ci dans le champ en haut du widget et de cliquer sur le bouton « Afficher ». On peut utiliser différentes fonctions et constantes prédéfinies:
</p>
<h4>Les opérations de base</h4>
<ul>
<li>l'addition → +</li>
<li>la soustraction → -</li>
<li>la multiplication → *</li>
<li>la division → /</li>
<li>le modulo → %</li>
</ul>
<h4>Les fonctions trigonométriques</h4>
<ul>
<li>sin(x), cos(x), tan(x), cot(x)</li>
<li>asin(x), acos(x), atan(x), acot(x) ( ou arcsin(x), arccos(x), arctan(x), arccot(x) )</li>
</ul>
<h4>Les racines et les puissances</h4>
<ul>
<li>sqrt(x) fait la racine carrée de x</li>
<li>pow(x, y) élève un nombre x à une puissance y, par exemple :<br/>x² → pow(x, 2)<br/>(x+3)⁵ → pow((x+3), 5)</li>
<li>root(x, y) fait la racine yème d'un nombre x</li>
</ul>
<h4>Les exponentielles et logarithmes</h4>
<ul>
<li>exp(x)</li>
<li>ln(x) est le logarithme naturel</li>
<li>log(x) est le logarithme de base 10</li>
</ul>
<h4>Les arrondis</h4>
<ul>
<li>round(x) → arrondit à l'entier le plus proche</li>
<li>ceil(x) → arrondit à l'entier supérieur</li>
<li>floor(x) → arrondit à l'entier inférieur</li>
</ul>
<h4>Autres fonctions prédéfinies</h4>
<ul>
<li>abs(x) → la valeur absolue d'un nombre</li>
<li>random() → retourne un nombre aléatoire entre 0 et 1</li>
</ul>
<h4>Les constantes</h4>
<ul>
<li>pi = 4 * atan(1) ≈ 3.141592653589793</li>
<li>e = exp(1) ≈ 2.718281828459045 </li>
</ul>
<p>
Il n'est pas toujours facile de comprendre comment écrire la fonction désirée. En effet, une petite faute et elle ne s'affichera pas. De plus, il ne faut pas oublier de mettre un « * » entre les thermes à multiplier et d'utiliser le point « . » pour écrire des nombres à virgule.
</p>
<p>
Les fonctions en deux dimensions s'écrivent sous la forme : y=[...] et les fonctions en trois dimensions sous la forme : z=[...]. D'autres exemples sont disponibles dans le menu « aide » du widget si vous avez de la peine à entrer une fonction.
</p>
<h2 id="DeplacerAffichage">6. Se déplacer à travers la fonction</h2>
<p>
Parfois, lorsqu'on dessine une fonction, la zone visible n'est pas très intéressante. Pour cela, il est utile de déplacer l'affichage ou de définir soi-même la zone à afficher.
</p>
<img src="Images/Guide_Deplacement.png"/>
<p>
Pour déplacer la fonction, il suffit d'utiliser les flèches de navigation situées dans les quatre bords de l'affichage ou l'outil de déplacement à la souris (dans le menu « Outils »).
</p>
<p>
Pour définir la zone à afficher, il faut entrer des valeurs personnalisées dans les champs à gauche du widget. La valeur de gauche doit obligatoirement être plus petite que la valeur de droite. Dans le cas contraire, la fonction ne se dessinera pas.
</p>
<p>
Il est possible de zoomer ou dé-zoomer l'affichage en utilisant les boutons du menu de gauche pour voir une plus grande partie de la fonction. Le zoom peut être réinitialisé dans les options. On peut également cliquer deux fois sur le graphique pour zoomer ainsi que dé-zoomer en maintenant la touche « ctrl » appuyée et en cliquant deux fois.
</p>
<h2 id="MenuOptions">7. Le menu des options</h2>
<p>
Cliquez sur le bouton « Options » à gauche du widget pour ouvrir ce menu. En cliquant à nouveau sur le bouton, cela ferme le menu. Plusieurs onglets permettent de naviguer entre les différentes options. Description des options :
</p>
<ul>
<li>Le thème du widget change l'image de fond ainsi que différentes couleurs. Dans Uniboard, changer le thème permet de rendre le widget plus visible selon qu'il se trouve sur un fond noir ou un fond blanc.</li>
<li>La méthode d'affichage permet de définir la façon dont le graphique de la fonction sera dessiné. Il y a le choix entre six possibilités : <br/>
<ol>
<li>SVG est un format d'image vectoriel qui peut être intégré dans une page HTML. Il est compatible dans la plupart des navigateurs Internet et est très bien supporté par Uniboard, c'est pourquoi il est choisi par défaut.</li>
<li>« SVG (une image) » ne présente que peu de différence avec la méthode d'affichage « SVG ». A moins d'un problème de compatibilité, il n'est pas très utile de la choisir.</li>
<li>Canvas est une nouvelle balise présente depuis HTML 5.0. Elle permet de définir une zone dans laquelle on peut faire des dessins. Cette méthode d'affichage est plus rapide que d'utiliser du SVG, cependant, elle n'est pas complètement compatible dans Uniboard. Il est conseillé de choisir cette option si vous utilisez le widget ailleurs que dans Uniboard.</li>
<li>Canvas (point) utilise aussi canvas, mais dessine des points à la place de lignes.</li>
<li>XPM est un format d'image très peu connu. De ce fait, il est compatible qu'avec une minorité de navigateur.</li>
<li>La méthode d'affichage « Uniboard » permet de dessiner directement sur la page d'Uniboard avec les outils de dessins.</li>
</ol>
<img src="Images/Guide_Options.png"/>
</li>
<li>Le zoom par défaut ainsi que le bouton « réinitialiser le zoom » permettent de remettre l'affichage à l'état qu'il était à l'ouverture du widget. Cela permet aussi de centrer l'affichage sur l'origine.</li>
<li>Les options d'affichage permettent d'afficher ou non la grille, les axes ainsi que l'échelle. Elles sont utiles pour rendre l'affichage plus lisible. Il est également possible de modifier l'épaisseur du trait de la fonction.</li>
<li>Le décalage du graphique n'a en principe pas besoin d'être utilisé. Il permet de déplacer tout l'affichage dans un sens ou dans l'autre, s'il n'est pas centré à la bonne place. Cela peut arriver avec certains navigateurs Internet.</li>
<li>La précision des calculs du graphique permet d'augmenter ou de diminuer le nombre de points calculés. Plus le nombre est petit, plus la précision est grande. Il est utile de mettre cette valeur à « 0.01 » si vous dessinez des fonctions ressemblant à 0.5*sin(10*x*x).</li>
<li>Dans les options 3D, le style d'affichage permet de choisir comment la fonction est dessinée : avec des petits points ou avec des polygones (surfaces). La plupart des fonctions sont plus jolies en dessinant la surface entre les points calculés. Toutefois, c'est mieux de dessiner des points pour des fonctions comme la demi-sphère : sqrt(12-x*x-y*y).</li>
<li>Dans le dernier onglet, vous pouvez modifier d'autres options 3D, comme la précision des calculs ainsi que la couleur de la fonction.</li>
</ul>
<h2 id="MenuOutils">8. Le menu des outils</h2>
<p>
Ce menu permet tout d'abord de choisir l'action de la souris sur le graphique. Il y a le choix entre trois possibilités :
</p>
<ul>
<li>L'outil sélectionné par défaut est le point. En bougeant la souris, un point se déplace sur la fonction et les coordonnées de ce point sont indiquées en haut à gauche de l'affichage.</li>
<li>Le deuxième outil est le déplacement. Il permet de déplacer le graphique avec la souris. Il suffit de tenir cliqué sur l'affichage et de bouger la souris. Malheureusement, cet outil peut être lent sur certains navigateurs.</li>
<li>Le troisième outil est la tangente. Cet outil dessine la tangente à la fonction au point où se trouve la souris.</li>
</ul>
<p>
Ensuite, ce menu permet aussi de calculer un point de la fonction. Il faut simplement entrer la coordonnée « x » du point dont on veut trouver la coordonnée « y », et appuyer sur le bouton « Évaluer ». Par exemple, si la fonction est « x*x » et qu'on défini « x=2 », alors le point dont la coordonnée sur l'axe des X est « 2 » aura comme coordonnée sur l'axe des Y « 4 ».
</p>
<p>
Un autre outil très utile est l'étude de fonction. Pour étudier la fonction entrée dans le champ en haut du widget, cliquez sur « démarrer l'étude ». Les études de fonction de ce widget ne sont pas fiables à 100% mais servent de complément à une étude de fonction que l'on fait soi-même. Il se peut que cet outil soit amélioré dans une prochaine version du widget.
</p>
<p>
Dans ce menu, on trouve également des tests d'affichage. Ils permettent d'essayer les différentes méthodes d'affichage et de voir si elles fonctionnent sur le navigateur internet utilisé.
</p>
<h2 id="PlusieursFonctions">9. Dessiner plusieurs fonctions</h2>
<p>
Pour dessiner plusieurs fonctions simultanément, cliquez sur le petit bouton « + » qui se situe à droite du bouton « Afficher » (point 1). Ensuite, un menu apparaît.
</p>
<img src="Images/Guide_Plus.png"/>
<p>
Dans ce menu, des onglets permettent d'aller à l'historique ou aux fonctions supplémentaires (point 2). Pour ajouter une fonction, cliquez sur le bouton à droite de la fonction actuelle (point 3). En dessous, une liste contient toutes les fonctions affichées (point 4). Pour supprimer une fonction, il faut simplement cliquer sur le bouton « - » à coté de celle-ci. Il est également possible de modifier la couleur de chaque fonction séparément.
</p>
<p>
L'historique permet de revoir toutes les fonctions qui ont déjà été dessinées. Lorsque l'on clique sur une fonction de l'historique, celle qui est dessinée actuellement est remplacée par la fonction de l'historique.
</p>
<p>
Dessiner plusieurs fonctions simultanément est uniquement possible avec la méthode d'affichage « canvas » en deux dimensions. Par contre, l'historique est utilisable avec toutes les méthodes d'affichage.
</p>
<h2 id="MaJ">10. Mettre à jour GraphMe</h2>
<p>
La dernière version du widget est téléchargeable sur la page suivante : <a href="http://gyb.educanet2.ch/tm-widgets/.ws_gen/?15">http://gyb.educanet2.ch/tm-widgets/.ws_gen/?15</a>. Pour mettre à jour GraphMe, vous pouvez aussi cliquer sur le bouton "Mise à jour" dans le menu des options.
</p>
<h2 id="Contact">11. Contact</h2>
<p>
Si vous voulez rapporter un bug, avez une suggestion par rapport au widget ou voulez simplement poser une question, merci de me contacter par e-mail à l'adresse : <a href="mailto:yannick.vessaz@gmail.com">yannick.vessaz@gmail.com</a>.
</p>
</body>
</html>
\ No newline at end of file
// Convertir une coordonnée sur le graphique en position relative à l'affichage (ou à l'écran si ecran = true)
function coordToPosX(x, ecran){
if(ecran){
return coordToPosX(x, false)+affichage.offsetLeft;
}
else{
return (x - affichage.xGauche) * affichage.multX;
}
}
function coordToPosY(y, ecran){
if(ecran){
return coordToPosY(y, false)+affichage.offsetTop;
}
else{
return affichage.hauteur - (y - affichage.yBas) * affichage.multY;
}
}
var affichage = {
// Options
id : "affichage",
largeur : 640, // Set by init
hauteur : 430, // Set by init
couleurFond : "rgba(0,0,0,0)",
// Bornes (zone d'affichage)
xGauche : -5.5, // Set by init
xDroite : 5.5, // Set by init
yBas : -3.7,
yHaut : 3.7,
multX : 1,
multY : 1,
// Axes
axes : true,
couleurAxes : "rgba(0,0,0,0.5)",
widthAxes : 2,
// Grille
grille : true,
couleurGrille : "rgba(255,255,255,0.1)",
widthGrille : 2,
// Echelle
echelle : true,
couleurEchelle : "rgba(255,255,255,1)",
// Précision
precision : 100,
precisionAmelioree : true, // false = fonction plus jolie lorsqu'on dé-zoom, true = affichage plus rapide lors du dé-zoom.
// Méthode et style
methode : "canvas",
style : "continu",
// Variable définies lors de l'initialisation
canvas : null,
ctx : null,
object : null,
offsetTop : null, // Position de l'affichage par rapport à la page
offsetLeft : null,
init : function(element, width, height){
this.setBornes();
// Supprimer le contenu de l'affichage
if(!element){
element = document.getElementById(this.id);
}
if(element.hasChildNodes()){
while(element.childNodes.length >= 1 ){
element.removeChild(element.firstChild);
}
}
// Définir la taille
this.largeur = width || element.clientWidth;
this.hauteur = height || element.clientHeight;
// Set left and right proportionally to width, height, top and bottom
var centerX = this.xGauche + (this.xDroite - this.xGauche)/2;
var centerY = this.yBas + (this.yHaut - this.yBas)/2;
var dx = ((this.yHaut - this.yBas) / 2) * this.largeur / this.hauteur;
this.xGauche = Math.round((centerX - dx)*100)/100;
this.xDroite= Math.round((centerX + dx)*100)/100;
this.setBornes();
// Récupérer la position
var boundingClientRect = element.getBoundingClientRect();
this.offsetTop = boundingClientRect.top;
this.offsetLeft = boundingClientRect.left;
// Sélectionner la méthode d'affichage
if(this.methode == "svg"){
// this.object = document.createElement("embed");
// this.object.type = "image/svg+xml";
// this.object.src = "AffichageSVG.svg";
this.object = document.getElementById("embedSVG");
this.object.width = this.largeur;
this.object.height = this.hauteur;
this.object.style.top = this.offsetTop +1 +"px";
this.object.style.left = this.offsetLeft +1 +"px";
this.object.style.display = "block";
// element.appendChild(this.object);
// affichage.ctx = svg;
// affichage.dessiner();
// // Exécuter this.dessiner() maintenant ne va pas car svg n'est pas
// // encore défini dans cette fonction, il faut en lancer un nouvelle...
setTimeout("affichage.ctx = svg", 50);
setTimeout("affichage.dessiner()", 100);
}
else if(this.methode == "uniboard"){
if(window.uniboard || window.sankore){
try{
initUniboard();
this.ctx = uniboard;
this.dessiner();
}
catch(err){
alert(err.message);
}
}
else{
this.methode = "canvas";
this.setOptions();
this.init();
}
}
else{
document.getElementById("embedSVG").style.display = "none";
this.canvas = document.createElement("canvas");
this.canvas.width = this.largeur;
this.canvas.height = this.hauteur;
element.appendChild(this.canvas);
this.ctx = this.canvas.getContext("2d");
this.dessiner();
}
// Événements
if(window.addEventListener){
element = document.getElementById("eventAffichage");
element.addEventListener('DOMMouseScroll', souris.wheel, false);
element.onmousewheel = souris.wheel;
element.oncontextmenu = ctxMenu.ouvrir;
}
},
calculer : function(){
this.getBornes();
this.getOptions();
if(fonction3D){
display3D.draw()
}
else{
this.dessiner();
}
saveOptions();
},
dessiner : function(){
try{
// var ti = new Date().getTime();
var precision;
if(this.precisionAmelioree){
precision = 10/this.precision;
}
else{
precision = Math.abs(this.xDroite - this.xGauche)/this.precision;
}
this.multX = this.largeur/Math.abs(this.xDroite - this.xGauche);
this.multY = this.hauteur/Math.abs(this.yHaut - this.yBas);
var ctx = new Object();
ctx = this.ctx;
ctx.clearRect(0,0,this.largeur,this.hauteur);
ctx.fillStyle = this.couleurFond;
ctx.fillRect(0,0,this.largeur,this.hauteur);
ctx.strokeOpacity = 1; // svg
// Couleur pour l'aire sous la fonction
ctx.fillStyle = "rgba(0,180,255,0.3)";
// Fonctions
for(var i=0; i<fct.list.length; i++){
if(!fct.list[i]){
continue;
}
fct.list[i].plot(ctx, precision, affichage);
}
ctx.strokeOpacity = 0.2; // svg
// Grille et échelle
// var intervalX = Math.round(Math.abs(this.xGauche-this.xDroite)/10);
var interval = Math.round(Math.abs(this.yBas-this.yHaut)/10);
if(interval <= 0){
interval = 1;
}
// if(intervalY <= 0){
// intervalY = 1;
// }
var initialX = Math.floor(-this.xGauche) % interval;
var initialY = Math.floor(-this.yBas) % interval;
ctx.beginPath();
ctx.fillStyle = this.couleurEchelle;
ctx.strokeStyle = this.couleurEchelle;
ctx.lineWidth = this.widthGrille;
if(this.methode == "uniboard"){
ctx.lineWidth /= 2;
ctx.fillStyle = "rgb(0,0,0)";
ctx.strokeStyle = "rgb(100,100,100)";
}
for(var i=initialX; i<=Math.round(this.xDroite-this.xGauche); i=i+interval){
var position = Math.round((Math.ceil(this.xGauche) - this.xGauche +i) * this.multX);
if(this.grille){
ctx.moveTo(position, 0);
ctx.lineTo(position, this.hauteur);
}
if(this.echelle){
ctx.fillText(Math.ceil(i+this.xGauche), position-6, (this.hauteur-(-this.yBas*this.multY))-2);
}
}
for(var i=initialY;i<=Math.round(this.yHaut-this.yBas);i=i+interval){
var position = this.hauteur - Math.round((Math.ceil(this.yBas) - this.yBas +i) * this.multY);
if(this.grille){
ctx.moveTo(0, position);
ctx.lineTo(this.largeur, position);
}
if(this.echelle){
ctx.fillText(Math.ceil(i+this.yBas), (-this.xGauche*this.multX)+2, position+6);
}
}
ctx.strokeStyle = this.couleurGrille;
ctx.stroke();
ctx.strokeOpacity = 0.8; //svg
// Axes
if(this.axes){
ctx.beginPath();
ctx.strokeStyle = this.couleurAxes;
ctx.lineWidth = this.widthAxes;
if(this.methode == "uniboard"){
ctx.lineWidth *= 2;
ctx.strokeStyle = "rgb(0,0,0)";
}
ctx.moveTo(-this.xGauche*this.multX, 0)
ctx.lineTo(-this.xGauche*this.multX, this.hauteur)
ctx.moveTo(0, this.hauteur+this.yBas*this.multY)
ctx.lineTo(this.largeur, this.hauteur+this.yBas*this.multY)
ctx.stroke()
}
// Autres
outil.dessinerListe();
// var tf = new Date().getTime();
// window.console.log(tf-ti);
}
catch(err){
var message = err.message;
afficherErreur(message);
}
},
getBornes : function(){
this.xGauche = parseFloat(document.getElementById("borneXGauche").value);
this.xDroite = parseFloat(document.getElementById("borneXDroite").value);
this.yBas = parseFloat(document.getElementById("borneYGauche").value);
this.yHaut = parseFloat(document.getElementById("borneYDroite").value);
},
setBornes : function(){
document.getElementById("borneXGauche").value = this.xGauche;
document.getElementById("borneXDroite").value = this.xDroite;
document.getElementById("borneYGauche").value = this.yBas;
document.getElementById("borneYDroite").value = this.yHaut;
},
getOptions : function(){
this.axes = document.getElementById("checkAxes").checked ? true : false;
this.grille = document.getElementById("checkGrille").checked ? true : false;
this.echelle = document.getElementById("checkEchelle").checked ? true : false;
this.precision = document.getElementById("inputPrecision").value;
this.precisionAmelioree = document.getElementById("checkPrecision").checked ? true : false;
var methode = document.getElementById("selectMethodeAffichage").value;
if(methode != this.methode){
this.methode = methode;
this.init();
}
},
setOptions : function(){
document.getElementById("selectMethodeAffichage").value = this.methode;
document.getElementById("checkGrille").checked = this.grille;
document.getElementById("checkAxes").checked = this.axes;
document.getElementById("checkEchelle").checked = this.echelle;
document.getElementById("inputPrecision").value = this.precision;
document.getElementById("checkPrecision").checked = this.precisionAmelioree;
},
deplacerX : function(x){
if(fonction3D){
display3D.move(x);
return;
}
this.xGauche += x;
this.xDroite += x;
this.dessiner();
this.setBornes();
saveOptions();
},
deplacerY : function(y){
if(fonction3D){
return;
}
this.yHaut += y;
this.yBas += y;
this.dessiner();
this.setBornes();
saveOptions();
},
centrer: function(){
var valeurX = (this.xDroite-this.xGauche)/2;
var valeurY = (this.yHaut-this.yBas)/2;
this.initZoom(valeurX, valeurY);
},
initZoom : function(valeurX, valeurY){
if(fonction3D){
display3D.initZoom();
}
this.xGauche = -valeurX;
this.xDroite = valeurX;
this.yBas = -valeurY;
this.yHaut = valeurY;
this.setBornes();
this.dessiner();
},
initZoom2 : function(valeur){
var valeurY = parseFloat(valeur);
var valeurX = valeurY * this.largeur / this.hauteur;
this.initZoom(valeurX, valeurY);
},
zoom : function(facteur){
if(fonction3D){
return;
}
var diffBornes, ajouter;
// Horizontal
diffBornes = Math.abs(this.xDroite - this.xGauche);
ajouter = Math.round(diffBornes * (facteur-1)*2)/4;
// log(diffBornes, ajouter, facteur)
if(ajouter == 0){
ajouter = 0.25;
// log("affichage.zoom -> x : ajouter = 0.5")
}
this.xGauche -= ajouter;
this.xDroite += ajouter;
// Vertical
diffBornes = Math.abs(this.yHaut - this.yBas);
ajouter = Math.round(diffBornes * (facteur-1)*2)/4;
if(ajouter == 0){
ajouter = 0.25;
// log("affichage.zoom -> y : ajouter = 0.5")
}
this.yBas -= ajouter;
this.yHaut += ajouter;
this.dessiner();
this.setBornes();
saveOptions();
}
};
var fonction3D = false;
var outilPrecedent = "";
function activer3D(){
if(fonction3D){ // Si activé alors on le désative
fonction3D = false;
outil.choisir(outilPrecedent);
document.getElementById('onglet3D').innerHTML = "3D";
document.getElementById('zoomButtons').style.display = "block";
document.getElementById('toolButtons').style.display = "block";
affichage.init();
outil.init();
affichage.initZoom2(document.getElementById('zoomDefaut').value);
}
else{ // Sinon on l'active
fonction3D = true;
outilPrecedent = outil.actuel;
outil.choisir("deplacement");
document.getElementById('onglet3D').innerHTML = "2D";
document.getElementById('zoomButtons').style.display = "none";
document.getElementById('toolButtons').style.display = "none";
display3D.init();
outil.liste = [];
outil.init();
message.supprimer();
}
cacherMenu();
if(fonction3D){
if(document.getElementById('input3D').value == ""){
afficherMenu('menuFonctions3D');
}
else{
display3D.draw();
}
}
saveOptions();
}
var display3D = {
canvas: null,
ctx: null,
width: 0,
height: 0,
centerX: 0,
centerY: 0,
scale: 50,
linePrecision: 0.02,
functionPrecision: 0.2,
angle: Math.PI/8,
zoomValue: 1,
left: -6.5,
right: 6.5,
rouge3D: 0,
vert3D: 1,
bleu3D: 2,
couleurGenerale: 0,
background: "rgba(0, 0, 0, 0.5)",
init: function(width, height){
var displayElement = document.getElementById("affichage");
// Clear displayElement content
if(displayElement.hasChildNodes()){
while(displayElement.childNodes.length >= 1 ){
displayElement.removeChild(displayElement.firstChild);
}
}
// Setup sizes
this.width = width || displayElement.clientWidth;
this.height = height || displayElement.clientHeight;
this.centerX = this.width / 2;
this.centerY = this.height / 2;
// Create canvas
this.canvas = document.createElement("canvas");
this.canvas.width = this.width;
this.canvas.height = this.height;
displayElement.appendChild(this.canvas);
this.ctx = this.canvas.getContext('2d');
this.clear();
},
clear: function(){
var ctx = this.ctx;
ctx.clearRect(0, 0, this.width, this.height);
ctx.fillStyle = this.background;
ctx.fillRect(0, 0, this.width, this.height);
this.axes();
},
draw: function(){
// var ti = new Date().getTime();
// this.init();
this.clear();
var txtFct = fct.remplacer(fct.verifier(document.getElementById("input3D").value));
if(txtFct == ""){
return;
}
var func = new CartesianFunction(txtFct);
if(document.getElementById("selectAffichage3D").value == "points"){
var coordX, coordY, coordZ;
for(var x=this.left; x<this.right; x+=this.functionPrecision){
for(var y=this.left; y<this.right; y+=this.functionPrecision){
coordX = x;
coordY = y;
coordZ = func.f(x,y);
if(isNaN(coordZ)){
continue;
}
this.point3D(coordX, coordY, coordZ);
}
}
}
else{
var x1, y1, z1, x2, y2, z2, x3, y3, z3;
var x, y;
var valAngle = Math.round(this.angle/Math.PI);
if(valAngle%2==0){
for(var x1=this.left; x1<this.right; x1+=this.functionPrecision){
for(var y1=this.left; y1<this.right; y1+=this.functionPrecision){
x = x1;
y = y1;
z1 = func.f(x,y);
x2 = x1 + this.functionPrecision;
y2 = y1;
x = x2;
//y = y2;
z2 = func.f(x,y);
x3 = x2;
y3 = y2 + this.functionPrecision;
//x = x3
y = y3;
z3 = func.f(x,y);
x4 = x3 - this.functionPrecision;
y4 = y3;
x = x4;
//y = y4;
z4 = func.f(x,y);
if(isNaN(z1)||isNaN(z2)||isNaN(z3)||isNaN(z4)){
continue;
}
this.polygone3D(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4);
}
}
}
else{
for(var x1=this.right; x1>this.left; x1-=this.functionPrecision){
for(var y1=this.right; y1>this.left; y1-=this.functionPrecision){
x = x1;
y = y1;
z1 = func.f(x,y);
x2 = x1 - this.functionPrecision;
y2 = y1;
x = x2;
//y = y2;
z2 = func.f(x,y);
x3 = x2;
y3 = y2 - this.functionPrecision;
//x = x3;
y = y3;
z3 = func.f(x,y);
x4 = x3 + this.functionPrecision;
y4 = y3;
x = x4;
//y = y4;
z4 = func.f(x,y);
if(isNaN(z1)||isNaN(z2)||isNaN(z3)||isNaN(z4)){
continue;
}
this.polygone3D(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4);
}
}
}
}
// var tf = new Date().getTime();
// window.console.log(tf-ti);
},
// Dessine un point à la position (x, y, z)
point3D: function(x, y, z){
var posX = (Math.sin(this.angle)*x + Math.cos(this.angle)*y)*this.scale;
var posZ = -(z - Math.cos(this.angle)*x/2.6 + Math.sin(this.angle)*y/2.6)*this.scale;
var opacity = Math.round((1-((5+y*Math.sin(this.angle)-x*Math.cos(this.angle)) / 450)*this.scale)*1000)/1000;
var couleur = new Array();
couleur[0] = Math.round((5+z)*this.scale);
couleur[1] = Math.round(510 - (5+z)*this.scale);
couleur[2] = this.couleurGenerale;
if(opacity > 1){ opacity = 1; }
if(opacity < 0){ opacity = 0; }
if(couleur[0] > 255){ couleur[0] = 255; }
if(couleur[0] < 0){ couleur[0] = 0; }
if(couleur[1] > 255){ couleur[1] = 255; }
if(couleur[1] < 0){ couleur[1] = 0; }
var ctx = this.ctx;
ctx.save();
ctx.translate(this.centerX, this.centerY);
ctx.scale(this.zoomValue, this.zoomValue);
ctx.fillStyle = "rgba("+couleur[this.rouge3D]+","+couleur[this.vert3D]+", "+couleur[this.bleu3D]+", "+opacity+")";
ctx.fillRect(posX-1, posZ-1, 2, 2);
ctx.restore();
},
// Dessine un polygone qui a comme sommets : (x1, y1, z1) , (x2, y2, z2), (x3, y3, z3) et (x4, y4, z4)
polygone3D: function(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4){
var ctx = this.ctx;
ctx.save();
ctx.translate(this.centerX, this.centerY);
ctx.scale(this.zoomValue, this.zoomValue);
ctx.beginPath();
ctx.moveTo((Math.sin(this.angle)*x1 + Math.cos(this.angle)*y1)*this.scale , -(z1 - Math.cos(this.angle)*x1/2.6 + Math.sin(this.angle)*y1/2.6)*this.scale);
ctx.lineTo((Math.sin(this.angle)*x2 + Math.cos(this.angle)*y2)*this.scale , -(z2 - Math.cos(this.angle)*x2/2.6 + Math.sin(this.angle)*y2/2.6)*this.scale);
ctx.lineTo((Math.sin(this.angle)*x3 + Math.cos(this.angle)*y3)*this.scale , -(z3 - Math.cos(this.angle)*x3/2.6 + Math.sin(this.angle)*y3/2.6)*this.scale);
ctx.lineTo((Math.sin(this.angle)*x4 + Math.cos(this.angle)*y4)*this.scale , -(z4 - Math.cos(this.angle)*x4/2.6 + Math.sin(this.angle)*y4/2.6)*this.scale);
var opacity = Math.round((1-((5+y1*Math.sin(this.angle)-x1*Math.cos(this.angle)) / 450)*this.scale)*1000)/1000;
var couleur = new Array();
couleur[0] = Math.round((5+z1)*this.scale);
couleur[1] = Math.round(510 - (5+z1)*this.scale);
couleur[2] = this.couleurGenerale;
if(opacity > 1){ opacity = 1; }
if(opacity < 0){ opacity = 0; }
// for(var i=0; i<couleur.length; i++){
// couleur[i] -= parseInt((opacity*255));
// }
if(couleur[0] > 255){ couleur[0] = 255; }
if(couleur[0] < 0){ couleur[0] = 0; }
if(couleur[1] > 255){ couleur[1] = 255; }
if(couleur[1] < 0){ couleur[1] = 0; }
ctx.fillStyle = "rgba("+couleur[this.rouge3D]+","+couleur[this.vert3D]+", "+couleur[this.bleu3D]+", "+opacity+")";
ctx.strokeStyle = "rgba(0,0,0,0.1)";
ctx.closePath();
ctx.fill();
ctx.stroke();
ctx.restore();
},
// Dessine les axes
axes: function(){
for(var i=-5; i<5; i+=this.linePrecision){
this.point3D(0, 0, i);
}
for(var i=-5.5; i<5.5; i+=this.linePrecision){
this.point3D(i, 0, 0);
}
for(var i=-5.5; i<5.5; i+=this.linePrecision){
this.point3D(0, i, 0);
}
},
cube: function(x, y, z, r){
// Face de devant
for(var i=0; i<r; i+=this.linePrecision){
this.point3D(x+i, y, z);
}
for(var i=0; i<r; i+=this.linePrecision){
this.point3D(x+r, y+i, z);
}
for(var i=0; i<r; i+=this.linePrecision){
this.point3D(x+r-i, y+r, z);
}
for(var i=0; i<r; i+=this.linePrecision){
this.point3D(x, y+r-i, z);
}
// Face de derrière
for(var i=0; i<r; i+=this.linePrecision){
this.point3D(x+i, y, z+r);
}
for(var i=0; i<r; i+=this.linePrecision){
this.point3D(x+r, y+i, z+r);
}
for(var i=0; i<r; i+=this.linePrecision){
this.point3D(x+r-i, y+r, z+r);
}
for(var i=0; i<r; i+=this.linePrecision){
this.point3D(x, y+r-i, z+r);
}
// Arrêtes
for(var i=0; i<r; i+=this.linePrecision){
this.point3D(x, y, z+i);
}
for(var i=0; i<r; i+=this.linePrecision){
this.point3D(x, y+r, z+i);
}
for(var i=0; i<r; i+=this.linePrecision){
this.point3D(x+r, y, z+i);
}
for(var i=0; i<r; i+=this.linePrecision){
this.point3D(x+r, y+r, z+i);
}
},
// Change les couleurs de l'affichage 3D et affiche l'aperçu de celles-ci.
checkCouleurs3D: function(){
var rouge, vert, bleu;
var sensRouge, sensVert, sensBleu;
var precisionApercu = 64;
this.couleurGenerale = parseInt(document.getElementById("couleur3Dgenerale").value);
if(!this.couleurGenerale){
this.couleurGenerale = 0;
}
if(this.couleurGenerale < 0){
this.couleurGenerale = 0;
}
if(this.couleurGenerale > 255){
this.couleurGenerale = 255;
}
switch(document.getElementById("selectRouge3D").value){
case "plus":
this.rouge3D = 0;
rouge = 255;
sensRouge = -1;
break;
case "moins":
this.rouge3D = 1;
rouge = 0;
sensRouge = 1;
break;
case "tout":
this.rouge3D = 2;
rouge = this.couleurGenerale;
sensRouge = 0;
break;
}
switch(document.getElementById("selectVert3D").value){
case "plus":
this.vert3D = 0;
vert = 255;
sensVert = -1;
break;
case "moins":
this.vert3D = 1;
vert = 0;
sensVert = 1;
break;
case "tout":
this.vert3D = 2;
vert = this.couleurGenerale;
sensVert = 0;
break;
}
switch(document.getElementById("selectBleu3D").value){
case "plus":
this.bleu3D = 0;
bleu = 255;
sensBleu = -1;
break;
case "moins":
this.bleu3D = 1;
bleu = 0;
sensBleu = 1;
break;
case "tout":
this.bleu3D = 2;
bleu = this.couleurGenerale;
sensBleu = 0;
break;
}
document.getElementById("apercuCouleur3D").innerHTML = "<span style='background-color:rgba("+rouge+","+vert+","+bleu+",1);color:rgba(0,0,0,0);'>.</span>";
for(var i=0; i<precisionApercu; i++){
rouge = rouge + sensRouge*(256/precisionApercu);
vert = vert + sensVert*(256/precisionApercu);
bleu = bleu + sensBleu*(256/precisionApercu);
document.getElementById("apercuCouleur3D").innerHTML = document.getElementById("apercuCouleur3D").innerHTML + "<span style='background-color:rgba("+rouge+","+vert+","+bleu+",1);color:rgba(0,0,0,0);'>.</span>";
}
if(this.ctx){
this.draw();
}
},
zoom: function(value){
if(!fonction3D){
return;
}
this.zoomValue *= value;
this.left /= value;
this.right /= value;
this.functionPrecision /= value;
this.linePrecision /= value;
//alert(this.zoomValue+" ; "+this.left+" ; "+this.right+" ; "+this.functionPrecision+" ; "+this.linePrecision);
this.draw();
},
move: function(value){
this.angle += Math.PI/32 * value;
this.draw();
},
initZoom: function(){
this.angle = Math.PI/8;
this.zoomValue = 1;
this.left = -6.5;
this.right = 6.5;
this.draw();
}
};
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%">
<script type="text/javascript">
<![CDATA[
top.svg = {
cursorX : 50,
cursorY : 50,
fillStyle : "blue",
fillOpacity : 1,
strokeStyle : "red",
strokeOpacity : 1,
lineWidth : 1,
moveTo : function(x, y){
this.cursorX = x;
this.cursorY = y;
},
lineTo : function(x, y){
var newLine = document.createElementNS("http://www.w3.org/2000/svg", "line");
newLine.setAttribute("x1", this.cursorX);
newLine.setAttribute("y1", this.cursorY);
newLine.setAttribute("x2", x);
newLine.setAttribute("y2", y);
newLine.setAttribute("stroke", this.strokeStyle);
newLine.setAttribute("stroke-width", this.lineWidth);
newLine.setAttribute("stroke-opacity", this.strokeOpacity);
document.getElementById("affichageSVG").appendChild(newLine);
this.moveTo(x, y);
},
beginPath : function(){
this.moveTo(0,0);
},
stroke : function(){
// rien
},
fill : function(){
// rien
},
clearRect : function(){
var element = document.getElementById("affichageSVG");
if(element.hasChildNodes()){
while(element.childNodes.length >= 1 ){
element.removeChild(element.firstChild);
}
}
},
fillRect : function(x, y, l, h){
if(h<0){
h = Math.abs(h);
y -= h;
}
if(l<0){
l = Math.abs(l);
x -= l;
}
var newRect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
newRect.setAttribute("x", x);
newRect.setAttribute("y", y);
newRect.setAttribute("width", l);
newRect.setAttribute("height", h);
newRect.setAttribute("fill", this.fillStyle);
newRect.setAttribute("fill-opacity", this.fillOpacity);
document.getElementById("affichageSVG").appendChild(newRect);
},
arc : function(cx, cy, r){
var newCircle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
newCircle.setAttribute("cx", cx);
newCircle.setAttribute("cy", cy);
newCircle.setAttribute("r", r);
newCircle.setAttribute("fill", this.fillStyle);
newCircle.setAttribute("fill-opacity", this.fillOpacity);
document.getElementById("affichageSVG").appendChild(newCircle);
},
fillText : function(txt, x, y){
var newText = document.createElementNS("http://www.w3.org/2000/svg", "text");
newText.setAttribute("x", x);
newText.setAttribute("y", y);
newText.setAttribute("fill", this.fillStyle);
newText.setAttribute("fill-opacity", 0.6);
newText.setAttribute("style", "font-size: 14px;");
newText.textContent = txt;
document.getElementById("affichageSVG").appendChild(newText);
}
}
]]>
</script>
<g id="affichageSVG">
</g>
</svg>
\ No newline at end of file
// -------------------- Uniboard --------------------
// Ces fonctions permettent de dessiner le graphique directement dans Uniboard.
function colorToHex(color) {
var addZero = function(myString){
if (myString.length == 1) return "0" + myString;
else return myString;
}
var digits = /(.*?)rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(color);
if (digits == null){
digits = /(.*?)rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(color);
}
if(digits == null){
return "";
}
var red = parseInt(digits[2]);
var green = parseInt(digits[3]);
var blue = parseInt(digits[4]);
var hexcode = addZero(red.toString(16)) + addZero(green.toString(16)) + addZero(blue.toString(16));
return '#' + hexcode.toUpperCase();
}
function initUniboard(){
if(!window.uniboard && window.sankore){
uniboard = sankore;
}
uniboard.centerOn(337,245);
// uniboard.setTool("pen");
// Paramètres par défaut
uniboard.lineWidth = 1;
uniboard.fillStyle = "black";
uniboard.strokeStyle = "black";
// Position du curseur pour écrire des nombres
uniboard.cursorX = 0;
uniboard.cursorY = 0;
// Fonctions
uniboard.strokeColor = function(){
this.setPenColor(colorToHex(this.strokeStyle));
};
uniboard.fillColor = function(){
this.setPenColor(colorToHex(this.fillStyle));
};
uniboard.lineTo = function(x, y){
if(y>-20 && y<affichage.hauteur+20){
this.strokeColor();
this.drawLineTo(x, y, this.lineWidth/2);
}
};
uniboard.arc = function(x, y, r){
this.fillColor();
this.moveTo(x, y);
this.drawLineTo(x, y, r*2);
};
uniboard.clearRect = function(x, y, width, height){
if(height<0){
height = Math.abs(height);
y -= height;
}
if(width<0){
width = Math.abs(width);
x -= width;
}
this.moveTo(x, y)
this.eraseLineTo(x+width, y+height, this.lineWidth);
};
uniboard.fillRect = function(x, y, width, height){
this.fillColor();
if(height<0){
height = Math.abs(height);
y -= height;
}
if(width<0){
width = Math.abs(width);
x -= width;
}
this.moveTo(x, y)
this.drawLineTo(x+width, y+height, this.lineWidth);
};
uniboard.fillText = function(txt, x, y){
// TODO
this.fillNumber(txt, x, y);
};
uniboard.beginPath = function(){
this.moveTo(0, 0);
};
uniboard.fill = function(){};
uniboard.stroke = function(){};
uniboard.fillNumber = function(nbr, x, y){
var w = 5;
var number = "" + nbr;
if(!x || !y){
x = this.cursorX;
y = this.cursorY;
}
else{
x += 3;
y -= 12;
}
this.moveTo(x, y);
this.fillColor();
var move = function(){
uniboard.moveTo(x, y);
};
var draw = function(){
uniboard.drawLineTo(x, y, uniboard.lineWidth)
};
var space = function(){
x += 2*w/3;
move();
};
for(var i=0; i<number.length; i++){
switch(number.charAt(i)){
case "1":
y += w
move()
x += w
y -= w
draw()
y += 2*w
draw()
y -= 2*w
space()
break;
case "2":
x += w
draw()
y += w
draw()
x -= w
draw()
y += w
draw()
x += w
draw()
y -= 2*w
space()
break;
case "3":
x += w
draw()
y += w
draw()
x -= w
draw()
x += w
move()
y += w
draw()
x -= w
draw()
y -= 2*w
x += w
space()
break;
case "4":
y += w
draw()
x += w
draw()
y -= w
draw()
y += w
move()
y += w
draw()
y -= 2*w
space()
break;
case "5":
x += w
move()
x -= w
draw()
y += w
draw()
x += w
draw()
y += w
draw()
x -= w
draw()
x += w
y -= 2*w
space()
break;
case "6":
x += w
move()
x -= w
draw()
y += w
draw()
x += w
draw()
y += w
draw()
x -= w
draw()
y -= w
draw()
x += w
y -= w
space()
break;
case "7":
x += w
draw()
x -= w/2
y += 2*w
draw()
x += w/2
y -= 2*w
space()
break;
case "8":
x += w
draw()
y += 2*w
draw()
x -= w
draw()
y -= 2*w
draw()
y += w
move()
x += w
draw()
y -= w
move()
space()
break;
case "9":
x += w
move()
x -= w
draw()
y += w
draw()
x += w
draw()
y += w
draw()
x -= w
draw()
y -= w
x += w
move()
y -= w
draw()
space()
break;
case "0":
x += w
draw()
y += 2*w
draw()
x -= w
draw()
y -= 2*w
draw()
x += w
move()
space()
break;
case "-":
y += w
move()
x += w
draw()
y -= w
move()
space()
break;
default: // Nombre inconnu
// this.showMessage("Error : "+number.charAt(i)+" isn't a number");
}
}
this.cursorX = x;
this.cursorY = y;
// this.showMessage(number);
}
}
function CartesianFunction(txtFct){
this.setFct = function(txt){
this.fct = txt;
this.f = new Function("x", "y", "return "+this.fct);
}
if(txtFct){
this.setFct(txtFct);
}
this.couleur = fct.couleur;
this.width = document.getElementById("inputTaille").value;
this.aire = document.getElementById("checkAire").checked ? true : false;
this.derivee1 = document.getElementById("checkDerivee1").checked ? true : false;
this.couleurDerivee1 = "rgba(255,128,0,1)";
this.derivee2 = document.getElementById("checkDerivee2").checked ? true : false;
this.couleurDerivee2 = "rgba(255,255,0,1)";
this.primitive1 = document.getElementById("checkPrimitive1").checked ? true : false;
this.couleurPrimitive1 = "rgba(255,50,0,1)";
this.conditionInitiale = 0;
this.style = document.getElementById("selectStyle").value;
this.getX = function(x){
return x;
};
this.getY = function(x){
return this.f(x);
};
this.set = function(f){
this.setFct(fct.remplacer(fct.verifier(f.fct)));
this.couleur = f.couleur;
this.couleurDerivee1 = f.couleurD1;
this.couleurDerivee2 = f.couleurD2;
this.couleurPrimitive1 = f.couleurP1;
this.width = f.width;
this.style = f.style;
this.aire = f.aire;
this.derivee1 = f.derivee1;
this.derivee2 = f.derivee2;
this.primitive1 = f.primitive1;
this.conditionInitiale = f.conditionInitiale;
return this;
};
this.get = function(){
var f = {};
f.type = "cartesian";
f.fct = this.fct;
f.couleur = this.couleur;
f.couleurD1 = this.couleurDerivee1;
f.couleurD2 = this.couleurDerivee2;
f.couleurP1 = this.couleurPrimitive1;
f.width = this.width;
f.style = this.style;
f.aire = this.aire;
f.derivee1 = this.derivee1;
f.derivee2 = this.derivee2;
f.primitive1 = this.primitive1;
f.conditionInitiale = this.conditionInitiale;
return f;
};
this.readableText = function(){
return "f(x) = " + this.fct;
};
this.plot = function(ctx, precision, affichage){
var x, y;
var pointX, pointY;
var nonDefini;
if(this.style == "points"){
precision *= 2;
}
// Dérivée première
if(this.derivee1){
ctx.beginPath();
ctx.strokeStyle = this.couleurDerivee1;
ctx.fillStyle = this.couleurDerivee1;
ctx.moveTo(-100,-100);
nonDefini = 1;
var pente;
var x0 = affichage.xGauche-precision;
var y0 = this.f(x0);
for(x = affichage.xGauche-precision*2; x <= affichage.xDroite+precision; x+=precision){
// Evaluer la valeur y du point x
y = this.f(x);
if(!isNaN(y)){
// Transformation des coordonnées
pente = (y-y0)/precision;
pointX = (x-precision/2 - affichage.xGauche) * affichage.multX;
pointY = affichage.hauteur - (pente - affichage.yBas) * affichage.multY;
y0 = y;
// Dessiner la dérivée
if(nonDefini>0){
nonDefini--;
ctx.moveTo(pointX, pointY);
}
else{
if(this.style == "continu"){
ctx.lineTo(pointX, pointY);
}
else if(this.style == "points"){
ctx.beginPath();
ctx.arc(pointX, pointY, this.width, 0, 2*Math.PI, true);
ctx.fill();
}
else{
ctx.lineTo(pointX, pointY);
nonDefini = 1;
}
}
}
else{
nonDefini = 2;
}
}
if(this.style != "points"){
ctx.stroke();
}
}
// Dérivée seconde
if(this.derivee2){
ctx.beginPath();
ctx.strokeStyle = this.couleurDerivee2;
ctx.fillStyle = this.couleurDerivee2;
ctx.moveTo(-100,-100);
nonDefini = 1;
var pente, pente2;
var x0 = affichage.xGauche-precision;
var y0 = this.f(x0);
var p0 = 0;
for(x = affichage.xGauche-precision*3; x <= affichage.xDroite+precision; x+=precision){
// Evaluer la valeur y du point x
y = this.f(x);
if(!isNaN(y)){
// Transformation des coordonnées
p = (y-y0)/precision;
pente = (p-p0)/precision;
pointX = (x-precision/2 - affichage.xGauche) * affichage.multX;
pointY = affichage.hauteur - (pente - affichage.yBas) * affichage.multY;
y0 = y;
p0 = p;
// Dessiner la dérivée seconde
if(nonDefini>0){
nonDefini--;
ctx.moveTo(pointX, pointY);
}
else{
if(this.style == "continu"){
ctx.lineTo(pointX, pointY);
}
else if(this.style == "points"){
ctx.beginPath();
ctx.arc(pointX, pointY, this.width, 0, 2*Math.PI, true);
ctx.fill();
}
else{
ctx.lineTo(pointX, pointY);
nonDefini = 1;
}
}
}
else{
nonDefini = 3;
}
}
if(this.style != "points"){
ctx.stroke();
}
}
// Primitive première
if(this.primitive1){
ctx.beginPath();
ctx.strokeStyle = this.couleurPrimitive1;
ctx.fillStyle = this.couleurPrimitive1;
ctx.moveTo(-affichage.xGauche*affichage.multX,affichage.hauteur-(this.conditionInitiale-affichage.yBas)*affichage.multY);
nonDefini = 0;
var pente, y0;
var conditionInitiale = this.conditionInitiale;
// precision /= 4;
// Partie droite
y0 = conditionInitiale;
for(x = precision; x <= affichage.xDroite+precision; x+=precision){
// Evaluer la valeur y du point x
pente = this.f(x);
if(!isNaN(pente)){
// Transformation des coordonnées
y = y0 + pente * precision;
pointX = (x - affichage.xGauche) * affichage.multX;
pointY = affichage.hauteur - (y - affichage.yBas) * affichage.multY;
y0 = y;
// Dessiner la primitive
if(nonDefini>0){
nonDefini--;
ctx.moveTo(pointX, pointY);
}
else{
if(this.style == "continu"){
ctx.lineTo(pointX, pointY);
}
else if(this.style == "points"){
ctx.beginPath();
ctx.arc(pointX, pointY, this.width, 0, 2*Math.PI, true);
ctx.fill();
}
else{
ctx.lineTo(pointX, pointY);
nonDefini = 1;
}
}
}
else{
nonDefini = 2;
}
}
if(this.style != "points"){
ctx.stroke();
}
// Partie gauche
ctx.beginPath();
ctx.moveTo(-affichage.xGauche*affichage.multX,affichage.hauteur-(this.conditionInitiale-affichage.yBas)*affichage.multY);
nonDefini = 0;
y0 = conditionInitiale;
for(x = -precision; x >= affichage.xGauche-precision; x-=precision){
// Evaluer la valeur y du point x
pente = this.f(x);
if(!isNaN(pente)){
// Transformation des coordonnées
y = y0 - pente * precision;
pointX = (x - affichage.xGauche) * affichage.multX;
pointY = affichage.hauteur - (y - affichage.yBas) * affichage.multY;
y0 = y;
// Dessiner la primitive
if(nonDefini>0){
nonDefini--;
ctx.moveTo(pointX, pointY);
}
else{
if(this.style == "continu"){
ctx.lineTo(pointX, pointY);
}
else if(this.style == "points"){
ctx.beginPath();
ctx.arc(pointX, pointY, this.width, 0, 2*Math.PI, true);
ctx.fill();
}
else{
ctx.lineTo(pointX, pointY);
nonDefini = 1;
}
}
}
else{
nonDefini = 2;
}
}
if(this.style != "points"){
ctx.stroke();
}
}
// Fonction
ctx.beginPath();
ctx.lineWidth = this.width;
if(affichage.methode == "uniboard"){
ctx.lineWidth *= 3;
}
ctx.strokeStyle = this.couleur;
ctx.fillStyle = this.couleur;
ctx.moveTo(-100,-100);
nonDefini = true;
for(x = affichage.xGauche-precision; x <= affichage.xDroite+precision; x+=precision){
// Evaluer la valeur y du point x
y = this.f(x);
if(!isNaN(y) && y <= affichage.yHaut+Math.abs(affichage.yHaut) && y >= affichage.yBas-Math.abs(affichage.yBas)){
// Transformation des coordonnées
pointX = (x - affichage.xGauche) * affichage.multX;
pointY = affichage.hauteur - (y - affichage.yBas) * affichage.multY;
// Dessiner la fonction
if(nonDefini){
nonDefini = false;
ctx.moveTo(pointX, pointY);
}
else{
if(this.style == "continu"){
ctx.lineTo(pointX, pointY);
}
else if(this.style == "points"){
ctx.beginPath();
ctx.arc(pointX, pointY, this.width, 0, 2*Math.PI, true);
ctx.fill();
}
else{
ctx.lineTo(pointX, pointY);
nonDefini = true;
}
}
// Dessiner l'aire sous la fonction
if(this.aire){
var zero = affichage.hauteur + affichage.yBas * affichage.multY;
var l = precision*affichage.multX;
ctx.fillStyle = "rgba(0,180,255,0.3)";
ctx.fillRect(pointX-l/2, zero, l , pointY-zero);
ctx.fillStyle = this.couleur;
}
}
else{
nonDefini = true;
}
}
if(this.style != "points"){
ctx.stroke();
}
if(this.style == "points"){
precision /= 2;
}
};
}
// -------------------- Color Picker --------------------
var idColor = "";
// Différentes fonctions nécessaire au Color Picker (menu du choix de la couleur)
var colorPicker = {
// Configuration
idSV : "canvasSV", // id du canvas affichant la saturation et la valeur
idT : "canvasT", // id du canvas affichant la teinte
idO : "canvasO", // id du canvas affichant l'opacité
width : 250, // largeur
height : 250, // hauteur
rayonRonds : 5, // rayon des ronds
ombreActive : "0px 0px 3px rgba(150,200,255,1), 0px 0px 8px rgba(64,190,255,1)",
ombreInactive : "0px 0px 5px rgba(64,64,64,0.4)",
// Variables définies lors de l'initialisation
canvasSV : null,
canvasT : null,
canvasO : null,
ctxSV : null,
ctxT : null,
ctxO : null,
lingradS : null,
lingradV : null,
lingradT : null,
// Couleurs
backgroundColor : "rgb(193,255,0)",
saturation : 100,
valeur : 100,
teinte : 75,
rouge : 193,
vert : 255,
bleu : 0,
opacity: 1,
// Couleurs RGB sans application de la saturation et de la valeur
r : 255,
g : 0,
b : 0,
// Autres variables
sourisDown : false, // Indique si on clique sur le colorPicker ou pas
sourisDehors : true, // Indique si la souris est en-dehors du colorPicker lors d'un clique
idColor : null,
// Fonction d'initialisation
init : function(id){
// Récupérer les éléments
this.canvasSV = document.getElementById(this.idSV);
this.canvasT = document.getElementById(this.idT);
this.canvasO = document.getElementById(this.idO);
// Définir la taille
this.canvasSV.width = this.width;
this.canvasSV.height = this.height;
this.canvasSV.style.width = this.width + "px";
this.canvasSV.style.height = this.height + "px";
this.canvasT.width = this.width/10;
this.canvasT.height = this.height;
this.canvasT.style.width = this.width/10 + "px";
this.canvasT.style.height = this.height + "px";
this.canvasO.width = this.width*1.15;
this.canvasO.height = this.height/10;
this.canvasO.style.width = this.width*1.15 + "px";
this.canvasO.style.height = this.height/10 + "px";
// Initialisation canvas
this.ctxSV = this.canvasSV.getContext("2d");
this.ctxT = this.canvasT.getContext("2d");
this.ctxO = this.canvasO.getContext("2d");
// Création des dégradés
this.lingradV = this.ctxSV.createLinearGradient(0, 0, 0, this.height);
this.lingradV.addColorStop(0, 'rgba(255,255,255,0)');
this.lingradV.addColorStop(1, 'rgba(255,255,255,1)');
this.lingradS = this.ctxSV.createLinearGradient(0, 0, this.width, 0);
this.lingradS.addColorStop(0, 'rgba(0,0,0,1)');
this.lingradS.addColorStop(1, 'rgba(0,0,0,0)');
this.lingradT = this.ctxT.createLinearGradient(0, 0, 0, this.height);
this.lingradT.addColorStop(0, 'rgb(255,0,0)');
this.lingradT.addColorStop(1/6, 'rgb(255,255,0)');
this.lingradT.addColorStop(2/6, 'rgb(0,255,0)');
this.lingradT.addColorStop(3/6, 'rgb(0,255,255)');
this.lingradT.addColorStop(4/6, 'rgb(0,0,255)');
this.lingradT.addColorStop(5/6, 'rgb(255,0,255)');
this.lingradT.addColorStop(1, 'rgb(255,0,0)');
// Événements roulette (initialisé seulement une fois)
if(window.addEventListener && !this.idColor){
this.canvasSV.addEventListener('DOMMouseScroll', function(event){colorPicker.eventWheel(event, colorPicker.idSV)}, false);
this.canvasSV.onmousewheel = function(event){colorPicker.eventWheel(event, colorPicker.idSV)};
this.canvasT.addEventListener('DOMMouseScroll', function(event){colorPicker.eventWheel(event, colorPicker.idT)}, false);
this.canvasT.onmousewheel = function(event){colorPicker.eventWheel(event, colorPicker.idT)};
this.canvasO.addEventListener('DOMMouseScroll', function(event){colorPicker.eventWheel(event, colorPicker.idO)}, false);
this.canvasO.onmousewheel = function(event){colorPicker.eventWheel(event, colorPicker.idO)};
}
// Définir la couleur
this.idColor = id;
var couleur = eval(document.getElementById(this.idColor).title);
// alert(id+" ; "+couleur)
document.getElementById("apercuCouleur").style.backgroundColor = couleur;
document.getElementById("apercuCouleur2").style.backgroundColor = couleur;
this.definirCouleur(couleur);
// Dessiner
this.dessiner();
this.dessinerApercu();
// Définir les valeurs des inputs
this.definirInputs();
// Définir le style de l'ombre
this.sourisOut();
},
definirCouleur : function(colorRGB){
var table = /(.*?)rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(colorRGB);
if (table == null){
table = /(.*?)rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(colorRGB);
}
if(table == null){
return "";
}
this.rouge = parseInt(table[2]);
this.vert = parseInt(table[3]);
this.bleu = parseInt(table[4]);
this.RGB_SVT();
},
sourisClick : function(id){
this.sourisDown = id;
if(id != this.idO){
document.getElementById(id).style.boxShadow = this.ombreActive;
}
},
sourisOut : function(){
this.canvasSV.style.boxShadow = this.ombreInactive;
this.canvasT.style.boxShadow = this.ombreInactive;
},
sourisOver : function(id){
if(this.sourisDown == id && id != this.idO){
document.getElementById(id).style.boxShadow = this.ombreActive;
}
},
sourisUp : function(){
this.sourisDown = false;
this.canvasSV.style.boxShadow = this.ombreInactive;
this.canvasT.style.boxShadow = this.ombreInactive;
this.dessinerO();
},
eventWheel : function(event, id){
if(!event) event = window.event;
if(event.wheelDelta){
if(event.wheelDelta < 0){
colorPicker.sourisWheelUp(id);
}
else{
colorPicker.sourisWheelDown(id);
}
}
else if(event.detail){
if(event.detail > 0){
colorPicker.sourisWheelUp(id);
}
else{
colorPicker.sourisWheelDown(id);
}
}
},
sourisWheelUp : function(id){
switch(id){
case this.idT:
colorPicker.ajouterT(5);
break;
case this.idO:
colorPicker.ajouterO(0.1);
break;
case this.idSV:
colorPicker.ajouterS(-5);
break;
}
},
sourisWheelDown : function(id){
switch(id){
case this.idT:
colorPicker.ajouterT(-5);
break;
case this.idO:
colorPicker.ajouterO(-0.1);
break;
case this.idSV:
colorPicker.ajouterS(5);
break;
}
},
ajouterT : function(nbr){
this.teinte += nbr;
if(this.teinte < 0){
this.teinte = 0;
}
else if(this.teinte > 360){
this.teinte = 360;
}
this.SVT_RGB();
},
ajouterO : function(nbr){
this.opacity = Math.round((this.opacity+nbr)*100)/100;
if(this.opacity < 0){
this.opacity = 0;
}
else if(this.opacity > 1){
this.opacity = 1;
}
this.SVT_RGB();
},
ajouterS : function(nbr){
this.saturation += nbr;
if(this.saturation < 0){
this.saturation = 0;
}
else if(this.saturation > 100){
this.saturation = 100;
}
this.SVT_RGB();
},
// Lors du déplacement de la souris
moveSV : function(event){
// Vérifie si on appuie sur la souris
if(this.sourisDown != this.idSV){
return 0;
}
var element = this.canvasSV;
var posDivY = 0;
var posDivX = 0;
// Récupérer la position du canvas par rapport à la page
while(element){
posDivY = posDivY + element.offsetTop;
posDivX = posDivX + element.offsetLeft;
element = element.offsetParent;
}
// Définir la saturation et la valeur à partir de la position de la souris
this.saturation = 100-Math.round((event.clientY - posDivY -1)/(this.height+1)*100);
this.valeur = Math.round((event.clientX - posDivX -1)/(this.width+1)*100);
this.SVT_RGB();
},
moveT : function(event){
if(this.sourisDown != this.idT){
return 0;
}
var element = this.canvasT;
var posDivY = 0;
while(element){
posDivY = posDivY + element.offsetTop;
element = element.offsetParent;
}
this.teinte = Math.round( (event.clientY - posDivY -0) / (this.height+1)*360);
this.SVT_RGB();
},
SVT_RGB : function(){
this.T_rgb();
this.rouge = Math.round((this.r + (255-this.r) * (-1) * (this.saturation-100) / 100 )* this.valeur / 100);
this.vert = Math.round((this.g + (255-this.g) * (-1) * (this.saturation-100) / 100 )* this.valeur / 100);
this.bleu = Math.round((this.b + (255-this.b) * (-1) * (this.saturation-100) / 100 )* this.valeur / 100);
this.definirInputs();
this.dessinerApercu();
this.dessiner();
},
T_rgb : function(){
var r,g,b = 0;
var T = this.teinte;
if (T<60){
r = 255;
g = T/60*255;
b = 0;
}
else if (T<120){
r = (255-(T%60/60*255))%256;
g = 255;
b = 0;
}
else if (T<180){
r = 0;
g = 255;
b = T%60/60*255;
}
else if (T<240){
r = 0;
g = (255-(T%60/60*255))%256;
b = 255;
}
else if (T<300){
r = T%60/60*255;
g = 0;
b = 255;
}
else if (T<360){
r = 255;
g = 0;
b = (255-(T%60/60*255))%256;
}
else{
r = 255;
g = 0;
b = 0;
}
this.r = Math.round(r);
this.g = Math.round(g);
this.b = Math.round(b);
},
RGB_SVT : function(){
// Voir http://fr.wikipedia.org/wiki/Teinte_Saturation_Valeur#Conversion_de_RVB_vers_TSV
var r = this.rouge/255;
var g = this.vert/255;
var b = this.bleu/255;
if(!isFinite(r)){
r = 0;
}
if(!isFinite(g)){
g = 0;
}
if(!isFinite(b)){
b = 0;
}
var max = Math.max(r,g,b);
var min = Math.min(r,g,b);
var s, v, t;
// Teinte
switch(max){
case r:
t = (60 * (g-b)/(max-min) + 360) % 360;
break;
case g:
t = 60 * (b-r)/(max-min) + 120;
break;
case b:
t = 60 * (r-g)/(max-min) + 240;
break;
default: /* case min: */
t = 0;
break;
}
// Saturation
if(max == 0){
s = 0;
}
else{
s = 1-(min/max);
}
// Valeur
v = max;
// Définir les variables
this.saturation = s*100;
this.valeur = v*100;
this.teinte = Math.round(t);
this.T_rgb();
},
dessiner : function(){
var ctxSV = this.ctxSV;
var ctxT = this.ctxT;
// Fond
ctxSV.fillStyle = "rgb("+this.r+","+this.g+","+this.b+")";
ctxSV.fillRect(0, 0, this.width, this.height);
// Dégradés
ctxSV.fillStyle = this.lingradV;
ctxSV.fillRect(0, 0, this.width, this.height);
ctxSV.fillStyle = this.lingradS;
ctxSV.fillRect(0, 0, this.width, this.height);
// Souris
var x = Math.round(this.width*this.valeur/100);
var y = Math.round(this.height-this.height*this.saturation/100);
ctxSV.beginPath();
ctxSV.arc(x, y, this.rayonRonds, 0, 2*Math.PI, true);
ctxSV.strokeStyle = "rgba(255,255,255,0.8)";
ctxSV.shadowOffsetX = 1;
ctxSV.shadowOffsetY = 1;
ctxSV.shadowColor = "rgba(0,0,0,1)";
ctxSV.shadowBlur = 2;
ctxSV.lineWidth = 1.5;
ctxSV.stroke();
// Fond Teinte
ctxT.fillStyle = this.lingradT;
ctxT.fillRect(0, 0, this.width/10, this.height);
// Souris Teinte
var pos = Math.round(0.99*this.height*this.teinte/360);
ctxT.fillStyle = "rgba(255,255,255,0.8)";
ctxT.shadowOffsetX = 0;
ctxT.shadowOffsetY = 0;
ctxT.shadowColor = "rgba(0,0,0,1)";
ctxT.shadowBlur = 3;
ctxT.fillRect(0, pos, this.width/10, 2);
// Désactiver les ombres
ctxSV.shadowColor = "rgba(0,0,0,0)";
ctxT.shadowColor = "rgba(0,0,0,0)";
this.dessinerO();
},
dessinerApercu : function(){
document.getElementById("apercuCouleur").style.backgroundColor = "rgba("+this.rouge+","+this.vert+","+this.bleu+","+this.opacity+")";
},
definirInputs : function(){
document.getElementById("inputValeur").value = this.valeur;
document.getElementById("inputSaturation").value = this.saturation;
document.getElementById("inputTeinte").value = this.teinte;
document.getElementById("inputRouge").value = this.rouge;
document.getElementById("inputVert").value = this.vert;
document.getElementById("inputBleu").value = this.bleu;
document.getElementById("inputOpacity").value = this.opacity;
},
recupererInputs : function(){
this.valeur = parseInt(document.getElementById("inputValeur").value);
this.saturation = parseInt(document.getElementById("inputSaturation").value);
this.teinte = parseInt(document.getElementById("inputTeinte").value);
this.opacity = parseFloat(document.getElementById("inputOpacity").value);
this.SVT_RGB();
this.definirInputs();
this.dessinerApercu();
this.dessiner();
},
recupererInputs2 : function(){
this.rouge = parseInt(document.getElementById("inputRouge").value);
this.vert = parseInt(document.getElementById("inputVert").value);
this.bleu = parseInt(document.getElementById("inputBleu").value);
this.RGB_SVT();
this.definirInputs();
this.dessinerApercu();
this.dessiner();
},
moveO : function(event){
if(this.sourisDown != this.idO){
return 0;
}
var element = this.canvasO;
var posDivX = 0;
while(element){
posDivX = posDivX + element.offsetLeft;
element = element.offsetParent;
}
this.opacity = Math.round( (event.clientX - posDivX -this.width/10) / (this.width*0.9)*100)/100;
if(this.opacity < 0){
this.opacity = 0;
}
else if(this.opacity > 1){
this.opacity = 1;
}
this.dessinerO();
this.definirInputs();
this.dessinerApercu();
},
dessinerO : function(){
var ctx = this.ctxO;
ctx.shadowBlur = 2;
// Ligne
if(this.sourisDown == this.idO){
ctx.shadowColor = "rgba(0,50,100,1)";
}
else{
ctx.shadowColor = "rgba(0,0,0,1)";
}
ctx.globalAlpha = 1;
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 0;
ctx.fillStyle = "rgba("+this.rouge+","+this.vert+","+this.bleu+",1)";
ctx.clearRect(0,0,this.width*1.15,this.height);
ctx.fillRect(this.width/10, this.height/20-1, this.width*0.9, 3);
// Rond
var x = this.width/10 + this.width*0.9*this.opacity-1;
var y = this.height/20;
if(this.sourisDown == this.idO){
ctx.fillStyle = "rgba(0,40,80,1)";
ctx.strokeStyle = "rgba(230,250,255,0.8)";
}
else{
ctx.fillStyle = "rgba(0,0,0,1)";
ctx.strokeStyle = "rgba(255,255,255,0.8)";
}
ctx.globalAlpha = 0.1+this.opacity*0.9;
ctx.beginPath();
ctx.arc(x, y, this.rayonRonds+1, 0, 2*Math.PI, true);
ctx.shadowColor = "rgba(0,0,0,1)";
ctx.shadowOffsetX = 1;
ctx.shadowOffsetY = 1;
ctx.lineWidth = 1;
ctx.fill();
ctx.stroke();
// Petits ronds
ctx.globalAlpha = 1;
ctx.shadowColor = "rgba(0,0,0,1)";
ctx.beginPath();
ctx.arc(8, this.height/20+0.5, this.rayonRonds, 0, 2*Math.PI, true);
ctx.strokeStyle = "rgba(0,0,0,0.5)";
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 0;
ctx.lineWidth = 1;
ctx.stroke();
ctx.beginPath();
ctx.arc(this.width*1.08, this.height/20+0.5, this.rayonRonds, 0, 2*Math.PI, true);
ctx.strokeStyle = "rgba(0,0,0,0.8)";
ctx.fillStyle = "rgba(0,0,0,0.6)";
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 0;
ctx.lineWidth = 1;
ctx.stroke();
ctx.fill();
},
exporterCouleur : function(){
eval(document.getElementById(this.idColor).title+' = "rgba(" + this.rouge +", " + this.vert + ", " + this.bleu +", "+this.opacity+")"');
document.getElementById(this.idColor).style.backgroundColor = eval(document.getElementById(this.idColor).title);
},
fermer : function(){
colorPicker.exporterCouleur();
if(colorPicker.idColor == 'buttonColor'){
cacherMenu();
}
else if(dernierMenu == "menuFonctions"){
editeur.getOptions();
afficherMenu(dernierMenu);
}
else{
cacherMenu();
}
actualiserGraph();
}
};
var editeur = {
idFct : 0,
fct : {
fct : "",
fctX : "",
fctY : "",
from : 0,
to : 2*Math.PI,
couleur : "",
couleurD1 : "",
couleurD2 : "",
couleurP1 : "",
width : 2,
style : "continu",
aire : false,
derivee1 : false,
derivee2 : false,
primitive1 : false,
conditionInitiale : 0
},
editer : function(id){
this.idFct = id;
if(fct.list[this.idFct]){
document.getElementById("editeurFonction").style.visibility = "visible";
this.setOptions();
}
else{
document.getElementById("editeurFonction").style.visibility = "hidden";
}
fct.updateList();
},
couleur : function(id){
colorPicker.init(id);
afficherMenu('menuCouleur');
},
getOptions : function(){
this.fct.fct = document.getElementById("editeurInput").value;
this.fct.fctX = document.getElementById("editeurFctX").value;
this.fct.fctY = document.getElementById("editeurFctY").value;
this.fct.from = document.getElementById("editeurFrom").value;
this.fct.to = document.getElementById("editeurTo").value;
this.fct.width = document.getElementById("editeurWidth").value;
this.fct.style = document.getElementById("editeurStyle").value;
this.fct.aire = document.getElementById("editeurAire").checked ? true : false;
this.fct.derivee1 = document.getElementById("editeurD1").checked ? true : false;
this.fct.derivee2 = document.getElementById("editeurD2").checked ? true : false;
this.fct.primitive1 = document.getElementById("editeurP1").checked ? true : false;
if(this.fct.primitive1){
document.getElementById("editeurConditionInitiale").disabled = "";
document.getElementById("editeurTexteConditionInitiale").style.color = "rgb(0,0,0)"
}
else{
document.getElementById("editeurConditionInitiale").disabled = "disabled";
document.getElementById("editeurTexteConditionInitiale").style.color = "rgb(128,128,128)"
}
this.fct.conditionInitiale = parseFloat(document.getElementById("editeurConditionInitiale").value);
fct.list[this.idFct].set(this.fct);
fct.updateList();
historique.ajouter(fct.list[this.idFct]);
this.apercu();
},
setOptions : function(){
var f = fct.list[this.idFct].get();
for(var i in f){
this.fct[i] = f[i];
}
this.setDisplayStyle();
document.getElementById("editeurInput").value = this.fct.fct;
document.getElementById("editeurFctX").value = this.fct.fctX;
document.getElementById("editeurFctY").value = this.fct.fctY;
document.getElementById("editeurFrom").value = this.fct.from;
document.getElementById("editeurTo").value = this.fct.to;
document.getElementById("editeurCouleur").style.backgroundColor = this.fct.couleur;
document.getElementById("editeurCouleurD1").style.backgroundColor = this.fct.couleurD1;
document.getElementById("editeurCouleurD2").style.backgroundColor = this.fct.couleurD2;
document.getElementById("editeurCouleurP1").style.backgroundColor = this.fct.couleurP1;
document.getElementById("editeurWidth").value = this.fct.width;
document.getElementById("editeurStyle").value = this.fct.style;
document.getElementById("editeurAire").checked = this.fct.aire ? "checked" : "";
document.getElementById("editeurD1").checked = this.fct.derivee1 ? "checked" : "";
document.getElementById("editeurD2").checked = this.fct.derivee2 ? "checked" : "";
document.getElementById("editeurP1").checked = this.fct.primitive1 ? "checked" : "";
if(this.fct.primitive1){
document.getElementById("editeurConditionInitiale").disabled = "";
document.getElementById("editeurTexteConditionInitiale").style.color = "rgb(0,0,0)"
}
else{
document.getElementById("editeurConditionInitiale").disabled = "disabled";
document.getElementById("editeurTexteConditionInitiale").style.color = "rgb(128,128,128)"
}
document.getElementById("editeurConditionInitiale").value = this.fct.conditionInitiale;
document.getElementById("outputX").innerHTML = " ";
document.getElementById("outputAire").innerHTML = " ";
this.apercu();
},
setDisplayStyle : function(){
if(fct.list[this.idFct] instanceof CartesianFunction){
document.getElementById("editeurFctPrefix").textContent = "f(x) = ";
document.getElementById("editeurFctDiv").style.display = "block";
document.getElementById("editeurFctXYDiv").style.display = "none";
document.getElementById("editeurRangeDiv").style.display = "none";
document.getElementById("editeurDeriveesDiv").style.display = "block";
document.getElementById("editeurStyleDiv").style.display = "block";
document.getElementById("editeurAireDiv").style.display = "block";
}
else if(fct.list[this.idFct] instanceof ImplicitFunction){
document.getElementById("editeurFctPrefix").textContent = "";
document.getElementById("editeurFctDiv").style.display = "block";
document.getElementById("editeurFctXYDiv").style.display = "none";
document.getElementById("editeurRangeDiv").style.display = "none";
document.getElementById("editeurDeriveesDiv").style.display = "none";
document.getElementById("editeurStyleDiv").style.display = "none";
document.getElementById("editeurAireDiv").style.display = "none";
}
else if(fct.list[this.idFct] instanceof PolarFunction){
document.getElementById("editeurFctPrefix").textContent = "r(t) = ";
document.getElementById("editeurFctDiv").style.display = "block";
document.getElementById("editeurFctXYDiv").style.display = "none";
document.getElementById("editeurRangeDiv").style.display = "block";
document.getElementById("editeurDeriveesDiv").style.display = "none";
document.getElementById("editeurStyleDiv").style.display = "block";
document.getElementById("editeurAireDiv").style.display = "none";
}
else if(fct.list[this.idFct] instanceof ParametricFunction){
document.getElementById("editeurFctDiv").style.display = "none";
document.getElementById("editeurFctXYDiv").style.display = "block";
document.getElementById("editeurRangeDiv").style.display = "block";
document.getElementById("editeurDeriveesDiv").style.display = "none";
document.getElementById("editeurStyleDiv").style.display = "block";
document.getElementById("editeurAireDiv").style.display = "none";
}
},
etudier : function(){
fct.etudier(this.idFct);
},
supprimer : function(){
fct.enlever(this.idFct);
if(!fct.list[this.idFct]){
this.editer(this.idFct - 1);
}
else{
this.editer(this.idFct);
}
},
dupliquer : function(){
fct.dupliquer(this.idFct);
this.editer(this.idFct + 1);
},
apercu : function(){
editorPreview.drawFunction(fct.list[this.idFct]);
}
};
var editorPreview = {
id : "editeurApercu",
xGauche : -5,
xDroite : 5,
yBas : -4,
yHaut : 4,
largeur : 0,
hauteur : 0,
multX : 1,
multY : 1,
ctx: null,
init : function(){
var canvas = document.getElementById("editeurApercu");
this.ctx = canvas.getContext("2d");
this.largeur = canvas.width;
this.hauteur = canvas.height;
this.multX = this.largeur/Math.abs(this.xDroite - this.xGauche);
this.multY = this.hauteur/Math.abs(this.yHaut - this.yBas);
this.precision = Math.abs(this.xDroite - this.xGauche)/50;
},
drawFunction : function(func){
var x, y, pointX, pointY;
var ctx = this.ctx;
ctx.clearRect(0,0,100,80);
ctx.globalAlpha = 0.7;
ctx.fillStyle = "rgba(0,0,0,0.5)"
ctx.fillRect(0,39.5, 100, 1);
ctx.fillRect(49.5,0, 1, 80);
ctx.beginPath();
// ctx.lineWidth = func.width/1.8;
// ctx.strokeStyle = func.couleur;
// ctx.moveTo(-100,-100);
// for(x = -5; x <= 5; x+=0.2){
// // Evaluer la valeur y du point x
// try{
// y = func.f(x);
// }
// catch(e){}
// if(!isNaN(y)){
// // Transformation des coordonnées
// pointX = x * 10 + 50;
// pointY = 40 - y * 10;
//
// // Dessiner la fonction
// ctx.lineTo(pointX, pointY);
// }
// }
func.plot(ctx, this.precision, this);
// ctx.stroke();
}
};
// -------------------- Etudes de fonctions --------------------
function consoleInfos(){
var table = [];
for(var i in arguments){
table.push(arguments[i]);
}
document.getElementById("infos").innerHTML += table +"<br/>";
}
Array.prototype.first = function(){
return this[0];
}
Array.prototype.last = function(){
return this[this.length-1];
}
Array.prototype.removeDoubles = function(){
// Sort numerically
this.sort(function(nbr1,nbr2){return nbr1-nbr2});
// Remove doubles
for(var i=1; i<this.length; i++){
if(this[i] == this[i-1]){
this.splice(i, 1);
i--;
}
}
}
var etude = {
f : null,
fct : "",
xGauche : -10,
xDroite : 10,
precision: 0.001,
listeX : [],
listeY : [],
listeD : [],
listeD2 : [],
listeIndefini : [],
listeZeros : [],
etudier : function(txtFct){
// document.getElementById("infos").innerHTML = "";
this.fct = fct.remplacer(fct.verifier(txtFct));
// this.fct = txtFct;
this.f = new Function("x", "return "+this.fct);
this.listeX = [];
this.listeY = [];
this.listeD = [];
this.listeD2 = [];
document.getElementById("etudeFdeX").innerHTML = ""+this.fct;
this.preparer();
this.ensembleDefNum();
this.pariteNum();
this.zerosNum();
this.signeNum();
this.asymptotesNum();
this.extremumsNum();
this.pointI();
},
round : function(nbr){
return Math.round(nbr*1000)/1000;
},
preparer : function(){
var f = this.f;
var a, b;
for(var x=this.xGauche; x<=this.xDroite; x+=this.precision){
x = this.round(x);
this.listeX.push(x);
this.listeY.push(f(x));
a = (f(x+0.0001)-f(x))/0.0001;
b = (f(x)-f(x-0.0001))/0.0001;
this.listeD.push((a+b)/2);
this.listeD2.push((b-a)/0.0001);
// this.listeD2.push(Math.round((b-a)*10000000)/100000000000);
if(x==0){
this.posZero = this.listeX.length-1;
}
// consoleInfos(x, f(x));
}
},
ensembleDefNum : function(){
var EDF = "";
var definie = false;
var listeIndefini = [];
if(isFinite(this.listeY.first())){
EDF += "]-∞;"
definie = true;
}
for(var i=0; i<this.listeY.length; i++){
// consoleInfos(i, definie, this.listeX[i])
if(definie){
if(!isFinite(this.listeY[i]) && isFinite(this.listeY[i-1])){
// consoleInfos(this.listeY[(i)], !isFinite(this.listeY[i+1]), definie)
if(!isFinite(this.listeY[i+1])){
definie = false;
// Définition de [ ou ] en fonction de l'entier le plus proche
if(Math.round(this.listeX[i-1]) == this.listeX[i-1]){
EDF += this.round(this.listeX[i-1])+"]";
}
else{
if(Math.round(this.listeX[i]) != this.listeX[i]){
// consoleInfos(Math.round(this.listeX[i-1]*10)/10, this.listeX[i-1]);
if(Math.round(this.listeX[i-1]*10)/10 == this.listeX[i-1]){
EDF += this.round(this.listeX[i-1])+"]";
}
else{
EDF += this.round(this.listeX[i])+"[";
}
}
else{
EDF += this.round(this.listeX[i])+"[";
}
}
}
else{
listeIndefini.push(this.listeX[i]);
}
}
}
else{
if(isFinite(this.listeY[i])){
definie = true;
if(EDF != ""){
EDF += " u ";
}
// Définition de [ ou ] en fonction de l'entier le plus proche
if(Math.round(this.listeX[i-1]) == this.listeX[i-1]){
EDF += "]"+this.round(this.listeX[i-1])+";";
}
else{
if(Math.round(this.listeX[i]) != this.listeX[i]){
if(Math.round(this.listeX[i-1]*10)/10 == this.listeX[i-1]){
EDF += "]"+this.round(this.listeX[i-1])+";";
}
else{
EDF += "["+this.round(this.listeX[i])+";";
}
}
else{
EDF += "["+this.round(this.listeX[i])+";";
}
}
}
}
}
if(definie && isFinite(this.listeY.last())){
EDF += "+∞["
definie = true;
}
for(var i=0; i<listeIndefini.length; i++){
if(i==0){
EDF += " - {"
}
EDF += listeIndefini[i]
if(i==listeIndefini.length-1){
EDF += "}"
}
else{
EDF += ";"
}
}
this.listeIndefini = listeIndefini;
document.getElementById("etudeEDF").textContent = EDF;
// consoleInfos("EDF = "+EDF);
},
pariteNum : function(){
var paire = true;
var impaire = true;
var yPositif, yNegatif;
for(var i=1; i<this.listeX.length/2; i++){
yPositif = this.listeY[this.posZero+i];
yNegatif = this.listeY[this.posZero-i];
if(yPositif<100000 && yPositif>-100000){
if(yPositif != yNegatif){
paire = false
}
if(yPositif != (-yNegatif)){
impaire = false
}
}
}
if(paire){
var text = "even";
try{
text = languages.getText("even");
}
catch(e){}
document.getElementById("etudeParite").textContent = text;
}
else if(impaire){
var text = "odd";
try{
text = languages.getText("odd");
}
catch(e){}
document.getElementById("etudeParite").textContent = text;
}
else{
var text = "odd";
try{
text = languages.getText("none_f");
}
catch(e){}
document.getElementById("etudeParite").textContent = text;
}
// consoleInfos("paire = "+paire);
// consoleInfos("impaire = "+impaire);
},
zerosNum : function(){
var f = this.f;
// Rechercher des zéros dans les points calculés
var listeZerosA = [];
for(var i=0; i<this.listeX.length; i++){
if(this.listeY[i] == 0){
listeZerosA.push(this.listeX[i]);
}
}
// consoleInfos("zérosA : "+listeZerosA);
// Recherche des zéros en prenant 2 points qui ne sont pas du même côté de l'axe
var listeZerosB = [];
var a, b;
for(var i=1; i<this.listeX.length-1; i++){
a = sign(this.listeY[i-1]);
b = sign(this.listeY[i+1]);
if(a!=b && a!=undefined && b!=undefined){
// consoleInfos(this.listeX[i]);
var zeros = [];
var check = false;
for(var x=this.listeX[i-1]; x<=this.listeX[i]; x+=this.precision/100){
// consoleInfos(f(x), this.round(f(x)));
if(this.round(f(x)) == 0){
check = true;
zeros.push(this.round(x));
// break;
}
}
if(check){
listeZerosB.push(zeros[Math.floor(zeros.length/2)]);
}
}
}
// consoleInfos("zérosB : "+listeZerosB);
// Résultat des deux méthodes
var listeZeros = listeZerosA.concat(listeZerosB);
listeZeros.removeDoubles();
this.listeZeros = listeZeros;
if(this.listeZeros.length == 0){
document.getElementById("etudeZeros").innerHTML = "Ø";
}
else{
document.getElementById("etudeZeros").innerHTML = "{"+listeZeros+"}";
}
// consoleInfos("zéros : "+listeZeros);
},
signeNum : function(){
var f = this.f;
var txtSigne = "";
var listeNbr = [];
// Remplire la liste des zéros et points indéf.
// true pour défini, false pour indéfini
// liste[0] <= point ; liste[1] <= true/false
for(var i=0; i<this.listeZeros.length; i++){
listeNbr.push([this.listeZeros[i], true]);
}
for(var i=0; i<this.listeIndefini.length; i++){
listeNbr.push([this.listeIndefini[i], false]);
}
// consoleInfos(listeNbr);
listeNbr.sort(function(nbr1,nbr2){return nbr1[0]-nbr2[0]});
// consoleInfos(listeNbr);
var dernierSigne;
var a, b;
switch(sign(this.listeY.first())){
case -1:
txtSigne += "<td>-</td>";
dernierSigne = "-";
break;
case 1:
txtSigne += "<td>+</td>";
dernierSigne = "+";
break;
}
for(var i=0; i<listeNbr.length; i++){
a = sign(f(listeNbr[i][0]-this.precision));
b = sign(f(listeNbr[i][0]+this.precision));
switch(a){
case -1:
if(dernierSigne != "-"){
txtSigne += "<td>-</td>";
}
break;
case 1:
if(dernierSigne != "+"){
txtSigne += "<td>+</td>";
}
break;
}
if(listeNbr[i][1]){
txtSigne += '<td class="bordure">'+listeNbr[i][0]+'</td>'
}
else{
txtSigne += '<td class="bordure fondNoir">'+listeNbr[i][0]+'</td>'
}
switch(b){
case -1:
txtSigne += "<td>-</td>";
dernierSigne = "-";
break;
case 1:
txtSigne += "<td>+</td>";
dernierSigne = "+";
break;
}
}
document.getElementById("etudeSigneRow").innerHTML = txtSigne;
// consoleInfos("<table><tr><td>Signe : </td>"+txtSigne+"</tr></table>");
},
asymptotesNum : function(){
var f = this.f;
// Verticales
var texteA = "";
for(var i=0; i<this.listeIndefini.length; i++){
if(texteA == ""){
texteA += "AV : " ;
}
if(i!=0){
texteA += " ; ";
}
texteA += "x = "+this.listeIndefini[i];
}
// consoleInfos("AV : "+texteA);
// Horizontales et obliques
var lim1, lim2, lim3, lim4, pente1, pente2;
var val1 = 100000;
var val2 = 10000;
// Gauche
lim1 = this.round(f(-val1));
lim2 = this.round(f(-val2));
lim3 = this.round(f(-val1+1));
lim4 = this.round(f(-val2+1));
// consoleInfos(lim1, lim2, lim3, lim4)
if(lim1==lim2){
// consoleInfos("AHG : y="+lim1);
if(texteA!=""){
texteA += "<br/>";
}
texteA += "AHG : y="+lim1;
}
else{
pente1 = this.round(lim3-lim1);
pente2 = this.round(lim4-lim2);
// consoleInfos(pente1, pente2);
if(pente1 == pente2 && pente1!=0){
// consoleInfos("AOG : y="+pente1+"x+"+(lim1+pente1*val1));
if(texteA!=""){
texteA += "<br/>";
}
texteA += "AOG : y="+pente1+"x+"+(lim1+pente1*val1);
}
}
// Droite
lim1 = this.round(f(val1));
lim2 = this.round(f(val2));
lim3 = this.round(f(val1+1));
lim4 = this.round(f(val2+1));
// consoleInfos(lim1, lim2, lim3, lim4)
if(lim1==lim2 && isFinite(lim1)){
// consoleInfos("AHD : y="+lim1);
if(texteA!=""){
texteA += "<br/>";
}
texteA += "AHD : y="+lim1;
}
else{
pente1 = this.round(lim3-lim1);
pente2 = this.round(lim4-lim2);
// consoleInfos(pente1, pente2);
if(pente1 == pente2 && pente1!=0){
// consoleInfos("AOD : y="+pente1+"x+"+(lim1-pente1*val1));
if(texteA!=""){
texteA += "<br/>";
}
texteA += "AOD : y="+pente1+"x+"+(lim1-pente1*val1);
}
}
if(texteA == ""){
texteA = "none";
try{
texteA = languages.getText("none_f");
}
catch(e){}
}
document.getElementById("etudeA").innerHTML = texteA;
},
extremumsNum : function(){
// Rechercher des zéros dans les points calculés
var listeID = [];
for(var i=1; i<this.listeX.length; i++){
if(Math.round(this.listeD[i]*10000000)/10000000 == 0){
listeID.push(i);
}
}
// Recherche des zéros en prenant 2 points qui ne sont pas du même côté de l'axe
var a, b;
for(var i=1; i<this.listeX.length-1; i++){
a = sign(this.listeD[i-1]);
b = sign(this.listeD[i+1]);
if(a!=b && a!=undefined && b!=undefined){
listeID.push(i);
}
}
// consoleInfos(listeID);
// Résultat des deux méthodes
listeID.removeDoubles();
var nbrI = 0;
var txtMinMax = "";
for(var j=0; j<listeID.length; j++){
var i = listeID[j];
var a = this.listeD[i-1];
var b = this.listeD[i+1];
// consoleInfos(a, b);
if(a<0 && b>0){
if(txtMinMax != ""){
txtMinMax += "<br/>";
}
txtMinMax += "Min("+this.listeX[i]+";"+this.round(this.listeY[i])+")";
}
else if(a>0 && b<0){
if(txtMinMax != ""){
txtMinMax += "<br/>";
}
txtMinMax += "Max("+this.listeX[i]+";"+this.round(this.listeY[i])+")";
}
}
// consoleInfos(txtMinMax);
if(txtMinMax == ""){
txtMinMax = "none";
try{
txtMinMax = languages.getText("none_m");
}
catch(e){}
}
document.getElementById("etudeMinMax").innerHTML = txtMinMax;
},
pointI : function(){
// Rechercher des zéros dans les points calculés
var listeID = [];
// for(var i=1; i<this.listeX.length; i++){
// if(Math.round(this.listeD2[i]*100000000)/100000000 == 0){
// listeID.push(i);
// // consoleInfos(this.listeD2[i-2], this.listeD2[i-1], this.listeD2[i], this.listeD2[i+1] ,this.listeD2[i+2]);
// }
// }
// Recherche des zéros en prenant 2 points qui ne sont pas du même côté de l'axe
var a, b;
for(var i=1; i<this.listeX.length-1; i++){
a = sign(this.listeD2[i-1]);
b = sign(this.listeD2[i+1]);
c1 = this.listeY[i-1];
c2 = this.listeY[i];
c3 = this.listeY[i+1];
// if(a!=b && a!=undefined && b!=undefined){
if(a!=b && a!=undefined && b!=undefined && isFinite(c1) && isFinite(c2) && isFinite(c3)){
// consoleInfos(this.listeD2[i-1],this.listeD2[i+1]);
listeID.push(i);
}
}
// consoleInfos(listeID);
// Résultat des deux méthodes
// listeID.removeDoubles();
var txtI = "";
for(var j=0; j<listeID.length; j++){
var i = listeID[j];
if(txtI != ""){
txtI += "<br/>";
}
txtI += 'I<span style="vertical-align:sub;font-size:50%;">'+(j+1)+"</span>("+this.listeX[i]+";"+this.round(this.listeY[i])+")";
}
// consoleInfos(txtI);
if(txtI == ""){
txtI = "none";
try{
txtI = languages.getText("none_m");
}
catch(e){}
}
document.getElementById("etudeI").innerHTML = txtI;
},
}
var fct = {
list : [],
couleur : "rgba(193,255,0,1)",
colorsList : ["rgba(255,0,0,1)","rgba(255,128,0,1)","rgba(255,255,0,1)","rgba(128,255,0,1)","rgba(0,255,0,1)","rgba(0,255,128,1)","rgba(0,255,255,1)","rgba(0,128,255,1)","rgba(0,0,255,1)","rgba(128,0,255,1)","rgba(255,0,255,1)","rgba(255,0,128,1)"],
interdit : [";", "interdit", "'", '"', "eval", "new", "uniboard", "sankore", "=", "document", "window", "alert", "fct", "affichage", "colorPicker", "languages"],
functionFromObject: function(f){
if(f.type == "cartesian"){
return new CartesianFunction().set(f);
}
else if(f.type == "implicit"){
return new ImplicitFunction().set(f);
}
else if(f.type == "polar"){
return new PolarFunction().set(f);
}
else if(f.type == "parametric"){
return new ParametricFunction().set(f);
}
console.err("Unknown function:", f);
},
addCartesian : function(txt){
var txtFct = this.remplacer(this.verifier(txt));
if(txtFct == ""){
return false;
}
var f = new CartesianFunction(txtFct);
this.add(f, true);
return true;
},
addImplicit : function(txtFct){
var equalPos = txtFct.indexOf("=");
if(equalPos >= 0){
txtFct = txtFct.replace("=", "-(") + ")";
}
txtFct = this.remplacer(this.verifier(txtFct));
if(txtFct == ""){
return false;
}
var f = new ImplicitFunction(txtFct);
this.add(f, true);
return true;
},
addPolar : function(txt){
var txtFct = this.remplacer(this.verifier(txt));
if(txtFct == ""){
return false;
}
var f = new PolarFunction(txtFct);
this.add(f, true);
return true;
},
addParametric : function(txtX, txtY){
var fctX = this.remplacer(this.verifier(txtX));
var fctY = this.remplacer(this.verifier(txtY));
if(fctX == "" || fctY == ""){
return false;
}
var f = new ParametricFunction(fctX, fctY);
this.add(f, true);
return true;
},
add : function(f, useRandomColor){
this.list.unshift(f);
if(useRandomColor){
f.couleur = this.colorsList[alea(0,this.colorsList.length-1)];
}
historique.ajouter(f);
this.updateList();
editeur.editer(0);
},
ajouter : function(){
var type = document.getElementById("functionType").value;
if(type == "cartesian"){
var input = document.getElementById("input");
if(this.addCartesian(input.value)){
input.value = "";
}
}
else if(type == "implicit"){
var input = document.getElementById("implicitInput");
if(this.addImplicit(input.value)){
input.value = "";
}
}
else if(type == "polar"){
var input = document.getElementById("polarInput");
if(this.addPolar(input.value)){
input.value = "";
}
}
else if(type == "parametric"){
var inputX = document.getElementById("parametricInputX");
var inputY = document.getElementById("parametricInputY");
if(this.addParametric(inputX.value, inputY.value)){
inputX.value = "";
inputY.value = "";
}
}
},
changeType : function(type){
document.getElementById("cartesianDiv").style.display = "none";
document.getElementById("implicitDiv").style.display = "none";
document.getElementById("polarDiv").style.display = "none";
document.getElementById("parametricDiv").style.display = "none";
document.getElementById(type+"Div").style.display = "initial";
},
enlever : function(id){
this.list.splice(id, 1);
this.updateList();
},
dupliquer : function(id){
var newFct = this.functionFromObject(this.list[id].get());
newFct.couleur = this.colorsList[alea(0,this.colorsList.length-1)];
this.list.splice(id+1, 0, newFct);
this.updateList();
},
etudier : function(id){
etude.etudier(this.list[id].fct);
afficherMenu("menuEtude");
},
updateList : function(){
var texteFctSupp = "";
for(var i=0; i<this.list.length; i++){
var className = "spanFonction";
if(i == editeur.idFct){
className += " spanFonctionSelect";
}
texteFctSupp += '<div class="'+className+'" onclick="editeur.editer('+i+')" style="text-shadow: 0px 0px 3px '+this.list[i].couleur+'">'+this.list[i].fct+'</div>';
}
document.getElementById("fonctionsSupp").innerHTML = texteFctSupp;
affichage.dessiner();
saveOptions();
},
verifier : function(txtFonction){
for(var i=0; i<this.interdit.length; i++){
var condition = "";
for(var k=0; k<this.interdit[i].length; k++){
if(k==0){
condition = condition + "txtFonction.charAt(j) == this.interdit[i].charAt(0)";
}
else{
condition = condition + "&& txtFonction.charAt(j+"+k+") == this.interdit[i].charAt("+k+")";
}
}
for(var j=0; j<txtFonction.length; j++){
if(eval(condition)){
document.getElementById("spanFctInterdite").innerHTML = this.interdit[i];
afficherMenu("fctInterdite");
return 0;
}
}
}
return txtFonction;
},
remplacer : function(txtFonction){
// Remplace a^b par pow(a, b)
var start = 0;
var end = 0;
var pos1, pos2;
while(true){
// start = end;
end = txtFonction.indexOf("^",0);
if(end != -1){
pos1 = txtFonction.getLastIndexOf(["+", "-", "*", "/", "%", "(", ","], start, end);
if(pos1 == -1){
pos1 = start-1;
}
pos2 = txtFonction.getIndexOf(["+", "-", "*", "/", "%", "^"], end+1);
if(pos2 == -1){
pos2 = txtFonction.length;
}
txtFonction = txtFonction.substring(0,pos1+1)+"pow("+txtFonction.substring(pos1+1,end)+","+txtFonction.substring(end+1,pos2)+")"+txtFonction.substring(pos2,txtFonction.length);
// alert(txtFonction)
}
else{
break;
}
}
return txtFonction;
},
get : function(){
var list = [];
for(var i=0; i<this.list.length; i++){
list.push(this.list[i].get());
}
return {list: list};
},
set: function(obj){
var list = obj.list;
for(var i=0; i<list.length; i++){
this.list.push(fct.functionFromObject(list[i]));
}
this.updateList();
if(this.list.length > 0){
editeur.editer(0);
}
}
};
function ImplicitFunction(txtFct){
this.setFct = function(txt){
this.fct = txt;
this.f = new Function("x", "y", "return "+this.fct);
}
if(txtFct){
this.setFct(txtFct);
}
this.couleur = fct.couleur;
this.width = document.getElementById("inputTaille").value;
this.style = document.getElementById("selectStyle").value;
this.getX = function(x){
return x;
};
this.getY = function(x){
return -1000000;
};
this.set = function(f){
var equalPos = f.fct.indexOf("=");
if(equalPos >= 0){
f.fct = f.fct.replace("=", "-(") + ")";
}
this.setFct(fct.remplacer(fct.verifier(f.fct)));
this.couleur = f.couleur;
this.width = f.width;
this.style = f.style;
return this;
};
this.get = function(){
var f = {};
f.type = "implicit";
f.fct = this.fct;
f.couleur = this.couleur;
f.width = this.width;
f.style = this.style;
return f;
};
this.readableText = function(){
return this.fct + " = 0";
};
this.plot = function(ctx, precision, affichage){
var epsilon = 0.01;
var width2 = this.width / 2;
precision /= 20;
ctx.beginPath();
ctx.lineWidth = this.width;
ctx.strokeStyle = this.couleur;
ctx.fillStyle = this.couleur;
ctx.moveTo(-100,-100);
for(var x = affichage.xGauche-precision; x <= affichage.xDroite+precision; x+=precision){
for(var y = affichage.yBas-precision; y <= affichage.yHaut+precision; y+=precision){
// Compute function for current (x, y) position
z = this.f(x, y);
// Check condition f(x, y) = 0
if(!isNaN(z) && Math.abs(z) < epsilon){
// Transform coordinates
var pointX = (x - affichage.xGauche) * affichage.multX;
var pointY = affichage.hauteur - (y - affichage.yBas) * affichage.multY;
ctx.fillRect(pointX-width2, pointY-width2, this.width, this.width);
// ctx.beginPath();
// ctx.arc(pointX, pointY, this.width, 0, 2*Math.PI, true);
// ctx.fill();
}
}
}
// ctx.stroke();
};
}
// -------------------- Fonctions de l'interface --------------------
var menuActuel = "divInputRapide"
var dernierMenu = ""
var pleinEcran = false
var maximise = true
var tailleFenetreX = window.innerWidth
var tailleFenetreY = window.innerHeight
var AncienneMethodeAffichage = 0
// Cette fonction permet d'afficher le menu désiré.
// Il faut lui donner l'id du menu à afficher.
function afficherMenu(id){
if (menuActuel == id){
cacherMenu()
dernierMenu = false;
}
else {
if (menuActuel != ""){
dernierMenu = menuActuel;
cacherMenu()
}
menuActuel = id
document.getElementById(id).style.display = "block"
message.supprimer();
}
}
// Permet de cacher le menu actuellement affiché
function cacherMenu(){
if(menuActuel != ""){
document.getElementById(menuActuel).style.display = "none"
menuActuel = ""
}
}
// Affiche un message d'erreur
function afficherErreur(message){
document.getElementById("spanErreurFct").innerHTML = message;
afficherMenu("erreurFct");
}
// Messages d'info
var message = {
liste : [],
ajouter : function(x, y, contenu){
var newDiv = document.createElement("div");
newDiv.style.left = x + "px";
newDiv.style.top = y + "px";
var textDiv = document.createElement("span");
textDiv.innerHTML = contenu;
newDiv.appendChild(textDiv);
document.getElementById("divMessages").appendChild(newDiv);
},
supprimer : function(){
var div = document.getElementById("divMessages");
div.innerHTML = "";
}
};
// ---- Minimiser ou Maximiser le widget (pour Uniboard) ----
function miniMax(){
if (maximise){
maximise = false
document.getElementById('affichage').style.display = "none"
document.getElementById('gauche').style.display = "none"
document.getElementById('miniMax').innerHTML = "+"
window.resizeTo(400,50)
AncienneMethodeAffichage = document.getElementById("selectMethodeAffichage").selectedIndex
document.getElementById("selectMethodeAffichage").selectedIndex = "3"
}
else{
maximise = true
document.getElementById('affichage').style.display = "block"
document.getElementById('gauche').style.display = "block"
document.getElementById('miniMax').innerHTML = "-"
window.resizeTo(tailleFenetreX,tailleFenetreY)
document.getElementById("selectMethodeAffichage").selectedIndex = AncienneMethodeAffichage
}
}
// Affiche le menu +
function menuFonctions(){
if(fonction3D){
afficherMenu('menuHistorique');
}
else{
afficherMenu('menuFonctions');
editeur.editer(0);
}
}
// Action des petits bouton + et - dans les options
function boutonPlus(id, nombre){
var element = document.getElementById(id)
var valeurActuelle = Number(element.value)
element.value = valeurActuelle + nombre
}
function boutonMoins(id, nombre){
var element = document.getElementById(id)
var valeurActuelle = Number(element.value)
if(valeurActuelle>=nombre*2){
element.value = valeurActuelle - nombre
}
}
// Changer de thème
function changerTheme(theme){
var positions = [
"top-left",
"top",
"top-right",
"right",
"bottom-right",
"bottom",
"bottom-left",
"left",
"center"
];
for(var i=0; i<positions.length; i++){
var pos = positions[i];
var id = "background-" + pos;
var path = "Images/" + theme + "/" + pos + ".png";
document.getElementById(id).style.backgroundImage = "url("+path+")";
}
// switch(theme){
// case "white":
// document.body.style.backgroundColor = "black";
// var couleurEchelle = "rgba(0,0,0,0.8)"
// var couleurGrille = "rgba(255,255,255,0.2)"
// var couleurAxes = "rgba(0,0,0,0.5)"
// break;
// default:
// document.body.style.backgroundColor = "transparent";
// var couleurEchelle = "rgba(255,255,255,0.8)"
// var couleurGrille = "rgba(255,255,255,0.1)"
// var couleurAxes = "rgba(0,0,0,0.5)"
// break;
// }
saveOptions();
}
// Affiche un message d'erreur
function error(err){
alert(" Erreur sur la page...\n\n Description: " + err.description + "\n\n Cliquez sur OK pour continuer.\n\n")
}
function agrandirAffichage(){
if(pleinEcran){
pleinEcran = false;
document.getElementById('background-center').style.paddingTop = "30px";
document.getElementById('ongletsHaut').style.display = "block";
document.getElementById('onglet3D').style.display = "block";
document.getElementById('boutonSaveGraph').style.display = "inline-block";
if(window.sankore || window.uniboard){
document.getElementById('zoneJoystick').style.display = "block";
document.getElementById('zoomButtons').style.display = "block";
document.getElementById('toolButtons').style.display = "block";
}
}
else{
pleinEcran = true;
document.getElementById('background-center').style.paddingTop = "0px";
document.getElementById('ongletsHaut').style.display = "none";
document.getElementById('onglet3D').style.display = "none";
document.getElementById('boutonSaveGraph').style.display = "none";
if(window.sankore || window.uniboard){
document.getElementById('zoneJoystick').style.display = "none";
document.getElementById('zoomButtons').style.display = "none";
document.getElementById('toolButtons').style.display = "none";
}
}
widget.resize();
}
// Ferme le widget
function close(){
window.close()
}
// Actions de mise à jour du widget
function miseAjour(){
var txtHTML = "";
document.getElementById("thisVersion").innerHTML = '<object type="text/html" data="version.html"></object>';
for(var i=0; i<listeServeurs.length; i++){
if(i != 0){
txtHTML += '<br/>';
}
txtHTML += '<object type="text/html" data="'+listeServeurs[i]+'version.html"></object>';
// txtHTML += '<input type="button" value="utiliser" onclick="document.location.href = \''+listeServeurs[i]+'Grapheur.html\'"/>';
// txtHTML += '<input type="button" value="télécharger" onclick="window.open(\''+listeServeurs[i]+'../GraphMe.zip\', \'_blank\')"/>';
}
document.getElementById("newVersion").innerHTML = txtHTML;
afficherMenu("mAj");
}
function checkboxMaJ(){
if(versionOnline()){
afficherMenu('erreurMaJ')
document.getElementById("checkMaJ").checked = false
}
else{
if(document.getElementById("checkMaJ").checked){
loadOptions()
document.getElementById("checkMaJ").checked = true
saveOptions()
}
else{
loadOptions()
document.getElementById("checkMaJ").checked = false
saveOptions()
}
}
}
function majAuto(){
// var audio = new Audio();
// audio.src = "version.ogg";
// audio.load();
// setTimeout(function(){
// window.console.log(" "+audio.duration);
// }, 0)
if(versionOnline()){
document.getElementById("cacheMaJ").style.display = "block";
document.getElementById("checkMaJ").disabled = true;
document.getElementById("checkMaJ").checked = true;
}
else{
if(document.getElementById("checkMaJ").checked){
afficherMenu('demandeMaJ');
}
}
}
function majAccept(){
// document.location.href='http://gyb.educanet2.ch/tm-widgets/yannick/GraphMe.wgt/Grapheur.html';
for(var i=0; i<listeServeurs.length; i++){
setTimeout(majServeur, i*500, listeServeurs[i]);
}
}
function majServeur(serveur){
var img = new Image();
img.onload = function(){
document.location.href = serveur + "Grapheur.html";
};
img.src = serveur + "icon.png";
}
// Retourne true si le widget est utilisé depuis un des sites en ligne
function versionOnline(){
for(var i=0; i<listeServeurs.length; i++){
if(document.location.href == listeServeurs[i]+"Grapheur.html"){
return true;
}
}
return false;
}
// Afficher une page web à la place dans la zone d'affichage
function navigateur(lien){
// cacherMenu()
// document.getElementById("affichage").innerHTML = '<object type="text/html" data="'+lien+'" style="width:100%;height:100%;"></object>'
window.open(lien, "_blank")
}
var languages = {
current: "en",
init: function(){
var lang = this.navigatorLanguage();
if(lang){
lang = lang.substr(0,2);
this.set(lang);
}
},
navigatorLanguage: function(){
if(window.sankore){
return sankore.locale();
}
return navigator.language || navigator.userLanguage;
},
set: function(lang){
if(lang in langTexts){
this.current = lang;
this.setTexts(langTexts[lang]);
}
},
getText: function(id){
return langTexts[this.current][id];
},
setTexts: function(texts){
this.id("graphMeButton").textContent = texts.widgetName;
this.id("functionsButton").textContent = texts.functions;
this.id("displayButton").textContent = texts.display;
this.id("helpButton").textContent = texts.help;
this.id("boutonAgrandir").title = texts.fullscreen;
this.id("boutonSaveGraph").title = texts.save;
this.id("inputRapideButton").value = texts.displayAction;
this.id("pointTool").title = texts.pointTool;
this.id("moveTool").title = texts.moveTool;
this.id("tangentTool").title = texts.tangentTool;
this.id("menuExempleCloseButton").value = texts.close;
this.id("menuGraphMeOptionsTab").textContent = texts.options;
this.id("menuGraphMeAboutTab").textContent = texts.about;
this.id("widgetOptions").textContent = texts.widgetOptions;
this.id("widgetTheme").textContent = texts.widgetTheme;
this.id("selectThemeDarkBlue").textContent = texts.darkBlue;
this.id("selectThemeBlack").textContent = texts.black;
this.id("selectThemeBlue").textContent = texts.blue;
this.id("selectThemeWhite").textContent = texts.white;
this.id("resetWidgetButton").value = texts.resetWidget;
this.id("checkForUpdateButton").value = texts.checkForUpdate;
this.id("menuGraphMeCloseButton").value = texts.close;
this.id("menuCreditsOptionsTab").textContent = texts.options;
this.id("menuCreditsAboutTab").textContent = texts.about;
this.id("widgetDevelopedBy").textContent = texts.widgetDevelopedBy;
this.id("widgetContactInfo").textContent = texts.widgetContactInfo;
this.id("widgetBackgroundSource").textContent = texts.widgetBackgroundSource;
this.id("changelogButton").textContent = texts.changelogButton;
this.id("menuCreditsCloseButton").value = texts.close;
this.id("changelogTitle").textContent = texts.changelogTitle;
this.id("menuChangelogBackButton").value = texts.back;
this.id("menuChangelogCloseButton").value = texts.close;
this.id("menuAffichageDisplayParametersTab").textContent = texts.displayParameters;
this.id("menuAffichageFunctionsParametersTab").textContent = texts.functionsParameters;
this.id("plotRange").textContent = texts.plotRange;
this.id("xAxis").textContent = texts.xAxis;
this.id("yAxis").textContent = texts.yAxis;
this.id("xAxisTo").textContent = texts.to;
this.id("yAxisTo").textContent = texts.to;
this.id("defaultZoom").textContent = texts.defaultZoom;
this.id("defaultDisplayParameters").value = texts.defaultDisplayParameters;
this.id("displayOptions").textContent = texts.options;
this.id("displayMethod").textContent = texts.displayMethod;
this.id("showGrid").textContent = texts.showGrid;
this.id("showAxis").textContent = texts.showAxis;
this.id("showScale").textContent = texts.showScale;
this.id("graphAccuracy").textContent = texts.graphAccuracy;
this.id("improveAccuracy").textContent = texts.improveAccuracy;
this.id("menuAffichageOkButton").value = texts.ok;
this.id("menuFunctionParametersDisplayParametersTab").textContent = texts.displayParameters;
this.id("menuFunctionParametersFunctionsParametersTab").textContent = texts.functionsParameters;
this.id("defaultFunctionParameters").textContent = texts.defaultFunctionParameters;
this.id("thickness").textContent = texts.thickness;
this.id("drawDerivativeAndPrimitive").textContent = texts.drawDerivativeAndPrimitive;
this.id("drawArea").textContent = texts.drawArea;
this.id("lineStyle").textContent = texts.lineStyle;
this.id("selectStyleLine").textContent = texts.styleLine;
this.id("selectStyleDotted").textContent = texts.styleDotted;
this.id("selectStyleDashed").textContent = texts.styleDashed;
this.id("menuFunctionParametersCloseButton").value = texts.close;
this.id("display3D").textContent = texts.display3D;
this.id("displayStyle").textContent = texts.displayStyle;
this.id("displayStyleSurfaces").textContent = texts.styleSurfaces;
this.id("displayStyleDotted").textContent = texts.styleDotted;
this.id("resetDisplay3D").value = texts.resetDisplay;
this.id("graphAccuracy3D").textContent = texts.graphAccuracy;
this.id("colorsConfig").textContent = texts.colorsConfig;
this.id("useRedFor").textContent = texts.useRedFor;
this.id("useGreenFor").textContent = texts.useGreenFor;
this.id("useBlueFor").textContent = texts.useBlueFor;
this.id("redPositive").textContent = texts.positiveValues;
this.id("redNegative").textContent = texts.negativeValues;
this.id("redAlways").textContent = texts.always;
this.id("greenPositive").textContent = texts.positiveValues;
this.id("greenNegative").textContent = texts.negativeValues;
this.id("greenAlways").textContent = texts.always;
this.id("bluePositive").textContent = texts.positiveValues;
this.id("blueNegative").textContent = texts.negativeValues;
this.id("blueAlways").textContent = texts.always;
this.id("globalValue").textContent = texts.globalValue;
this.id("globalValueRange").textContent = texts.globalValueRange;
this.id("menuAffichage3dOk").value = texts.ok;
this.id("menuAideUsageTab").textContent = texts.usage;
this.id("menuAideExamplesTab").textContent = texts.examples;
this.id("howItWorks").textContent = texts.howItWorks;
this.id("howItWorksText").textContent = texts.howItWorksText;
this.id("availableFunctionsText").textContent = texts.availableFunctionsText;
this.id("basicOperations").textContent = texts.basicOperations;
this.id("plus").textContent = texts.plus;
this.id("minus").textContent = texts.minus;
this.id("multiplication").textContent = texts.multiplication;
this.id("division").textContent = texts.division;
this.id("modulus").textContent = texts.modulus;
this.id("trigonometricFunctions").textContent = texts.trigonometricFunctions;
this.id("sine").textContent = texts.sine;
this.id("cosine").textContent = texts.cosine;
this.id("tangent").textContent = texts.tangent;
this.id("cotangent").textContent = texts.cotangent;
this.id("secant").textContent = texts.secant;
this.id("cosecant").textContent = texts.cosecant;
this.id("arcSine").textContent = texts.arcSine;
this.id("arcCosine").textContent = texts.arcCosine;
this.id("arcTangent").textContent = texts.arcTangent;
this.id("arcCotangent").textContent = texts.arcCotangent;
this.id("hyperbolicFunctions").textContent = texts.hyperbolicFunctions;
this.id("hypSine").textContent = texts.hypSine;
this.id("hypCosine").textContent = texts.hypCosine;
this.id("hypTangent").textContent = texts.hypTangent;
this.id("hypCotangent").textContent = texts.hypCotangent;
this.id("hypSecant").textContent = texts.hypSecant;
this.id("hypCosecant").textContent = texts.hypCosecant;
this.id("hypArcSine").textContent = texts.hypArcSine;
this.id("hypArcCosine").textContent = texts.hypArcCosine;
this.id("hypArcTangent").textContent = texts.hypArcTangent;
this.id("hypArcCotangent").textContent = texts.hypArcCotangent;
this.id("powerAndRoot").textContent = texts.powerAndRoot;
this.id("squareRoot").textContent = texts.squareRoot;
this.id("power").textContent = texts.power;
this.id("xPowY").textContent = texts.xPowY;
this.id("root").textContent = texts.root;
this.id("rootText").textContent = texts.rootText;
this.id("expAndLog").textContent = texts.expAndLog;
this.id("naturalLog").textContent = texts.naturalLog;
this.id("decimalLog").textContent = texts.decimalLog;
this.id("absValue").textContent = texts.absValue;
this.id("rounding").textContent = texts.rounding;
this.id("roundText").textContent = texts.roundText;
this.id("ceilText").textContent = texts.ceilText;
this.id("floorText").textContent = texts.floorText;
this.id("constants").textContent = texts.constants;
this.id("keyboardShortcuts").textContent = texts.keyboardShortcuts;
this.id("moveLeft").textContent = texts.moveLeft;
this.id("moveTop").textContent = texts.moveTop;
this.id("moveRight").textContent = texts.moveRight;
this.id("moveBottom").textContent = texts.moveBottom;
this.id("menuAideCloseButton").value = texts.close;
this.id("menuAideExemplesUsageTab").textContent = texts.usage;
this.id("menuAideExemplesExamplesTab").textContent = texts.examples;
this.id("examplesText").textContent = texts.examplesText;
this.id("functions2d").textContent = texts.functions2d;
this.id("functions3d").textContent = texts.functions3d;
this.id("menuAideExemplesCloseButton").value = texts.close;
this.id("functionStudyTitle").textContent = texts.functionStudy;
this.id("domainOfDefinition").textContent = texts.domainOfDefinition;
this.id("symmetry").textContent = texts.symmetry;
this.id("zeros").textContent = texts.zeros;
this.id("sign").textContent = texts.sign;
this.id("asymptotes").textContent = texts.asymptotes;
this.id("extremums").textContent = texts.extremums;
this.id("inflexionPoints").textContent = texts.inflexionPoints;
this.id("functionStudyText").textContent = texts.functionStudyText;
this.id("menuEtudeBackButton").value = texts.back;
this.id("menuEtudeCloseButton").value = texts.close;
this.id("menuFonctionsFunctionsTab").textContent = texts.functions;
this.id("menuFonctionsHistoryTab").textContent = texts.history;
this.id("newFunction").textContent = texts.newFunction;
this.id("functionTypeCartesian").textContent = texts.cartesian;
this.id("functionTypeImplicit").textContent = texts.implicit;
this.id("functionTypePolar").textContent = texts.polar;
this.id("functionTypeParametric").textContent = texts.parametric;
this.id("addFunctionButton").value = texts.add;
this.id("functionsListText").textContent = texts.functionsListText;
this.id("editorEditPageEditTab").textContent = texts.edit;
this.id("editorEditPageToolsTab").textContent = texts.tools;
this.id("editorRangeFrom").textContent = texts.from;
this.id("editorRangeTo").textContent = texts.to;
this.id("editorThickness").textContent = texts.thickness;
this.id("editorColor").textContent = texts.color;
this.id("editorDerivatives").textContent = texts.derivatives;
this.id("editorPrimitive").textContent = texts.primitive;
this.id("editorLineStyle").textContent = texts.lineStyle;
this.id("editorStyleLine").textContent = texts.styleLine;
this.id("editorStyleDotted").textContent = texts.styleDotted;
this.id("editorStyleDashed").textContent = texts.styleDashed;
this.id("editorDrawArea").textContent = texts.drawArea;
this.id("editorDuplicate").value = texts.duplicate;
this.id("editorRemove").value = texts.remove;
this.id("editorToolsPageEditTab").textContent = texts.edit;
this.id("editorToolsPageToolsTab").textContent = texts.tools;
this.id("computePoint").textContent = texts.computePoint;
this.id("computePointButton").value = texts.compute;
this.id("computeArea").textContent = texts.computeArea;
this.id("areaFrom").textContent = texts.from;
this.id("areaTo").textContent = texts.to;
this.id("computeAreaButton").value = texts.compute;
this.id("functionStudy").textContent = texts.functionStudy;
this.id("functionStudyButton").value = texts.startStudy;
this.id("editorToolsDuplicate").value = texts.duplicate;
this.id("editorToolsRemove").value = texts.remove;
this.id("menuFonctionsCloseButton").value = texts.close;
this.id("input3dDisplayButton").value = texts.displayAction;
this.id("menuHistoriqueFunctionsTab").textContent = texts.functions;
this.id("menuHistoriqueHistoryTab").textContent = texts.history;
this.id("latestDisplayedFunctions").textContent = texts.latestDisplayedFunctions;
this.id("menuHistoriqueCloseButton").value = texts.close;
this.id("chooseColor").textContent = texts.chooseColor;
this.id("colorPickerColor").textContent = texts.color;
this.id("colorPickerValue").textContent = texts.value;
this.id("colorPickerSaturation").textContent = texts.saturation;
this.id("colorPickerRed").textContent = texts.red;
this.id("colorPickerGreen").textContent = texts.green;
this.id("colorPickerBlue").textContent = texts.blue;
this.id("inputOpacity").textContent = texts.opacity;
this.id("apercuCouleur").title = texts.newColor;
this.id("apercuCouleur2").title = texts.oldColor;
this.id("colorPickerCancelButton").value = texts.cancel;
this.id("colorPickerOkButton").value = texts.ok;
this.id("blackListError").textContent = texts.error;
this.id("cannotDrawFunction").textContent = texts.cannotDrawFunction;
this.id("invalidExpression").textContent = texts.invalidExpression;
this.id("blackListErrorOkButton").value = texts.ok;
this.id("fctError").textContent = texts.error;
this.id("checkTheFunction").textContent = texts.checkTheFunction;
this.id("errorMessage").textContent = texts.errorMessage;
this.id("youCanFindExamples").textContent = texts.youCanFindExamples;
this.id("fctErrorHelpButton").value = texts.help;
this.id("fctErrorOkButton").value = texts.ok;
this.id("menuSaveGraphTitle").textContent = texts.saveGraph;
this.id("saveWidthText").textContent = texts.width;
this.id("saveHeightText").textContent = texts.height;
this.id("saveBackgroundColor").textContent = texts.backgroundColor;
this.id("imageFormat").textContent = texts.imageFormat;
this.id("menuSaveGraphCancelButton").value = texts.cancel;
this.id("menuSaveGraphOkButton").value = texts.ok;
this.id("saveImageTitle").textContent = texts.saveImageTitle;
this.id("saveImageText").textContent = texts.saveImageText;
this.id("menuSaveImageCloseButton").value = texts.close;
this.id("updateTitle").textContent = texts.update;
this.id("currentVersion").textContent = texts.currentVersion;
this.id("latestVersionAvailable").textContent = texts.latestVersionAvailable;
// this.id("useLatestVersionText").textContent = texts.useLatestVersionText;
// this.id("useLatestVersion").value = texts.useLatestVersion;
this.id("updateBackButton").value = texts.back;
this.id("updateOkButton").value = texts.ok;
this.id("updateErrorTitle").textContent = texts.error;
this.id("updateErrorText").textContent = texts.updateErrorText;
this.id("updateErrorOkButton").value = texts.ok;
this.id("ctxMenuDisplay").textContent = texts.display;
this.id("ctxMenuAxes").textContent = texts.axes;
this.id("ctxMenuScale").textContent = texts.scale;
this.id("ctxMenuGrid").textContent = texts.grid;
this.id("ctxMenuReset").value = texts.reset;
this.id("ctxMenuSave").value = texts.save;
},
class: function(className){
return document.getElementsByClassName(className);
},
id: function(id){
return document.getElementById(id);
}
};
var langTexts = {
"fr": {
"widgetName": "GraphMe",
"functions": "Fonctions",
"display": "Affichage",
"help": "Aide",
"close": "Fermer",
"back": "Retour",
"ok": "Ok",
"fullscreen": "Plein écran",
"save": "Sauvegarder",
"displayAction": "Afficher",
"pointTool": "Outil point",
"moveTool": "Outil déplacement",
"tangentTool": "Outil tangente",
"options": "Options",
"about": "À propos",
"darkBlue": "Bleu foncé",
"black": "Noir",
"blue": "Bleu",
"white": "Blanc",
"widgetOptions": "Options du widget",
"widgetTheme": "Thème du widget",
"resetWidget": "Réinitialiser le widget",
"checkForUpdate": "Vérifier les mises à jour",
"widgetDevelopedBy": "Widget réalisé par",
"widgetContactInfo": "Si vous voulez rapporter un bug, avez une suggestion par rapport au widget ou voulez simplement poser une question, merci de me contacter par e-mail à l'adresse suivante",
"widgetBackgroundSource": "Les images d'arrière-plan viennent de l'environnement de bureau KDE",
"changelogButton": "qu'est-ce qui a changé?",
"changelogTitle": "Notes de version",
"displayParameters": "Paramètres d'affichage",
"functionsParameters": "Paramètres des fonctions",
"plotRange": "Zone d'affichage",
"xAxis": "Axe des X",
"yAxis": "Axe des Y",
"to": "à",
"defaultZoom": "Zoom par défaut",
"defaultDisplayParameters": "Réinitialiser l'affichage",
"displayMethod": "Méthode d'affichage du graphique",
"showGrid": "Afficher la grille",
"showAxis": "Afficher les axes",
"showScale": "Afficher l'échelle",
"graphAccuracy": "Précision du graphique, points calculés",
"improveAccuracy": "Améliorer la précision lors d'un zoom arrière (plus lent)",
"defaultFunctionParameters": "Paramètres par défaut des fonctions",
"thickness": "Épaisseur",
"drawDerivativeAndPrimitive": "Dessiner les dérivées et primitives",
"drawArea": "Dessiner l'aire sous la fonction",
"lineStyle": "Style de ligne",
"styleLine": "continu",
"styleDotted": "points",
"styleDashed": "traits",
"display3D": "Affichage 3D",
"displayStyle": "Style d'affichage",
"styleSurfaces": "surfaces",
"resetDisplay": "Réinitialiser l'affichage",
"colorsConfig": "Configuration des couleurs",
"useRedFor": "utiliser le rouge pour",
"useGreenFor": "utiliser le vert pour",
"useBlueFor": "utiliser le bleu pour",
"positiveValues": "valeur positive",
"negativeValues": "valeur négative",
"always": "toujours",
"globalValue": "Valeur générale",
"globalValueRange": "(entre 0 et 255)",
"usage": "Utilisation",
"examples": "Exemples",
"howItWorks": "Fonctionnement",
"howItWorksText": "Ce widget vous permet de dessiner des fonctions mathématiques. Entrez une première fonction dans le champ en haut du widget et cliquez sur le bouton \"Afficher\". Ouvrez le menu \"Fonctions\" pour modifier votre fonction ou en ajouter une nouvelle.",
"availableFunctionsText": "Vous pouvez saisir les fonctions mathématiques suivantes",
"basicOperations": "Les opérations de base",
"plus": "Addition",
"minus": "Soustraction",
"multiplication": "Multiplication",
"division": "Division",
"modulus": "Modulo",
"trigonometricFunctions": "Les fonctions trigonométriques",
"sine": "Sinus",
"cosine": "Cosinus",
"tangent": "Tangente",
"cotangent": "Cotangente",
"secant": "Secante",
"cosecant": "Cosecante",
"arcSine": "Arcsinus",
"arcCosine": "Arccosinus",
"arcTangent": "Arctangente",
"arcCotangent": "Arccotangente",
"hyperbolicFunctions": "Les fonctions hyperboliques",
"hypSine": "Sinus hyp",
"hypCosine": "Cosinus hyp",
"hypTangent": "Tangente hyp",
"hypCotangent": "Cotangente hyp",
"hypSecant": "Secante hyp",
"hypCosecant": "Cosecante hyp",
"hypArcSine": "Arcsinus hyp",
"hypArcCosine": "Arccosinus hyp",
"hypArcTangent": "Arctangente hyp",
"hypArcCotangent": "Arccotangente hyp",
"powerAndRoot": "Les racines et les puissances",
"squareRoot": "Racine carrée",
"power": "Puissances",
"xPowY": "Élève x à une puissance y",
"root": "Racines",
"rootText": "Racine y d'un nombre x",
"expAndLog": "Les exponentielles et logarithmes",
"naturalLog": "logarithme naturel",
"decimalLog": "logarithme de base",
"absValue": "La valeur absolue d'un nombre",
"rounding": "Les arrondis",
"roundText": "arrondit à l'entier le plus proche",
"ceilText": "arrondit à l'entier supérieur",
"floorText": "arrondit à l'entier inférieur",
"constants": "Constantes",
"keyboardShortcuts": "Raccourcis clavier",
"moveLeft": "déplacer le graphique à gauche",
"moveTop": "déplacer le graphique en haut",
"moveRight": "déplacer le graphique à droite",
"moveBottom": "déplacer le graphique en bas",
"examplesText": "(Vous pouvez cliquer sur un exemple pour l'afficher. Pensez à ajuster la précision du graphique dans les options si nécessaire.)",
"functions2d": "Fonctions 2D",
"functions3d": "Fonctions 3D",
"saveGraph": "Enregistrer le graphique",
"functionStudy": "Étude de fonction",
"domainOfDefinition": "Ensemble de définition",
"symmetry": "Parité",
"zeros": "Zéros de la fonction",
"sign": "Signe",
"asymptotes": "Asymptotes",
"extremums": "Extremums",
"inflexionPoints": "Points d'inflexion",
"functionStudyText": "L'outil permettant d'étudier les fonctions n'est pas fiable à 100%. Pensez à vérifier les résultats de l'étude avant d'en faire une quelconque utilisation.",
"history": "Historique",
"newFunction": "Nouvelle fonction",
"cartesian": "Cartésienne",
"implicit": "Implicite",
"polar": "Polaire",
"parametric": "Paramétrique",
"add": "Ajouter",
"functionsListText": "Fonction dessinées",
"edit": "Modifier",
"tools": "Outils",
"from": "de",
"to": "à",
"color": "Couleur",
"derivatives": "Dérivées",
"primitive": "Primitive",
"duplicate": "Dupliquer",
"remove": "Supprimer",
"computePoint": "Calculer un point de la fonction",
"compute": "Calculer",
"computeArea": "Calculer l'aire sous la fonction",
"startStudy": "Démarrer l'étude",
"latestDisplayedFunctions": "Dernières fonctions dessinées",
"chooseColor": "Choix de la couleur",
"value": "Valeur",
"saturation": "Saturation",
"red": "Rouge",
"green": "Vert",
"blue": "Bleu",
"opacity": "Opacité",
"oldColor": "Ancienne Couleur",
"newColor": "Nouvelle Couleur",
"cancel": "Annuler",
"error": "Erreur",
"cannotDrawFunction": "Impossible de dessiner la fonction",
"invalidExpression": "Expression ou caractère invalide",
"checkTheFunction": "Vérifiez la fonction que vous vouliez dessiner",
"errorMessage": "Message d'erreur",
"youCanFindExamples": "Une description ainsi que des exemples des différentes fonctions que vous pouvez dessiner se trouvent dans l'aide",
"width": "Largeur",
"height": "Hauteur",
"backgroundColor": "Couleur de fond",
"imageFormat": "Format de l'image",
"update": "Mise à jour",
"currentVersion": "Version en cours d'utilisation",
"latestVersionAvailable": "Dernière version disponible en ligne",
"useLatestVersionText": "Vous pouvez remplacer la version en cours d'utilisation par une version du widget en ligne. Notez que ceci ne met pas à jour le widget. Il faudra réitérer cette procédure la prochaine fois que vous l'utiliserez.",
"useLatestVersion": "Utiliser la dernière version",
"updateErrorText": "Il est impossible de mettre à jour le widget vers la version en ligne car vous utilisez déjà la version en ligne",
"axes": "Axes",
"scale": "Échelle",
"grid": "Grille",
"reset": "Réinitialiser",
"saveImageTitle": "Sauvegarder l'image",
"saveImageText": "Cliquez avec le bouton de droite sur l'image et sélectionnez \"Enregistrer l'image\". Il est aussi possible de choisir \"Copier l'image\" et ensuite la coller dans une autre application.",
/* Inside code */
"even": "paire",
"odd": "impaire",
"none_f": "aucune",
"none_m": "aucun",
"clickHereToModify": "Cliquez ici pour modifier les fonctions ou en ajouter une nouvelle.",
"enterFunction": "Entrez une fonction à dessiner",
"needHelp": "Consulter l'aide",
"unableLoadParameters": "Impossible de charger les paramètres enregistrés..."
}
};
// -------------------- Fonctions des outils --------------------
// Permet d'afficher la valeur en "y" pour un point donné en "x"
function calculerPoint() {
x = document.getElementById("inputX").value;
document.getElementById("outputX").innerHTML = " f(x) = "+fct.list[editeur.idFct].f(x)+"";
//alert("Si x = "+x+" \nf(x) = "+eval(fonction)+"")
}
// Historique
var historique = {
liste : [],
actualiser : function(){
var texteHistorique = ""
for(var i=0; i<this.liste.length; i++){
texteHistorique += '<span class="survol" onclick="historique.use('+i+'); actualiserGraph()">';
texteHistorique += this.liste[i].readableText();
texteHistorique += '</span> <br/>';
}
document.getElementById("spanHistorique").innerHTML = texteHistorique
document.getElementById("divHistorique").scrollTop = 0
},
use : function(index){
fct.add(this.liste[index]);
},
ajouter : function(func){
if(func.fct == ""){
return;
}
for(var i=0; i<this.liste.length; i++){
if(this.liste[i].fct == func.fct){
this.liste.splice(i, 1);
}
}
var newFunction = fct.functionFromObject(func.get());
this.liste.unshift(newFunction);
this.actualiser();
saveOptions();
},
get: function(){
var list = [];
for(var i=0; i<this.liste.length; i++){
list.push(this.liste[i].get());
}
return list;
},
set: function(obj){
for(var i=0; i<obj.length; i++){
this.liste.push(fct.functionFromObject(obj[i]));
}
this.actualiser();
}
}
// Outils de la souris
var outil = {
//
idAffichage : "affichageOutils",
// Outil sélectionné
actuel : "point",
// Canvas
canvas : null,
ctx : null,
width: 0,
height: 0,
// Liste des éléments à dessiner
liste : [],
// Fonction d'initialisation
init : function(width, height){
var element = document.getElementById(this.idAffichage);
if(element.hasChildNodes()){
while(element.childNodes.length >= 1 ){
element.removeChild(element.firstChild);
}
}
this.width = width || element.clientWidth;
this.height = height || element.clientHeight;
// element.style.width = affichage.largeur +"px";
// element.style.height = affichage.hauteur +"px";
// element.style.left = document.getElementById(affichage.id).offsetLeft+1 +"px";
// element.style.top = document.getElementById(affichage.id).offsetTop+1 +"px";
this.canvas = document.createElement("canvas");
this.canvas.width = this.width;
this.canvas.height = this.height;
element.appendChild(this.canvas);
this.ctx = this.canvas.getContext('2d');
},
// Permet de changer d'outil et de faire différentes actions lors du choix de l'outil
choisir : function(nom){
document.getElementById("pointTool").className = "toolButton";
document.getElementById("moveTool").className = "toolButton";
document.getElementById("tangentTool").className = "toolButton";
switch(nom){
case 'point':
document.getElementById("pointTool").className += " selectedTool";
break;
case 'deplacement':
document.getElementById("moveTool").className += " selectedTool";
break;
case 'tangente':
document.getElementById("tangentTool").className += " selectedTool";
break;
}
if(nom == 'deplacement'){
document.getElementById("eventAffichage").style.cursor = "move";
}
else{
document.getElementById("eventAffichage").style.cursor = "auto";
}
this.dessinerListe();
this.actuel = nom;
saveOptions();
},
// Gestion des événements reçus de l'objet souris
move : function(x, y, xInit, yInit, active){
switch(this.actuel){
case "deplacement":
if(active){
this.deplacement(x, y, xInit, yInit);
}
break;
case "point":
this.point(x, y);
break;
case "tangente":
this.tangente(x, y);
break;
}
},
down : function(x, y){
switch(this.actuel){
case "point":
this.point(x, y, true)
break;
case "tangente":
this.tangente(x, y, true);
break;
}
},
// Fonctions des outils
deplacement : function(x, y, xInit, yInit){
var valeurX = (x-xInit)/affichage.multX;
var valeurY = (yInit-y)/affichage.multY;
if(Math.round(Math.abs(valeurX)) > 0){
if(fonction3D){
affichage.deplacerX(Math.round(2*valeurX)/2);
}
else{
affichage.deplacerX(-Math.round(2*valeurX)/2);
}
souris.xInit = x;
}
if(Math.round(Math.abs(valeurY)) > 0){
affichage.deplacerY(-Math.round(2*valeurY)/2);
souris.yInit = y;
}
},
point : function(sourisX, sourisY, ajouterDansListe){
var ctx = new Object();
ctx = this.ctx;
// Dessiner les points et tangentes supplémentaires
this.dessinerListe();
for(var i=0; i<fct.list.length; i++){
var func = fct.list[i];
if(!func || func == ""){
continue;
}
// Position de la souris par rapport au coin supérieur gauche de l'affichage
var posX = sourisX - affichage.offsetLeft - 2;
// Valeur de la coordonnée x et y sous la souris
var t = posX / affichage.multX + affichage.xGauche;
if("startAngle" in func){
if(t < func.startAngle || t > func.endAngle){
continue;
}
}
var x = func.getX(t);
var y = func.getY(t);
// Afficher les coordonnées et le point sous la souris
if(!isNaN(x) && !isNaN(y)){
if(ajouterDansListe){
this.ajouterPoint(x, y, func.couleur);
}
this.dessinerPoint(x, y, func.couleur);
}
}
},
dessinerPoint : function(x, y, couleur){
var ctx = new Object();
ctx = this.ctx;
// Conversion des coordonnées
var posX = coordToPosX(x) + 1;
var posY = coordToPosY(y) + 1;
ctx.shadowColor = couleur;
ctx.shadowBlur = 4;
// Texte
var txtPos = "("+Math.round(x*100)/100+";"+Math.round(y*100)/100+")";
ctx.fillStyle = "rgba(255,255,255,0.5)";
try{
ctx.bulle(posX+7, posY-7, txtPos.length*5.5, 20);
}
catch(err){
ctx.fillRect(posX+7, posY-27, txtPos.length*5.5, 20);
}
ctx.fillStyle = "black";
ctx.shadowColor = "black";
ctx.shadowOffsetX = 1;
ctx.shadowOffsetY = 1;
ctx.shadowBlur = 2;
ctx.fillText(txtPos, posX+8+txtPos.length/4, posY-13);
// Rond
ctx.beginPath();
ctx.arc(posX, posY, 4, 0, 2*Math.PI, true);
ctx.shadowColor = couleur;
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 0;
ctx.shadowBlur = 4;
ctx.fillStyle = "rgba(0,0,0,1)";
ctx.strokeStyle = "rgba(255,255,255,0.8)";
ctx.lineWidth = 1;
ctx.fill()
ctx.stroke();
},
tangente : function(sourisX, sourisY, ajouterDansListe){
var delta = 0.001;
var ctx = new Object();
ctx = this.ctx;
// Dessiner les points et tangentes supplémentaires
this.dessinerListe();
// Dessiner les tangentes des fonctions
for(var i=0; i<fct.list.length; i++){
var func = fct.list[i];
// Vérifier la fonction sur laquelle doit s'appliquer l'outil
if(!func || func == ""){
continue;
}
// Position de la souris par rapport au coin supérieur gauche de l'affichage
var posX = sourisX - affichage.offsetLeft - 2;
// Valeur de la coordonnée x sous la souris
var t = posX / affichage.multX + affichage.xGauche;
if("startAngle" in func){
if(t < func.startAngle || t > func.endAngle){
continue;
}
}
var t1 = t + delta;
var x = func.getX(t);
var x1 = func.getX(t1);
// Calcul de deux valeurs y et de la pente
var y = func.getY(t);
var y1 = func.getY(t1);
var pente;
if(x1 != x){
pente = (y1-y)/(x1-x);
}
else{
pente = Number.POSITIVE_INFINITY;
}
// Dessiner la pente;
if(!isNaN(x) && !isNaN(y) && !isNaN(y1)){
if(ajouterDansListe){
this.ajouterTangente(x, y, pente, func.couleur);
}
this.dessinerTangente(x, y, pente, func.couleur);
}
}
},
dessinerTangente : function(x, y, pente, couleur){
var ctx = new Object();
ctx = this.ctx;
// Conversion des coordonnées
var posX = coordToPosX(x) + 1;
var posY = coordToPosY(y) + 1;
// Carré
ctx.shadowColor = couleur;
ctx.shadowBlur = 4;
ctx.fillStyle = "white";
ctx.fillRect(posX-3, posY-3, 6, 6);
// Pente
ctx.strokeStyle = "white";
ctx.lineWidth = 2;
ctx.beginPath();
var pente2 = pente * (affichage.hauteur/affichage.largeur) * (affichage.xDroite-affichage.xGauche)/(affichage.yHaut-affichage.yBas);
ctx.moveTo(0, posY+posX*pente2);
ctx.lineTo(affichage.largeur, posY+posX*pente2-affichage.largeur*pente2);
ctx.stroke();
// Texte
var txtPente;
if(isFinite(pente)){
txtPente = pente.toFixed(2);
}
else{
txtPente = "∞"
}
ctx.fillStyle = "rgba(255,255,255,0.5)";
try{
ctx.bulle(posX+7, posY-7, txtPente.length*5.5+1, 20);
}
catch(err){
ctx.fillRect(posX+7, posY-27, txtPente.length*5.5, 20);
}
ctx.fillStyle = "black";
ctx.shadowColor = "black";
ctx.shadowOffsetX = 1;
ctx.shadowOffsetY = 1;
ctx.shadowBlur = 2;
ctx.fillText(txtPente, posX+8+txtPente.length/4, posY-13);
},
ajouterPoint : function(x, y, couleur){
var newPoint = {
x : x,
y : y,
couleur : couleur,
dessiner : function(){
outil.dessinerPoint(this.x, this.y, this.couleur);
}
};
this.liste.push(newPoint);
},
ajouterTangente : function(x, y, pente, couleur){
var newTangente = {
x : x,
y : y,
pente : pente,
couleur : couleur,
dessiner : function(){
outil.dessinerTangente(this.x, this.y, this.pente, this.couleur);
}
};
this.liste.push(newTangente);
},
dessinerListe : function(){
if(!this.ctx){
return;
}
this.ctx.clearRect(0,0,affichage.largeur*2,affichage.hauteur*2);
for(var i=0; i<this.liste.length; i++){
this.liste[i].dessiner();
}
this.actualiserListe();
},
actualiserListe : function(){
var element = document.getElementById("divSuppOutil");
element.innerHTML = "";
for(var i=0; i<this.liste.length; i++){
var posX = Math.floor(coordToPosX(this.liste[i].x, true)+9);
var posY = Math.floor(coordToPosY(this.liste[i].y, true)-28);
if(posX > affichage.largeur+affichage.offsetLeft || posX < affichage.offsetLeft || posY > affichage.hauteur+affichage.offsetTop || posX < affichage.offsetTop){
continue;
}
var txt = '<div style="left:'
txt += posX +'px;';
txt += 'top:'
txt += posY +'px;" ';
txt += 'onclick="'
txt += 'outil.supprimer('+i+')';
txt += '">x</div>';
// alert(txt);
element.innerHTML += txt;
}
},
supprimer : function(id){
outil.liste.splice(id, 1);
outil.dessinerListe();
// alert(id)
}
};
// Evènements du clavier
function keyPress(event){
switch(event.keyCode){
case 27:
// widget.resetState()
break
case 37:
if(event.ctrlKey){
affichage.deplacerX(-1)
}
break
case 38:
if(event.ctrlKey){
affichage.deplacerY(1)
}
break
case 39:
if(event.ctrlKey){
affichage.deplacerX(1)
}
break
case 40:
if(event.ctrlKey){
affichage.deplacerY(-1)
}
break
default:
//alert(event.keyCode+" ; "+event.ctrlKey)
}
}
// ---- Aire sous la fonction (intégrale) ----
function AireSousFct(fct, a, b, n){
var aire, largeurRect, gaucheRect, droiteRect, millieuRect, hauteurRect, aireRect;
var f = new Function("x", "return "+fct);
aire = 0;
largeurRect = (b-a)/n;
for(var i=0; i<n; i++){
gaucheRect = a + i*largeurRect;
droiteRect = a + (i+1)*largeurRect;
millieuRect = (gaucheRect+droiteRect) / 2;
hauteurRect = f(millieuRect);
aireRect = largeurRect * hauteurRect;
aire = aire + aireRect;
}
//alert("a="+a+";b="+b+";n="+n+";A="+aire)
return aire;
}
function calculerAire(){
var fonction = fct.remplacer(fct.verifier(fct.list[editeur.idFct].fct));
var a = parseInt(document.getElementById("aireG").value);
var b = parseInt(document.getElementById("aireD").value);
var n = 50;
var arrondi = Math.round(AireSousFct(fonction, a, b, n)*1000)/1000;
document.getElementById("outputAire").innerHTML = "A = " + arrondi;
actualiserGraph();
}
// ---- Sauvegarde du graphique ----
var backgroundSauvegarde = "rgba(0,0,0,0.5)";
function saveGraph(){
var userWidth = parseInt(document.getElementById("saveWidth").value);
var userHeight = parseInt(document.getElementById("saveHeight").value);
if(userWidth <= 0 || userHeight <= 0){
userWidth = affichage.width;
userHeight = affichage.height;
}
if(fonction3D){
var background = display3D.background;
display3D.background = backgroundSauvegarde;
display3D.init(userWidth, userHeight);
display3D.draw();
var dataURL;
if(document.getElementById("selectSaveType").value == "jpg"){
dataURL = display3D.canvas.toDataURL("image/jpeg");
}
else{
dataURL = display3D.canvas.toDataURL();
}
document.getElementById("saveImageContent").innerHTML = '<img src="' + dataURL + '"/>';
afficherMenu('menuSaveImage');
display3D.background = background;
setTimeout(function(){
display3D.init();
display3D.draw();
}, 1);
}
else{
if(affichage.methode == "canvas"){
var l = affichage.largeur;
var h = affichage.hauteur;
var c = affichage.couleurFond;
affichage.largeur = parseInt(document.getElementById("saveWidth").value);
affichage.hauteur = parseInt(document.getElementById("saveHeight").value);
affichage.couleurFond = backgroundSauvegarde;
var newDiv = document.createElement("div");
affichage.init(newDiv, userWidth, userHeight);
outil.init();
outil.dessinerListe();
affichage.ctx.drawImage(outil.canvas,0,0);
var dataURL;
if(document.getElementById("selectSaveType").value == "jpg"){
dataURL = affichage.canvas.toDataURL("image/jpeg");
}
else{
dataURL = affichage.canvas.toDataURL();
}
document.getElementById("saveImageContent").innerHTML = '<img src="' + dataURL + '"/>';
afficherMenu('menuSaveImage');
affichage.largeur = l;
affichage.hauteur = h;
affichage.couleurFond = c;
affichage.init();
outil.init();
}
else if(affichage.methode == "svg"){
window.open("JavaScript/AffichageSVG.svg");
}
}
}
function ParametricFunction(fctX, fctY){
this.setFct = function(fctX, fctY){
this.fct = "x(t) = " + fctX + " ; y(t) = " + fctY;
this.fctX = fctX;
this.fctY = fctY;
this.fx = new Function("t", "return "+this.fctX);
this.fy = new Function("t", "return "+this.fctY);
}
if(fctX && fctY){
this.setFct(fctX, fctY);
}
this.couleur = fct.couleur;
this.width = document.getElementById("inputTaille").value;
this.startAngle = 0;
this.endAngle = 2*Math.PI;
this.from = "0";
this.to = "2*pi";
this.style = document.getElementById("selectStyle").value;
this.getX = function(t){
return this.fx(t);
};
this.getY = function(t){
return this.fy(t);
};
this.set = function(f){
var fctX = fct.remplacer(fct.verifier(f.fctX));
var fctY = fct.remplacer(fct.verifier(f.fctY));
this.setFct(fctX, fctY);
this.couleur = f.couleur;
this.width = f.width;
this.style = f.style;
this.from = f.from;
this.to = f.to;
this.startAngle = eval(fct.remplacer(fct.verifier(f.from)));
this.endAngle = eval(fct.remplacer(fct.verifier(f.to)));
return this;
};
this.get = function(){
var f = {};
f.type = "parametric";
f.fctX = this.fctX;
f.fctY = this.fctY;
f.couleur = this.couleur;
f.width = this.width;
f.style = this.style;
f.from = this.from;
f.to = this.to;
return f;
};
this.readableText = function(){
return "x(t) = " + this.fctX + "; y(t) = " + this.fctY;
};
this.setStartEnd = function(start, end){
if(start > end){
var tmp = start;
start = end;
end = start;
}
this.startAngle = start;
this.endAngle = end;
};
this.plot = function(ctx, precision, affichage){
if(this.style == "points"){
precision *= 2;
}
ctx.beginPath();
ctx.lineWidth = this.width;
ctx.strokeStyle = this.couleur;
ctx.fillStyle = this.couleur;
notDefined = true;
for(var t = this.startAngle; t <= this.endAngle; t+=precision){
var x = this.fx(t);
var y = this.fy(t);
if(!isNaN(x) && !isNaN(y)){
// Transform coordinates
var pointX = (x - affichage.xGauche) * affichage.multX;
var pointY = affichage.hauteur - (y - affichage.yBas) * affichage.multY;
// Draw point
if(notDefined){
notDefined = false;
ctx.moveTo(pointX, pointY);
}
else{
if(this.style == "continu"){
ctx.lineTo(pointX, pointY);
}
else if(this.style == "points"){
ctx.beginPath();
ctx.arc(pointX, pointY, this.width, 0, 2*Math.PI, true);
ctx.fill();
}
else{
ctx.lineTo(pointX, pointY);
notDefined = true;
}
}
}
}
if(this.style != "points"){
ctx.stroke();
}
};
}
function PolarFunction(txtFct){
this.setFct = function(txt){
this.fct = txt;
this.f = new Function("t", "return "+this.fct);
};
if(txtFct){
this.setFct(txtFct);
}
this.couleur = fct.couleur;
this.width = document.getElementById("inputTaille").value;
this.startAngle = 0;
this.endAngle = 2*Math.PI;
this.from = "0";
this.to = "2*pi";
this.style = document.getElementById("selectStyle").value;
this.getX = function(t){
var r = this.f(t);
return r * Math.cos(t);
};
this.getY = function(t){
var r = this.f(t);
return r * Math.sin(t);
};
this.set = function(f){
this.setFct(fct.remplacer(fct.verifier(f.fct)));
this.couleur = f.couleur;
this.width = f.width;
this.style = f.style;
this.from = f.from;
this.to = f.to;
this.startAngle = eval(fct.remplacer(fct.verifier(f.from)));
this.endAngle = eval(fct.remplacer(fct.verifier(f.to)));
return this;
};
this.get = function(){
var f = {};
f.type = "polar";
f.fct = this.fct;
f.couleur = this.couleur;
f.width = this.width;
f.style = this.style;
f.from = this.from;
f.to = this.to;
return f;
};
this.readableText = function(){
return "r(t) = " + this.fct;
};
this.setStartEnd = function(start, end){
if(start > end){
var tmp = start;
start = end;
end = start;
}
this.startAngle = start;
this.endAngle = end;
};
this.plot = function(ctx, precision, affichage){
if(this.style == "points"){
precision *= 2;
}
ctx.beginPath();
ctx.lineWidth = this.width;
ctx.strokeStyle = this.couleur;
ctx.fillStyle = this.couleur;
notDefined = true;
for(var t = this.startAngle; t <= this.endAngle; t+=precision){
var r = this.f(t);
if(!isNaN(r)){
// Transform coordinates
var x = r * Math.cos(t);
var y = r * Math.sin(t);
var pointX = (x - affichage.xGauche) * affichage.multX;
var pointY = affichage.hauteur - (y - affichage.yBas) * affichage.multY;
// Draw point
if(notDefined){
notDefined = false;
ctx.moveTo(pointX, pointY);
}
else{
if(this.style == "continu"){
ctx.lineTo(pointX, pointY);
}
else if(this.style == "points"){
ctx.beginPath();
ctx.arc(pointX, pointY, this.width, 0, 2*Math.PI, true);
ctx.fill();
}
else{
ctx.lineTo(pointX, pointY);
notDefined = true;
}
}
}
}
if(this.style != "points"){
ctx.stroke();
}
};
}
// Fonctions permettant de sauvegarder les options
var optionsLoaded = false;
function setCookie(nom,valeur){
var jours = 545; // Durée de validité des cookies
var date = new Date();
date.setDate(date.getDate()+jours);
document.cookie = nom + "=" + escape(valeur) + "; expires="+date.toGMTString();
}
function getCookie(nom){
var start = 0;
var end = 0;
if(document.cookie.length>0){
start = document.cookie.indexOf(nom + "=");
if(start!=-1){
start = start + nom.length+1;
end = document.cookie.indexOf(";",start);
if(end==-1){
end = document.cookie.length;
}
return unescape(document.cookie.substring(start,end));
}
}
return "";
}
function delCookie(nom){
var date = new Date();
date.setDate(date.getDate()-1);
document.cookie = nom + "=; expires="+date.toGMTString();
}
function saveOptions(){
if(!optionsLoaded){
return;
}
var state = JSON.stringify(widget.getState());
if(window.sankore){
sankore.setPreference("state", state);
}
else if(navigator.cookieEnabled){
setCookie("state", state);
}
}
function loadOptions(){
var state;
if(window.sankore){
state = sankore.preference("state", null);
}
else if(navigator.cookieEnabled){
state = getCookie("state");
}
if(!state){
optionsLoaded = true;
return;
}
var stateObject = JSON.parse(state);
var goodState = widget.getState();
if(!checkState(stateObject, goodState)){
loadOptionsFailed();
}
try{
widget.setState(stateObject);
optionsLoaded = true;
}
catch(e){
loadOptionsFailed();
}
}
function loadOptionsFailed(){
var text = "Unable to load the saved parameters...";
try{
text = languages.getText("unableLoadParameters");
}
catch(e){}
alert(text);
delOptions();
}
function checkState(state, goodState){
for(var i in goodState){
if(! i in state){
return false;
}
}
return true;
}
function delOptions(){
if(window.sankore){
sankore.setPreference("state", "");
}
else if(navigator.cookieEnabled){
delCookie("state");
}
}
function alertOptions(){
// alert("Options actuellement sauvegardées\n------------------------------------------------------------\n"+document.cookie);
document.getElementById("divAlertCookies").innerHTML = document.cookie;
afficherMenu("menuAlertCookies");
}
var souris = {
active : false,
xInit : 0,
yInit : 0,
down : function(event){
var x = event.clientX;
var y = event.clientY;
this.active = true;
this.xInit = x;
this.yInit = y;
if(event.button != 2 && !ctxMenu.ouvert){
outil.down(x, y);
}
ctxMenu.fermer();
},
up : function(){
this.active = false;
},
move : function(event){
var x = event.clientX;
var y = event.clientY;
outil.move(x, y, souris.xInit, souris.yInit, souris.active);
},
out : function(event){
outil.dessinerListe();
if(event.relatedTarget && event.relatedTarget.className != "flecheDeplacement"){
this.active = false;
}
},
wheel : function(event){
if(!event) event = window.event;
if(event.wheelDelta){
if(event.wheelDelta < 0){
affichage.zoom(1.25);
}
else{
affichage.zoom(0.8);
}
}
else if(event.detail){
if(event.detail > 0){
affichage.zoom(1.25);
}
else{
affichage.zoom(0.8);
}
}
},
dblClick : function(event){
if(event.ctrlKey){
affichage.zoom(1.25)
display3D.zoom(1.25)
}
else{
affichage.zoom(0.8)
display3D.zoom(0.8)
}
}
}
var ctxMenu = {
id : "ctxMenu",
ouvert : false,
ouvrir : function(){
if(!fonction3D){
ctxMenu.ouvert = true;
var element = document.getElementById("ctxMenu");
var x = souris.xInit;
var y = souris.yInit;
// var x = 300;
// var y = 300;
element.style.display = "block";
element.style.left = (x+1)+"px";
element.style.top = (y+1)+"px";
// Désactive le menu du navigateur
return false;
}
},
fermer : function(){
ctxMenu.ouvert = false;
var element = document.getElementById("ctxMenu");
element.style.display = "none";
}
}
// Lance la procédure pour dessiner la fonction qui se trouve dans l'input en haut du widget.
// Permet aussi d'actualiser le graphique.
function actualiserGraph(){
affichage.calculer();
}
// Retourne l'index du dernier endroit où se trouve listCharacter dans une chaîne de caractère.
String.prototype.getLastIndexOf = function(listCharacter, minPos, maxPos){
var count = 0;
var parenthese = false;
if(!maxPos){
maxPos = this.length;
}
for(var i=maxPos; i>=minPos; i--){
if(this.charAt(i) == ")"){
count++;
parenthese = true;
}
else if(this.charAt(i) == "("){
count--;
}
// window.console.log(this.charAt(i)+" ; "+count);
for(var j=0; j<listCharacter.length; j++){
if(this.charAt(i) == listCharacter[j]){
if(count<=0){
if(parenthese){
parenthese = false;
}
else{
return i;
}
}
}
}
}
return -1;
}
String.prototype.getIndexOf = function(listCharacter, minPos, maxPos){
var count = 0;
if(!maxPos){
maxPos = this.length;
}
for(var i=minPos; i<=maxPos; i++){
if(this.charAt(i) == "("){
count++;
}
else if(this.charAt(i) == ")"){
count--;
}
for(var j=0; j<listCharacter.length; j++){
if(this.charAt(i) == listCharacter[j]){
if(count==0){
return i;
}
}
}
}
return -1;
}
// Retourne un nombre aléatoire entre a et b.
function alea(a,b){
return Math.floor((b-a+1)*Math.random()+a);
}
// ---- Fonctions canvas personnalisées ----
var ctxPrototype = Object.getPrototypeOf(document.createElement("canvas").getContext("2d"));
// Dessiner une bulle
ctxPrototype.bulle = function(x, y, largeur, hauteur, rayon){
if(!rayon){
rayon = 5;
}
this.beginPath();
this.moveTo(x+0, y-rayon);
this.quadraticCurveTo(x+0, y-0, x+rayon, y-0);
this.lineTo(x+largeur-rayon, y);
this.quadraticCurveTo(x+largeur, y-0, x+largeur, y-rayon);
this.lineTo(x+largeur, y-hauteur+rayon);
this.quadraticCurveTo(x+largeur, y-hauteur, x+largeur-rayon, y-hauteur);
this.lineTo(x+rayon, y-hauteur);
this.quadraticCurveTo(x+0, y-hauteur, x+0, y-hauteur+rayon);
this.closePath();
this.fill();
}
// ---- Fonctions Mathématiques et constantes ----
// (rempalce sin() par Math.sin(), cos() par Math.cos(), tan() par Math.tan(), etc.
var pi = 4 * atan(1);
var PI = pi;
var e = exp(1);
function sin(valeur){
return Math.sin(valeur);
}
function cos(valeur){
return Math.cos(valeur);
}
function tan(valeur){
return Math.tan(valeur);
}
function cot(valeur){
return 1/Math.tan(valeur);
}
function sec(valeur){
return 1/cos(valeur);
}
function csc(valeur){
return 1/sin(valeur);
}
function asin(valeur){
return Math.asin(valeur);
}
function acos(valeur){
return Math.acos(valeur);
}
function atan(valeur){
return Math.atan(valeur);
}
function acot(valeur){
return Math.atan(1/valeur);
}
function asec(valeur){
return Math.acos(1/valeur);
}
function acsc(valeur){
return Math.asin(1/valeur);
}
var arcsin = asin;
var arccos = acos;
var arctan = atan;
var arccot = acot;
var arcsec = asec;
var arccsc = acsc;
function sinh(valeur){
return (Math.exp(valeur)-Math.exp(-valeur))/2;
}
function cosh(valeur){
return (Math.exp(valeur)+Math.exp(-valeur))/2;
}
function tanh(valeur){
return (Math.exp(valeur)-Math.exp(-valeur))/(Math.exp(valeur)+Math.exp(-valeur));
}
function coth(valeur){
return (Math.exp(valeur)+Math.exp(-valeur))/(Math.exp(valeur)-Math.exp(-valeur));
}
function sech(valeur){
return 1/cosh(valeur);
}
function csch(valeur){
return 1/sinh(valeur);
}
function asinh(valeur){
return Math.log(valeur+Math.sqrt(Math.pow(valeur,2)+1));
}
function acosh(valeur){
return Math.log(valeur+Math.sqrt(Math.pow(valeur,2)-1));
}
function atanh(valeur){
return Math.log((1+valeur)/(1-valeur))/2;
}
function acoth(valeur){
return Math.log((valeur+1)/(valeur-1))/2;
}
var arcsinh = asinh;
var arccosh = acosh;
var arctanh = atanh;
var arccoth = acoth;
function sqrt(valeur){
return Math.sqrt(valeur);
}
function pow(valeur1, valeur2){
return Math.pow(valeur1, valeur2);
}
function root(valeur1, valeur2){
if(valeur2%2==1 && valeur1<0){
return -Math.pow(-valeur1, (1/valeur2));
}
else{
return Math.pow(valeur1, (1/valeur2));
}
}
function exp(valeur){
return Math.exp(valeur);
}
function log(valeur){
return Math.log(valeur)/Math.log(10);
}
function ln(valeur){
return Math.log(valeur);
}
function abs(valeur){
return Math.abs(valeur);
}
function sign(valeur){
if(valeur<0){
return -1;
}
else if(valeur>0){
return 1;
}
else{
return undefined;
}
}
function round(valeur){
return Math.round(valeur);
}
function ceil(valeur){
return Math.ceil(valeur);
}
function floor(valeur){
return Math.floor(valeur);
}
function random(){
return Math.random();
}
var listeServeurs = [
'http://yannick.vessaz.net/GraphMe/GraphMe.wgt/'
/*'http://gyb.educanet2.ch/tm-widgets/yannick/GraphMe.wgt/'*/
];
var widget = {
init: function(){
// try{
document.getElementById('inputRapide').value = "";
document.getElementById('selectTheme').value = "darkblue";
affichage.setOptions();
document.getElementById('zoomDefaut').value = "3.7";
document.getElementById('functionType').value = "cartesian";
document.getElementById('inputTaille').value = "3";
document.getElementById('checkDerivee1').checked = false;
document.getElementById('checkDerivee2').checked = false;
document.getElementById('checkPrimitive1').checked = false;
document.getElementById('checkAire').checked = false;
document.getElementById('selectStyle').value = "continu";
document.getElementById('input3D').value = "";
document.getElementById('inputPrecision3D').value = "0.2";
document.getElementById('selectAffichage3D').value = "surfaces";
document.getElementById('selectRouge3D').value = "plus";
document.getElementById('selectVert3D').value = "moins";
document.getElementById('selectBleu3D').value = "tout";
document.getElementById('couleur3Dgenerale').value = "0";
affichage.init();
outil.init();
editorPreview.init();
display3D.checkCouleurs3D();
loadOptions();
if(!fonction3D){
if(fct.list.length == 0){
this.displayStartInput();
}
else if(!window.sankore){
this.displayFunctionsHelp();
}
}
// }
// catch(err){
// alert(err+'\n'+err.stack);
// }
},
displayStartInput: function(){
document.getElementById('divInputRapide').style.display = "block";
var textEnterFunction = "Enter a cartesian function";
try{
textEnterFunction = languages.getText("enterFunction");
}
catch(e){}
var textNeedHelp = "Need help ?";
try{
textNeedHelp = languages.getText("needHelp");
}
catch(e){}
var text = textEnterFunction + '. <a onclick="' + "message.supprimer(); afficherMenu('menuAide') " + '">'+ textNeedHelp +'</a>'
message.ajouter(275,75,text);
setTimeout(message.supprimer, 15000);
document.getElementById('inputRapide').focus();
},
addStartFunction: function(){
message.supprimer();
document.getElementById('divInputRapide').style.display = 'none';
document.getElementById('input').value = document.getElementById('inputRapide').value;
fct.ajouter();
this.displayFunctionsHelp();
},
displayFunctionsHelp: function(){
var text = "Click here to modify the functions or add a new function.";
try{
text = languages.getText("clickHereToModify");
}
catch(e){}
setTimeout(function(){message.ajouter(220,35,text)}, 50);
setTimeout(message.supprimer, 5000);
},
resize: function(){
if(fonction3D){
display3D.init();
display3D.draw();
}
else{
affichage.init();
}
outil.init();
},
reset: function(){
delOptions();
window.location.reload();
},
getState: function(){
var state = {
theme: document.getElementById("selectTheme").value,
displayMethod: document.getElementById("selectMethodeAffichage").value,
defaultZoom: document.getElementById("zoomDefaut").value,
displayGrid: document.getElementById("checkGrille").checked,
displayAxes: document.getElementById("checkAxes").checked,
displayScale: document.getElementById("checkEchelle").checked,
accuracy: document.getElementById("inputPrecision").value,
improvedAccuracy: document.getElementById("checkPrecision").checked,
thickness: document.getElementById("inputTaille").value,
lineStyle: document.getElementById("selectStyle").value,
derivative1: document.getElementById("checkDerivee1").checked,
derivative2: document.getElementById("checkDerivee2").checked,
primitive: document.getElementById("checkPrimitive1").checked,
drawArea: document.getElementById("checkAire").checked,
lineStyle3D: document.getElementById("selectAffichage3D").value,
accuracy3D: document.getElementById("inputPrecision3D").value,
plotHistory: historique.get(),
functions: fct.get(),
display3D: fonction3D,
input3D: document.getElementById('input3D').value,
currentTool: outil.actuel
};
if(window.sankore){
state.fullScreen = pleinEcran;
state.displayLeft = affichage.xGauche;
state.displayRight = affichage.xDroite;
state.displayUp = affichage.yHaut;
state.displayDown = affichage.yBas;
}
return state;
},
setState: function(state){
document.getElementById("selectTheme").value = state.theme;
document.getElementById("selectMethodeAffichage").value = state.displayMethod;
document.getElementById("zoomDefaut").value = state.defaultZoom;
document.getElementById("checkGrille").checked = state.displayGrid;
document.getElementById("checkAxes").checked = state.displayAxes;
document.getElementById("checkEchelle").checked = state.displayScale;
document.getElementById("inputPrecision").value = state.accuracy;
document.getElementById("checkPrecision").checked = state.improvedAccuracy;
document.getElementById("inputTaille").value = state.thickness;
document.getElementById("selectStyle").value = state.lineStyle;
document.getElementById("checkDerivee1").checked = state.derivative1;
document.getElementById("checkDerivee2").checked = state.derivative2;
document.getElementById("checkPrimitive1").checked = state.primitive;
document.getElementById("checkAire").checked = state.drawArea;
document.getElementById("selectAffichage3D").value = state.lineStyle3D;
document.getElementById("inputPrecision3D").value = state.accuracy3D;
historique.set(state.plotHistory);
fct.set(state.functions);
document.getElementById('input3D').value = state.input3D || "";
if(state.display3D){
activer3D();
}
if(window.sankore){
if(state.fullScreen){
agrandirAffichage();
}
affichage.xGauche = state.displayLeft;
affichage.xDroite = state.displayRight;
affichage.yHaut = state.displayUp;
affichage.yBas = state.displayDown;
affichage.setBornes();
}
affichage.getOptions();
if(!window.sankore){
affichage.initZoom2(document.getElementById('zoomDefaut').value);
}
changerTheme(document.getElementById("selectTheme").value);
if(state.display3D){
display3D.draw();
}
else{
affichage.dessiner();
}
outil.choisir(state.currentTool);
}
};
/* ColorPicker */
#canvasSV{
width: 250px;
height: 250px;
border: 1px solid black;
}
#canvasT{
width: 25px;
height: 250px;
border: 1px solid black;
position: relative;
left: 10px;
}
#canvasO{
width: 290px;
height: 25px;
position: relative;
top: 5px;
}
/* Valeurs de la couleur dans le ColorPicker */
#colorValues{
position: relative;
left: 10px;
font-size: 11px;
float: right;
}
#colorValues td{
vertical-align: middle;
text-align: right;
}
/* Aperçus dans le ColorPicker */
#apercuCouleur{
position: absolute;
right: 20px;
bottom: 40px;
width: 40px;
height: 30px;
border: 1px white solid;
border-radius: 5px;
-webkit-border-radius: 5px;
background-color: rgb(193,255,0);
}
#apercuCouleur2{
position: absolute;
right: 65px;
bottom: 40px;
width: 40px;
height: 30px;
border: 1px white solid;
border-radius: 5px;
-webkit-border-radius: 5px;
background-color: rgb(193,255,0);
}
body{
background-color: rgba(255,255,255,0.6);
}
h1{
font-size: 250%;
text-align: center;
text-decoration: underline;
}
h2{
margin-top: 40px;
}
h4{
margin-top: 20px;
margin-bottom: 0px;
}
img{
display: block;
margin-left: auto;
margin-right: auto;
}
p{
text-align: justify;
}
li{
text-align: justify;
}
.droite{
float: right;
font-size: 80%;
font-style: italic;
margin: 5px;
}
.gauche{
float: left;
font-size: 80%;
font-style: italic;
}
#Sommaire{
margin-top: 100px;
margin-bottom: 100px;
}
\ No newline at end of file
/* Boutons qui sont en haut du widget */
#haut{
position: absolute;
top: 0px;
left: 8px;
right: 0px;
height: 30px;
z-index: 2;
pointer-events: none;
}
#haut > *{
pointer-events: auto;
}
/* Onglets */
.ongletHaut{
/* background-color: rgba(255, 255, 255, 0.3); */
background-image: url('../Images/gradient2.png');
border-color: rgba(255, 255, 255, 0.2);
border-style: none solid solid solid;
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
border-width: 1px;
box-shadow: 0px 0px 2px rgba(0,0,0,0.5);
color: white;
font-size: 16px;
text-align: center;
display: inline-block;
min-width: 90px;
height: 19px;
margin-right: 5px;
padding: 2px 8px;
opacity: 0.9;
cursor: pointer;
vertical-align: bottom;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.ongletHaut:hover{
background-color: rgba(0,180,255,0.3);
/* border-color: rgba(255, 255, 255, 0.6); */
box-shadow:0px 0px 6px rgba(0,180,255,1), 0px 0px 3px rgba(0,0,0,1);
opacity: 1;
}
.ongletHaut:active{
background-color: rgba(0,90,128,0.3);
box-shadow:0px 0px 6px rgba(0,90,128,1), 0px 0px 3px rgba(0,0,0,1);
position: relative;
color: rgba(255,255,255,0.8);
padding-top: 1px;
bottom: 1px;
}
.premierOngletHaut{
font-weight: bold;
background-color: rgba(255,160,0,0.3);
}
.premierOngletHaut:hover{
background-color: rgba(255,160,0,0.5);
box-shadow:0px 0px 6px rgba(255,160,0,1), 0px 0px 3px rgba(0,0,0,1);
}
.premierOngletHaut:active{
background-color: rgba(128,80,0,0.5);
box-shadow:0px 0px 6px rgba(128,80,0,1), 0px 0px 3px rgba(0,0,0,1);
/* position: relative; */
/* bottom: 1px; */
}
/* Bouton qui sert à choisir entre l'affichage 3D et 2D */
#onglet3D{
position: absolute;
top: 8px;
left: 538px;
width: 40px;
height: 19px;
padding-top: 2px;
color: white;
font-size: 16px;
text-align: center;
background-color: rgba(255,255,255,0);
background-image: url('../Images/gradient2.png');
/* background-image: url("../Images/onglet1.png"); */
border: 1px solid rgba(255,255,255,0.2);
border-bottom: none;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
-webkit-border-top-left-radius: 4px;
-webkit-border-top-right-radius: 4px;
box-shadow: 0px 0px 2px rgba(0,0,0,0.2);
cursor: pointer;
opacity: 0.8;
z-index: 3;
}
#onglet3D:hover{
background-color: rgba(255, 255, 255, 0.2);
box-shadow: 0px 0px 4px rgba(255,255,255,1);
opacity: 1;
}
#onglet3D:active{
background-color: rgba(255, 255, 255, 0.1);
box-shadow: 0px 0px 4px rgba(255,255,255,0.5);
top: 9px;
color: rgba(255,255,255,0.8);
}
/* Petits boutons en haut à droite du widget */
#topRightButtons{
position: absolute;
right: 10px;
top: 3px;
z-index: 4;
}
.miniBouton{
display: inline-block;
width: 12px;
height: 12px;
color: white;
font-size: 12px;
text-align: center;
background-color: rgba(255,255,255,0);
background-image: url('../Images/gradient.png');
background-position: 0px 0px;
border: 1px solid rgba(255,255,255,0.5);
border-radius: 6px;
-webkit-border-radius: 6px;
box-shadow: 0px 0px 2px rgba(0,0,0,1);
cursor: pointer;
opacity: 0.5;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.miniBouton:hover{
opacity: 1;
box-shadow: 0px 0px 4px rgba(255,255,255,1);
}
.miniBouton:active{
box-shadow: 0px 0px 4px rgba(255,255,255,0.5);
border: 1px solid rgba(255,255,255,0.4);
width: 11px;
height: 11px;
font-size: 11px;
margin-left: 1px;
}
/* Bouton permettant de minimiser et maximiser le widget */
/* Non utilisé pour le moment...*/
#miniMax{
position: absolute;
left: 564px;
top: 3px;
z-index: 3;
}
/* Boutons pour changer l'action de la souris*/
#zoomButtons{
position: absolute;
left: 13px;
top: 70px;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#toolButtons{
position: absolute;
left: 23px;
top: 103px;
padding: 2px;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#toolButtons .toolButton{
margin-bottom: 5px;
margin-top: 0px;
}
#toolButtons .toolButton:active{
margin-bottom: 7px;
}
.toolButton{
margin-left: auto;
margin-right: auto;
width: 16px;
height: 16px;
color: white;
font-size: 14px;
text-align: center;
font-weight: bold;
background-color: rgba(255,255,255,0);
background-image: url('../Images/gradient.png');
background-position: 0px 0px;
border: 1px solid rgba(255,255,255,0.5);
border-radius: 100%;
-webkit-border-radius: 10px;
box-shadow: 0px 0px 2px rgba(0,0,0,1);
cursor: pointer;
opacity: 0.5;
}
.toolButton:hover{
opacity: 1;
box-shadow: 0px 0px 4px rgba(255,255,255,1);
}
.toolButton:active{
box-shadow: 0px 0px 4px rgba(255,255,255,0.5);
border: 1px solid rgba(255,255,255,0.4);
width: 14px;
height: 14px;
font-size: 12px;
position: relative;
top: 1px;
}
.toolButton.selectedTool{
/* background-color: rgba(255,255,255,0); */
background-color: rgba(0,180,255,0.3);
box-shadow:0px 0px 6px rgba(0,180,255,1), 0px 0px 3px rgba(0,0,0,1);
opacity: 0.7;
}
.zoomButton{
display: inline-block;
width: 22px;
height: 22px;
border-radius: 6px;
box-sizing: border-box;
padding: 2px;
}
.zoomButton:active{
width: 20px;
height: 20px;
top: 0px;
}
#zoomOut{
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
}
#zoomOut:active{
margin-left: 2px;
}
#zoomIn{
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
}
.toolButton > .icon{
background-size: 100%;
width: 100%;
height: 100%;
}
#moveTool > .icon{
background-image: url('../Images/move.png');
}
#tangentTool> .icon{
background-image: url('../Images/tangent.png');
}
/* Joystick de déplacement */
#zoneJoystick{
position: absolute;
left: 8px;
top: 8px;
width: 50px;
height: 50px;
padding-left: 6px;
padding-top: 6px;
/* border: 1px solid green; */
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#joystick{
width: 40px;
height: 40px;
color: white;
font-size: 14px;
text-align: center;
font-weight: bold;
background-color: rgba(255,255,255,0.2);
background-image: url('../Images/gradient4.png');
background-position: 0px 0px;
border: 1px solid rgba(255,255,255,0.5);
border-radius: 25px; /*100% bug dans uniboard*/
-webkit-border-radius: 25px;
box-shadow: 0px 0px 2px rgba(0,0,0,1);
cursor: pointer;
opacity: 0.5;
}
#joystick:hover{
opacity: 1;
box-shadow: 0px 0px 2px rgba(255,255,255,1);
}
#joystick:active{
/* box-shadow: 0px 0px 4px rgba(255,255,255,0.5); */
/* border: 1px solid rgba(255,255,255,0.4); */
/* width: 38px; */
/* height: 38px; */
/* font-size: 12px; */
/* position: relative; */
/* top: 1px; */
/* left: 1px; */
/* margin-bottom: 7px; */
}
#joystick table{
border-collapse: collapse;
width: 40px;
height: 40px;
font-size: 11px;
}
#joystick table tr td{
padding: 0px;
text-shadow: 0px 0px 5px black;
/* border: 1px solid orange; */
opacity: 0.5;
}
#joystick table tr td:hover{
text-shadow: 0px 0px 3px white;
opacity: 1;
}
#joystick table tr td:active{
opacity: 0.8;
}
/* Style pour les menus */
.menu{
position: absolute;
top: 0%;
width: 100%;
max-width: 800px;
min-height: 411px;
max-height: 100%;
overflow: auto;
background-color: rgba(255, 255, 255, 0.7);
border-style: none;
border-width: 1px;
border-color: rgba(0,70,128, 0.9);
border-radius: 4px;
-webkit-border-radius: 4px;
z-index: 2;
display: none;
box-sizing: border-box;
}
.barreBasMenu{
position: absolute;
bottom: 0px;
/* right: 0px; */
}
.barreBasMenu > div{
position: fixed;
width: 100%;
max-width: 800px;
box-sizing: border-box;
/* right: 0px; */
/* bottom: 14px; */
}
.barreBasMenu > div > div{
position: absolute;
bottom: 0px;
right: 0px;
width: 100%;
box-sizing: border-box;
padding-right: 28px;
/* background-color: rgba(255,0,0,0.3); */
text-align: right;
}
.contenuMenu{
font-size: 14px;
padding: 15px;
padding-top: 40px;
/* overflow: auto; */
/* height: 100%; */
/* position: absolute; */
/* top: 0px; */
/* bottom: 0px; */
}
.avecBordures{
/* border-top: 1px solid rgba(255, 255, 255, 0.4); */
/* height: 80% */
}
.ongletMenu{
position: fixed;
/* top: 0px; */
width: 100%;
max-width: 800px;
/* height: 50px; */
/* background-color: rgba(255,0,0,0.3); */
/* border-spacing: 15px; */
box-sizing: border-box;
padding-right: 14px;
text-align: center;
z-index: 1;
}
.ongletMenu > div{
/* position: fixed; */
/* width: inherit; */
/* top: 0px; */
/* left: 0px; */
/* right: 0px; */
}
.deuxOnglets span{
width: 44%;
}
.troisOnglets span{
width: 28%;
}
.ongletMenu span{
display: inline-block;
min-width: 150px;
padding: 5px;
margin: 0px 7px;
text-align: center;
font-weight: normal;
background-color: rgba(255, 255, 255, 0.8);
background-image: url('../Images/gradient3.png');
border: 1px solid rgba(255, 255, 255, 0.9);
border-top: none;
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
-webkit-border-bottom-left-radius: 6px;
-webkit-border-bottom-right-radius: 6px;
box-shadow: 0px 0px 3px rgba(0,0,0,0.5);
opacity: 0.7;
cursor: pointer;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.ongletMenu span.ongletMenuActuel{
opacity: 0.9;
font-weight: bold;
background-color: rgba(255, 255, 255, 0.9);
}
.ongletMenu span:hover{
opacity: 1;
box-shadow:0px 0px 3px rgba(0,0,0,0.5), 0px 0px 7px rgba(255,255,255,1);
}
.ongletMenu span:active{
opacity: 0.7;
font-weight: bold;
box-shadow:0px 0px 3px rgba(0,0,0,0.5), 0px 0px 7px rgba(255,255,255,0.5);
}
.menu table.colonnes tr td{
vertical-align: top;
}
.menu table.colonnes tr td{
border-left: 1px solid rgba(255,255,255,0.5);
padding-left: 4px;
}
.menu table.colonnes tr td.premiereColonne{
border: none;
padding-right: 4px;
}
.miniMenu{
position: absolute;
top: 45%;
left: 50%;
margin-left: -160px;
margin-top: -120px;
width: 320px;
min-height: 240px;
padding: 5px;
text-align: center;
font-size: 14px;
overflow: auto;
background-color: rgba(255, 255, 255, 0.6);
background-image: url('../Images/gradient2.png');
background-size: 100% 100%;
box-shadow: 0px 0px 5px rgba(0,0,0,0.5);
border-style: solid;
border-width: 1px;
border-color: rgba(255,255,255, 0.5);
border-radius: 8px;
-webkit-border-radius: 8px;
z-index: 2;
display: none;
}
.alertMenu{
position: absolute;
top: 126px;
left: 206px;
width: 220px;
height: 140px;
padding: 10px;
text-align: center;
font-size: 14px;
overflow: auto;
background-color: rgba(255, 255, 255, 0.9);
background-image: url('../Images/gradient2.png');
background-size: 100% 100%;
border-style: solid;
border-width: 1px;
border-color: rgba(0,70,128, 0.9);
border-radius: 15px;
-webkit-border-radius: 15px;
z-index: 3;
display: none;
}
.miniMenu select{
/* width: 65px; */
}
.miniMenu input{
width: 45%;
height: 32px;
}
.miniMenu input.smallInput{
width: 45%;
height: 16px;
}
.alertMenu input{
width: 45%;
height: 32px;
}
/* Menu "à propos" */
#credits{
width: 80%;
margin: auto;
margin-top: 10px;
}
#credits tr td{
padding: 10px;
width: 100%;
height: 150px;
text-align: center;
text-shadow: 2px 2px 6px rgba(255,255,255,1);
vertical-align: middle;
background-color: rgba(255,220,150,0.5);
background-image: url('../Images/gradient2.png');
background-size: 100% 100%;
border: 1px solid rgba(255,230,150,0.6);
border-radius: 10px;
-webkit-border-radius: 10px;
box-shadow: 0px 0px 8px rgba(140,70,0,0.5) ;
}
#credits tr td img{
float: left;
margin-top: 20px;
margin-bottom: 20px;
}
#credits tr td a{
font-size: 80%;
}
#credits tr td h3{
text-align:center;
}
#saveImageContent{
width: 100%;
height: 100%;
box-sizing: border-box;
padding-bottom: 30px;
}
#saveImageContent img{
max-width: 100%;
max-height: 100%;
}
body{
background-color: transparent;
font-family: Sans-Serif;
}
table tr td{
padding: 0px;
}
/* Widget background */
html, body{
height: 100%;
margin: 0px;
}
#background{
width: 100%;
height: 100%;
border-spacing: 0;
border-collapse: collapse;
}
.background-border-x{
height: 14px;
padding: 0px;
background-color: "black";
}
.background-border-y{
width: 14px;
padding: 0px;
background-color: "black";
}
#background-top-left{
background-image: url('../Images/darkblue/top-left.png');
background-size: 100% 100%;
}
#background-top{
background-image: url('../Images/darkblue/top.png');
background-size: 100% 100%;
}
#background-top-right{
background-image: url('../Images/darkblue/top-right.png');
background-size: 100% 100%;
}
#background-bottom-left{
background-image: url('../Images/darkblue/bottom-left.png');
background-size: 100% 100%;
}
#background-bottom{
background-image: url('../Images/darkblue/bottom.png');
background-size: 100% 100%;
}
#background-bottom-right{
background-image: url('../Images/darkblue/bottom-right.png');
background-size: 100% 100%;
}
#background-left{
background-image: url('../Images/darkblue/left.png');
background-size: 100% 100%;
}
#background-right{
background-image: url('../Images/darkblue/right.png');
background-size: 100% 100%;
}
#background-center{
background-image: url('../Images/darkblue/center.png');
background-size: 100% 100%;
height: 100%;
padding-top: 30px;
position: relative;
}
/* Widget center */
#widgetCenter{
height: 100%;
position: relative;
}
/* Zone d'affichage des fonctions */
#eventAffichage{
height: 100%;
position: relative;
}
#eventAffichage canvas{
display: block;
}
#affichage{
height: 100%;
box-sizing: border-box;
overflow: hidden;
border: 1px solid rgba(255,255,255,0.5);
border-radius: 5px;
-webkit-border-radius: 5px;
}
#affichageOutils{
position: absolute;
top: 0px;
box-sizing: border-box;
height: 100%;
width: 100%;
}
#divInputRapide{
display: none;
position: absolute;
top: 11px;
left: 108px;
padding: 3px;
color: white;
text-align: center;
border: 1px solid rgba(255,255,255,0.2);
border-radius: 5px;
-webkit-border-radius: 5px;
box-shadow: 0px 0px 2px rgba(0,0,0,0.5);
background-image: url('../Images/gradient3.png');
background-color: rgba(255,255,255,0.1);
background-size: 100% 100%;
z-index: 2;
}
#inputRapide{
width: 270px;
}
#menuFonctions3D{
position: absolute;
top: 11px;
left: 108px;
padding: 3px;
color: white;
text-align: center;
border: 1px solid rgba(255,255,255,0.2);
border-radius: 5px;
-webkit-border-radius: 5px;
box-shadow: 0px 0px 2px rgba(0,0,0,0.5);
background-image: url('../Images/gradient3.png');
background-color: rgba(255,255,255,0.1);
background-size: 100% 100%;
z-index: 2;
}
#input3D{
width: 265px;
}
/* Messages */
#divMessages div{
position: absolute;
background-image: url('../Images/cursor.png');
background-repeat: no-repeat;
z-index: 4;
pointer-events: none;
min-height: 24px;
}
#divMessages div span{
position: relative;
left: 19px;
top: 20px;
padding: 2px;
color: white;
font-size: 11px;
text-align: center;
border: 1px solid rgba(255,255,255,0.2);
border-radius: 5px;
-webkit-border-radius: 5px;
box-shadow: 0px 0px 2px rgba(0,0,0,0.5);
text-shadow: 0px 0px 3px rgba(0,165,255,0.7);
background-image: url('../Images/gradient2.png');
background-color: rgba(0,86,134,0.6);
pointer-events: auto;
}
#divMessages div span a{
color : rgb(135,210,255);
cursor: pointer;
}
#divMessages div span a:hover{
color : rgb(110,200,255);
text-decoration: underline;
text-decoration-style: dotted;
}
/* Taille standard des boutons*/
.bouton{
/*width: 100px;*/
height: 25px;
font-size: 12px;
}
/* Boutons qui sont dans la partie gauche et qui ouvrent les différents menus */
.boutonGauche{
width: 100%;
height: 32px;
text-align: center;
}
/* Aperçu couleur 3D*/
#apercuCouleur3D{
border: 1px solid rgba(0, 0, 0, 0.7);
border-radius: 4px;
-webkit-border-radius: 4px;
}
/* Taille des champs contenant seulement 2 ou 3 caractères */
.smallInput{
width: 35px;
}
.mediumInput{
width: 45px;
}
/* Boutons qui ouvrent le ColorPicker */
.boutonCouleur{
position: relative;
left: 2px;
top: 4px;
width: 15px;
height: 15px;
border: 1px solid rgba(0,0,0,0.5);
border-radius: 5px;
-webkit-border-radius: 5px;
background-color: rgba(0,128,255,0.8);
display: inline-block;
cursor:pointer;
opacity: 0.7;
}
.boutonCouleur:hover{
box-shadow: 0px 0px 2px rgba(0,128,255,1);
opacity: 1;
}
/* Texte d'information (plus petit) */
.texteSecondaire{
font-size: 11px;
color: rgba(0,0,0,0.5);
margin-left: 10px;
}
/* Style pour le texte où on peut cliquer dessus */
.survol{
cursor: pointer;
color: rgb(0,70,120);
}
.survol:hover{
color: rgb(0,110,150);
opacity: 0.7;
/* text-shadow: 0px 0px 3px white; */
}
/* Texte en gras */
.gras{
font-weight: bold;
}
/* Flèches permettant de deplacer l'affichage */
.flecheDeplacement{
color: black;
text-shadow: 0px 0px 20px rgba(255,255,255,1);
opacity: 0;
font-size: 56px;
text-align: center;
cursor: pointer;
z-index: 1;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.flecheDeplacement:hover{
opacity: 0.4;
}
.flecheDeplacement:active{
opacity: 0.3;
}
#flecheHaut{
position: absolute;
top: 15px;
left: 50%;
margin-left: -35px;
width: 70px;
height: 55px;
}
#flecheBas{
position: absolute;
bottom: 20px;
left: 50%;
margin-left: -35px;
width: 70px;
height: 55px;
}
#flecheGauche{
position: absolute;
top: 50%;
margin-top: -36px;
left: 15px;
width: 55px;
height: 70px;
}
#flecheDroite{
position: absolute;
top: 50%;
margin-top: -36px;
right: 15px;
width: 55px;
height: 70px;
}
/* Boutons permettant de choisir l'action de la souris dans le menu des outils */
.choixOutil{
width: 125px;
height: 40px;
font-size: 14px;
cursor: pointer;
}
/* Petits boutons plus et moins dans les options */
.boutonPlus{
position: relative;
top: -7px;
left: -5px;
width: 10px;
height: 10px;
font-size: 9px;
text-align: center;
background-color: rgba(0, 140, 255, 0.2);
border: 1px rgba(0,0,0,0.5) solid;
border-radius: 3px;
-webkit-border-radius: 3px;
cursor: pointer;
display: inline-block;
}
.boutonMoins{
position: relative;
top: 6px;
left: -17px;
width: 10px;
height: 10px;
font-size: 9px;
text-align: center;
background-color: rgba(0, 140, 255, 0.2);
border: 1px rgba(0,0,0,0.5) solid;
border-radius: 3px;
-webkit-border-radius: 3px;
cursor: pointer;
display: inline-block;
}
.boutonPlus:hover{
border: 1px rgba(0,0,0,0.7) solid;
background-color: rgba(0, 140, 255, 0.5);
}
.boutonMoins:hover{
border: 1px rgba(0,0,0,0.7) solid;
background-color: rgba(0, 140, 255, 0.5);
}
/* Menu etudes fonctions*/
#menuEtude p{
margin-top: 7px;
margin-bottom: 0px;
/* font-weight: bold; */
}
#menuEtude span{
/* font-weight : normal; */
}
/* Tableau du signe dans le menu d'étude de la fonction*/
#etudeSigne{
/* border-collapse: collapse; */
border-spacing: 0px;
}
#etudeSigne td{
min-width: 25px;
text-align: center;
padding: 0px;
}
#etudeSigne td.premier{
font-weight: bold;
}
#etudeSigne td.bordure{
border: 1px solid black;
border-radius: 3px;
-webkit-border-radius: 3px;
}
#etudeSigne td.fondNoir{
background-color: rgba(0,0,0,0.5);
}
/* Titres des menus */
h1{
font-size: 16px;
font-weight: 600;
text-align: center;
/*font-style: italic;*/
margin-top: 15px;
margin-bottom: 25px;
}
h2{
font-size: 14px;
font-weight: normal;
font-style: italic;
margin-top: 30px;
}
h3{
font-size: 16px;
font-weight: 600;
text-align: left;
/*font-style: italic;*/
margin-top: 7px;
margin-bottom: 20px;
}
h4{
font-size: 16px;
font-weight: 600;
text-align: center;
/*font-style: italic;*/
margin-top: 15px;
margin-bottom: 10px;
}
/* Menu Mise à Jour */
#mAj{
text-align: center;
font-size: 14px;
}
#mAj h1{
font-size: 22px;
margin-top: 5px;
margin-bottom: 15px;
}
#mAj span object{
position: relative;
bottom: 4px;
width: 150px;
height: 27px;
overflow: hidden;
}
#mAj input{
min-height: 27px;
}
.boutonSauvegarde{
width: 100px;
height: 32px;
}
#cacheCookies{
position: absolute;
top: 150px;
left: 10px;
width: 93%;
height: 150px;
background-color: rgba(255,255,255,0.7);
border: 1px rgba(255,255,255,0.8) solid;
border-radius: 3px;
-webkit-border-radius: 3px;
text-align: center;
display: none;
}
#cacheMaJ{
position: absolute;
padding-top: 20px;
padding-bottom: 10px;
top: 250px;
left: 14px;
width: 93%;
height: 25px;
background-color: rgba(255,255,255,0.8);
border: 1px rgba(255,255,255,0.8) solid;
border-radius: 3px;
-webkit-border-radius: 3px;
text-align: center;
font-weight: bold;
display: none;
}
/* Menu clique droite sur le graphique */
#ctxMenu{
position: absolute;
border: 1px solid black;
border-radius: 5px;
background-color: rgba(255,255,255,0.8);
box-shadow: 0px 0px 5px rgba(0,64,126,0.5);
font-size: 12px;
padding: 2px;
z-index: 2;
display: none;
}
#ctxMenu input.bouton{
width: 140px;
height: 25px;
}
#ctxMenu h1{
font-size: 14px;
text-align: center;
text-decoration: underline;
text-shadow: 0px 0px 4px rgba(0,100,200,0.7);
margin: 3px;
}
#ctxMenu div.fermer{
position: absolute;
right: 0px;
top: 0px;
width: 10px;
height: 10px;
font-size: 10px;
cursor: pointer;
opacity: 0.7;
}
#ctxMenu div.fermer:hover{
text-shadow: 0px 0px 2px rgba(0,128,255,1);
opacity: 1;
}
.miniCouleur{
display: inline-block;
width: 10px;
height: 10px;
border: 1px solid rgba(0,0,0,0.5);
border-radius: 3px;
background-color: rgba(0,128,255,0.8);
cursor: pointer;
opacity: 0.7;
}
.miniCouleur:hover{
box-shadow: 0px 0px 2px rgba(0,128,255,1);
opacity: 1;
}
/* Editeur de fonctions dans le menu + */
#functionMenuRight{
position: absolute;
right: 15px;
width: 45%;
box-sizing: border-box;
}
#functionMenuLeft{
max-width: 50%;
/* min-height: 400px; */
box-sizing: border-box;
}
#fonctionsSupp{
width: 100%;
min-height: 305px;
/* height: 245px; */
/* border: 1px solid blue; */
overflow: auto;
}
.spanFonction{
/* width: 320px; */
border: 1px solid rgba(0,0,0,0.3);
border-radius: 5px;
background-color: rgba(255,255,255,0.2);
background-image: url('../Images/gradient2.png');
background-position: 0px -2px;
box-shadow: 0px 0px 4px rgba(0,64,126,0.2);
padding: 2px;
margin: 4px;
font-weight: bold;
text-align: center;
overflow: hidden;
cursor: pointer;
}
.spanFonction:hover{
background-color: rgba(164,228,255,0.2);
box-shadow: 0px 0px 2px rgba(0,150,255,0.6);
}
.spanFonctionSelect{
background-color: rgba(118,214,255,0.4);
border-color: rgba(0,63,126,0.3);
}
.spanFonctionSelect:hover{
background-color: rgba(118,214,255,0.6);
}
#editeurFonction{
/* position: absolute; */
/* right: 15px; */
/* top: 45px; */
min-width: 300px;
/* height: 75%; */
border: 1px solid rgba(255,255,255,0.7);
/* border-top: 1px solid rgba(255,255,255,0.3); */
border-radius: 5px;
background-color: rgba(255,255,255,0.2);
background-image: url('../Images/gradient2.png');
background-size: 100% 100%;
box-shadow: 0px 0px 4px rgba(0,64,126,0.2);
font-size: 12px;
padding: 2px;
}
#editeurApercu{
position: relative;
display : block;
margin : auto;
width: 100px;
height : 80px;
border: 1px solid white;
border-radius: 3px;
background-color: rgba(255,255,255,0.8);
box-shadow: 0px 0px 2px rgba(0,64,126,0.5);
font-size: 12px;
padding: 2px;
}
.editeurOnglets{
position: relative;
bottom: 3px;
width: 100%;
text-align: center;
}
.editeurOnglets span{
display: inline-block;
min-width: 70px;
width: 40%;
padding: 5px;
margin: 0px 2px;
text-align: center;
font-weight: normal;
background-color: rgba(255, 255, 255, 0.7);
background-image: url('../Images/gradient3.png');
border: 1px solid rgba(255, 255, 255, 0.9);
border-top: 1px solid white;
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
-webkit-border-bottom-left-radius: 6px;
-webkit-border-bottom-right-radius: 6px;
box-shadow: 0px 0px 3px rgba(0,0,0,0.5);
opacity: 0.5;
cursor: pointer;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.editeurOnglets span.ongletActuel{
opacity: 0.8;
font-weight: bold;
}
.editeurOnglets span:hover{
opacity: 1;
box-shadow:0px 0px 3px rgba(0,0,0,0.5), 0px 0px 7px rgba(255,255,255,1);
}
.editeurOnglets span:active{
opacity: 0.7;
font-weight: bold;
box-shadow:0px 0px 3px rgba(0,0,0,0.5), 0px 0px 7px rgba(255,255,255,0.5);
}
#divSuppOutil div{
position: absolute;
width: 10px;
height: 10px;
font-size: 10px;
cursor: pointer;
opacity: 1;
z-index: 1;
}
#divSuppOutil div:hover{
color: rgb(200,0,0);
}
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
identifier="http://getuniboard.com/"
version="1.6.0"
width="800"
height="600"
ub:resizable="true">
<name>Mathematical function plotter</name>
<content src="Grapheur.html"/>
</widget>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>GraphMe - Version</title>
</head>
<body>
<span style="font-size:12px; text-align:center;">2.1.0 (2018-06-04)</span>
</body>
</html>
██████ ███ ███
██ ██████ █████ ██████ ██ ██ ████ ████ ███████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██
██ ███ ███████ ███████ ██████ ███████ ██ ██ ██ █████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███████
---- 2.1 ----
Général:
- Résolution de bugs avec l'historique des fonctions
- Reprogrammation de la liste des fonctions
- Gestion des erreurs lors de la restauration de l'état sauvegardé
- Sauvegarde du mode d'affichage en cours, 3D ou 2D
- Sauvegarde de l'état de la liste des fonctions
- Sauvegarde de l'outil sélectionné
- Icône du widget amélioré pour OpenBoard
Interface:
- Amélioration de l'interface pour le changelog et l'aide
- Masquage des boutons de l'affichage en plein à écran avec OpenBoard
- Amélioration de l'affichage des fonctions dans l'historique
- Message d'info au chargement du widget en cas de fonctions restaurées
- Thème bleu foncé avec les coins carrés
Outils:
- Correction des outils décalés par rapport à la souris
---- 2.0.x ----
- (2.0.2) Amélioration de la sauvegarde du graphique en image:
affichage de l'image générée dans un menu
- (2.0.1) Cacher les nouveaux boutons de zoom en mode affichage 3D
- Bug: Impossible de changer de thème avec OpenBoard
- Bug: Les fonctions d'exemple ne fonctionnent pas si un autre type
que cartésien est sélectionné dans l'interface des fonctions
---- 2.0 ----
Général:
- Nouvelle interface adaptive selon la taille de la fenêtre
- Bug: Passer de 3D à 2D essaie de dessiner la fonction 3D en 2D
- Mettre en évidence l'outil sélectionné
- Boutons de zoom
- Historique des dernières fonctions pour tous les types de fonction
- Réinitialisation des inputs quand la page est actualisée
- Sauvegarde de l'état des inputs et de l'historique
---- 1.6 ----
Fonctions:
- Fonctions implicites (Par exemple un cercle: y^2 + x^2 = 9)
- Fonctions polaires (Par exemple une spirale: r(t) = t)
- Fonctions paramétriques (Par exemple un cercle: x(t) = cos(t) et y(t) = sin(t))
Interface:
- Traduction anglais/français selon la langue du navigateur
- Police d'écriture sans-serif
- Aperçu des fonctions implicites, polaires et paramétriques
- Dans la liste des fonctions, afficher la fonction ouverte dans l'éditeur
- Bug: L'éditeur permet d'éditer une fonction alors que la liste est vide
- Bug: Le choix du style de ligne par défaut ne fonctionne pas
- Bug: Bouton non cliquable près d'un message d'aide
Outils:
- Outil point et tangente pour les fonctions polaires et paramétriques.
---- 1.5.x ----
- (1.5.1) Sauvegarde du graphique 3D
- Amélioration du menu des mises à jour, prise en compte de tous les serveur
- Menu pour afficher les options sauvegardées dans les cookies
- Correction des problèmes de l'échelle et de la grille du graphique
- Bug: L'outil déplacement est stoppé quand on passe sur une flèche de déplacement
---- 1.5 ----
Fonction:
- Pouvoir changer le style de chaque fonction (ligne, points, traits)
- Bug: l'outil déplacement est toujours actif quand on sort du graphique
- Bug: le bouton dupliquer dans l'éditeur fonctionne mal
- Condition initiale de la primitive à coté de F(x) dans l'éditeur
(utilisation de disabled="disabled" lorsque F(x) n'est pas coché)
- Bug: impossible de modifier la fonction principale avec l'éditeur de fonctions
- Nouveau menu pour modifier les valeurs par défaut des fonctions
Affichage 3D:
- La partie de la fonction éloignée est maintenant dessinée après la partie proche
- La grille est plus visible
Outils:
- Suppression du menu des outils
- Outils pour chaque fonction dans le menu "fonctions"
Interface:
- Nouvelle interface. Onglets en haut du widget. Boutons "animés"
- Modifier l'aide pour qu'elle corresponde à la nouvelle interface
- Suppression de la sélection du texte sur les boutons et les onglets
- Joystick de déplacement en haut à gauche de l'affichage
- Choix des outils à la souris plus facile (ajout de boutons à gauche de l'affichage)
- Zone de texte au millieu de l'écran pour écrire facilement la première fonction
Focus automatique sur la zone
- Bulles d'aide
---- 1.4.x ----
- (1.4.3) ColorPicker: Récupérer la bonne couleur lors de l'ouverture
- ColorPicker: Pouvoir changer la couleur à partir des inputs
- ColorPicker: Choisir la couleur avec la roulette de la souris
- (1.4.2) Amélioration de la qualité et de la rapidité des études de fonction
- Pouvoir choisir la fonction à étudier
- Bug: impossible de modifier les fonctions depuis l'éditeur
- (1.4.1) Choisir la taille et la couleur de fond du graphique sauvegardé
- L'utilisation de ^ dans les fonctions n'est possible qu'avec un chiffre.
Il faudrait pouvoir écrire 2^x ou 4^(x+2)
- Bug: fermer le menu clique droit ajoute un point sur le graphique
---- 1.4 ----
Fonctions:
- Affichages canvas, svg et uniboard complétement refaits
- Grande amélioration des perfomances d'affichage 2D et 3D en définissant
les fonctions avec "new Function()"
- Amélioration des fonctions supplémentaires
- Suppression de la méthode d'affichage xpm
- Style de la fonction (continu, points, traits)
- Bug: la fonction 3D "sin(x)+cos(y)" afficher l'erreur "y is not defined";
- Couleur aléatoire pour les nouvelles fonctions supplémentaires
Interface:
- Menu clique droite sur le graphique
- Fenêtre d'édition des fonctions supplémentaires
- Désactiver le bouton de mise à jour automatique lorsqu'on utilise la version online du widget
(utiliser disabled="disabled")
Outils:
- Outils pour le nouvel affichage
- Outil point refait avec canvas
- Déplacer les informations des outils (point et tangente) à coté de la souris
- Bug: le déplacement de l'affichage 3D à la souris va dans le mauvais sens
- Cliquer permet de conserver le point ou la tangente actuelle
- Tous les outils fonctionnent en plein écran
- Outils sur plusieurs fonctions
ColorPicker:
- Bug: mauvaise couleur lorsque la teinte est à 240 ou 120
Général:
- Abandon du format xhtml pour passer à l'html5
- Sauvegardes pour les nouvelles options
- Amélioration des messages d'erreur
- Amélioration du système de mise à jour
---- 1.3.x ----
- (1.3.4) ColorPicker: Slide barre permettant de changer la transparence
- ColorPicker: Reprogrammer en canvas
- (1.3.3) Sauvegarde du graphique
- Remplacer les ^ par pow() pour pouvoir écrire des fonctions plus facilement,
comme x^2 ou (4-x)^5
- La couleur des fonctions supplémentaires n'est pas toujours juste
- (1.3.2) Modification de la taille des boutons
- (1.3.1) Mise à jour automatique
---- 1.3 ----
Fonctions:
- Amélioration des études de fonctions
- Pouvoir dessiner la dérivée seconde
- Corriger la tangente lorsque la zone d'affichage est modifiée
- Corriger l'échelle lors du déplacement de la fonction
- Ajout des fonctions sec, csc, arcsec, arccsc, sinh, cosh, tanh, coth, sech, csch
ainsi que arcsinh, arccosh, arctanh et arccoth
- Supprimer les traits où la fonction n'est pas définie
- Corriger l'outil point sur certaines fonctions (root(x,4))
(problème lié à la fonction non-définie)
- Aire sous la fonction
- Corrigé bug canvas lors de l'agrandissement
- Les outils de la souris ne fonctionnent pas au survol des flèches de déplacement
Interface:
- Sauvegarder les options
- Explication de la sauvegarde du graphique dans l'aide
- Guide d'utilisation
- Corrections dans l'aide
ColorPicker:
- Aperçu de la couleur
Autres:
- Modification de la précision par défaut
---- 1.2 ----
Fonctions:
- Dessiner plusieurs fonctions
- Historique
- Bug: certaines fonctions ne s'affichent pas correctement
exemples: pow(1-x*x*x, 1/3) , pow(x*x*x-3*x, 1/3) , pow(x*x*x-3*x+2, 1/3)
- Corriger l'affichage de la dérivée lorsqu'on change la précision d'affichage
- Corriger l'affichage des coordonnées
- Gestion des erreurs avec try and catch
- Outil tangente
Interface:
- Défilement des menus
- Tests d'affichage
- Bouton de maximisation du widget
- Mise à Jour
Affichage 3D:
- Zoom
-------------------------------
Idées d'améliorations futures
-------------------------------
Fonctions:
- Ajouter les fonctions arcsech et arccsch
- Détecter et mettre en évidence les AV
- Progression pendant le calcul des fonctions 3D
- Progression pendant l'étude de fonction
- Écrire le nom de la fonction sur le graphique
- Récupérer la fonction à partir de l'URL, pour pouvoir
envoyer le lien d'une fonction à qqn
- Bug: la puissance de la fonction sin(x)*cos(x)^2 n'est pas remplacée juste
- Sauvegarder l'historique
- Afficher le type de fonction dans l'éditeur
- Ne pas choisir aléatoirement la même couleur qu'une couleur déjà utilisée
- Amélioration du dessin des fonctions implicites
- Aperçu des fonctions d'exemple avant de les ajouter au graphique
Fonction 3D:
- Amélioration du choix de la couleur (interpolation entre 2 couleurs)
- Affichage 3D avec WebGL
Outils:
- Outils point et tangente pour les fonctions implicites
- Personnalisation de la sauvegarde du graphique
- Magnétisme de l'outil point
- Calculer le volume du corps de rotation de la fonction
- Outil affichant le cercle tangent à la courbe (selon la seconde dérivée)
- Utiliser le point de la fonction le plus proche de la position de la souris
Affichage:
- Style de grille: quadrillée, polaire, aucune
- Mode "trigonomètrique" pour que l'échelle soit affichée sur des multiples de PI
- Mode d'affichage ASCII
Affichage uniboard:
- Finir de coder
- Choisir où placer le graphique
- Uniboard 3D
Interface:
- Option pour redimensionner le widget dans OpenBoard / Sankoré
- Bulles d'aide
- Scroll dans uniboard
- Menu clique droit dans uniboard
- Le bouton actualiser dans le menu étude n'actualise pas forcément la bonne fonction
- Icone du bouton sauvegarder
- Cacher le joystick et les boutons des outils en mode plein écran après 5s
ColorPicker:
- Dessiner avec svg lorsqu'on choisit svg dans les options
- Vérifier les valeurs entrées dans les inputs
- Annuler le choix de la couleur ne revient pas au menu précédent
Général:
- Récupérer le numéro de la version en ligne pour comparer les versions
- Multithreading
!- Rendu des dessins progressivement de plus en plus précis
- Sauvegarder les options automatiquement, bouton reset dans le menu GraphMe
Script portable:
- Créer un script pour intégrer le widget à n'importe quelle page web
- Personnalisation de la taille du widget portable
- Déplacement du widget comme une fenêtre
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
id="http://www.amxa.ch/widgets/QR-Code"
version="1.0"
width="300"
height="340"
>
<name>QR-Code</name>
<description>QR-Code erzeugen</description>
<content src="index.html"/>
<icon src="icon.png"/>
<author>Basil Stotz</author>
<licence>
Creative Commons ShareAlike 3.0
http://creativecommons.org/licenses/by-sa/3.0/
</licence>
</widget>
*{
margin: 0;
padding: 0 ;
}
img{
width:200px;
}
.hidden{
display:none;
}
.grey{
background:lightgrey;
}
.center{
margin:auto;
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width">
<meta charset="UTF-8">
<link rel="stylesheet" href="design.css">
<script src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/jquery.qrcode.js"></script>
<script type="text/javascript" src="js//qrcode.js"></script>
<title>QR-Code</title>
</head>
<body class="grey">
<div id="codediv" class="hidden" style="margin:20px"></div>
<div id="textdiv" style="width:260px" class="hidden">
<p id="display" style="margin:auto;"></p>
</div>
<div id="formdiv" >
<form id="form" action="" style="padding-top:100px;width:100%">
<input type="text" size="30" id="qrtext" style="margin-left:15px;"><br/>
</form>
<img id="ok" src="ok.png" alt="" style="width:100px;margin-left:100px;"
</div>
<script src="js/main.js"></script>
</body>
</html>
/*! jQuery v3.2.1 | (c) JS Foundation and other contributors | jquery.org/license */
!function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){"use strict";var c=[],d=a.document,e=Object.getPrototypeOf,f=c.slice,g=c.concat,h=c.push,i=c.indexOf,j={},k=j.toString,l=j.hasOwnProperty,m=l.toString,n=m.call(Object),o={};function p(a,b){b=b||d;var c=b.createElement("script");c.text=a,b.head.appendChild(c).parentNode.removeChild(c)}var q="3.2.1",r=function(a,b){return new r.fn.init(a,b)},s=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/^-ms-/,u=/-([a-z])/g,v=function(a,b){return b.toUpperCase()};r.fn=r.prototype={jquery:q,constructor:r,length:0,toArray:function(){return f.call(this)},get:function(a){return null==a?f.call(this):a<0?this[a+this.length]:this[a]},pushStack:function(a){var b=r.merge(this.constructor(),a);return b.prevObject=this,b},each:function(a){return r.each(this,a)},map:function(a){return this.pushStack(r.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(f.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(a<0?b:0);return this.pushStack(c>=0&&c<b?[this[c]]:[])},end:function(){return this.prevObject||this.constructor()},push:h,sort:c.sort,splice:c.splice},r.extend=r.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||r.isFunction(g)||(g={}),h===i&&(g=this,h--);h<i;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(r.isPlainObject(d)||(e=Array.isArray(d)))?(e?(e=!1,f=c&&Array.isArray(c)?c:[]):f=c&&r.isPlainObject(c)?c:{},g[b]=r.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},r.extend({expando:"jQuery"+(q+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===r.type(a)},isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){var b=r.type(a);return("number"===b||"string"===b)&&!isNaN(a-parseFloat(a))},isPlainObject:function(a){var b,c;return!(!a||"[object Object]"!==k.call(a))&&(!(b=e(a))||(c=l.call(b,"constructor")&&b.constructor,"function"==typeof c&&m.call(c)===n))},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?j[k.call(a)]||"object":typeof a},globalEval:function(a){p(a)},camelCase:function(a){return a.replace(t,"ms-").replace(u,v)},each:function(a,b){var c,d=0;if(w(a)){for(c=a.length;d<c;d++)if(b.call(a[d],d,a[d])===!1)break}else for(d in a)if(b.call(a[d],d,a[d])===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(s,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(w(Object(a))?r.merge(c,"string"==typeof a?[a]:a):h.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:i.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;d<c;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;f<g;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,e,f=0,h=[];if(w(a))for(d=a.length;f<d;f++)e=b(a[f],f,c),null!=e&&h.push(e);else for(f in a)e=b(a[f],f,c),null!=e&&h.push(e);return g.apply([],h)},guid:1,proxy:function(a,b){var c,d,e;if("string"==typeof b&&(c=a[b],b=a,a=c),r.isFunction(a))return d=f.call(arguments,2),e=function(){return a.apply(b||this,d.concat(f.call(arguments)))},e.guid=a.guid=a.guid||r.guid++,e},now:Date.now,support:o}),"function"==typeof Symbol&&(r.fn[Symbol.iterator]=c[Symbol.iterator]),r.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(a,b){j["[object "+b+"]"]=b.toLowerCase()});function w(a){var b=!!a&&"length"in a&&a.length,c=r.type(a);return"function"!==c&&!r.isWindow(a)&&("array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a)}var x=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=function(a,b){for(var c=0,d=a.length;c<d;c++)if(a[c]===b)return c;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",M="\\["+K+"*("+L+")(?:"+K+"*([*^$|!~]?=)"+K+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+L+"))|)"+K+"*\\]",N=":("+L+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+M+")*)|.*)\\)|)",O=new RegExp(K+"+","g"),P=new RegExp("^"+K+"+|((?:^|[^\\\\])(?:\\\\.)*)"+K+"+$","g"),Q=new RegExp("^"+K+"*,"+K+"*"),R=new RegExp("^"+K+"*([>+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(N),U=new RegExp("^"+L+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L+"|[*])"),ATTR:new RegExp("^"+M),PSEUDO:new RegExp("^"+N),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),aa=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:d<0?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ba=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ca=function(a,b){return b?"\0"===a?"\ufffd":a.slice(0,-1)+"\\"+a.charCodeAt(a.length-1).toString(16)+" ":"\\"+a},da=function(){m()},ea=ta(function(a){return a.disabled===!0&&("form"in a||"label"in a)},{dir:"parentNode",next:"legend"});try{G.apply(D=H.call(v.childNodes),v.childNodes),D[v.childNodes.length].nodeType}catch(fa){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s=b&&b.ownerDocument,w=b?b.nodeType:9;if(d=d||[],"string"!=typeof a||!a||1!==w&&9!==w&&11!==w)return d;if(!e&&((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,p)){if(11!==w&&(l=Z.exec(a)))if(f=l[1]){if(9===w){if(!(j=b.getElementById(f)))return d;if(j.id===f)return d.push(j),d}else if(s&&(j=s.getElementById(f))&&t(b,j)&&j.id===f)return d.push(j),d}else{if(l[2])return G.apply(d,b.getElementsByTagName(a)),d;if((f=l[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(f)),d}if(c.qsa&&!A[a+" "]&&(!q||!q.test(a))){if(1!==w)s=b,r=a;else if("object"!==b.nodeName.toLowerCase()){(k=b.getAttribute("id"))?k=k.replace(ba,ca):b.setAttribute("id",k=u),o=g(a),h=o.length;while(h--)o[h]="#"+k+" "+sa(o[h]);r=o.join(","),s=$.test(a)&&qa(b.parentNode)||b}if(r)try{return G.apply(d,s.querySelectorAll(r)),d}catch(x){}finally{k===u&&b.removeAttribute("id")}}}return i(a.replace(P,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("fieldset");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=c.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&a.sourceIndex-b.sourceIndex;if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return function(b){return"form"in b?b.parentNode&&b.disabled===!1?"label"in b?"label"in b.parentNode?b.parentNode.disabled===a:b.disabled===a:b.isDisabled===a||b.isDisabled!==!a&&ea(b)===a:b.disabled===a:"label"in b&&b.disabled===a}}function pa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function qa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return!!b&&"HTML"!==b.nodeName},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=n.documentElement,p=!f(n),v!==n&&(e=n.defaultView)&&e.top!==e&&(e.addEventListener?e.addEventListener("unload",da,!1):e.attachEvent&&e.attachEvent("onunload",da)),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(n.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(n.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!n.getElementsByName||!n.getElementsByName(u).length}),c.getById?(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){return a.getAttribute("id")===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c?[c]:[]}}):(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c,d,e,f=b.getElementById(a);if(f){if(c=f.getAttributeNode("id"),c&&c.value===a)return[f];e=b.getElementsByName(a),d=0;while(f=e[d++])if(c=f.getAttributeNode("id"),c&&c.value===a)return[f]}return[]}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){if("undefined"!=typeof b.getElementsByClassName&&p)return b.getElementsByClassName(a)},r=[],q=[],(c.qsa=Y.test(n.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="<a id='"+u+"'></a><select id='"+u+"-\r\\' msallowcapture=''><option selected=''></option></select>",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){a.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var b=n.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+K+"*[*^$|!~]?="),2!==a.querySelectorAll(":enabled").length&&q.push(":enabled",":disabled"),o.appendChild(a).disabled=!0,2!==a.querySelectorAll(":disabled").length&&q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=Y.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"*"),s.call(a,"[s!='']:x"),r.push("!=",N)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=Y.test(o.compareDocumentPosition),t=b||Y.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===n||a.ownerDocument===v&&t(v,a)?-1:b===n||b.ownerDocument===v&&t(v,b)?1:k?I(k,a)-I(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,g=[a],h=[b];if(!e||!f)return a===n?-1:b===n?1:e?-1:f?1:k?I(k,a)-I(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)g.unshift(c);c=b;while(c=c.parentNode)h.unshift(c);while(g[d]===h[d])d++;return d?la(g[d],h[d]):g[d]===v?-1:h[d]===v?1:0},n):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(S,"='$1']"),c.matchesSelector&&p&&!A[b+" "]&&(!r||!r.test(b))&&(!q||!q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.escape=function(a){return(a+"").replace(ba,ca)},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(_,aa),a[3]=(a[3]||a[4]||a[5]||"").replace(_,aa),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return V.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&T.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(_,aa).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:!b||(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(O," ")+" ").indexOf(c)>-1:"|="===b&&(e===c||e.slice(0,c.length+1)===c+"-"))}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h,t=!1;if(q){if(f){while(p){m=b;while(m=m[p])if(h?m.nodeName.toLowerCase()===r:1===m.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){m=q,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n&&j[2],m=n&&q.childNodes[n];while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if(1===m.nodeType&&++t&&m===b){k[a]=[w,n,t];break}}else if(s&&(m=b,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n),t===!1)while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if((h?m.nodeName.toLowerCase()===r:1===m.nodeType)&&++t&&(s&&(l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),k[a]=[w,t]),m===b))break;return t-=e,t===d||t%d===0&&t/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(P,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(_,aa),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return U.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(_,aa).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:oa(!1),disabled:oa(!0),checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:pa(function(){return[0]}),last:pa(function(a,b){return[b-1]}),eq:pa(function(a,b,c){return[c<0?c+b:c]}),even:pa(function(a,b){for(var c=0;c<b;c+=2)a.push(c);return a}),odd:pa(function(a,b){for(var c=1;c<b;c+=2)a.push(c);return a}),lt:pa(function(a,b,c){for(var d=c<0?c+b:c;--d>=0;)a.push(d);return a}),gt:pa(function(a,b,c){for(var d=c<0?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=ma(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=na(b);function ra(){}ra.prototype=d.filters=d.pseudos,d.setFilters=new ra,g=ga.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){c&&!(e=Q.exec(h))||(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=R.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(P," ")}),h=h.slice(c.length));for(g in d.filter)!(e=V[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?ga.error(a):z(a,i).slice(0)};function sa(a){for(var b=0,c=a.length,d="";b<c;b++)d+=a[b].value;return d}function ta(a,b,c){var d=b.dir,e=b.next,f=e||d,g=c&&"parentNode"===f,h=x++;return b.first?function(b,c,e){while(b=b[d])if(1===b.nodeType||g)return a(b,c,e);return!1}:function(b,c,i){var j,k,l,m=[w,h];if(i){while(b=b[d])if((1===b.nodeType||g)&&a(b,c,i))return!0}else while(b=b[d])if(1===b.nodeType||g)if(l=b[u]||(b[u]={}),k=l[b.uniqueID]||(l[b.uniqueID]={}),e&&e===b.nodeName.toLowerCase())b=b[d]||b;else{if((j=k[f])&&j[0]===w&&j[1]===h)return m[2]=j[2];if(k[f]=m,m[2]=a(b,c,i))return!0}return!1}}function ua(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function va(a,b,c){for(var d=0,e=b.length;d<e;d++)ga(a,b[d],c);return c}function wa(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;h<i;h++)(f=a[h])&&(c&&!c(f,d,e)||(g.push(f),j&&b.push(h)));return g}function xa(a,b,c,d,e,f){return d&&!d[u]&&(d=xa(d)),e&&!e[u]&&(e=xa(e,f)),ia(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||va(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:wa(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=wa(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?I(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=wa(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ya(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=ta(function(a){return a===b},h,!0),l=ta(function(a){return I(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];i<f;i++)if(c=d.relative[a[i].type])m=[ta(ua(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;e<f;e++)if(d.relative[a[e].type])break;return xa(i>1&&ua(m),i>1&&sa(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(P,"$1"),c,i<e&&ya(a.slice(i,e)),e<f&&ya(a=a.slice(e)),e<f&&sa(a))}m.push(c)}return ua(m)}function za(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,o,q,r=0,s="0",t=f&&[],u=[],v=j,x=f||e&&d.find.TAG("*",k),y=w+=null==v?1:Math.random()||.1,z=x.length;for(k&&(j=g===n||g||k);s!==z&&null!=(l=x[s]);s++){if(e&&l){o=0,g||l.ownerDocument===n||(m(l),h=!p);while(q=a[o++])if(q(l,g||n,h)){i.push(l);break}k&&(w=y)}c&&((l=!q&&l)&&r--,f&&t.push(l))}if(r+=s,c&&s!==r){o=0;while(q=b[o++])q(t,u,g,h);if(f){if(r>0)while(s--)t[s]||u[s]||(u[s]=E.call(i));u=wa(u)}G.apply(i,u),k&&!f&&u.length>0&&r+b.length>1&&ga.uniqueSort(i)}return k&&(w=y,j=v),t};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=ya(b[c]),f[u]?d.push(f):e.push(f);f=A(a,za(e,d)),f.selector=a}return f},i=ga.select=function(a,b,c,e){var f,i,j,k,l,m="function"==typeof a&&a,n=!e&&g(a=m.selector||a);if(c=c||[],1===n.length){if(i=n[0]=n[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&9===b.nodeType&&p&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(_,aa),b)||[])[0],!b)return c;m&&(b=b.parentNode),a=a.slice(i.shift().value.length)}f=V.needsContext.test(a)?0:i.length;while(f--){if(j=i[f],d.relative[k=j.type])break;if((l=d.find[k])&&(e=l(j.matches[0].replace(_,aa),$.test(i[0].type)&&qa(b.parentNode)||b))){if(i.splice(f,1),a=e.length&&sa(i),!a)return G.apply(c,e),c;break}}}return(m||h(a,n))(e,b,!p,c,!b||$.test(a)&&qa(b.parentNode)||b),c},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("fieldset"))}),ja(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){if(!c)return a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){if(!c&&"input"===a.nodeName.toLowerCase())return a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(J,function(a,b,c){var d;if(!c)return a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);r.find=x,r.expr=x.selectors,r.expr[":"]=r.expr.pseudos,r.uniqueSort=r.unique=x.uniqueSort,r.text=x.getText,r.isXMLDoc=x.isXML,r.contains=x.contains,r.escapeSelector=x.escape;var y=function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&r(a).is(c))break;d.push(a)}return d},z=function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c},A=r.expr.match.needsContext;function B(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()}var C=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i,D=/^.[^:#\[\.,]*$/;function E(a,b,c){return r.isFunction(b)?r.grep(a,function(a,d){return!!b.call(a,d,a)!==c}):b.nodeType?r.grep(a,function(a){return a===b!==c}):"string"!=typeof b?r.grep(a,function(a){return i.call(b,a)>-1!==c}):D.test(b)?r.filter(b,a,c):(b=r.filter(b,a),r.grep(a,function(a){return i.call(b,a)>-1!==c&&1===a.nodeType}))}r.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?r.find.matchesSelector(d,a)?[d]:[]:r.find.matches(a,r.grep(b,function(a){return 1===a.nodeType}))},r.fn.extend({find:function(a){var b,c,d=this.length,e=this;if("string"!=typeof a)return this.pushStack(r(a).filter(function(){for(b=0;b<d;b++)if(r.contains(e[b],this))return!0}));for(c=this.pushStack([]),b=0;b<d;b++)r.find(a,e[b],c);return d>1?r.uniqueSort(c):c},filter:function(a){return this.pushStack(E(this,a||[],!1))},not:function(a){return this.pushStack(E(this,a||[],!0))},is:function(a){return!!E(this,"string"==typeof a&&A.test(a)?r(a):a||[],!1).length}});var F,G=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,H=r.fn.init=function(a,b,c){var e,f;if(!a)return this;if(c=c||F,"string"==typeof a){if(e="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:G.exec(a),!e||!e[1]&&b)return!b||b.jquery?(b||c).find(a):this.constructor(b).find(a);if(e[1]){if(b=b instanceof r?b[0]:b,r.merge(this,r.parseHTML(e[1],b&&b.nodeType?b.ownerDocument||b:d,!0)),C.test(e[1])&&r.isPlainObject(b))for(e in b)r.isFunction(this[e])?this[e](b[e]):this.attr(e,b[e]);return this}return f=d.getElementById(e[2]),f&&(this[0]=f,this.length=1),this}return a.nodeType?(this[0]=a,this.length=1,this):r.isFunction(a)?void 0!==c.ready?c.ready(a):a(r):r.makeArray(a,this)};H.prototype=r.fn,F=r(d);var I=/^(?:parents|prev(?:Until|All))/,J={children:!0,contents:!0,next:!0,prev:!0};r.fn.extend({has:function(a){var b=r(a,this),c=b.length;return this.filter(function(){for(var a=0;a<c;a++)if(r.contains(this,b[a]))return!0})},closest:function(a,b){var c,d=0,e=this.length,f=[],g="string"!=typeof a&&r(a);if(!A.test(a))for(;d<e;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&r.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?r.uniqueSort(f):f)},index:function(a){return a?"string"==typeof a?i.call(r(a),this[0]):i.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(r.uniqueSort(r.merge(this.get(),r(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function K(a,b){while((a=a[b])&&1!==a.nodeType);return a}r.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return y(a,"parentNode")},parentsUntil:function(a,b,c){return y(a,"parentNode",c)},next:function(a){return K(a,"nextSibling")},prev:function(a){return K(a,"previousSibling")},nextAll:function(a){return y(a,"nextSibling")},prevAll:function(a){return y(a,"previousSibling")},nextUntil:function(a,b,c){return y(a,"nextSibling",c)},prevUntil:function(a,b,c){return y(a,"previousSibling",c)},siblings:function(a){return z((a.parentNode||{}).firstChild,a)},children:function(a){return z(a.firstChild)},contents:function(a){return B(a,"iframe")?a.contentDocument:(B(a,"template")&&(a=a.content||a),r.merge([],a.childNodes))}},function(a,b){r.fn[a]=function(c,d){var e=r.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=r.filter(d,e)),this.length>1&&(J[a]||r.uniqueSort(e),I.test(a)&&e.reverse()),this.pushStack(e)}});var L=/[^\x20\t\r\n\f]+/g;function M(a){var b={};return r.each(a.match(L)||[],function(a,c){b[c]=!0}),b}r.Callbacks=function(a){a="string"==typeof a?M(a):r.extend({},a);var b,c,d,e,f=[],g=[],h=-1,i=function(){for(e=e||a.once,d=b=!0;g.length;h=-1){c=g.shift();while(++h<f.length)f[h].apply(c[0],c[1])===!1&&a.stopOnFalse&&(h=f.length,c=!1)}a.memory||(c=!1),b=!1,e&&(f=c?[]:"")},j={add:function(){return f&&(c&&!b&&(h=f.length-1,g.push(c)),function d(b){r.each(b,function(b,c){r.isFunction(c)?a.unique&&j.has(c)||f.push(c):c&&c.length&&"string"!==r.type(c)&&d(c)})}(arguments),c&&!b&&i()),this},remove:function(){return r.each(arguments,function(a,b){var c;while((c=r.inArray(b,f,c))>-1)f.splice(c,1),c<=h&&h--}),this},has:function(a){return a?r.inArray(a,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return e=g=[],f=c="",this},disabled:function(){return!f},lock:function(){return e=g=[],c||b||(f=c=""),this},locked:function(){return!!e},fireWith:function(a,c){return e||(c=c||[],c=[a,c.slice?c.slice():c],g.push(c),b||i()),this},fire:function(){return j.fireWith(this,arguments),this},fired:function(){return!!d}};return j};function N(a){return a}function O(a){throw a}function P(a,b,c,d){var e;try{a&&r.isFunction(e=a.promise)?e.call(a).done(b).fail(c):a&&r.isFunction(e=a.then)?e.call(a,b,c):b.apply(void 0,[a].slice(d))}catch(a){c.apply(void 0,[a])}}r.extend({Deferred:function(b){var c=[["notify","progress",r.Callbacks("memory"),r.Callbacks("memory"),2],["resolve","done",r.Callbacks("once memory"),r.Callbacks("once memory"),0,"resolved"],["reject","fail",r.Callbacks("once memory"),r.Callbacks("once memory"),1,"rejected"]],d="pending",e={state:function(){return d},always:function(){return f.done(arguments).fail(arguments),this},"catch":function(a){return e.then(null,a)},pipe:function(){var a=arguments;return r.Deferred(function(b){r.each(c,function(c,d){var e=r.isFunction(a[d[4]])&&a[d[4]];f[d[1]](function(){var a=e&&e.apply(this,arguments);a&&r.isFunction(a.promise)?a.promise().progress(b.notify).done(b.resolve).fail(b.reject):b[d[0]+"With"](this,e?[a]:arguments)})}),a=null}).promise()},then:function(b,d,e){var f=0;function g(b,c,d,e){return function(){var h=this,i=arguments,j=function(){var a,j;if(!(b<f)){if(a=d.apply(h,i),a===c.promise())throw new TypeError("Thenable self-resolution");j=a&&("object"==typeof a||"function"==typeof a)&&a.then,r.isFunction(j)?e?j.call(a,g(f,c,N,e),g(f,c,O,e)):(f++,j.call(a,g(f,c,N,e),g(f,c,O,e),g(f,c,N,c.notifyWith))):(d!==N&&(h=void 0,i=[a]),(e||c.resolveWith)(h,i))}},k=e?j:function(){try{j()}catch(a){r.Deferred.exceptionHook&&r.Deferred.exceptionHook(a,k.stackTrace),b+1>=f&&(d!==O&&(h=void 0,i=[a]),c.rejectWith(h,i))}};b?k():(r.Deferred.getStackHook&&(k.stackTrace=r.Deferred.getStackHook()),a.setTimeout(k))}}return r.Deferred(function(a){c[0][3].add(g(0,a,r.isFunction(e)?e:N,a.notifyWith)),c[1][3].add(g(0,a,r.isFunction(b)?b:N)),c[2][3].add(g(0,a,r.isFunction(d)?d:O))}).promise()},promise:function(a){return null!=a?r.extend(a,e):e}},f={};return r.each(c,function(a,b){var g=b[2],h=b[5];e[b[1]]=g.add,h&&g.add(function(){d=h},c[3-a][2].disable,c[0][2].lock),g.add(b[3].fire),f[b[0]]=function(){return f[b[0]+"With"](this===f?void 0:this,arguments),this},f[b[0]+"With"]=g.fireWith}),e.promise(f),b&&b.call(f,f),f},when:function(a){var b=arguments.length,c=b,d=Array(c),e=f.call(arguments),g=r.Deferred(),h=function(a){return function(c){d[a]=this,e[a]=arguments.length>1?f.call(arguments):c,--b||g.resolveWith(d,e)}};if(b<=1&&(P(a,g.done(h(c)).resolve,g.reject,!b),"pending"===g.state()||r.isFunction(e[c]&&e[c].then)))return g.then();while(c--)P(e[c],h(c),g.reject);return g.promise()}});var Q=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;r.Deferred.exceptionHook=function(b,c){a.console&&a.console.warn&&b&&Q.test(b.name)&&a.console.warn("jQuery.Deferred exception: "+b.message,b.stack,c)},r.readyException=function(b){a.setTimeout(function(){throw b})};var R=r.Deferred();r.fn.ready=function(a){return R.then(a)["catch"](function(a){r.readyException(a)}),this},r.extend({isReady:!1,readyWait:1,ready:function(a){(a===!0?--r.readyWait:r.isReady)||(r.isReady=!0,a!==!0&&--r.readyWait>0||R.resolveWith(d,[r]))}}),r.ready.then=R.then;function S(){d.removeEventListener("DOMContentLoaded",S),
a.removeEventListener("load",S),r.ready()}"complete"===d.readyState||"loading"!==d.readyState&&!d.documentElement.doScroll?a.setTimeout(r.ready):(d.addEventListener("DOMContentLoaded",S),a.addEventListener("load",S));var T=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===r.type(c)){e=!0;for(h in c)T(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,r.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(r(a),c)})),b))for(;h<i;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},U=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function V(){this.expando=r.expando+V.uid++}V.uid=1,V.prototype={cache:function(a){var b=a[this.expando];return b||(b={},U(a)&&(a.nodeType?a[this.expando]=b:Object.defineProperty(a,this.expando,{value:b,configurable:!0}))),b},set:function(a,b,c){var d,e=this.cache(a);if("string"==typeof b)e[r.camelCase(b)]=c;else for(d in b)e[r.camelCase(d)]=b[d];return e},get:function(a,b){return void 0===b?this.cache(a):a[this.expando]&&a[this.expando][r.camelCase(b)]},access:function(a,b,c){return void 0===b||b&&"string"==typeof b&&void 0===c?this.get(a,b):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d=a[this.expando];if(void 0!==d){if(void 0!==b){Array.isArray(b)?b=b.map(r.camelCase):(b=r.camelCase(b),b=b in d?[b]:b.match(L)||[]),c=b.length;while(c--)delete d[b[c]]}(void 0===b||r.isEmptyObject(d))&&(a.nodeType?a[this.expando]=void 0:delete a[this.expando])}},hasData:function(a){var b=a[this.expando];return void 0!==b&&!r.isEmptyObject(b)}};var W=new V,X=new V,Y=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Z=/[A-Z]/g;function $(a){return"true"===a||"false"!==a&&("null"===a?null:a===+a+""?+a:Y.test(a)?JSON.parse(a):a)}function _(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(Z,"-$&").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c=$(c)}catch(e){}X.set(a,b,c)}else c=void 0;return c}r.extend({hasData:function(a){return X.hasData(a)||W.hasData(a)},data:function(a,b,c){return X.access(a,b,c)},removeData:function(a,b){X.remove(a,b)},_data:function(a,b,c){return W.access(a,b,c)},_removeData:function(a,b){W.remove(a,b)}}),r.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=X.get(f),1===f.nodeType&&!W.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=r.camelCase(d.slice(5)),_(f,d,e[d])));W.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){X.set(this,a)}):T(this,function(b){var c;if(f&&void 0===b){if(c=X.get(f,a),void 0!==c)return c;if(c=_(f,a),void 0!==c)return c}else this.each(function(){X.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){X.remove(this,a)})}}),r.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=W.get(a,b),c&&(!d||Array.isArray(c)?d=W.access(a,b,r.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=r.queue(a,b),d=c.length,e=c.shift(),f=r._queueHooks(a,b),g=function(){r.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return W.get(a,c)||W.access(a,c,{empty:r.Callbacks("once memory").add(function(){W.remove(a,[b+"queue",c])})})}}),r.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?r.queue(this[0],a):void 0===b?this:this.each(function(){var c=r.queue(this,a,b);r._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&r.dequeue(this,a)})},dequeue:function(a){return this.each(function(){r.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=r.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=W.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var aa=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,ba=new RegExp("^(?:([+-])=|)("+aa+")([a-z%]*)$","i"),ca=["Top","Right","Bottom","Left"],da=function(a,b){return a=b||a,"none"===a.style.display||""===a.style.display&&r.contains(a.ownerDocument,a)&&"none"===r.css(a,"display")},ea=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};function fa(a,b,c,d){var e,f=1,g=20,h=d?function(){return d.cur()}:function(){return r.css(a,b,"")},i=h(),j=c&&c[3]||(r.cssNumber[b]?"":"px"),k=(r.cssNumber[b]||"px"!==j&&+i)&&ba.exec(r.css(a,b));if(k&&k[3]!==j){j=j||k[3],c=c||[],k=+i||1;do f=f||".5",k/=f,r.style(a,b,k+j);while(f!==(f=h()/i)&&1!==f&&--g)}return c&&(k=+k||+i||0,e=c[1]?k+(c[1]+1)*c[2]:+c[2],d&&(d.unit=j,d.start=k,d.end=e)),e}var ga={};function ha(a){var b,c=a.ownerDocument,d=a.nodeName,e=ga[d];return e?e:(b=c.body.appendChild(c.createElement(d)),e=r.css(b,"display"),b.parentNode.removeChild(b),"none"===e&&(e="block"),ga[d]=e,e)}function ia(a,b){for(var c,d,e=[],f=0,g=a.length;f<g;f++)d=a[f],d.style&&(c=d.style.display,b?("none"===c&&(e[f]=W.get(d,"display")||null,e[f]||(d.style.display="")),""===d.style.display&&da(d)&&(e[f]=ha(d))):"none"!==c&&(e[f]="none",W.set(d,"display",c)));for(f=0;f<g;f++)null!=e[f]&&(a[f].style.display=e[f]);return a}r.fn.extend({show:function(){return ia(this,!0)},hide:function(){return ia(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){da(this)?r(this).show():r(this).hide()})}});var ja=/^(?:checkbox|radio)$/i,ka=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i,la=/^$|\/(?:java|ecma)script/i,ma={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};ma.optgroup=ma.option,ma.tbody=ma.tfoot=ma.colgroup=ma.caption=ma.thead,ma.th=ma.td;function na(a,b){var c;return c="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||"*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):[],void 0===b||b&&B(a,b)?r.merge([a],c):c}function oa(a,b){for(var c=0,d=a.length;c<d;c++)W.set(a[c],"globalEval",!b||W.get(b[c],"globalEval"))}var pa=/<|&#?\w+;/;function qa(a,b,c,d,e){for(var f,g,h,i,j,k,l=b.createDocumentFragment(),m=[],n=0,o=a.length;n<o;n++)if(f=a[n],f||0===f)if("object"===r.type(f))r.merge(m,f.nodeType?[f]:f);else if(pa.test(f)){g=g||l.appendChild(b.createElement("div")),h=(ka.exec(f)||["",""])[1].toLowerCase(),i=ma[h]||ma._default,g.innerHTML=i[1]+r.htmlPrefilter(f)+i[2],k=i[0];while(k--)g=g.lastChild;r.merge(m,g.childNodes),g=l.firstChild,g.textContent=""}else m.push(b.createTextNode(f));l.textContent="",n=0;while(f=m[n++])if(d&&r.inArray(f,d)>-1)e&&e.push(f);else if(j=r.contains(f.ownerDocument,f),g=na(l.appendChild(f),"script"),j&&oa(g),c){k=0;while(f=g[k++])la.test(f.type||"")&&c.push(f)}return l}!function(){var a=d.createDocumentFragment(),b=a.appendChild(d.createElement("div")),c=d.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),o.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="<textarea>x</textarea>",o.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var ra=d.documentElement,sa=/^key/,ta=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,ua=/^([^.]*)(?:\.(.+)|)/;function va(){return!0}function wa(){return!1}function xa(){try{return d.activeElement}catch(a){}}function ya(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)ya(a,h,c,d,b[h],f);return a}if(null==d&&null==e?(e=c,d=c=void 0):null==e&&("string"==typeof c?(e=d,d=void 0):(e=d,d=c,c=void 0)),e===!1)e=wa;else if(!e)return a;return 1===f&&(g=e,e=function(a){return r().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=r.guid++)),a.each(function(){r.event.add(this,b,e,d,c)})}r.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=W.get(a);if(q){c.handler&&(f=c,c=f.handler,e=f.selector),e&&r.find.matchesSelector(ra,e),c.guid||(c.guid=r.guid++),(i=q.events)||(i=q.events={}),(g=q.handle)||(g=q.handle=function(b){return"undefined"!=typeof r&&r.event.triggered!==b.type?r.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(L)||[""],j=b.length;while(j--)h=ua.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n&&(l=r.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=r.event.special[n]||{},k=r.extend({type:n,origType:p,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&r.expr.match.needsContext.test(e),namespace:o.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,o,g)!==!1||a.addEventListener&&a.addEventListener(n,g)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),r.event.global[n]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=W.hasData(a)&&W.get(a);if(q&&(i=q.events)){b=(b||"").match(L)||[""],j=b.length;while(j--)if(h=ua.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n){l=r.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],h=h[2]&&new RegExp("(^|\\.)"+o.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&p!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,o,q.handle)!==!1||r.removeEvent(a,n,q.handle),delete i[n])}else for(n in i)r.event.remove(a,n+b[j],c,d,!0);r.isEmptyObject(i)&&W.remove(a,"handle events")}},dispatch:function(a){var b=r.event.fix(a),c,d,e,f,g,h,i=new Array(arguments.length),j=(W.get(this,"events")||{})[b.type]||[],k=r.event.special[b.type]||{};for(i[0]=b,c=1;c<arguments.length;c++)i[c]=arguments[c];if(b.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,b)!==!1){h=r.event.handlers.call(this,b,j),c=0;while((f=h[c++])&&!b.isPropagationStopped()){b.currentTarget=f.elem,d=0;while((g=f.handlers[d++])&&!b.isImmediatePropagationStopped())b.rnamespace&&!b.rnamespace.test(g.namespace)||(b.handleObj=g,b.data=g.data,e=((r.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(b.result=e)===!1&&(b.preventDefault(),b.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,b),b.result}},handlers:function(a,b){var c,d,e,f,g,h=[],i=b.delegateCount,j=a.target;if(i&&j.nodeType&&!("click"===a.type&&a.button>=1))for(;j!==this;j=j.parentNode||this)if(1===j.nodeType&&("click"!==a.type||j.disabled!==!0)){for(f=[],g={},c=0;c<i;c++)d=b[c],e=d.selector+" ",void 0===g[e]&&(g[e]=d.needsContext?r(e,this).index(j)>-1:r.find(e,this,null,[j]).length),g[e]&&f.push(d);f.length&&h.push({elem:j,handlers:f})}return j=this,i<b.length&&h.push({elem:j,handlers:b.slice(i)}),h},addProp:function(a,b){Object.defineProperty(r.Event.prototype,a,{enumerable:!0,configurable:!0,get:r.isFunction(b)?function(){if(this.originalEvent)return b(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[a]},set:function(b){Object.defineProperty(this,a,{enumerable:!0,configurable:!0,writable:!0,value:b})}})},fix:function(a){return a[r.expando]?a:new r.Event(a)},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==xa()&&this.focus)return this.focus(),!1},delegateType:"focusin"},blur:{trigger:function(){if(this===xa()&&this.blur)return this.blur(),!1},delegateType:"focusout"},click:{trigger:function(){if("checkbox"===this.type&&this.click&&B(this,"input"))return this.click(),!1},_default:function(a){return B(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}}},r.removeEvent=function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c)},r.Event=function(a,b){return this instanceof r.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.returnValue===!1?va:wa,this.target=a.target&&3===a.target.nodeType?a.target.parentNode:a.target,this.currentTarget=a.currentTarget,this.relatedTarget=a.relatedTarget):this.type=a,b&&r.extend(this,b),this.timeStamp=a&&a.timeStamp||r.now(),void(this[r.expando]=!0)):new r.Event(a,b)},r.Event.prototype={constructor:r.Event,isDefaultPrevented:wa,isPropagationStopped:wa,isImmediatePropagationStopped:wa,isSimulated:!1,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=va,a&&!this.isSimulated&&a.preventDefault()},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=va,a&&!this.isSimulated&&a.stopPropagation()},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=va,a&&!this.isSimulated&&a.stopImmediatePropagation(),this.stopPropagation()}},r.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,"char":!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:function(a){var b=a.button;return null==a.which&&sa.test(a.type)?null!=a.charCode?a.charCode:a.keyCode:!a.which&&void 0!==b&&ta.test(a.type)?1&b?1:2&b?3:4&b?2:0:a.which}},r.event.addProp),r.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,b){r.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return e&&(e===d||r.contains(d,e))||(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),r.fn.extend({on:function(a,b,c,d){return ya(this,a,b,c,d)},one:function(a,b,c,d){return ya(this,a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,r(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return b!==!1&&"function"!=typeof b||(c=b,b=void 0),c===!1&&(c=wa),this.each(function(){r.event.remove(this,a,c,b)})}});var za=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,Aa=/<script|<style|<link/i,Ba=/checked\s*(?:[^=]|=\s*.checked.)/i,Ca=/^true\/(.*)/,Da=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;function Ea(a,b){return B(a,"table")&&B(11!==b.nodeType?b:b.firstChild,"tr")?r(">tbody",a)[0]||a:a}function Fa(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function Ga(a){var b=Ca.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Ha(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(W.hasData(a)&&(f=W.access(a),g=W.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;c<d;c++)r.event.add(b,e,j[e][c])}X.hasData(a)&&(h=X.access(a),i=r.extend({},h),X.set(b,i))}}function Ia(a,b){var c=b.nodeName.toLowerCase();"input"===c&&ja.test(a.type)?b.checked=a.checked:"input"!==c&&"textarea"!==c||(b.defaultValue=a.defaultValue)}function Ja(a,b,c,d){b=g.apply([],b);var e,f,h,i,j,k,l=0,m=a.length,n=m-1,q=b[0],s=r.isFunction(q);if(s||m>1&&"string"==typeof q&&!o.checkClone&&Ba.test(q))return a.each(function(e){var f=a.eq(e);s&&(b[0]=q.call(this,e,f.html())),Ja(f,b,c,d)});if(m&&(e=qa(b,a[0].ownerDocument,!1,a,d),f=e.firstChild,1===e.childNodes.length&&(e=f),f||d)){for(h=r.map(na(e,"script"),Fa),i=h.length;l<m;l++)j=e,l!==n&&(j=r.clone(j,!0,!0),i&&r.merge(h,na(j,"script"))),c.call(a[l],j,l);if(i)for(k=h[h.length-1].ownerDocument,r.map(h,Ga),l=0;l<i;l++)j=h[l],la.test(j.type||"")&&!W.access(j,"globalEval")&&r.contains(k,j)&&(j.src?r._evalUrl&&r._evalUrl(j.src):p(j.textContent.replace(Da,""),k))}return a}function Ka(a,b,c){for(var d,e=b?r.filter(b,a):a,f=0;null!=(d=e[f]);f++)c||1!==d.nodeType||r.cleanData(na(d)),d.parentNode&&(c&&r.contains(d.ownerDocument,d)&&oa(na(d,"script")),d.parentNode.removeChild(d));return a}r.extend({htmlPrefilter:function(a){return a.replace(za,"<$1></$2>")},clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=r.contains(a.ownerDocument,a);if(!(o.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||r.isXMLDoc(a)))for(g=na(h),f=na(a),d=0,e=f.length;d<e;d++)Ia(f[d],g[d]);if(b)if(c)for(f=f||na(a),g=g||na(h),d=0,e=f.length;d<e;d++)Ha(f[d],g[d]);else Ha(a,h);return g=na(h,"script"),g.length>0&&oa(g,!i&&na(a,"script")),h},cleanData:function(a){for(var b,c,d,e=r.event.special,f=0;void 0!==(c=a[f]);f++)if(U(c)){if(b=c[W.expando]){if(b.events)for(d in b.events)e[d]?r.event.remove(c,d):r.removeEvent(c,d,b.handle);c[W.expando]=void 0}c[X.expando]&&(c[X.expando]=void 0)}}}),r.fn.extend({detach:function(a){return Ka(this,a,!0)},remove:function(a){return Ka(this,a)},text:function(a){return T(this,function(a){return void 0===a?r.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=a)})},null,a,arguments.length)},append:function(){return Ja(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Ea(this,a);b.appendChild(a)}})},prepend:function(){return Ja(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Ea(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return Ja(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return Ja(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(r.cleanData(na(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null!=a&&a,b=null==b?a:b,this.map(function(){return r.clone(this,a,b)})},html:function(a){return T(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!Aa.test(a)&&!ma[(ka.exec(a)||["",""])[1].toLowerCase()]){a=r.htmlPrefilter(a);try{for(;c<d;c++)b=this[c]||{},1===b.nodeType&&(r.cleanData(na(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=[];return Ja(this,arguments,function(b){var c=this.parentNode;r.inArray(this,a)<0&&(r.cleanData(na(this)),c&&c.replaceChild(b,this))},a)}}),r.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){r.fn[a]=function(a){for(var c,d=[],e=r(a),f=e.length-1,g=0;g<=f;g++)c=g===f?this:this.clone(!0),r(e[g])[b](c),h.apply(d,c.get());return this.pushStack(d)}});var La=/^margin/,Ma=new RegExp("^("+aa+")(?!px)[a-z%]+$","i"),Na=function(b){var c=b.ownerDocument.defaultView;return c&&c.opener||(c=a),c.getComputedStyle(b)};!function(){function b(){if(i){i.style.cssText="box-sizing:border-box;position:relative;display:block;margin:auto;border:1px;padding:1px;top:1%;width:50%",i.innerHTML="",ra.appendChild(h);var b=a.getComputedStyle(i);c="1%"!==b.top,g="2px"===b.marginLeft,e="4px"===b.width,i.style.marginRight="50%",f="4px"===b.marginRight,ra.removeChild(h),i=null}}var c,e,f,g,h=d.createElement("div"),i=d.createElement("div");i.style&&(i.style.backgroundClip="content-box",i.cloneNode(!0).style.backgroundClip="",o.clearCloneStyle="content-box"===i.style.backgroundClip,h.style.cssText="border:0;width:8px;height:0;top:0;left:-9999px;padding:0;margin-top:1px;position:absolute",h.appendChild(i),r.extend(o,{pixelPosition:function(){return b(),c},boxSizingReliable:function(){return b(),e},pixelMarginRight:function(){return b(),f},reliableMarginLeft:function(){return b(),g}}))}();function Oa(a,b,c){var d,e,f,g,h=a.style;return c=c||Na(a),c&&(g=c.getPropertyValue(b)||c[b],""!==g||r.contains(a.ownerDocument,a)||(g=r.style(a,b)),!o.pixelMarginRight()&&Ma.test(g)&&La.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function Pa(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}var Qa=/^(none|table(?!-c[ea]).+)/,Ra=/^--/,Sa={position:"absolute",visibility:"hidden",display:"block"},Ta={letterSpacing:"0",fontWeight:"400"},Ua=["Webkit","Moz","ms"],Va=d.createElement("div").style;function Wa(a){if(a in Va)return a;var b=a[0].toUpperCase()+a.slice(1),c=Ua.length;while(c--)if(a=Ua[c]+b,a in Va)return a}function Xa(a){var b=r.cssProps[a];return b||(b=r.cssProps[a]=Wa(a)||a),b}function Ya(a,b,c){var d=ba.exec(b);return d?Math.max(0,d[2]-(c||0))+(d[3]||"px"):b}function Za(a,b,c,d,e){var f,g=0;for(f=c===(d?"border":"content")?4:"width"===b?1:0;f<4;f+=2)"margin"===c&&(g+=r.css(a,c+ca[f],!0,e)),d?("content"===c&&(g-=r.css(a,"padding"+ca[f],!0,e)),"margin"!==c&&(g-=r.css(a,"border"+ca[f]+"Width",!0,e))):(g+=r.css(a,"padding"+ca[f],!0,e),"padding"!==c&&(g+=r.css(a,"border"+ca[f]+"Width",!0,e)));return g}function $a(a,b,c){var d,e=Na(a),f=Oa(a,b,e),g="border-box"===r.css(a,"boxSizing",!1,e);return Ma.test(f)?f:(d=g&&(o.boxSizingReliable()||f===a.style[b]),"auto"===f&&(f=a["offset"+b[0].toUpperCase()+b.slice(1)]),f=parseFloat(f)||0,f+Za(a,b,c||(g?"border":"content"),d,e)+"px")}r.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=Oa(a,"opacity");return""===c?"1":c}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=r.camelCase(b),i=Ra.test(b),j=a.style;return i||(b=Xa(h)),g=r.cssHooks[b]||r.cssHooks[h],void 0===c?g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:j[b]:(f=typeof c,"string"===f&&(e=ba.exec(c))&&e[1]&&(c=fa(a,b,e),f="number"),null!=c&&c===c&&("number"===f&&(c+=e&&e[3]||(r.cssNumber[h]?"":"px")),o.clearCloneStyle||""!==c||0!==b.indexOf("background")||(j[b]="inherit"),g&&"set"in g&&void 0===(c=g.set(a,c,d))||(i?j.setProperty(b,c):j[b]=c)),void 0)}},css:function(a,b,c,d){var e,f,g,h=r.camelCase(b),i=Ra.test(b);return i||(b=Xa(h)),g=r.cssHooks[b]||r.cssHooks[h],g&&"get"in g&&(e=g.get(a,!0,c)),void 0===e&&(e=Oa(a,b,d)),"normal"===e&&b in Ta&&(e=Ta[b]),""===c||c?(f=parseFloat(e),c===!0||isFinite(f)?f||0:e):e}}),r.each(["height","width"],function(a,b){r.cssHooks[b]={get:function(a,c,d){if(c)return!Qa.test(r.css(a,"display"))||a.getClientRects().length&&a.getBoundingClientRect().width?$a(a,b,d):ea(a,Sa,function(){return $a(a,b,d)})},set:function(a,c,d){var e,f=d&&Na(a),g=d&&Za(a,b,d,"border-box"===r.css(a,"boxSizing",!1,f),f);return g&&(e=ba.exec(c))&&"px"!==(e[3]||"px")&&(a.style[b]=c,c=r.css(a,b)),Ya(a,c,g)}}}),r.cssHooks.marginLeft=Pa(o.reliableMarginLeft,function(a,b){if(b)return(parseFloat(Oa(a,"marginLeft"))||a.getBoundingClientRect().left-ea(a,{marginLeft:0},function(){return a.getBoundingClientRect().left}))+"px"}),r.each({margin:"",padding:"",border:"Width"},function(a,b){r.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];d<4;d++)e[a+ca[d]+b]=f[d]||f[d-2]||f[0];return e}},La.test(a)||(r.cssHooks[a+b].set=Ya)}),r.fn.extend({css:function(a,b){return T(this,function(a,b,c){var d,e,f={},g=0;if(Array.isArray(b)){for(d=Na(a),e=b.length;g<e;g++)f[b[g]]=r.css(a,b[g],!1,d);return f}return void 0!==c?r.style(a,b,c):r.css(a,b)},a,b,arguments.length>1)}});function _a(a,b,c,d,e){return new _a.prototype.init(a,b,c,d,e)}r.Tween=_a,_a.prototype={constructor:_a,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||r.easing._default,this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(r.cssNumber[c]?"":"px")},cur:function(){var a=_a.propHooks[this.prop];return a&&a.get?a.get(this):_a.propHooks._default.get(this)},run:function(a){var b,c=_a.propHooks[this.prop];return this.options.duration?this.pos=b=r.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):_a.propHooks._default.set(this),this}},_a.prototype.init.prototype=_a.prototype,_a.propHooks={_default:{get:function(a){var b;return 1!==a.elem.nodeType||null!=a.elem[a.prop]&&null==a.elem.style[a.prop]?a.elem[a.prop]:(b=r.css(a.elem,a.prop,""),b&&"auto"!==b?b:0)},set:function(a){r.fx.step[a.prop]?r.fx.step[a.prop](a):1!==a.elem.nodeType||null==a.elem.style[r.cssProps[a.prop]]&&!r.cssHooks[a.prop]?a.elem[a.prop]=a.now:r.style(a.elem,a.prop,a.now+a.unit)}}},_a.propHooks.scrollTop=_a.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},r.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2},_default:"swing"},r.fx=_a.prototype.init,r.fx.step={};var ab,bb,cb=/^(?:toggle|show|hide)$/,db=/queueHooks$/;function eb(){bb&&(d.hidden===!1&&a.requestAnimationFrame?a.requestAnimationFrame(eb):a.setTimeout(eb,r.fx.interval),r.fx.tick())}function fb(){return a.setTimeout(function(){ab=void 0}),ab=r.now()}function gb(a,b){var c,d=0,e={height:a};for(b=b?1:0;d<4;d+=2-b)c=ca[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function hb(a,b,c){for(var d,e=(kb.tweeners[b]||[]).concat(kb.tweeners["*"]),f=0,g=e.length;f<g;f++)if(d=e[f].call(c,b,a))return d}function ib(a,b,c){var d,e,f,g,h,i,j,k,l="width"in b||"height"in b,m=this,n={},o=a.style,p=a.nodeType&&da(a),q=W.get(a,"fxshow");c.queue||(g=r._queueHooks(a,"fx"),null==g.unqueued&&(g.unqueued=0,h=g.empty.fire,g.empty.fire=function(){g.unqueued||h()}),g.unqueued++,m.always(function(){m.always(function(){g.unqueued--,r.queue(a,"fx").length||g.empty.fire()})}));for(d in b)if(e=b[d],cb.test(e)){if(delete b[d],f=f||"toggle"===e,e===(p?"hide":"show")){if("show"!==e||!q||void 0===q[d])continue;p=!0}n[d]=q&&q[d]||r.style(a,d)}if(i=!r.isEmptyObject(b),i||!r.isEmptyObject(n)){l&&1===a.nodeType&&(c.overflow=[o.overflow,o.overflowX,o.overflowY],j=q&&q.display,null==j&&(j=W.get(a,"display")),k=r.css(a,"display"),"none"===k&&(j?k=j:(ia([a],!0),j=a.style.display||j,k=r.css(a,"display"),ia([a]))),("inline"===k||"inline-block"===k&&null!=j)&&"none"===r.css(a,"float")&&(i||(m.done(function(){o.display=j}),null==j&&(k=o.display,j="none"===k?"":k)),o.display="inline-block")),c.overflow&&(o.overflow="hidden",m.always(function(){o.overflow=c.overflow[0],o.overflowX=c.overflow[1],o.overflowY=c.overflow[2]})),i=!1;for(d in n)i||(q?"hidden"in q&&(p=q.hidden):q=W.access(a,"fxshow",{display:j}),f&&(q.hidden=!p),p&&ia([a],!0),m.done(function(){p||ia([a]),W.remove(a,"fxshow");for(d in n)r.style(a,d,n[d])})),i=hb(p?q[d]:0,d,m),d in q||(q[d]=i.start,p&&(i.end=i.start,i.start=0))}}function jb(a,b){var c,d,e,f,g;for(c in a)if(d=r.camelCase(c),e=b[d],f=a[c],Array.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=r.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kb(a,b,c){var d,e,f=0,g=kb.prefilters.length,h=r.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=ab||fb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;g<i;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),f<1&&i?c:(i||h.notifyWith(a,[j,1,0]),h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:r.extend({},b),opts:r.extend(!0,{specialEasing:{},easing:r.easing._default},c),originalProperties:b,originalOptions:c,startTime:ab||fb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=r.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;c<d;c++)j.tweens[c].run(1);return b?(h.notifyWith(a,[j,1,0]),h.resolveWith(a,[j,b])):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jb(k,j.opts.specialEasing);f<g;f++)if(d=kb.prefilters[f].call(j,a,k,j.opts))return r.isFunction(d.stop)&&(r._queueHooks(j.elem,j.opts.queue).stop=r.proxy(d.stop,d)),d;return r.map(k,hb,j),r.isFunction(j.opts.start)&&j.opts.start.call(a,j),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always),r.fx.timer(r.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j}r.Animation=r.extend(kb,{tweeners:{"*":[function(a,b){var c=this.createTween(a,b);return fa(c.elem,a,ba.exec(b),c),c}]},tweener:function(a,b){r.isFunction(a)?(b=a,a=["*"]):a=a.match(L);for(var c,d=0,e=a.length;d<e;d++)c=a[d],kb.tweeners[c]=kb.tweeners[c]||[],kb.tweeners[c].unshift(b)},prefilters:[ib],prefilter:function(a,b){b?kb.prefilters.unshift(a):kb.prefilters.push(a)}}),r.speed=function(a,b,c){var d=a&&"object"==typeof a?r.extend({},a):{complete:c||!c&&b||r.isFunction(a)&&a,duration:a,easing:c&&b||b&&!r.isFunction(b)&&b};return r.fx.off?d.duration=0:"number"!=typeof d.duration&&(d.duration in r.fx.speeds?d.duration=r.fx.speeds[d.duration]:d.duration=r.fx.speeds._default),null!=d.queue&&d.queue!==!0||(d.queue="fx"),d.old=d.complete,d.complete=function(){r.isFunction(d.old)&&d.old.call(this),d.queue&&r.dequeue(this,d.queue)},d},r.fn.extend({fadeTo:function(a,b,c,d){return this.filter(da).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=r.isEmptyObject(a),f=r.speed(b,c,d),g=function(){var b=kb(this,r.extend({},a),f);(e||W.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=r.timers,g=W.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&db.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));!b&&c||r.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=W.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=r.timers,g=d?d.length:0;for(c.finish=!0,r.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;b<g;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),r.each(["toggle","show","hide"],function(a,b){var c=r.fn[b];r.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(gb(b,!0),a,d,e)}}),r.each({slideDown:gb("show"),slideUp:gb("hide"),slideToggle:gb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){r.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),r.timers=[],r.fx.tick=function(){var a,b=0,c=r.timers;for(ab=r.now();b<c.length;b++)a=c[b],a()||c[b]!==a||c.splice(b--,1);c.length||r.fx.stop(),ab=void 0},r.fx.timer=function(a){r.timers.push(a),r.fx.start()},r.fx.interval=13,r.fx.start=function(){bb||(bb=!0,eb())},r.fx.stop=function(){bb=null},r.fx.speeds={slow:600,fast:200,_default:400},r.fn.delay=function(b,c){return b=r.fx?r.fx.speeds[b]||b:b,c=c||"fx",this.queue(c,function(c,d){var e=a.setTimeout(c,b);d.stop=function(){a.clearTimeout(e)}})},function(){var a=d.createElement("input"),b=d.createElement("select"),c=b.appendChild(d.createElement("option"));a.type="checkbox",o.checkOn=""!==a.value,o.optSelected=c.selected,a=d.createElement("input"),a.value="t",a.type="radio",o.radioValue="t"===a.value}();var lb,mb=r.expr.attrHandle;r.fn.extend({attr:function(a,b){return T(this,r.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){r.removeAttr(this,a)})}}),r.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return"undefined"==typeof a.getAttribute?r.prop(a,b,c):(1===f&&r.isXMLDoc(a)||(e=r.attrHooks[b.toLowerCase()]||(r.expr.match.bool.test(b)?lb:void 0)),void 0!==c?null===c?void r.removeAttr(a,b):e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:(a.setAttribute(b,c+""),c):e&&"get"in e&&null!==(d=e.get(a,b))?d:(d=r.find.attr(a,b),
null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"===b&&B(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},removeAttr:function(a,b){var c,d=0,e=b&&b.match(L);if(e&&1===a.nodeType)while(c=e[d++])a.removeAttribute(c)}}),lb={set:function(a,b,c){return b===!1?r.removeAttr(a,c):a.setAttribute(c,c),c}},r.each(r.expr.match.bool.source.match(/\w+/g),function(a,b){var c=mb[b]||r.find.attr;mb[b]=function(a,b,d){var e,f,g=b.toLowerCase();return d||(f=mb[g],mb[g]=e,e=null!=c(a,b,d)?g:null,mb[g]=f),e}});var nb=/^(?:input|select|textarea|button)$/i,ob=/^(?:a|area)$/i;r.fn.extend({prop:function(a,b){return T(this,r.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[r.propFix[a]||a]})}}),r.extend({prop:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return 1===f&&r.isXMLDoc(a)||(b=r.propFix[b]||b,e=r.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=r.find.attr(a,"tabindex");return b?parseInt(b,10):nb.test(a.nodeName)||ob.test(a.nodeName)&&a.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),o.optSelected||(r.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null},set:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}}),r.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){r.propFix[this.toLowerCase()]=this});function pb(a){var b=a.match(L)||[];return b.join(" ")}function qb(a){return a.getAttribute&&a.getAttribute("class")||""}r.fn.extend({addClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).addClass(a.call(this,b,qb(this)))});if("string"==typeof a&&a){b=a.match(L)||[];while(c=this[i++])if(e=qb(c),d=1===c.nodeType&&" "+pb(e)+" "){g=0;while(f=b[g++])d.indexOf(" "+f+" ")<0&&(d+=f+" ");h=pb(d),e!==h&&c.setAttribute("class",h)}}return this},removeClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).removeClass(a.call(this,b,qb(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof a&&a){b=a.match(L)||[];while(c=this[i++])if(e=qb(c),d=1===c.nodeType&&" "+pb(e)+" "){g=0;while(f=b[g++])while(d.indexOf(" "+f+" ")>-1)d=d.replace(" "+f+" "," ");h=pb(d),e!==h&&c.setAttribute("class",h)}}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):r.isFunction(a)?this.each(function(c){r(this).toggleClass(a.call(this,c,qb(this),b),b)}):this.each(function(){var b,d,e,f;if("string"===c){d=0,e=r(this),f=a.match(L)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else void 0!==a&&"boolean"!==c||(b=qb(this),b&&W.set(this,"__className__",b),this.setAttribute&&this.setAttribute("class",b||a===!1?"":W.get(this,"__className__")||""))})},hasClass:function(a){var b,c,d=0;b=" "+a+" ";while(c=this[d++])if(1===c.nodeType&&(" "+pb(qb(c))+" ").indexOf(b)>-1)return!0;return!1}});var rb=/\r/g;r.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=r.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,r(this).val()):a,null==e?e="":"number"==typeof e?e+="":Array.isArray(e)&&(e=r.map(e,function(a){return null==a?"":a+""})),b=r.valHooks[this.type]||r.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=r.valHooks[e.type]||r.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(rb,""):null==c?"":c)}}}),r.extend({valHooks:{option:{get:function(a){var b=r.find.attr(a,"value");return null!=b?b:pb(r.text(a))}},select:{get:function(a){var b,c,d,e=a.options,f=a.selectedIndex,g="select-one"===a.type,h=g?null:[],i=g?f+1:e.length;for(d=f<0?i:g?f:0;d<i;d++)if(c=e[d],(c.selected||d===f)&&!c.disabled&&(!c.parentNode.disabled||!B(c.parentNode,"optgroup"))){if(b=r(c).val(),g)return b;h.push(b)}return h},set:function(a,b){var c,d,e=a.options,f=r.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=r.inArray(r.valHooks.option.get(d),f)>-1)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),r.each(["radio","checkbox"],function(){r.valHooks[this]={set:function(a,b){if(Array.isArray(b))return a.checked=r.inArray(r(a).val(),b)>-1}},o.checkOn||(r.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var sb=/^(?:focusinfocus|focusoutblur)$/;r.extend(r.event,{trigger:function(b,c,e,f){var g,h,i,j,k,m,n,o=[e||d],p=l.call(b,"type")?b.type:b,q=l.call(b,"namespace")?b.namespace.split("."):[];if(h=i=e=e||d,3!==e.nodeType&&8!==e.nodeType&&!sb.test(p+r.event.triggered)&&(p.indexOf(".")>-1&&(q=p.split("."),p=q.shift(),q.sort()),k=p.indexOf(":")<0&&"on"+p,b=b[r.expando]?b:new r.Event(p,"object"==typeof b&&b),b.isTrigger=f?2:3,b.namespace=q.join("."),b.rnamespace=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=e),c=null==c?[b]:r.makeArray(c,[b]),n=r.event.special[p]||{},f||!n.trigger||n.trigger.apply(e,c)!==!1)){if(!f&&!n.noBubble&&!r.isWindow(e)){for(j=n.delegateType||p,sb.test(j+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),i=h;i===(e.ownerDocument||d)&&o.push(i.defaultView||i.parentWindow||a)}g=0;while((h=o[g++])&&!b.isPropagationStopped())b.type=g>1?j:n.bindType||p,m=(W.get(h,"events")||{})[b.type]&&W.get(h,"handle"),m&&m.apply(h,c),m=k&&h[k],m&&m.apply&&U(h)&&(b.result=m.apply(h,c),b.result===!1&&b.preventDefault());return b.type=p,f||b.isDefaultPrevented()||n._default&&n._default.apply(o.pop(),c)!==!1||!U(e)||k&&r.isFunction(e[p])&&!r.isWindow(e)&&(i=e[k],i&&(e[k]=null),r.event.triggered=p,e[p](),r.event.triggered=void 0,i&&(e[k]=i)),b.result}},simulate:function(a,b,c){var d=r.extend(new r.Event,c,{type:a,isSimulated:!0});r.event.trigger(d,null,b)}}),r.fn.extend({trigger:function(a,b){return this.each(function(){r.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];if(c)return r.event.trigger(a,b,c,!0)}}),r.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(a,b){r.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),r.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),o.focusin="onfocusin"in a,o.focusin||r.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){r.event.simulate(b,a.target,r.event.fix(a))};r.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=W.access(d,b);e||d.addEventListener(a,c,!0),W.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=W.access(d,b)-1;e?W.access(d,b,e):(d.removeEventListener(a,c,!0),W.remove(d,b))}}});var tb=a.location,ub=r.now(),vb=/\?/;r.parseXML=function(b){var c;if(!b||"string"!=typeof b)return null;try{c=(new a.DOMParser).parseFromString(b,"text/xml")}catch(d){c=void 0}return c&&!c.getElementsByTagName("parsererror").length||r.error("Invalid XML: "+b),c};var wb=/\[\]$/,xb=/\r?\n/g,yb=/^(?:submit|button|image|reset|file)$/i,zb=/^(?:input|select|textarea|keygen)/i;function Ab(a,b,c,d){var e;if(Array.isArray(b))r.each(b,function(b,e){c||wb.test(a)?d(a,e):Ab(a+"["+("object"==typeof e&&null!=e?b:"")+"]",e,c,d)});else if(c||"object"!==r.type(b))d(a,b);else for(e in b)Ab(a+"["+e+"]",b[e],c,d)}r.param=function(a,b){var c,d=[],e=function(a,b){var c=r.isFunction(b)?b():b;d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(null==c?"":c)};if(Array.isArray(a)||a.jquery&&!r.isPlainObject(a))r.each(a,function(){e(this.name,this.value)});else for(c in a)Ab(c,a[c],b,e);return d.join("&")},r.fn.extend({serialize:function(){return r.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=r.prop(this,"elements");return a?r.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!r(this).is(":disabled")&&zb.test(this.nodeName)&&!yb.test(a)&&(this.checked||!ja.test(a))}).map(function(a,b){var c=r(this).val();return null==c?null:Array.isArray(c)?r.map(c,function(a){return{name:b.name,value:a.replace(xb,"\r\n")}}):{name:b.name,value:c.replace(xb,"\r\n")}}).get()}});var Bb=/%20/g,Cb=/#.*$/,Db=/([?&])_=[^&]*/,Eb=/^(.*?):[ \t]*([^\r\n]*)$/gm,Fb=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Gb=/^(?:GET|HEAD)$/,Hb=/^\/\//,Ib={},Jb={},Kb="*/".concat("*"),Lb=d.createElement("a");Lb.href=tb.href;function Mb(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(L)||[];if(r.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Nb(a,b,c,d){var e={},f=a===Jb;function g(h){var i;return e[h]=!0,r.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Ob(a,b){var c,d,e=r.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&r.extend(!0,a,d),a}function Pb(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}if(f)return f!==i[0]&&i.unshift(f),c[f]}function Qb(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}r.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:tb.href,type:"GET",isLocal:Fb.test(tb.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Kb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":r.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Ob(Ob(a,r.ajaxSettings),b):Ob(r.ajaxSettings,a)},ajaxPrefilter:Mb(Ib),ajaxTransport:Mb(Jb),ajax:function(b,c){"object"==typeof b&&(c=b,b=void 0),c=c||{};var e,f,g,h,i,j,k,l,m,n,o=r.ajaxSetup({},c),p=o.context||o,q=o.context&&(p.nodeType||p.jquery)?r(p):r.event,s=r.Deferred(),t=r.Callbacks("once memory"),u=o.statusCode||{},v={},w={},x="canceled",y={readyState:0,getResponseHeader:function(a){var b;if(k){if(!h){h={};while(b=Eb.exec(g))h[b[1].toLowerCase()]=b[2]}b=h[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return k?g:null},setRequestHeader:function(a,b){return null==k&&(a=w[a.toLowerCase()]=w[a.toLowerCase()]||a,v[a]=b),this},overrideMimeType:function(a){return null==k&&(o.mimeType=a),this},statusCode:function(a){var b;if(a)if(k)y.always(a[y.status]);else for(b in a)u[b]=[u[b],a[b]];return this},abort:function(a){var b=a||x;return e&&e.abort(b),A(0,b),this}};if(s.promise(y),o.url=((b||o.url||tb.href)+"").replace(Hb,tb.protocol+"//"),o.type=c.method||c.type||o.method||o.type,o.dataTypes=(o.dataType||"*").toLowerCase().match(L)||[""],null==o.crossDomain){j=d.createElement("a");try{j.href=o.url,j.href=j.href,o.crossDomain=Lb.protocol+"//"+Lb.host!=j.protocol+"//"+j.host}catch(z){o.crossDomain=!0}}if(o.data&&o.processData&&"string"!=typeof o.data&&(o.data=r.param(o.data,o.traditional)),Nb(Ib,o,c,y),k)return y;l=r.event&&o.global,l&&0===r.active++&&r.event.trigger("ajaxStart"),o.type=o.type.toUpperCase(),o.hasContent=!Gb.test(o.type),f=o.url.replace(Cb,""),o.hasContent?o.data&&o.processData&&0===(o.contentType||"").indexOf("application/x-www-form-urlencoded")&&(o.data=o.data.replace(Bb,"+")):(n=o.url.slice(f.length),o.data&&(f+=(vb.test(f)?"&":"?")+o.data,delete o.data),o.cache===!1&&(f=f.replace(Db,"$1"),n=(vb.test(f)?"&":"?")+"_="+ub++ +n),o.url=f+n),o.ifModified&&(r.lastModified[f]&&y.setRequestHeader("If-Modified-Since",r.lastModified[f]),r.etag[f]&&y.setRequestHeader("If-None-Match",r.etag[f])),(o.data&&o.hasContent&&o.contentType!==!1||c.contentType)&&y.setRequestHeader("Content-Type",o.contentType),y.setRequestHeader("Accept",o.dataTypes[0]&&o.accepts[o.dataTypes[0]]?o.accepts[o.dataTypes[0]]+("*"!==o.dataTypes[0]?", "+Kb+"; q=0.01":""):o.accepts["*"]);for(m in o.headers)y.setRequestHeader(m,o.headers[m]);if(o.beforeSend&&(o.beforeSend.call(p,y,o)===!1||k))return y.abort();if(x="abort",t.add(o.complete),y.done(o.success),y.fail(o.error),e=Nb(Jb,o,c,y)){if(y.readyState=1,l&&q.trigger("ajaxSend",[y,o]),k)return y;o.async&&o.timeout>0&&(i=a.setTimeout(function(){y.abort("timeout")},o.timeout));try{k=!1,e.send(v,A)}catch(z){if(k)throw z;A(-1,z)}}else A(-1,"No Transport");function A(b,c,d,h){var j,m,n,v,w,x=c;k||(k=!0,i&&a.clearTimeout(i),e=void 0,g=h||"",y.readyState=b>0?4:0,j=b>=200&&b<300||304===b,d&&(v=Pb(o,y,d)),v=Qb(o,v,y,j),j?(o.ifModified&&(w=y.getResponseHeader("Last-Modified"),w&&(r.lastModified[f]=w),w=y.getResponseHeader("etag"),w&&(r.etag[f]=w)),204===b||"HEAD"===o.type?x="nocontent":304===b?x="notmodified":(x=v.state,m=v.data,n=v.error,j=!n)):(n=x,!b&&x||(x="error",b<0&&(b=0))),y.status=b,y.statusText=(c||x)+"",j?s.resolveWith(p,[m,x,y]):s.rejectWith(p,[y,x,n]),y.statusCode(u),u=void 0,l&&q.trigger(j?"ajaxSuccess":"ajaxError",[y,o,j?m:n]),t.fireWith(p,[y,x]),l&&(q.trigger("ajaxComplete",[y,o]),--r.active||r.event.trigger("ajaxStop")))}return y},getJSON:function(a,b,c){return r.get(a,b,c,"json")},getScript:function(a,b){return r.get(a,void 0,b,"script")}}),r.each(["get","post"],function(a,b){r[b]=function(a,c,d,e){return r.isFunction(c)&&(e=e||d,d=c,c=void 0),r.ajax(r.extend({url:a,type:b,dataType:e,data:c,success:d},r.isPlainObject(a)&&a))}}),r._evalUrl=function(a){return r.ajax({url:a,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},r.fn.extend({wrapAll:function(a){var b;return this[0]&&(r.isFunction(a)&&(a=a.call(this[0])),b=r(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this},wrapInner:function(a){return r.isFunction(a)?this.each(function(b){r(this).wrapInner(a.call(this,b))}):this.each(function(){var b=r(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=r.isFunction(a);return this.each(function(c){r(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(a){return this.parent(a).not("body").each(function(){r(this).replaceWith(this.childNodes)}),this}}),r.expr.pseudos.hidden=function(a){return!r.expr.pseudos.visible(a)},r.expr.pseudos.visible=function(a){return!!(a.offsetWidth||a.offsetHeight||a.getClientRects().length)},r.ajaxSettings.xhr=function(){try{return new a.XMLHttpRequest}catch(b){}};var Rb={0:200,1223:204},Sb=r.ajaxSettings.xhr();o.cors=!!Sb&&"withCredentials"in Sb,o.ajax=Sb=!!Sb,r.ajaxTransport(function(b){var c,d;if(o.cors||Sb&&!b.crossDomain)return{send:function(e,f){var g,h=b.xhr();if(h.open(b.type,b.url,b.async,b.username,b.password),b.xhrFields)for(g in b.xhrFields)h[g]=b.xhrFields[g];b.mimeType&&h.overrideMimeType&&h.overrideMimeType(b.mimeType),b.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest");for(g in e)h.setRequestHeader(g,e[g]);c=function(a){return function(){c&&(c=d=h.onload=h.onerror=h.onabort=h.onreadystatechange=null,"abort"===a?h.abort():"error"===a?"number"!=typeof h.status?f(0,"error"):f(h.status,h.statusText):f(Rb[h.status]||h.status,h.statusText,"text"!==(h.responseType||"text")||"string"!=typeof h.responseText?{binary:h.response}:{text:h.responseText},h.getAllResponseHeaders()))}},h.onload=c(),d=h.onerror=c("error"),void 0!==h.onabort?h.onabort=d:h.onreadystatechange=function(){4===h.readyState&&a.setTimeout(function(){c&&d()})},c=c("abort");try{h.send(b.hasContent&&b.data||null)}catch(i){if(c)throw i}},abort:function(){c&&c()}}}),r.ajaxPrefilter(function(a){a.crossDomain&&(a.contents.script=!1)}),r.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(a){return r.globalEval(a),a}}}),r.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),r.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(e,f){b=r("<script>").prop({charset:a.scriptCharset,src:a.url}).on("load error",c=function(a){b.remove(),c=null,a&&f("error"===a.type?404:200,a.type)}),d.head.appendChild(b[0])},abort:function(){c&&c()}}}});var Tb=[],Ub=/(=)\?(?=&|$)|\?\?/;r.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Tb.pop()||r.expando+"_"+ub++;return this[a]=!0,a}}),r.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(Ub.test(b.url)?"url":"string"==typeof b.data&&0===(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&Ub.test(b.data)&&"data");if(h||"jsonp"===b.dataTypes[0])return e=b.jsonpCallback=r.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(Ub,"$1"+e):b.jsonp!==!1&&(b.url+=(vb.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||r.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){void 0===f?r(a).removeProp(e):a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,Tb.push(e)),g&&r.isFunction(f)&&f(g[0]),g=f=void 0}),"script"}),o.createHTMLDocument=function(){var a=d.implementation.createHTMLDocument("").body;return a.innerHTML="<form></form><form></form>",2===a.childNodes.length}(),r.parseHTML=function(a,b,c){if("string"!=typeof a)return[];"boolean"==typeof b&&(c=b,b=!1);var e,f,g;return b||(o.createHTMLDocument?(b=d.implementation.createHTMLDocument(""),e=b.createElement("base"),e.href=d.location.href,b.head.appendChild(e)):b=d),f=C.exec(a),g=!c&&[],f?[b.createElement(f[1])]:(f=qa([a],b,g),g&&g.length&&r(g).remove(),r.merge([],f.childNodes))},r.fn.load=function(a,b,c){var d,e,f,g=this,h=a.indexOf(" ");return h>-1&&(d=pb(a.slice(h)),a=a.slice(0,h)),r.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(e="POST"),g.length>0&&r.ajax({url:a,type:e||"GET",dataType:"html",data:b}).done(function(a){f=arguments,g.html(d?r("<div>").append(r.parseHTML(a)).find(d):a)}).always(c&&function(a,b){g.each(function(){c.apply(this,f||[a.responseText,b,a])})}),this},r.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){r.fn[b]=function(a){return this.on(b,a)}}),r.expr.pseudos.animated=function(a){return r.grep(r.timers,function(b){return a===b.elem}).length},r.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=r.css(a,"position"),l=r(a),m={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=r.css(a,"top"),i=r.css(a,"left"),j=("absolute"===k||"fixed"===k)&&(f+i).indexOf("auto")>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),r.isFunction(b)&&(b=b.call(a,c,r.extend({},h))),null!=b.top&&(m.top=b.top-h.top+g),null!=b.left&&(m.left=b.left-h.left+e),"using"in b?b.using.call(a,m):l.css(m)}},r.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){r.offset.setOffset(this,a,b)});var b,c,d,e,f=this[0];if(f)return f.getClientRects().length?(d=f.getBoundingClientRect(),b=f.ownerDocument,c=b.documentElement,e=b.defaultView,{top:d.top+e.pageYOffset-c.clientTop,left:d.left+e.pageXOffset-c.clientLeft}):{top:0,left:0}},position:function(){if(this[0]){var a,b,c=this[0],d={top:0,left:0};return"fixed"===r.css(c,"position")?b=c.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),B(a[0],"html")||(d=a.offset()),d={top:d.top+r.css(a[0],"borderTopWidth",!0),left:d.left+r.css(a[0],"borderLeftWidth",!0)}),{top:b.top-d.top-r.css(c,"marginTop",!0),left:b.left-d.left-r.css(c,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent;while(a&&"static"===r.css(a,"position"))a=a.offsetParent;return a||ra})}}),r.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c="pageYOffset"===b;r.fn[a]=function(d){return T(this,function(a,d,e){var f;return r.isWindow(a)?f=a:9===a.nodeType&&(f=a.defaultView),void 0===e?f?f[b]:a[d]:void(f?f.scrollTo(c?f.pageXOffset:e,c?e:f.pageYOffset):a[d]=e)},a,d,arguments.length)}}),r.each(["top","left"],function(a,b){r.cssHooks[b]=Pa(o.pixelPosition,function(a,c){if(c)return c=Oa(a,b),Ma.test(c)?r(a).position()[b]+"px":c})}),r.each({Height:"height",Width:"width"},function(a,b){r.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){r.fn[d]=function(e,f){var g=arguments.length&&(c||"boolean"!=typeof e),h=c||(e===!0||f===!0?"margin":"border");return T(this,function(b,c,e){var f;return r.isWindow(b)?0===d.indexOf("outer")?b["inner"+a]:b.document.documentElement["client"+a]:9===b.nodeType?(f=b.documentElement,Math.max(b.body["scroll"+a],f["scroll"+a],b.body["offset"+a],f["offset"+a],f["client"+a])):void 0===e?r.css(b,c,h):r.style(b,c,e,h)},b,g?e:void 0,g)}})}),r.fn.extend({bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}}),r.holdReady=function(a){a?r.readyWait++:r.ready(!0)},r.isArray=Array.isArray,r.parseJSON=JSON.parse,r.nodeName=B,"function"==typeof define&&define.amd&&define("jquery",[],function(){return r});var Vb=a.jQuery,Wb=a.$;return r.noConflict=function(b){return a.$===r&&(a.$=Wb),b&&a.jQuery===r&&(a.jQuery=Vb),r},b||(a.jQuery=a.$=r),r});
(function( $ ){
$.fn.qrcode = function(options) {
// if options is string,
if( typeof options === 'string' ){
options = { text: options };
}
// set default values
// typeNumber < 1 for automatic calculation
options = $.extend( {}, {
render : "canvas",
width : 256,
height : 256,
typeNumber : -1,
correctLevel : QRErrorCorrectLevel.H,
background : "#ffffff",
foreground : "#000000"
}, options);
var createCanvas = function(){
// create the qrcode itself
var qrcode = new QRCode(options.typeNumber, options.correctLevel);
qrcode.addData(options.text);
qrcode.make();
// create canvas element
var canvas = document.createElement('canvas');
canvas.width = options.width;
canvas.height = options.height;
var ctx = canvas.getContext('2d');
// compute tileW/tileH based on options.width/options.height
var tileW = options.width / qrcode.getModuleCount();
var tileH = options.height / qrcode.getModuleCount();
// draw in the canvas
for( var row = 0; row < qrcode.getModuleCount(); row++ ){
for( var col = 0; col < qrcode.getModuleCount(); col++ ){
ctx.fillStyle = qrcode.isDark(row, col) ? options.foreground : options.background;
var w = (Math.ceil((col+1)*tileW) - Math.floor(col*tileW));
var h = (Math.ceil((row+1)*tileW) - Math.floor(row*tileW));
ctx.fillRect(Math.round(col*tileW),Math.round(row*tileH), w, h);
}
}
// return just built canvas
return canvas;
}
// from Jon-Carlos Rivera (https://github.com/imbcmdth)
var createTable = function(){
// create the qrcode itself
var qrcode = new QRCode(options.typeNumber, options.correctLevel);
qrcode.addData(options.text);
qrcode.make();
// create table element
var $table = $('<table></table>')
.css("width", options.width+"px")
.css("height", options.height+"px")
.css("border", "0px")
.css("border-collapse", "collapse")
.css('background-color', options.background);
// compute tileS percentage
var tileW = options.width / qrcode.getModuleCount();
var tileH = options.height / qrcode.getModuleCount();
// draw in the table
for(var row = 0; row < qrcode.getModuleCount(); row++ ){
var $row = $('<tr></tr>').css('height', tileH+"px").appendTo($table);
for(var col = 0; col < qrcode.getModuleCount(); col++ ){
$('<td></td>')
.css('width', tileW+"px")
.css('background-color', qrcode.isDark(row, col) ? options.foreground : options.background)
.appendTo($row);
}
}
// return just built canvas
return $table;
}
return this.each(function(){
var element = options.render == "canvas" ? createCanvas() : createTable();
$(element).appendTo(this);
});
};
})( jQuery );
(function(r){r.fn.qrcode=function(h){var s;function u(a){this.mode=s;this.data=a}function o(a,c){this.typeNumber=a;this.errorCorrectLevel=c;this.modules=null;this.moduleCount=0;this.dataCache=null;this.dataList=[]}function q(a,c){if(void 0==a.length)throw Error(a.length+"/"+c);for(var d=0;d<a.length&&0==a[d];)d++;this.num=Array(a.length-d+c);for(var b=0;b<a.length-d;b++)this.num[b]=a[b+d]}function p(a,c){this.totalCount=a;this.dataCount=c}function t(){this.buffer=[];this.length=0}u.prototype={getLength:function(){return this.data.length},
write:function(a){for(var c=0;c<this.data.length;c++)a.put(this.data.charCodeAt(c),8)}};o.prototype={addData:function(a){this.dataList.push(new u(a));this.dataCache=null},isDark:function(a,c){if(0>a||this.moduleCount<=a||0>c||this.moduleCount<=c)throw Error(a+","+c);return this.modules[a][c]},getModuleCount:function(){return this.moduleCount},make:function(){if(1>this.typeNumber){for(var a=1,a=1;40>a;a++){for(var c=p.getRSBlocks(a,this.errorCorrectLevel),d=new t,b=0,e=0;e<c.length;e++)b+=c[e].dataCount;
for(e=0;e<this.dataList.length;e++)c=this.dataList[e],d.put(c.mode,4),d.put(c.getLength(),j.getLengthInBits(c.mode,a)),c.write(d);if(d.getLengthInBits()<=8*b)break}this.typeNumber=a}this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(a,c){this.moduleCount=4*this.typeNumber+17;this.modules=Array(this.moduleCount);for(var d=0;d<this.moduleCount;d++){this.modules[d]=Array(this.moduleCount);for(var b=0;b<this.moduleCount;b++)this.modules[d][b]=null}this.setupPositionProbePattern(0,0);this.setupPositionProbePattern(this.moduleCount-
7,0);this.setupPositionProbePattern(0,this.moduleCount-7);this.setupPositionAdjustPattern();this.setupTimingPattern();this.setupTypeInfo(a,c);7<=this.typeNumber&&this.setupTypeNumber(a);null==this.dataCache&&(this.dataCache=o.createData(this.typeNumber,this.errorCorrectLevel,this.dataList));this.mapData(this.dataCache,c)},setupPositionProbePattern:function(a,c){for(var d=-1;7>=d;d++)if(!(-1>=a+d||this.moduleCount<=a+d))for(var b=-1;7>=b;b++)-1>=c+b||this.moduleCount<=c+b||(this.modules[a+d][c+b]=
0<=d&&6>=d&&(0==b||6==b)||0<=b&&6>=b&&(0==d||6==d)||2<=d&&4>=d&&2<=b&&4>=b?!0:!1)},getBestMaskPattern:function(){for(var a=0,c=0,d=0;8>d;d++){this.makeImpl(!0,d);var b=j.getLostPoint(this);if(0==d||a>b)a=b,c=d}return c},createMovieClip:function(a,c,d){a=a.createEmptyMovieClip(c,d);this.make();for(c=0;c<this.modules.length;c++)for(var d=1*c,b=0;b<this.modules[c].length;b++){var e=1*b;this.modules[c][b]&&(a.beginFill(0,100),a.moveTo(e,d),a.lineTo(e+1,d),a.lineTo(e+1,d+1),a.lineTo(e,d+1),a.endFill())}return a},
setupTimingPattern:function(){for(var a=8;a<this.moduleCount-8;a++)null==this.modules[a][6]&&(this.modules[a][6]=0==a%2);for(a=8;a<this.moduleCount-8;a++)null==this.modules[6][a]&&(this.modules[6][a]=0==a%2)},setupPositionAdjustPattern:function(){for(var a=j.getPatternPosition(this.typeNumber),c=0;c<a.length;c++)for(var d=0;d<a.length;d++){var b=a[c],e=a[d];if(null==this.modules[b][e])for(var f=-2;2>=f;f++)for(var i=-2;2>=i;i++)this.modules[b+f][e+i]=-2==f||2==f||-2==i||2==i||0==f&&0==i?!0:!1}},setupTypeNumber:function(a){for(var c=
j.getBCHTypeNumber(this.typeNumber),d=0;18>d;d++){var b=!a&&1==(c>>d&1);this.modules[Math.floor(d/3)][d%3+this.moduleCount-8-3]=b}for(d=0;18>d;d++)b=!a&&1==(c>>d&1),this.modules[d%3+this.moduleCount-8-3][Math.floor(d/3)]=b},setupTypeInfo:function(a,c){for(var d=j.getBCHTypeInfo(this.errorCorrectLevel<<3|c),b=0;15>b;b++){var e=!a&&1==(d>>b&1);6>b?this.modules[b][8]=e:8>b?this.modules[b+1][8]=e:this.modules[this.moduleCount-15+b][8]=e}for(b=0;15>b;b++)e=!a&&1==(d>>b&1),8>b?this.modules[8][this.moduleCount-
b-1]=e:9>b?this.modules[8][15-b-1+1]=e:this.modules[8][15-b-1]=e;this.modules[this.moduleCount-8][8]=!a},mapData:function(a,c){for(var d=-1,b=this.moduleCount-1,e=7,f=0,i=this.moduleCount-1;0<i;i-=2)for(6==i&&i--;;){for(var g=0;2>g;g++)if(null==this.modules[b][i-g]){var n=!1;f<a.length&&(n=1==(a[f]>>>e&1));j.getMask(c,b,i-g)&&(n=!n);this.modules[b][i-g]=n;e--; -1==e&&(f++,e=7)}b+=d;if(0>b||this.moduleCount<=b){b-=d;d=-d;break}}}};o.PAD0=236;o.PAD1=17;o.createData=function(a,c,d){for(var c=p.getRSBlocks(a,
c),b=new t,e=0;e<d.length;e++){var f=d[e];b.put(f.mode,4);b.put(f.getLength(),j.getLengthInBits(f.mode,a));f.write(b)}for(e=a=0;e<c.length;e++)a+=c[e].dataCount;if(b.getLengthInBits()>8*a)throw Error("code length overflow. ("+b.getLengthInBits()+">"+8*a+")");for(b.getLengthInBits()+4<=8*a&&b.put(0,4);0!=b.getLengthInBits()%8;)b.putBit(!1);for(;!(b.getLengthInBits()>=8*a);){b.put(o.PAD0,8);if(b.getLengthInBits()>=8*a)break;b.put(o.PAD1,8)}return o.createBytes(b,c)};o.createBytes=function(a,c){for(var d=
0,b=0,e=0,f=Array(c.length),i=Array(c.length),g=0;g<c.length;g++){var n=c[g].dataCount,h=c[g].totalCount-n,b=Math.max(b,n),e=Math.max(e,h);f[g]=Array(n);for(var k=0;k<f[g].length;k++)f[g][k]=255&a.buffer[k+d];d+=n;k=j.getErrorCorrectPolynomial(h);n=(new q(f[g],k.getLength()-1)).mod(k);i[g]=Array(k.getLength()-1);for(k=0;k<i[g].length;k++)h=k+n.getLength()-i[g].length,i[g][k]=0<=h?n.get(h):0}for(k=g=0;k<c.length;k++)g+=c[k].totalCount;d=Array(g);for(k=n=0;k<b;k++)for(g=0;g<c.length;g++)k<f[g].length&&
(d[n++]=f[g][k]);for(k=0;k<e;k++)for(g=0;g<c.length;g++)k<i[g].length&&(d[n++]=i[g][k]);return d};s=4;for(var j={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,
78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(a){for(var c=a<<10;0<=j.getBCHDigit(c)-j.getBCHDigit(j.G15);)c^=j.G15<<j.getBCHDigit(c)-j.getBCHDigit(j.G15);return(a<<10|c)^j.G15_MASK},getBCHTypeNumber:function(a){for(var c=a<<12;0<=j.getBCHDigit(c)-
j.getBCHDigit(j.G18);)c^=j.G18<<j.getBCHDigit(c)-j.getBCHDigit(j.G18);return a<<12|c},getBCHDigit:function(a){for(var c=0;0!=a;)c++,a>>>=1;return c},getPatternPosition:function(a){return j.PATTERN_POSITION_TABLE[a-1]},getMask:function(a,c,d){switch(a){case 0:return 0==(c+d)%2;case 1:return 0==c%2;case 2:return 0==d%3;case 3:return 0==(c+d)%3;case 4:return 0==(Math.floor(c/2)+Math.floor(d/3))%2;case 5:return 0==c*d%2+c*d%3;case 6:return 0==(c*d%2+c*d%3)%2;case 7:return 0==(c*d%3+(c+d)%2)%2;default:throw Error("bad maskPattern:"+
a);}},getErrorCorrectPolynomial:function(a){for(var c=new q([1],0),d=0;d<a;d++)c=c.multiply(new q([1,l.gexp(d)],0));return c},getLengthInBits:function(a,c){if(1<=c&&10>c)switch(a){case 1:return 10;case 2:return 9;case s:return 8;case 8:return 8;default:throw Error("mode:"+a);}else if(27>c)switch(a){case 1:return 12;case 2:return 11;case s:return 16;case 8:return 10;default:throw Error("mode:"+a);}else if(41>c)switch(a){case 1:return 14;case 2:return 13;case s:return 16;case 8:return 12;default:throw Error("mode:"+
a);}else throw Error("type:"+c);},getLostPoint:function(a){for(var c=a.getModuleCount(),d=0,b=0;b<c;b++)for(var e=0;e<c;e++){for(var f=0,i=a.isDark(b,e),g=-1;1>=g;g++)if(!(0>b+g||c<=b+g))for(var h=-1;1>=h;h++)0>e+h||c<=e+h||0==g&&0==h||i==a.isDark(b+g,e+h)&&f++;5<f&&(d+=3+f-5)}for(b=0;b<c-1;b++)for(e=0;e<c-1;e++)if(f=0,a.isDark(b,e)&&f++,a.isDark(b+1,e)&&f++,a.isDark(b,e+1)&&f++,a.isDark(b+1,e+1)&&f++,0==f||4==f)d+=3;for(b=0;b<c;b++)for(e=0;e<c-6;e++)a.isDark(b,e)&&!a.isDark(b,e+1)&&a.isDark(b,e+
2)&&a.isDark(b,e+3)&&a.isDark(b,e+4)&&!a.isDark(b,e+5)&&a.isDark(b,e+6)&&(d+=40);for(e=0;e<c;e++)for(b=0;b<c-6;b++)a.isDark(b,e)&&!a.isDark(b+1,e)&&a.isDark(b+2,e)&&a.isDark(b+3,e)&&a.isDark(b+4,e)&&!a.isDark(b+5,e)&&a.isDark(b+6,e)&&(d+=40);for(e=f=0;e<c;e++)for(b=0;b<c;b++)a.isDark(b,e)&&f++;a=Math.abs(100*f/c/c-50)/5;return d+10*a}},l={glog:function(a){if(1>a)throw Error("glog("+a+")");return l.LOG_TABLE[a]},gexp:function(a){for(;0>a;)a+=255;for(;256<=a;)a-=255;return l.EXP_TABLE[a]},EXP_TABLE:Array(256),
LOG_TABLE:Array(256)},m=0;8>m;m++)l.EXP_TABLE[m]=1<<m;for(m=8;256>m;m++)l.EXP_TABLE[m]=l.EXP_TABLE[m-4]^l.EXP_TABLE[m-5]^l.EXP_TABLE[m-6]^l.EXP_TABLE[m-8];for(m=0;255>m;m++)l.LOG_TABLE[l.EXP_TABLE[m]]=m;q.prototype={get:function(a){return this.num[a]},getLength:function(){return this.num.length},multiply:function(a){for(var c=Array(this.getLength()+a.getLength()-1),d=0;d<this.getLength();d++)for(var b=0;b<a.getLength();b++)c[d+b]^=l.gexp(l.glog(this.get(d))+l.glog(a.get(b)));return new q(c,0)},mod:function(a){if(0>
this.getLength()-a.getLength())return this;for(var c=l.glog(this.get(0))-l.glog(a.get(0)),d=Array(this.getLength()),b=0;b<this.getLength();b++)d[b]=this.get(b);for(b=0;b<a.getLength();b++)d[b]^=l.gexp(l.glog(a.get(b))+c);return(new q(d,0)).mod(a)}};p.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],
[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,
116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,
43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,
3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,
55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,
45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];p.getRSBlocks=function(a,c){var d=p.getRsBlockTable(a,c);if(void 0==d)throw Error("bad rs block @ typeNumber:"+a+"/errorCorrectLevel:"+c);for(var b=d.length/3,e=[],f=0;f<b;f++)for(var h=d[3*f+0],g=d[3*f+1],j=d[3*f+2],l=0;l<h;l++)e.push(new p(g,j));return e};p.getRsBlockTable=function(a,c){switch(c){case 1:return p.RS_BLOCK_TABLE[4*(a-1)+0];case 0:return p.RS_BLOCK_TABLE[4*(a-1)+1];case 3:return p.RS_BLOCK_TABLE[4*
(a-1)+2];case 2:return p.RS_BLOCK_TABLE[4*(a-1)+3]}};t.prototype={get:function(a){return 1==(this.buffer[Math.floor(a/8)]>>>7-a%8&1)},put:function(a,c){for(var d=0;d<c;d++)this.putBit(1==(a>>>c-d-1&1))},getLengthInBits:function(){return this.length},putBit:function(a){var c=Math.floor(this.length/8);this.buffer.length<=c&&this.buffer.push(0);a&&(this.buffer[c]|=128>>>this.length%8);this.length++}};"string"===typeof h&&(h={text:h});h=r.extend({},{render:"canvas",width:256,height:256,typeNumber:-1,
correctLevel:2,background:"#ffffff",foreground:"#000000"},h);return this.each(function(){var a;if("canvas"==h.render){a=new o(h.typeNumber,h.correctLevel);a.addData(h.text);a.make();var c=document.createElement("canvas");c.width=h.width;c.height=h.height;for(var d=c.getContext("2d"),b=h.width/a.getModuleCount(),e=h.height/a.getModuleCount(),f=0;f<a.getModuleCount();f++)for(var i=0;i<a.getModuleCount();i++){d.fillStyle=a.isDark(f,i)?h.foreground:h.background;var g=Math.ceil((i+1)*b)-Math.floor(i*b),
j=Math.ceil((f+1)*b)-Math.floor(f*b);d.fillRect(Math.round(i*b),Math.round(f*e),g,j)}}else{a=new o(h.typeNumber,h.correctLevel);a.addData(h.text);a.make();c=r("<table></table>").css("width",h.width+"px").css("height",h.height+"px").css("border","0px").css("border-collapse","collapse").css("background-color",h.background);d=h.width/a.getModuleCount();b=h.height/a.getModuleCount();for(e=0;e<a.getModuleCount();e++){f=r("<tr></tr>").css("height",b+"px").appendTo(c);for(i=0;i<a.getModuleCount();i++)r("<td></td>").css("width",
d+"px").css("background-color",a.isDark(e,i)?h.foreground:h.background).appendTo(f)}}a=c;jQuery(a).appendTo(this)})}})(jQuery);
//Variables de référence
/*---------------------------------*/
//Fonctions de référence
var text="https://www.amxa.ch";
$(function(){
$("#ok").click(function()
{
text=$('#qrtext').val();
$("#codediv").html("");
$("#codediv").qrcode({text: text});
$("#formdiv").addClass("hidden");
$("#display").html(text);
$("body").removeClass("grey");
$("#codediv").removeClass("hidden");
$("#textdiv").removeClass("hidden");
});
$("#codediv").click(function(){
$("#codediv").addClass("hidden");
$("#textdiv").addClass("hidden");
$("body").addClass("grey");
$("#formdiv").removeClass("hidden");
});
});
//---------------------------------------------------------------------
// QRCode for JavaScript
//
// Copyright (c) 2009 Kazuhiko Arase
//
// URL: http://www.d-project.com/
//
// Licensed under the MIT license:
// http://www.opensource.org/licenses/mit-license.php
//
// The word "QR Code" is registered trademark of
// DENSO WAVE INCORPORATED
// http://www.denso-wave.com/qrcode/faqpatent-e.html
//
//---------------------------------------------------------------------
//---------------------------------------------------------------------
// QR8bitByte
//---------------------------------------------------------------------
function QR8bitByte(data) {
this.mode = QRMode.MODE_8BIT_BYTE;
this.data = data;
}
QR8bitByte.prototype = {
getLength : function(buffer) {
return this.data.length;
},
write : function(buffer) {
for (var i = 0; i < this.data.length; i++) {
// not JIS ...
buffer.put(this.data.charCodeAt(i), 8);
}
}
};
//---------------------------------------------------------------------
// QRCode
//---------------------------------------------------------------------
function QRCode(typeNumber, errorCorrectLevel) {
this.typeNumber = typeNumber;
this.errorCorrectLevel = errorCorrectLevel;
this.modules = null;
this.moduleCount = 0;
this.dataCache = null;
this.dataList = new Array();
}
QRCode.prototype = {
addData : function(data) {
var newData = new QR8bitByte(data);
this.dataList.push(newData);
this.dataCache = null;
},
isDark : function(row, col) {
if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) {
throw new Error(row + "," + col);
}
return this.modules[row][col];
},
getModuleCount : function() {
return this.moduleCount;
},
make : function() {
// Calculate automatically typeNumber if provided is < 1
if (this.typeNumber < 1 ){
var typeNumber = 1;
for (typeNumber = 1; typeNumber < 40; typeNumber++) {
var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, this.errorCorrectLevel);
var buffer = new QRBitBuffer();
var totalDataCount = 0;
for (var i = 0; i < rsBlocks.length; i++) {
totalDataCount += rsBlocks[i].dataCount;
}
for (var i = 0; i < this.dataList.length; i++) {
var data = this.dataList[i];
buffer.put(data.mode, 4);
buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber) );
data.write(buffer);
}
if (buffer.getLengthInBits() <= totalDataCount * 8)
break;
}
this.typeNumber = typeNumber;
}
this.makeImpl(false, this.getBestMaskPattern() );
},
makeImpl : function(test, maskPattern) {
this.moduleCount = this.typeNumber * 4 + 17;
this.modules = new Array(this.moduleCount);
for (var row = 0; row < this.moduleCount; row++) {
this.modules[row] = new Array(this.moduleCount);
for (var col = 0; col < this.moduleCount; col++) {
this.modules[row][col] = null;//(col + row) % 3;
}
}
this.setupPositionProbePattern(0, 0);
this.setupPositionProbePattern(this.moduleCount - 7, 0);
this.setupPositionProbePattern(0, this.moduleCount - 7);
this.setupPositionAdjustPattern();
this.setupTimingPattern();
this.setupTypeInfo(test, maskPattern);
if (this.typeNumber >= 7) {
this.setupTypeNumber(test);
}
if (this.dataCache == null) {
this.dataCache = QRCode.createData(this.typeNumber, this.errorCorrectLevel, this.dataList);
}
this.mapData(this.dataCache, maskPattern);
},
setupPositionProbePattern : function(row, col) {
for (var r = -1; r <= 7; r++) {
if (row + r <= -1 || this.moduleCount <= row + r) continue;
for (var c = -1; c <= 7; c++) {
if (col + c <= -1 || this.moduleCount <= col + c) continue;
if ( (0 <= r && r <= 6 && (c == 0 || c == 6) )
|| (0 <= c && c <= 6 && (r == 0 || r == 6) )
|| (2 <= r && r <= 4 && 2 <= c && c <= 4) ) {
this.modules[row + r][col + c] = true;
} else {
this.modules[row + r][col + c] = false;
}
}
}
},
getBestMaskPattern : function() {
var minLostPoint = 0;
var pattern = 0;
for (var i = 0; i < 8; i++) {
this.makeImpl(true, i);
var lostPoint = QRUtil.getLostPoint(this);
if (i == 0 || minLostPoint > lostPoint) {
minLostPoint = lostPoint;
pattern = i;
}
}
return pattern;
},
createMovieClip : function(target_mc, instance_name, depth) {
var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth);
var cs = 1;
this.make();
for (var row = 0; row < this.modules.length; row++) {
var y = row * cs;
for (var col = 0; col < this.modules[row].length; col++) {
var x = col * cs;
var dark = this.modules[row][col];
if (dark) {
qr_mc.beginFill(0, 100);
qr_mc.moveTo(x, y);
qr_mc.lineTo(x + cs, y);
qr_mc.lineTo(x + cs, y + cs);
qr_mc.lineTo(x, y + cs);
qr_mc.endFill();
}
}
}
return qr_mc;
},
setupTimingPattern : function() {
for (var r = 8; r < this.moduleCount - 8; r++) {
if (this.modules[r][6] != null) {
continue;
}
this.modules[r][6] = (r % 2 == 0);
}
for (var c = 8; c < this.moduleCount - 8; c++) {
if (this.modules[6][c] != null) {
continue;
}
this.modules[6][c] = (c % 2 == 0);
}
},
setupPositionAdjustPattern : function() {
var pos = QRUtil.getPatternPosition(this.typeNumber);
for (var i = 0; i < pos.length; i++) {
for (var j = 0; j < pos.length; j++) {
var row = pos[i];
var col = pos[j];
if (this.modules[row][col] != null) {
continue;
}
for (var r = -2; r <= 2; r++) {
for (var c = -2; c <= 2; c++) {
if (r == -2 || r == 2 || c == -2 || c == 2
|| (r == 0 && c == 0) ) {
this.modules[row + r][col + c] = true;
} else {
this.modules[row + r][col + c] = false;
}
}
}
}
}
},
setupTypeNumber : function(test) {
var bits = QRUtil.getBCHTypeNumber(this.typeNumber);
for (var i = 0; i < 18; i++) {
var mod = (!test && ( (bits >> i) & 1) == 1);
this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod;
}
for (var i = 0; i < 18; i++) {
var mod = (!test && ( (bits >> i) & 1) == 1);
this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
}
},
setupTypeInfo : function(test, maskPattern) {
var data = (this.errorCorrectLevel << 3) | maskPattern;
var bits = QRUtil.getBCHTypeInfo(data);
// vertical
for (var i = 0; i < 15; i++) {
var mod = (!test && ( (bits >> i) & 1) == 1);
if (i < 6) {
this.modules[i][8] = mod;
} else if (i < 8) {
this.modules[i + 1][8] = mod;
} else {
this.modules[this.moduleCount - 15 + i][8] = mod;
}
}
// horizontal
for (var i = 0; i < 15; i++) {
var mod = (!test && ( (bits >> i) & 1) == 1);
if (i < 8) {
this.modules[8][this.moduleCount - i - 1] = mod;
} else if (i < 9) {
this.modules[8][15 - i - 1 + 1] = mod;
} else {
this.modules[8][15 - i - 1] = mod;
}
}
// fixed module
this.modules[this.moduleCount - 8][8] = (!test);
},
mapData : function(data, maskPattern) {
var inc = -1;
var row = this.moduleCount - 1;
var bitIndex = 7;
var byteIndex = 0;
for (var col = this.moduleCount - 1; col > 0; col -= 2) {
if (col == 6) col--;
while (true) {
for (var c = 0; c < 2; c++) {
if (this.modules[row][col - c] == null) {
var dark = false;
if (byteIndex < data.length) {
dark = ( ( (data[byteIndex] >>> bitIndex) & 1) == 1);
}
var mask = QRUtil.getMask(maskPattern, row, col - c);
if (mask) {
dark = !dark;
}
this.modules[row][col - c] = dark;
bitIndex--;
if (bitIndex == -1) {
byteIndex++;
bitIndex = 7;
}
}
}
row += inc;
if (row < 0 || this.moduleCount <= row) {
row -= inc;
inc = -inc;
break;
}
}
}
}
};
QRCode.PAD0 = 0xEC;
QRCode.PAD1 = 0x11;
QRCode.createData = function(typeNumber, errorCorrectLevel, dataList) {
var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel);
var buffer = new QRBitBuffer();
for (var i = 0; i < dataList.length; i++) {
var data = dataList[i];
buffer.put(data.mode, 4);
buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber) );
data.write(buffer);
}
// calc num max data.
var totalDataCount = 0;
for (var i = 0; i < rsBlocks.length; i++) {
totalDataCount += rsBlocks[i].dataCount;
}
if (buffer.getLengthInBits() > totalDataCount * 8) {
throw new Error("code length overflow. ("
+ buffer.getLengthInBits()
+ ">"
+ totalDataCount * 8
+ ")");
}
// end code
if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
buffer.put(0, 4);
}
// padding
while (buffer.getLengthInBits() % 8 != 0) {
buffer.putBit(false);
}
// padding
while (true) {
if (buffer.getLengthInBits() >= totalDataCount * 8) {
break;
}
buffer.put(QRCode.PAD0, 8);
if (buffer.getLengthInBits() >= totalDataCount * 8) {
break;
}
buffer.put(QRCode.PAD1, 8);
}
return QRCode.createBytes(buffer, rsBlocks);
}
QRCode.createBytes = function(buffer, rsBlocks) {
var offset = 0;
var maxDcCount = 0;
var maxEcCount = 0;
var dcdata = new Array(rsBlocks.length);
var ecdata = new Array(rsBlocks.length);
for (var r = 0; r < rsBlocks.length; r++) {
var dcCount = rsBlocks[r].dataCount;
var ecCount = rsBlocks[r].totalCount - dcCount;
maxDcCount = Math.max(maxDcCount, dcCount);
maxEcCount = Math.max(maxEcCount, ecCount);
dcdata[r] = new Array(dcCount);
for (var i = 0; i < dcdata[r].length; i++) {
dcdata[r][i] = 0xff & buffer.buffer[i + offset];
}
offset += dcCount;
var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1);
var modPoly = rawPoly.mod(rsPoly);
ecdata[r] = new Array(rsPoly.getLength() - 1);
for (var i = 0; i < ecdata[r].length; i++) {
var modIndex = i + modPoly.getLength() - ecdata[r].length;
ecdata[r][i] = (modIndex >= 0)? modPoly.get(modIndex) : 0;
}
}
var totalCodeCount = 0;
for (var i = 0; i < rsBlocks.length; i++) {
totalCodeCount += rsBlocks[i].totalCount;
}
var data = new Array(totalCodeCount);
var index = 0;
for (var i = 0; i < maxDcCount; i++) {
for (var r = 0; r < rsBlocks.length; r++) {
if (i < dcdata[r].length) {
data[index++] = dcdata[r][i];
}
}
}
for (var i = 0; i < maxEcCount; i++) {
for (var r = 0; r < rsBlocks.length; r++) {
if (i < ecdata[r].length) {
data[index++] = ecdata[r][i];
}
}
}
return data;
}
//---------------------------------------------------------------------
// QRMode
//---------------------------------------------------------------------
var QRMode = {
MODE_NUMBER : 1 << 0,
MODE_ALPHA_NUM : 1 << 1,
MODE_8BIT_BYTE : 1 << 2,
MODE_KANJI : 1 << 3
};
//---------------------------------------------------------------------
// QRErrorCorrectLevel
//---------------------------------------------------------------------
var QRErrorCorrectLevel = {
L : 1,
M : 0,
Q : 3,
H : 2
};
//---------------------------------------------------------------------
// QRMaskPattern
//---------------------------------------------------------------------
var QRMaskPattern = {
PATTERN000 : 0,
PATTERN001 : 1,
PATTERN010 : 2,
PATTERN011 : 3,
PATTERN100 : 4,
PATTERN101 : 5,
PATTERN110 : 6,
PATTERN111 : 7
};
//---------------------------------------------------------------------
// QRUtil
//---------------------------------------------------------------------
var QRUtil = {
PATTERN_POSITION_TABLE : [
[],
[6, 18],
[6, 22],
[6, 26],
[6, 30],
[6, 34],
[6, 22, 38],
[6, 24, 42],
[6, 26, 46],
[6, 28, 50],
[6, 30, 54],
[6, 32, 58],
[6, 34, 62],
[6, 26, 46, 66],
[6, 26, 48, 70],
[6, 26, 50, 74],
[6, 30, 54, 78],
[6, 30, 56, 82],
[6, 30, 58, 86],
[6, 34, 62, 90],
[6, 28, 50, 72, 94],
[6, 26, 50, 74, 98],
[6, 30, 54, 78, 102],
[6, 28, 54, 80, 106],
[6, 32, 58, 84, 110],
[6, 30, 58, 86, 114],
[6, 34, 62, 90, 118],
[6, 26, 50, 74, 98, 122],
[6, 30, 54, 78, 102, 126],
[6, 26, 52, 78, 104, 130],
[6, 30, 56, 82, 108, 134],
[6, 34, 60, 86, 112, 138],
[6, 30, 58, 86, 114, 142],
[6, 34, 62, 90, 118, 146],
[6, 30, 54, 78, 102, 126, 150],
[6, 24, 50, 76, 102, 128, 154],
[6, 28, 54, 80, 106, 132, 158],
[6, 32, 58, 84, 110, 136, 162],
[6, 26, 54, 82, 110, 138, 166],
[6, 30, 58, 86, 114, 142, 170]
],
G15 : (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0),
G18 : (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0),
G15_MASK : (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1),
getBCHTypeInfo : function(data) {
var d = data << 10;
while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
d ^= (QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) ) );
}
return ( (data << 10) | d) ^ QRUtil.G15_MASK;
},
getBCHTypeNumber : function(data) {
var d = data << 12;
while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
d ^= (QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) ) );
}
return (data << 12) | d;
},
getBCHDigit : function(data) {
var digit = 0;
while (data != 0) {
digit++;
data >>>= 1;
}
return digit;
},
getPatternPosition : function(typeNumber) {
return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
},
getMask : function(maskPattern, i, j) {
switch (maskPattern) {
case QRMaskPattern.PATTERN000 : return (i + j) % 2 == 0;
case QRMaskPattern.PATTERN001 : return i % 2 == 0;
case QRMaskPattern.PATTERN010 : return j % 3 == 0;
case QRMaskPattern.PATTERN011 : return (i + j) % 3 == 0;
case QRMaskPattern.PATTERN100 : return (Math.floor(i / 2) + Math.floor(j / 3) ) % 2 == 0;
case QRMaskPattern.PATTERN101 : return (i * j) % 2 + (i * j) % 3 == 0;
case QRMaskPattern.PATTERN110 : return ( (i * j) % 2 + (i * j) % 3) % 2 == 0;
case QRMaskPattern.PATTERN111 : return ( (i * j) % 3 + (i + j) % 2) % 2 == 0;
default :
throw new Error("bad maskPattern:" + maskPattern);
}
},
getErrorCorrectPolynomial : function(errorCorrectLength) {
var a = new QRPolynomial([1], 0);
for (var i = 0; i < errorCorrectLength; i++) {
a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0) );
}
return a;
},
getLengthInBits : function(mode, type) {
if (1 <= type && type < 10) {
// 1 - 9
switch(mode) {
case QRMode.MODE_NUMBER : return 10;
case QRMode.MODE_ALPHA_NUM : return 9;
case QRMode.MODE_8BIT_BYTE : return 8;
case QRMode.MODE_KANJI : return 8;
default :
throw new Error("mode:" + mode);
}
} else if (type < 27) {
// 10 - 26
switch(mode) {
case QRMode.MODE_NUMBER : return 12;
case QRMode.MODE_ALPHA_NUM : return 11;
case QRMode.MODE_8BIT_BYTE : return 16;
case QRMode.MODE_KANJI : return 10;
default :
throw new Error("mode:" + mode);
}
} else if (type < 41) {
// 27 - 40
switch(mode) {
case QRMode.MODE_NUMBER : return 14;
case QRMode.MODE_ALPHA_NUM : return 13;
case QRMode.MODE_8BIT_BYTE : return 16;
case QRMode.MODE_KANJI : return 12;
default :
throw new Error("mode:" + mode);
}
} else {
throw new Error("type:" + type);
}
},
getLostPoint : function(qrCode) {
var moduleCount = qrCode.getModuleCount();
var lostPoint = 0;
// LEVEL1
for (var row = 0; row < moduleCount; row++) {
for (var col = 0; col < moduleCount; col++) {
var sameCount = 0;
var dark = qrCode.isDark(row, col);
for (var r = -1; r <= 1; r++) {
if (row + r < 0 || moduleCount <= row + r) {
continue;
}
for (var c = -1; c <= 1; c++) {
if (col + c < 0 || moduleCount <= col + c) {
continue;
}
if (r == 0 && c == 0) {
continue;
}
if (dark == qrCode.isDark(row + r, col + c) ) {
sameCount++;
}
}
}
if (sameCount > 5) {
lostPoint += (3 + sameCount - 5);
}
}
}
// LEVEL2
for (var row = 0; row < moduleCount - 1; row++) {
for (var col = 0; col < moduleCount - 1; col++) {
var count = 0;
if (qrCode.isDark(row, col ) ) count++;
if (qrCode.isDark(row + 1, col ) ) count++;
if (qrCode.isDark(row, col + 1) ) count++;
if (qrCode.isDark(row + 1, col + 1) ) count++;
if (count == 0 || count == 4) {
lostPoint += 3;
}
}
}
// LEVEL3
for (var row = 0; row < moduleCount; row++) {
for (var col = 0; col < moduleCount - 6; col++) {
if (qrCode.isDark(row, col)
&& !qrCode.isDark(row, col + 1)
&& qrCode.isDark(row, col + 2)
&& qrCode.isDark(row, col + 3)
&& qrCode.isDark(row, col + 4)
&& !qrCode.isDark(row, col + 5)
&& qrCode.isDark(row, col + 6) ) {
lostPoint += 40;
}
}
}
for (var col = 0; col < moduleCount; col++) {
for (var row = 0; row < moduleCount - 6; row++) {
if (qrCode.isDark(row, col)
&& !qrCode.isDark(row + 1, col)
&& qrCode.isDark(row + 2, col)
&& qrCode.isDark(row + 3, col)
&& qrCode.isDark(row + 4, col)
&& !qrCode.isDark(row + 5, col)
&& qrCode.isDark(row + 6, col) ) {
lostPoint += 40;
}
}
}
// LEVEL4
var darkCount = 0;
for (var col = 0; col < moduleCount; col++) {
for (var row = 0; row < moduleCount; row++) {
if (qrCode.isDark(row, col) ) {
darkCount++;
}
}
}
var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
lostPoint += ratio * 10;
return lostPoint;
}
};
//---------------------------------------------------------------------
// QRMath
//---------------------------------------------------------------------
var QRMath = {
glog : function(n) {
if (n < 1) {
throw new Error("glog(" + n + ")");
}
return QRMath.LOG_TABLE[n];
},
gexp : function(n) {
while (n < 0) {
n += 255;
}
while (n >= 256) {
n -= 255;
}
return QRMath.EXP_TABLE[n];
},
EXP_TABLE : new Array(256),
LOG_TABLE : new Array(256)
};
for (var i = 0; i < 8; i++) {
QRMath.EXP_TABLE[i] = 1 << i;
}
for (var i = 8; i < 256; i++) {
QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4]
^ QRMath.EXP_TABLE[i - 5]
^ QRMath.EXP_TABLE[i - 6]
^ QRMath.EXP_TABLE[i - 8];
}
for (var i = 0; i < 255; i++) {
QRMath.LOG_TABLE[QRMath.EXP_TABLE[i] ] = i;
}
//---------------------------------------------------------------------
// QRPolynomial
//---------------------------------------------------------------------
function QRPolynomial(num, shift) {
if (num.length == undefined) {
throw new Error(num.length + "/" + shift);
}
var offset = 0;
while (offset < num.length && num[offset] == 0) {
offset++;
}
this.num = new Array(num.length - offset + shift);
for (var i = 0; i < num.length - offset; i++) {
this.num[i] = num[i + offset];
}
}
QRPolynomial.prototype = {
get : function(index) {
return this.num[index];
},
getLength : function() {
return this.num.length;
},
multiply : function(e) {
var num = new Array(this.getLength() + e.getLength() - 1);
for (var i = 0; i < this.getLength(); i++) {
for (var j = 0; j < e.getLength(); j++) {
num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i) ) + QRMath.glog(e.get(j) ) );
}
}
return new QRPolynomial(num, 0);
},
mod : function(e) {
if (this.getLength() - e.getLength() < 0) {
return this;
}
var ratio = QRMath.glog(this.get(0) ) - QRMath.glog(e.get(0) );
var num = new Array(this.getLength() );
for (var i = 0; i < this.getLength(); i++) {
num[i] = this.get(i);
}
for (var i = 0; i < e.getLength(); i++) {
num[i] ^= QRMath.gexp(QRMath.glog(e.get(i) ) + ratio);
}
// recursive call
return new QRPolynomial(num, 0).mod(e);
}
};
//---------------------------------------------------------------------
// QRRSBlock
//---------------------------------------------------------------------
function QRRSBlock(totalCount, dataCount) {
this.totalCount = totalCount;
this.dataCount = dataCount;
}
QRRSBlock.RS_BLOCK_TABLE = [
// L
// M
// Q
// H
// 1
[1, 26, 19],
[1, 26, 16],
[1, 26, 13],
[1, 26, 9],
// 2
[1, 44, 34],
[1, 44, 28],
[1, 44, 22],
[1, 44, 16],
// 3
[1, 70, 55],
[1, 70, 44],
[2, 35, 17],
[2, 35, 13],
// 4
[1, 100, 80],
[2, 50, 32],
[2, 50, 24],
[4, 25, 9],
// 5
[1, 134, 108],
[2, 67, 43],
[2, 33, 15, 2, 34, 16],
[2, 33, 11, 2, 34, 12],
// 6
[2, 86, 68],
[4, 43, 27],
[4, 43, 19],
[4, 43, 15],
// 7
[2, 98, 78],
[4, 49, 31],
[2, 32, 14, 4, 33, 15],
[4, 39, 13, 1, 40, 14],
// 8
[2, 121, 97],
[2, 60, 38, 2, 61, 39],
[4, 40, 18, 2, 41, 19],
[4, 40, 14, 2, 41, 15],
// 9
[2, 146, 116],
[3, 58, 36, 2, 59, 37],
[4, 36, 16, 4, 37, 17],
[4, 36, 12, 4, 37, 13],
// 10
[2, 86, 68, 2, 87, 69],
[4, 69, 43, 1, 70, 44],
[6, 43, 19, 2, 44, 20],
[6, 43, 15, 2, 44, 16],
// 11
[4, 101, 81],
[1, 80, 50, 4, 81, 51],
[4, 50, 22, 4, 51, 23],
[3, 36, 12, 8, 37, 13],
// 12
[2, 116, 92, 2, 117, 93],
[6, 58, 36, 2, 59, 37],
[4, 46, 20, 6, 47, 21],
[7, 42, 14, 4, 43, 15],
// 13
[4, 133, 107],
[8, 59, 37, 1, 60, 38],
[8, 44, 20, 4, 45, 21],
[12, 33, 11, 4, 34, 12],
// 14
[3, 145, 115, 1, 146, 116],
[4, 64, 40, 5, 65, 41],
[11, 36, 16, 5, 37, 17],
[11, 36, 12, 5, 37, 13],
// 15
[5, 109, 87, 1, 110, 88],
[5, 65, 41, 5, 66, 42],
[5, 54, 24, 7, 55, 25],
[11, 36, 12],
// 16
[5, 122, 98, 1, 123, 99],
[7, 73, 45, 3, 74, 46],
[15, 43, 19, 2, 44, 20],
[3, 45, 15, 13, 46, 16],
// 17
[1, 135, 107, 5, 136, 108],
[10, 74, 46, 1, 75, 47],
[1, 50, 22, 15, 51, 23],
[2, 42, 14, 17, 43, 15],
// 18
[5, 150, 120, 1, 151, 121],
[9, 69, 43, 4, 70, 44],
[17, 50, 22, 1, 51, 23],
[2, 42, 14, 19, 43, 15],
// 19
[3, 141, 113, 4, 142, 114],
[3, 70, 44, 11, 71, 45],
[17, 47, 21, 4, 48, 22],
[9, 39, 13, 16, 40, 14],
// 20
[3, 135, 107, 5, 136, 108],
[3, 67, 41, 13, 68, 42],
[15, 54, 24, 5, 55, 25],
[15, 43, 15, 10, 44, 16],
// 21
[4, 144, 116, 4, 145, 117],
[17, 68, 42],
[17, 50, 22, 6, 51, 23],
[19, 46, 16, 6, 47, 17],
// 22
[2, 139, 111, 7, 140, 112],
[17, 74, 46],
[7, 54, 24, 16, 55, 25],
[34, 37, 13],
// 23
[4, 151, 121, 5, 152, 122],
[4, 75, 47, 14, 76, 48],
[11, 54, 24, 14, 55, 25],
[16, 45, 15, 14, 46, 16],
// 24
[6, 147, 117, 4, 148, 118],
[6, 73, 45, 14, 74, 46],
[11, 54, 24, 16, 55, 25],
[30, 46, 16, 2, 47, 17],
// 25
[8, 132, 106, 4, 133, 107],
[8, 75, 47, 13, 76, 48],
[7, 54, 24, 22, 55, 25],
[22, 45, 15, 13, 46, 16],
// 26
[10, 142, 114, 2, 143, 115],
[19, 74, 46, 4, 75, 47],
[28, 50, 22, 6, 51, 23],
[33, 46, 16, 4, 47, 17],
// 27
[8, 152, 122, 4, 153, 123],
[22, 73, 45, 3, 74, 46],
[8, 53, 23, 26, 54, 24],
[12, 45, 15, 28, 46, 16],
// 28
[3, 147, 117, 10, 148, 118],
[3, 73, 45, 23, 74, 46],
[4, 54, 24, 31, 55, 25],
[11, 45, 15, 31, 46, 16],
// 29
[7, 146, 116, 7, 147, 117],
[21, 73, 45, 7, 74, 46],
[1, 53, 23, 37, 54, 24],
[19, 45, 15, 26, 46, 16],
// 30
[5, 145, 115, 10, 146, 116],
[19, 75, 47, 10, 76, 48],
[15, 54, 24, 25, 55, 25],
[23, 45, 15, 25, 46, 16],
// 31
[13, 145, 115, 3, 146, 116],
[2, 74, 46, 29, 75, 47],
[42, 54, 24, 1, 55, 25],
[23, 45, 15, 28, 46, 16],
// 32
[17, 145, 115],
[10, 74, 46, 23, 75, 47],
[10, 54, 24, 35, 55, 25],
[19, 45, 15, 35, 46, 16],
// 33
[17, 145, 115, 1, 146, 116],
[14, 74, 46, 21, 75, 47],
[29, 54, 24, 19, 55, 25],
[11, 45, 15, 46, 46, 16],
// 34
[13, 145, 115, 6, 146, 116],
[14, 74, 46, 23, 75, 47],
[44, 54, 24, 7, 55, 25],
[59, 46, 16, 1, 47, 17],
// 35
[12, 151, 121, 7, 152, 122],
[12, 75, 47, 26, 76, 48],
[39, 54, 24, 14, 55, 25],
[22, 45, 15, 41, 46, 16],
// 36
[6, 151, 121, 14, 152, 122],
[6, 75, 47, 34, 76, 48],
[46, 54, 24, 10, 55, 25],
[2, 45, 15, 64, 46, 16],
// 37
[17, 152, 122, 4, 153, 123],
[29, 74, 46, 14, 75, 47],
[49, 54, 24, 10, 55, 25],
[24, 45, 15, 46, 46, 16],
// 38
[4, 152, 122, 18, 153, 123],
[13, 74, 46, 32, 75, 47],
[48, 54, 24, 14, 55, 25],
[42, 45, 15, 32, 46, 16],
// 39
[20, 147, 117, 4, 148, 118],
[40, 75, 47, 7, 76, 48],
[43, 54, 24, 22, 55, 25],
[10, 45, 15, 67, 46, 16],
// 40
[19, 148, 118, 6, 149, 119],
[18, 75, 47, 31, 76, 48],
[34, 54, 24, 34, 55, 25],
[20, 45, 15, 61, 46, 16]
];
QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) {
var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);
if (rsBlock == undefined) {
throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel);
}
var length = rsBlock.length / 3;
var list = new Array();
for (var i = 0; i < length; i++) {
var count = rsBlock[i * 3 + 0];
var totalCount = rsBlock[i * 3 + 1];
var dataCount = rsBlock[i * 3 + 2];
for (var j = 0; j < count; j++) {
list.push(new QRRSBlock(totalCount, dataCount) );
}
}
return list;
}
QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) {
switch(errorCorrectLevel) {
case QRErrorCorrectLevel.L :
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
case QRErrorCorrectLevel.M :
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
case QRErrorCorrectLevel.Q :
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
case QRErrorCorrectLevel.H :
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
default :
return undefined;
}
}
//---------------------------------------------------------------------
// QRBitBuffer
//---------------------------------------------------------------------
function QRBitBuffer() {
this.buffer = new Array();
this.length = 0;
}
QRBitBuffer.prototype = {
get : function(index) {
var bufIndex = Math.floor(index / 8);
return ( (this.buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1;
},
put : function(num, length) {
for (var i = 0; i < length; i++) {
this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1);
}
},
getLengthInBits : function() {
return this.length;
},
putBit : function(bit) {
var bufIndex = Math.floor(this.length / 8);
if (this.buffer.length <= bufIndex) {
this.buffer.push(0);
}
if (bit) {
this.buffer[bufIndex] |= (0x80 >>> (this.length % 8) );
}
this.length++;
}
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment