archematics/etc/deps/GeoGebra/deployggb.js

5 lines
36 KiB
JavaScript
Raw Permalink Normal View History

/*
@author: GeoGebra - Dynamic Mathematics for Everyone, http://www.geogebra.org
@license: This file is subject to the GeoGebra Non-Commercial License Agreement, see http://www.geogebra.org/license. For questions please write us at office@geogebra.org.
*/
(function(){if(typeof window.GGBApplet=="function"){console.warn("deployggb.js was loaded twice");return}var isRenderGGBElementEnabled=false;var scriptLoadStarted=false;var html5AppletsToProcess=null;var ggbHTML5LoadedCodebaseIsWebSimple=false;var ggbHTML5LoadedCodebaseVersion=null;var ggbHTML5LoadedScript=null;var GGBApplet=function(){"use strict";var applet={};var ggbVersion="5.0";var parameters={};var views=null;var html5NoWebSimple=false;var html5NoWebSimpleParamExists=false;var appletID=null;var initComplete=false;var html5OverwrittenCodebaseVersion=null;var html5OverwrittenCodebase=null;for(var i=0;i<arguments.length;i++){var p=arguments[i];if(p!==null){switch(typeof p){case"number":ggbVersion=p.toFixed(1);break;case"string":if(p.match(new RegExp("^[0-9]\\.[0-9]+$"))){ggbVersion=p}else{appletID=p}break;case"object":if(typeof p.is3D!=="undefined"){views=p}else{parameters=p}break;case"boolean":html5NoWebSimple=p;html5NoWebSimpleParamExists=true;break}}}if(views===null){views={is3D:false,AV:false,SV:false,CV:false,EV2:false,CP:false,PC:false,DA:false,FI:false,PV:false,macro:false};if(parameters.material_id!==undefined&&!html5NoWebSimpleParamExists){html5NoWebSimple=true}}if(appletID!==null&&parameters.id===undefined){parameters.id=appletID}var jnlpFilePath="";var html5Codebase="";var isHTML5Offline=false;var loadedAppletType=null;var html5CodebaseVersion=null;var html5CodebaseScript=null;var html5CodebaseIsWebSimple=false;var previewImagePath=null;var previewLoadingPath=null;var previewPlayPath=null;var fonts_css_url=null;var jnlpBaseDir=null;if(parameters.height!==undefined){parameters.height=Math.round(parameters.height)}if(parameters.width!==undefined){parameters.width=Math.round(parameters.width)}var parseVersion=function(d){return parseFloat(d)>4?parseFloat(d):5};applet.setHTML5Codebase=function(codebase,offline){html5OverwrittenCodebase=codebase;setHTML5CodebaseInternal(codebase,offline)};applet.setJavaCodebase=applet.setJavaCodebaseVersion=applet.isCompiledInstalled=applet.setPreCompiledScriptPath=applet.setPreCompiledResourcePath=function(){};applet.setHTML5CodebaseVersion=function(version,offline){var numVersion=parseFloat(version);if(numVersion!==NaN&&numVersion<5){console.log("The GeoGebra HTML5 codebase version "+numVersion+" is deprecated. Using version latest instead.");return}html5OverwrittenCodebaseVersion=version;setDefaultHTML5CodebaseForVersion(version,offline)};applet.getHTML5CodebaseVersion=function(){return html5CodebaseVersion};applet.getParameters=function(){return parameters};applet.setFontsCSSURL=function(url){fonts_css_url=url};applet.setGiacJSURL=function(url){};applet.setJNLPFile=function(newJnlpFilePath){jnlpFilePath=newJnlpFilePath};applet.setJNLPBaseDir=function(baseDir){};applet.inject=function(){function isOwnIFrame(){return window.frameElement&&window.frameElement.getAttribute("data-singleton")}var type="auto";var container_ID=parameters.id;var container;var noPreview=false;for(var i=0;i<arguments.length;i++){var p=arguments[i];if(typeof p==="string"){p=p.toLowerCase();if(p.match(/^(prefer)?(java|html5|compiled|auto|screenshot)$/)){type=p}else{container_ID=arguments[i]}}else if(typeof p==="boolean"){noPreview=p}else if(p instanceof HTMLElement){container=p}}continueInject();function continueInject(){if(!initComplete){setTimeout(continueInject,200);return}type=detectAppletType(type);var appletElem=container||document.getElementById(container_ID);if(!appletElem){console.log("possibly bug on ajax loading? ");return}applet.removeExistingApplet(appletElem,false);if(parameters.width===undefined&&appletElem.clientWidth){parameters.width=appletElem.clientWidth}if(parameters.height===undefined&&appletElem.clientHeight){parameters.height=appletElem.clientHeight}if(!(parameters.width&&parameters.height)&&type==="html5"){delete parameters.width;delete parameters.height}loadedAppletType=type;if(type==="screenshot"){injectScreenshot(appletElem,parameters)}else{var playButton=false;if(parameters.hasOwnProperty("playButton")&&parameters.playButton||parameters.hasOwnProperty("clickToLoad")&&paramete