Skip to content

Instantly share code, notes, and snippets.

@AhmadOsama4
Last active March 30, 2019 12:28
Show Gist options
  • Save AhmadOsama4/88a44c587645c2867d9f1e4a98b20173 to your computer and use it in GitHub Desktop.
Save AhmadOsama4/88a44c587645c2867d9f1e4a98b20173 to your computer and use it in GitHub Desktop.
Javascript code in Animated Set Internsection Example
/*
This is the javascript code contained in the animated set example which is a pdf file generated here:
http://www.texample.net/tikz/examples/andler-optimal-lot-size/
The javascript code is extracted using the Poppler Library by simply printing the extracted script to the console.
*/
// Page 2
// Script 1
if (typeof(curdoc) == 'undefined') {
curdoc = this;
}
if (typeof(a0) == 'undefined') {
a0 = new Object();
a0.fr = new Array();
for (i = 0; i < this.numFields; i++) {
var fldName = this.getNthFieldName(i).split('.');
if (fldName[0] == 0) {
a0.fr[fldName[1]] = this.getField(this.getNthFieldName(i));
}
}
a0.idx = 0;
a0.isPlaying = false;
a0.playsRight = true;
a0.isPaused = false;
a0.dt = 1000 / (1e-6 + Math.abs(3));
a0.actnEndLeft = function() {
a0.actnPause();
a0.isPaused = false;
a0.fr[a0.idx].display = display.hidden;
a0.idx = 0;
a0.fr[0].display = display.visible;
curdoc.dirty = false;
};
a0.actnEndRight = function() {
a0.actnPause();
a0.isPaused = false;
a0.fr[a0.idx].display = display.hidden;
a0.idx = 7;
a0.fr[a0.idx].display = display.visible;
curdoc.dirty = false;
};
a0.actnNext = function() {
a0.fr[a0.idx].display = display.hidden;
try {
a0.fr[++a0.idx].display = display.visible;
curdoc.dirty = false;
} catch (e) {
--a0.idx;
a0.fr[a0.idx].display = display.visible;
curdoc.dirty = false;
if (a0.isPlaying) {
a0.isPaused = true;
a0.actnPlayLeft();
}
}
};
a0.actnPrev = function() {
a0.fr[a0.idx].display = display.hidden;
try {
a0.fr[--a0.idx].display = display.visible;
curdoc.dirty = false;
} catch (e) {
++a0.idx;
a0.fr[a0.idx].display = display.visible;
curdoc.dirty = false;
if (a0.isPlaying) {
a0.isPaused = true;
a0.actnPlayRight();
}
}
};
a0.actnPause = function() {
try {
app.clearInterval(a0_int);
} catch (e) {}
a0.isPlaying = false;
a0.isPaused = true;
};
a0.actnPlayRight = function() {
try {
app.clearInterval(a0_int);
} catch (e) {}
if (!a0.isPaused) {
a0.actnEndLeft();
}
a0.playsRight = true;
a0.isPlaying = true;
a0.isPaused = false;
a0_int = app.setInterval('a0.actnNext()', a0.dt);
};
a0.actnPlayLeft = function() {
try {
app.clearInterval(a0_int);
} catch (e) {}
if (!a0.isPaused) {
a0.actnEndRight();
}
a0.playsRight = false;
a0.isPlaying = true;
a0.isPaused = false;
a0_int = app.setInterval('a0.actnPrev()', a0.dt);
};
}
if (a0.playsRight) {
a0_intd = app.setTimeOut('a0.actnPlayRight()', 1);
} else {
a0_intd = app.setTimeOut('a0.actnPlayLeft()', 1);
}
// Script 2
if(a0.isPaused)
{
a0.actnPause();
}
else{
a0.playsRight=true;
a0_intd=app.setTimeOut('a0.actnEndLeft()',1);
}
// Script 3
app.focusRect=false;
try{
if(a0.isPlaying){
a0.actnPause();
}
}
catch(e){}
// Script 4
try
{
if(a0.playsRight)
{
a0.actnPlayRight();
}
else
{
a0.actnPlayLeft();
}
}catch(e){}
/////////////////////////////////////////////////////////////////////////////////////////////
// Page 3
// Script 1
if (typeof(curdoc) == 'undefined') {
curdoc = this;
}
if (typeof(a1) == 'undefined') {
a1 = new Object();
a1.fr = new Array();
for (i = 0; i < this.numFields; i++) {
var fldName = this.getNthFieldName(i).split('.');
if (fldName[0] == 1) {
a1.fr[fldName[1]] = this.getField(this.getNthFieldName(i));
}
}
a1.idx = 0;
a1.isPlaying = false;
a1.playsRight = true;
a1.isPaused = false;
a1.dt = 1000 / (1e-6 + Math.abs(3));
a1.actnEndLeft = function() {
a1.actnPause();
a1.isPaused = false;
a1.fr[a1.idx].display = display.hidden;
a1.idx = 0;
a1.fr[0].display = display.visible;
curdoc.dirty = false;
};
a1.actnEndRight = function() {
a1.actnPause();
a1.isPaused = false;
a1.fr[a1.idx].display = display.hidden;
a1.idx = 6;
a1.fr[a1.idx].display = display.visible;
curdoc.dirty = false;
};
a1.actnNext = function() {
a1.fr[a1.idx].display = display.hidden;
try {
a1.fr[++a1.idx].display = display.visible;
curdoc.dirty = false;
} catch (e) {
--a1.idx;
a1.fr[a1.idx].display = display.visible;
curdoc.dirty = false;
if (a1.isPlaying) {
a1.isPaused = true;
a1.actnPlayLeft();
}
}
};
a1.actnPrev = function() {
a1.fr[a1.idx].display = display.hidden;
try {
a1.fr[--a1.idx].display = display.visible;
curdoc.dirty = false;
} catch (e) {
++a1.idx;
a1.fr[a1.idx].display = display.visible;
curdoc.dirty = false;
if (a1.isPlaying) {
a1.isPaused = true;
a1.actnPlayRight();
}
}
};
a1.actnPause = function() {
try {
app.clearInterval(a1_int);
} catch (e) {}
a1.isPlaying = false;
a1.isPaused = true;
};
a1.actnPlayRight = function() {
try {
app.clearInterval(a1_int);
} catch (e) {}
if (!a1.isPaused) {
a1.actnEndLeft();
}
a1.playsRight = true;
a1.isPlaying = true;
a1.isPaused = false;
a1_int = app.setInterval('a1.actnNext()', a1.dt);
};
a1.actnPlayLeft = function() {
try {
app.clearInterval(a1_int);
} catch (e) {}
if (!a1.isPaused) {
a1.actnEndRight();
}
a1.playsRight = false;
a1.isPlaying = true;
a1.isPaused = false;
a1_int = app.setInterval('a1.actnPrev()', a1.dt);
};
}
if (a1.playsRight) {
a1_intd = app.setTimeOut('a1.actnPlayRight()', 1);
} else {
a1_intd = app.setTimeOut('a1.actnPlayLeft()', 1);
}
// Script 2
if(a1.isPaused)
{
a1.actnPause();
}
else
{
a1.playsRight=true;
a1_intd=app.setTimeOut('a1.actnEndLeft()',1);
}
// Script 3
app.focusRect=false;
try
{
if(a1.isPlaying){
a1.actnPause();
}
}catch(e){}
// Script 4
try{
if(a1.playsRight){
a1.actnPlayRight();
}
else{
a1.actnPlayLeft();
}
}
catch(e){}
/*
This is the javascript code contained in the animated set example which is a pdf file generated here:
http://www.texample.net/tikz/examples/animated-set-intersection/
The javascript code is extracted using the Poppler Library by simply printing the extracted script to the console.
*/
// Script 1
if(typeof(curdoc)=='undefined')
{
var curdoc=this;
}
if(typeof(a0)=='undefined')
{
a0=new Object();
a0.fr=new Array();
for(i=0;i<this.numFields;i++)
{
var fldName=this.getNthFieldName(i).split('.');
if(fldName[0]==0)
{
a0.fr[fldName[1]]=this.getField(this.getNthFieldName(i));
}
}
a0.idx=0;
a0.isPlaying=false;
a0.playsRight=true;
a0.isPaused=false;
a0.dtDeflt=1000/(1e-6+Math.abs(12));
a0.dt=a0.dtDeflt;
a0.actnEndLeft=function()
{
a0.actnPause();
a0.isPaused=false;
a0.fr[a0.idx].display=display.hidden;
a0.idx=0;
a0.fr[0].display=display.visible;
curdoc.dirty=false;
};
a0.actnEndRight=function()
{
a0.actnPause();
a0.isPaused=false;
a0.fr[a0.idx].display=display.hidden;
a0.idx=21-1;
a0.fr[a0.idx].display=display.visible;
curdoc.dirty=false;
};
a0.actnNext=function()
{
a0.fr[a0.idx].display=display.hidden;
try
{
a0.fr[++a0.idx].display=display.visible;
curdoc.dirty=false;
}
catch(e)
{
--a0.idx;
a0.fr[a0.idx].display=display.visible;
curdoc.dirty=false;
if(a0.isPlaying)
{
a0.isPaused=true;
a0.actnPlayLeft();
}
}
};
a0.actnPrev=function()
{
a0.fr[a0.idx].display=display.hidden;
try
{
a0.fr[--a0.idx].display=display.visible;
curdoc.dirty=false;
}
catch(e)
{
++a0.idx;
a0.fr[a0.idx].display=display.visible;
curdoc.dirty=false;
if(a0.isPlaying)
{
a0.isPaused=true;
a0.actnPlayRight();
}
}
};
a0.actnPause=function()
{
try
{
app.clearInterval(a0_int);
}
catch(e){}
a0.isPlaying=false;
a0.isPaused=true;
};
a0.actnPlayRight=function()
{
try
{
app.clearInterval(a0_int);
}
catch(e){}
if(!a0.isPaused)
{
a0.actnEndLeft();
}
a0.playsRight=true;
a0.isPlaying=true;
a0.isPaused=false;
a0_int=app.setInterval('a0.actnNext()',a0.dt);
};
a0.actnPlayLeft=function()
{
try
{
app.clearInterval(a0_int);
}
catch(e)
{}
if(!a0.isPaused)
{
a0.actnEndRight();
}
a0.playsRight=false;
a0.isPlaying=true;
a0.isPaused=false;
a0_int=app.setInterval('a0.actnPrev()',a0.dt);
};
a0.actnSecEndLeft=function(){
try
{
app.clearInterval(a0_intd);
}
catch(e){}
a0.actnEndLeft();
};
a0.actnSecEndRight=function()
{
try
{
app.clearInterval(a0_intd);
}catch(e){}
a0.actnEndRight();
};
a0.actnSecPlayLeft=function()
{
try
{
app.clearInterval(a0_intd);
}
catch(e){}
a0.actnPlayLeft();
};
a0.actnSecPlayRight=function()
{
try
{
app.clearInterval(a0_intd);
}
catch(e){}
a0.actnPlayRight();
};
}
if(a0.playsRight)
{
a0_intd=app.setInterval('a0.actnSecPlayRight()',1);
}
else
{
a0_intd=app.setInterval('a0.actnSecPlayLeft()',1);
}
// Script 2
if(a0.isPaused)
{
a0.actnPause();
}
else
{
a0.playsRight=true;
a0_intd=app.setInterval('a0.actnSecEndLeft()',1);
}
// Script 3
app.focusRect=false;
if(a0.isPlaying)
{
a0.actnPause();
}
// Script 4
if(a0.playsRight)
{
a0.actnPlayRight();
}
else
{
a0.actnPlayLeft();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment