-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.min.js
1 lines (1 loc) · 33.5 KB
/
app.min.js
1
window.demo_gist={url:"https://api.github.com/gists/6e54093b297c0f9df01d0c82f65b89f6",forks_url:"https://api.github.com/gists/6e54093b297c0f9df01d0c82f65b89f6/forks",commits_url:"https://api.github.com/gists/6e54093b297c0f9df01d0c82f65b89f6/commits",id:"6e54093b297c0f9df01d0c82f65b89f6",git_pull_url:"https://gist.github.com/6e54093b297c0f9df01d0c82f65b89f6.git",git_push_url:"https://gist.github.com/6e54093b297c0f9df01d0c82f65b89f6.git",html_url:"https://gist.github.com/6e54093b297c0f9df01d0c82f65b89f6",files:{"Counters.json":{filename:"Counters.json",type:"application/json",language:"JSON",raw_url:"https://gist.githubusercontent.com/bordaigorl/6e54093b297c0f9df01d0c82f65b89f6/raw/a5cdec909a878fba0749a8993bc210739c8092e5/Counters.json",size:22,truncated:!1,content:'{\n "gravity": false\n}'},"Counters.pi":{filename:"Counters.pi",type:"text/plain",language:null,raw_url:"https://gist.githubusercontent.com/bordaigorl/6e54093b297c0f9df01d0c82f65b89f6/raw/eb34febe958f1dec230a7ad2fe376b7fd33c631d/Counters.pi",size:365,truncated:!1,content:"νc0,c1.( Z[c0] | Z[c1] | M1[c0,c1] )\n\nC[c,p] := c<p>\nZ[c] := c().Z[c]\nM[c1,c2] :=\n c1(r).M[r,c2]\n + c2(r).M[c1,r]\n + tau.new t.(M[t,c2] | C[t,c1])\n + tau.new t.(M[c1,t] | C[t,c2])\nM1[c1,c2] :=\n c1<>.new c.( M2[c,c2] | C[c,c1] )\n + c1(r).new c.( M1[r,c] | C[c,c2] )\nM2[c1,c2] :=\n c2<>.new c.( M1[c1,c] | C[c,c2] )\n + c2(r).new c.( M2[c,r] | C[c,c1] )\n"},"Couples.pi":{filename:"Couples.pi",type:"text/plain",language:null,raw_url:"https://gist.githubusercontent.com/bordaigorl/6e54093b297c0f9df01d0c82f65b89f6/raw/8dfac830addd89cd0da3a64db8a0ad3f3dc679ac/Couples.pi",size:207,truncated:!1,content:"new p,q.(M[p,q] | Gp[p] | Gq[q])\n\nM[p,q] := p(x).(M[p,q] | PM[q,x])\nGp[p] := tau.new w.(Gp[p] | Aw[p,w])\nGq[q] := tau.new z.(Gq[q] | Bw[q,z])\nBw[q,w] := q<w>.B[w]\nAw[q,w] := q<w>.A[w]\nPM[q,x] := q(y).N[x,y]\n"},"Hannenfass.json":{filename:"Hannenfass.json",type:"application/json",language:"JSON",raw_url:"https://gist.githubusercontent.com/bordaigorl/6e54093b297c0f9df01d0c82f65b89f6/raw/11fda76c3f6e1a9327903e507e33952ea2b70e98/Hannenfass.json",size:25,truncated:!1,content:'{\n "showGlobals": true\n}'},"Hannenfass.pi":{filename:"Hannenfass.pi",type:"text/plain",language:null,raw_url:"https://gist.githubusercontent.com/bordaigorl/6e54093b297c0f9df01d0c82f65b89f6/raw/a65b290f79ecbb035533e62516e7777360ec991c/Hannenfass.pi",size:893,truncated:!1,content:"/* * * * * * * * * * * * *\\\n * The Rumor Mill *\n * at the Hannenfass bar *\n * * * * * * * * * * * * * \n\n Coded by Thomas Schneider \n Adapted by Emanuele\n\n\\* * * * * * * * * * * * */\n\n\n// One wise man and four naive ones walk into a bar\nnew table.(\n Barman[bar,table]@(0,0)\n| Wise[bar,secret]\n| Naive[bar]\n| Naive[bar]\n| Naive[bar]\n| Naive[bar]\n| Naive[bar]\n)\n\n// Barman\nBarman[bar,t] :=\n bar<t>.B[bar,t]\n + tau.(Barman[bar,t] | Naive[bar])\nB[bar,t] :=\n bar<t>.new table.Barman[bar,table]\n\n// Wise Customer, knows the secret\nWise[bar,s] :=\n bar(t).W[bar,s,t]\nW[bar,s,t] :=\n t<s>.Wise[bar,s] // Tell the secret\n + t().Wise[bar,s] + t<>.Wise[bar,s] // Chitchat\n\n//Naive Customer\nNaive[bar] :=\n bar(t).N[bar,t]\nN[bar,t] :=\n t(s).Wise[bar,s]\n + t<>.Naive[bar]\n + t().Naive[bar]\n\n/*\n bar(t) - ask for table\n t - table-talk\n s - secret for more excitement\n*/\n"},"List.json":{filename:"List.json",type:"application/json",language:"JSON",raw_url:"https://gist.githubusercontent.com/bordaigorl/6e54093b297c0f9df01d0c82f65b89f6/raw/a5cdec909a878fba0749a8993bc210739c8092e5/List.json",size:22,truncated:!1,content:'{\n "gravity": false\n}'},"List.pi":{filename:"List.pi",type:"text/plain",language:null,raw_url:"https://gist.githubusercontent.com/bordaigorl/6e54093b297c0f9df01d0c82f65b89f6/raw/0d17440f75f3a6611d6b9ad95209fc0fc7fecc33/List.pi",size:45,truncated:!1,content:"new a.L[a]\n\nL[x] := tau.new y.(L[y] | B[x,y])"},"Lists.json":{filename:"Lists.json",type:"application/json",language:"JSON",raw_url:"https://gist.githubusercontent.com/bordaigorl/6e54093b297c0f9df01d0c82f65b89f6/raw/a5cdec909a878fba0749a8993bc210739c8092e5/Lists.json",size:22,truncated:!1,content:'{\n "gravity": false\n}'},"Lists.pi":{filename:"Lists.pi",type:"text/plain",language:null,raw_url:"https://gist.githubusercontent.com/bordaigorl/6e54093b297c0f9df01d0c82f65b89f6/raw/6aa1b9689802de9fd66103ce1e9ad287a7daafdf/Lists.pi",size:82,truncated:!1,content:"new a.A[a]\n\nA[x] := tau.(A[x] | L[x])\nL[x] := tau.new y,z.(L[y] | B[x,y,z] | C[z])"},"Ring.json":{filename:"Ring.json",type:"application/json",language:"JSON",raw_url:"https://gist.githubusercontent.com/bordaigorl/6e54093b297c0f9df01d0c82f65b89f6/raw/ee7615e48b7bbd53846de0219013be88f42aca7e/Ring.json",size:121,truncated:!1,content:'{\n "gravity": false,\n "palette": {\n "S": "#2ca02c",\n "M": "#1f77b4",\n "T": "#ff7f0e",\n "D": "#98df8a"\n }\n}'},"Ring.pi":{filename:"Ring.pi",type:"text/plain",language:null,raw_url:"https://gist.githubusercontent.com/bordaigorl/6e54093b297c0f9df01d0c82f65b89f6/raw/b15051bee4d2ec37005120584f3047bc6ace1c2d/Ring.pi",size:294,truncated:!1,content:"ν master.(\n M[master,master]\n | T[master]\n )\n\n// The master of the ring\nM[self, fst] :=\n self().new next,data.(\n M[self, next]\n | S[next, fst, data]\n | T[next]\n)\n\n// A slave\nS[self,next,data] :=\n self().(\n S[self, next,data]\n | T[next]\n | D[data]\n )\n\n// The Token\nT[x] := x<>"},"Server.json":{filename:"Server.json",type:"application/json",language:"JSON",raw_url:"https://gist.githubusercontent.com/bordaigorl/6e54093b297c0f9df01d0c82f65b89f6/raw/1c74ace2b7c28690c54a1018c732c913744effdb/Server.json",size:43,truncated:!1,content:'{\n "showLabels": true,\n "gravity": true\n}'},"Server.pi":{filename:"Server.pi",type:"text/plain",language:null,raw_url:"https://gist.githubusercontent.com/bordaigorl/6e54093b297c0f9df01d0c82f65b89f6/raw/d583dc6a9a5dcb3dfef1d50993213b8b9c6b3f0a/Server.pi",size:180,truncated:!1,content:"new s. (S[s] | E[s])\n\nS[s] := s(x).νd.( S[s] | A[x,d] )\nE[s] := τ.new m.(E[s] | C[s, m])\nC[s, m] := τ.( C1[s,m] | Q[s,m] )\nC1[s, m] := m(x).C[s, m]\nA[x,d] := x<d>\nQ[s,m] := s<m>"},"Servers.pi":{filename:"Servers.pi",type:"text/plain",language:null,raw_url:"https://gist.githubusercontent.com/bordaigorl/6e54093b297c0f9df01d0c82f65b89f6/raw/2012e5d48ded48c9245b8f9eba47c7eb466d6716/Servers.pi",size:213,truncated:!1,content:"new s. (S[s] | E[s])\n\nS[s] := s(x).νd.( S[s] | A[x,d] )\nE[s] := τ.new m.(E[s] | C[s, m]) + τ.νs'.(E[s'] | S[s'] | E[s])\nC[s, m] := τ.( C1[s,m] | Q[s,m] )\nC1[s, m] := m(x).C[s, m]\nA[x,d] := x<d>\nQ[s,m] := s<m>"},"default.json":{filename:"default.json",type:"application/json",language:"JSON",raw_url:"https://gist.githubusercontent.com/bordaigorl/6e54093b297c0f9df01d0c82f65b89f6/raw/c6f410da27a5c1cd42e6439638508224a8031c13/default.json",size:26,truncated:!1,content:'{\n "default": "Servers"\n}'}},public:!0,created_at:"2017-02-26T21:26:23Z",updated_at:"2017-11-13T23:26:30Z",description:"Examples of pi-calculus programs",comments:0,user:null,comments_url:"https://api.github.com/gists/6e54093b297c0f9df01d0c82f65b89f6/comments",owner:{login:"bordaigorl",id:2098241,avatar_url:"https://avatars3.githubusercontent.com/u/2098241?v=4",gravatar_id:"",url:"https://api.github.com/users/bordaigorl",html_url:"https://github.com/bordaigorl",followers_url:"https://api.github.com/users/bordaigorl/followers",following_url:"https://api.github.com/users/bordaigorl/following{/other_user}",gists_url:"https://api.github.com/users/bordaigorl/gists{/gist_id}",starred_url:"https://api.github.com/users/bordaigorl/starred{/owner}{/repo}",subscriptions_url:"https://api.github.com/users/bordaigorl/subscriptions",organizations_url:"https://api.github.com/users/bordaigorl/orgs",repos_url:"https://api.github.com/users/bordaigorl/repos",events_url:"https://api.github.com/users/bordaigorl/events{/privacy}",received_events_url:"https://api.github.com/users/bordaigorl/received_events",type:"User",site_admin:!1},forks:[],history:[{user:{login:"bordaigorl",id:2098241,avatar_url:"https://avatars3.githubusercontent.com/u/2098241?v=4",gravatar_id:"",url:"https://api.github.com/users/bordaigorl",html_url:"https://github.com/bordaigorl",followers_url:"https://api.github.com/users/bordaigorl/followers",following_url:"https://api.github.com/users/bordaigorl/following{/other_user}",gists_url:"https://api.github.com/users/bordaigorl/gists{/gist_id}",starred_url:"https://api.github.com/users/bordaigorl/starred{/owner}{/repo}",subscriptions_url:"https://api.github.com/users/bordaigorl/subscriptions",organizations_url:"https://api.github.com/users/bordaigorl/orgs",repos_url:"https://api.github.com/users/bordaigorl/repos",events_url:"https://api.github.com/users/bordaigorl/events{/privacy}",received_events_url:"https://api.github.com/users/bordaigorl/received_events",type:"User",site_admin:!1},version:"9b338bf5e451039ffa8c93fdf50658cccd101038",committed_at:"2017-11-13T23:26:29Z",change_status:{total:2,additions:1,deletions:1},url:"https://api.github.com/gists/6e54093b297c0f9df01d0c82f65b89f6/9b338bf5e451039ffa8c93fdf50658cccd101038"},{user:{login:"bordaigorl",id:2098241,avatar_url:"https://avatars3.githubusercontent.com/u/2098241?v=4",gravatar_id:"",url:"https://api.github.com/users/bordaigorl",html_url:"https://github.com/bordaigorl",followers_url:"https://api.github.com/users/bordaigorl/followers",following_url:"https://api.github.com/users/bordaigorl/following{/other_user}",gists_url:"https://api.github.com/users/bordaigorl/gists{/gist_id}",starred_url:"https://api.github.com/users/bordaigorl/starred{/owner}{/repo}",subscriptions_url:"https://api.github.com/users/bordaigorl/subscriptions",organizations_url:"https://api.github.com/users/bordaigorl/orgs",repos_url:"https://api.github.com/users/bordaigorl/repos",events_url:"https://api.github.com/users/bordaigorl/events{/privacy}",received_events_url:"https://api.github.com/users/bordaigorl/received_events",type:"User",site_admin:!1},version:"1cd18bf3e30656d61b236796dd750a399b7bec3d",committed_at:"2017-11-13T00:34:55Z",change_status:{total:92,additions:46,deletions:46},url:"https://api.github.com/gists/6e54093b297c0f9df01d0c82f65b89f6/1cd18bf3e30656d61b236796dd750a399b7bec3d"},{user:{login:"bordaigorl",id:2098241,avatar_url:"https://avatars3.githubusercontent.com/u/2098241?v=4",gravatar_id:"",url:"https://api.github.com/users/bordaigorl",html_url:"https://github.com/bordaigorl",followers_url:"https://api.github.com/users/bordaigorl/followers",following_url:"https://api.github.com/users/bordaigorl/following{/other_user}",gists_url:"https://api.github.com/users/bordaigorl/gists{/gist_id}",starred_url:"https://api.github.com/users/bordaigorl/starred{/owner}{/repo}",subscriptions_url:"https://api.github.com/users/bordaigorl/subscriptions",organizations_url:"https://api.github.com/users/bordaigorl/orgs",repos_url:"https://api.github.com/users/bordaigorl/repos",events_url:"https://api.github.com/users/bordaigorl/events{/privacy}",received_events_url:"https://api.github.com/users/bordaigorl/received_events",type:"User",site_admin:!1},version:"cf8db901ae90e11a35b362e15f633d3a1df2de54",committed_at:"2017-11-04T21:18:51Z",change_status:{total:30,additions:15,deletions:15},url:"https://api.github.com/gists/6e54093b297c0f9df01d0c82f65b89f6/cf8db901ae90e11a35b362e15f633d3a1df2de54"},{user:{login:"bordaigorl",id:2098241,avatar_url:"https://avatars3.githubusercontent.com/u/2098241?v=4",gravatar_id:"",url:"https://api.github.com/users/bordaigorl",html_url:"https://github.com/bordaigorl",followers_url:"https://api.github.com/users/bordaigorl/followers",following_url:"https://api.github.com/users/bordaigorl/following{/other_user}",gists_url:"https://api.github.com/users/bordaigorl/gists{/gist_id}",starred_url:"https://api.github.com/users/bordaigorl/starred{/owner}{/repo}",subscriptions_url:"https://api.github.com/users/bordaigorl/subscriptions",organizations_url:"https://api.github.com/users/bordaigorl/orgs",repos_url:"https://api.github.com/users/bordaigorl/repos",events_url:"https://api.github.com/users/bordaigorl/events{/privacy}",received_events_url:"https://api.github.com/users/bordaigorl/received_events",type:"User",site_admin:!1},version:"adf63557ff5f521a0d7fbb8c0622301dbef784ab",committed_at:"2017-10-30T00:02:36Z",change_status:{total:36,additions:29,deletions:7},url:"https://api.github.com/gists/6e54093b297c0f9df01d0c82f65b89f6/adf63557ff5f521a0d7fbb8c0622301dbef784ab"},{user:{login:"bordaigorl",id:2098241,avatar_url:"https://avatars3.githubusercontent.com/u/2098241?v=4",gravatar_id:"",url:"https://api.github.com/users/bordaigorl",html_url:"https://github.com/bordaigorl",followers_url:"https://api.github.com/users/bordaigorl/followers",following_url:"https://api.github.com/users/bordaigorl/following{/other_user}",gists_url:"https://api.github.com/users/bordaigorl/gists{/gist_id}",starred_url:"https://api.github.com/users/bordaigorl/starred{/owner}{/repo}",subscriptions_url:"https://api.github.com/users/bordaigorl/subscriptions",organizations_url:"https://api.github.com/users/bordaigorl/orgs",repos_url:"https://api.github.com/users/bordaigorl/repos",events_url:"https://api.github.com/users/bordaigorl/events{/privacy}",received_events_url:"https://api.github.com/users/bordaigorl/received_events",type:"User",site_admin:!1},version:"8ce17dec0626d9b673fb01864ff2fe6321f6f9c3",committed_at:"2017-10-28T16:13:53Z",change_status:{total:5,additions:2,deletions:3},url:"https://api.github.com/gists/6e54093b297c0f9df01d0c82f65b89f6/8ce17dec0626d9b673fb01864ff2fe6321f6f9c3"},{user:{login:"bordaigorl",id:2098241,avatar_url:"https://avatars3.githubusercontent.com/u/2098241?v=4",gravatar_id:"",url:"https://api.github.com/users/bordaigorl",html_url:"https://github.com/bordaigorl",followers_url:"https://api.github.com/users/bordaigorl/followers",following_url:"https://api.github.com/users/bordaigorl/following{/other_user}",gists_url:"https://api.github.com/users/bordaigorl/gists{/gist_id}",starred_url:"https://api.github.com/users/bordaigorl/starred{/owner}{/repo}",subscriptions_url:"https://api.github.com/users/bordaigorl/subscriptions",organizations_url:"https://api.github.com/users/bordaigorl/orgs",repos_url:"https://api.github.com/users/bordaigorl/repos",events_url:"https://api.github.com/users/bordaigorl/events{/privacy}",received_events_url:"https://api.github.com/users/bordaigorl/received_events",type:"User",site_admin:!1},version:"97f288001fba470715050ac323f8e7c34a0e3ed6",committed_at:"2017-10-14T19:22:38Z",change_status:{total:7,additions:5,deletions:2},url:"https://api.github.com/gists/6e54093b297c0f9df01d0c82f65b89f6/97f288001fba470715050ac323f8e7c34a0e3ed6"},{user:{login:"bordaigorl",id:2098241,avatar_url:"https://avatars3.githubusercontent.com/u/2098241?v=4",gravatar_id:"",url:"https://api.github.com/users/bordaigorl",html_url:"https://github.com/bordaigorl",followers_url:"https://api.github.com/users/bordaigorl/followers",following_url:"https://api.github.com/users/bordaigorl/following{/other_user}",gists_url:"https://api.github.com/users/bordaigorl/gists{/gist_id}",starred_url:"https://api.github.com/users/bordaigorl/starred{/owner}{/repo}",subscriptions_url:"https://api.github.com/users/bordaigorl/subscriptions",organizations_url:"https://api.github.com/users/bordaigorl/orgs",repos_url:"https://api.github.com/users/bordaigorl/repos",events_url:"https://api.github.com/users/bordaigorl/events{/privacy}",received_events_url:"https://api.github.com/users/bordaigorl/received_events",type:"User",site_admin:!1},version:"2673c0dccea00f4d62fdc60610bfa5795b9e1067",committed_at:"2017-02-26T21:26:22Z",change_status:{total:122,additions:122,deletions:0},url:"https://api.github.com/gists/6e54093b297c0f9df01d0c82f65b89f6/2673c0dccea00f4d62fdc60610bfa5795b9e1067"}],truncated:!1};"use strict";var NAME_REGEX=/^(.*)_(\d*)$/,sim;function parse_query_string(){var e={},t=window.location.search.split(/[?&]/);for(var s in t)if(""!=t[s]){var a=t[s].split("=");e[a[0]]=a[1]||!0}return e}function SimulationCtrl(e,t,s){if(!(this instanceof SimulationCtrl))return new SimulationCtrl(e,t,s);var a=0,r=1e3,o=50,i=$(e),n=this,l,c=0;function d(){return l&&clearInterval(l),l=setInterval(n.step,c),!0}function u(){p(n.DEFAULT_DELAY)}function p(e){return 0===arguments.length?c:((e=+e)<a&&(e=a),r<e&&(e=r),e!==c&&(c=e,l&&d()),$("#speed-val").text(Math.ceil(100*(1-(e-a)/(r-a)))+"%"),this)}function g(e){return 0===arguments.length&&(e=o),e<0?h(-e):!(r<c+e)&&(p(c+e),!0)}function h(e){return 0===arguments.length&&(e=o),e<0?g(-e):!(c-e<a)&&(p(c-e),!0)}n.DEFAULT_DELAY=500,n.main=i,n.speedControl=i.children("#speed-control"),n.toggleSimulation=i.children("#toggle-simulation"),n.playIcon=n.toggleSimulation.children("i"),n.redexBtn=i.children("#step-simulation"),n.slowerSpeed=i.find("#slower-speed"),n.fasterSpeed=i.find("#faster-speed"),n.resetSpeed=i.find("#speed-val").parent(),this.start=function(){d(),n.playIcon.removeClass("play").addClass("pause"),n.redexBtn.addClass("disabled")},this.stop=function(){l&&clearInterval(l),l=void 0,n.playIcon.removeClass("pause").addClass("play"),n.redexBtn.removeClass("disabled")},this.running=function(){return void 0!==l},this.step=function(){t()},this.stepDelay=p,this.increaseDelay=g,this.decreaseDelay=h,this.resetDelay=u,n.toggleSimulation.on("click",function(){$("#redex").sidebar("hide"),n.running()?n.stop():n.start()}),n.slowerSpeed.on("click",function(){n.increaseDelay()}),n.fasterSpeed.on("click",function(){n.decreaseDelay()}),n.resetSpeed.on("click",function(){n.resetDelay()})}$(function(){function n(e){e?(sim.layout().gravity(h.g).charge(h.c).start(),$("#gravity").state("activate")):(sim.layout().gravity(b.g).charge(b.c).start(),$("#gravity").state("deactivate"))}function l(){var e=d3.select("body").select("#legend").selectAll("div").data(sim.legend(),function(e){return e.name}),t=e.enter().append("div");t.classed("legend-item",!0),t.append("span").classed("legend-color",!0).attr("data-name",function(e){return e.name}).style("background-color",function(e){return e.color}),t.append("span").classed("legend-name",!0).text(function(e){return e.name}),e.exit().remove(),$("#current-config").text(sim.q.toPiCalc())}$("#suite").dropdown({direction:"upward"}),$("#share").dropdown({direction:"upward"}),$(".program-menu .dropdown").dropdown(),$(".message .close").click(function(){$(this).closest(".message").transition("fade")}),$("#gravity").state().click(function(e,t){return sim.layout().gravity()>=h.g?sim.layout().gravity(b.g).charge(b.c).start():sim.layout().gravity(h.g).charge(h.c).start(),!0}),$("#config-panel .item").tab();var s=new CP($("#legend").get(0),!1);$("#config-panel").click(function(e){var t=$(e.target);s.visible?s.exit():t.hasClass("legend-color")&&(s.source=t,s.set(t.css("background-color")),s.enter())}),s.on("enter",function(){var e=this.source.offset();this.self.style.top=e.top-$(this.self).outerHeight()-5+"px",this.self.style.left=e.left+"px"}),s.on("change",function(e){if(this.source.css){this.source.css("background-color","#"+e);var t={};t[this.source.attr("data-name")]="#"+e,sim.palette(t)}}),s.on("stop",function(e){l(),u()}),$("#show-labels").state().click(function(){m.classed("labels",!m.classed("labels"))}),$("#show-globals").state().click(function(){m.classed("globals",!m.classed("globals"))}),$("#search-bar").on("focusin",function(){$(this).width(200).addClass("focus")}).on("mouseenter",function(){$(this).width(200)}).on("mouseout",function(){$(this).width($(this).hasClass("focus")?200:100)}).on("focusout",function(){$(this).width(100).removeClass("focus error").find("input")}),$("#search-bar input").on("keyup",function(e){if($(this).parent().removeClass("error"),27==e.keyCode)this.blur();else{var t=$(this).val();if(0<t.length){var s=0;d3.selectAll("#graph #nodes .node.name").each(function(e){e.name==t||e.toPiCalc()==t?(s++,d3.select(this).classed("match",!0).classed("no-match",!1)):d3.select(this).classed("match",!1).classed("no-match",!0)}),d3.selectAll("#graph #nodes .node.seq").each(function(e){e.call.proc_name==t||e.call.toPiCalc()==t?(s++,d3.select(this).classed("match",!0).classed("no-match",!1)):d3.select(this).classed("match",!1).classed("no-match",!0)}),0==s&&$(this).parent().addClass("error")}else d3.selectAll("#graph #nodes .node").classed("match",!1).classed("no-match",!1)}}),$("#search-bar i.icon").click(function(){$("#search-bar input").val("").blur(),d3.selectAll("#graph #nodes .node").classed("match",!1).classed("no-match",!1)}),$("#collapse").state().click(function(e,t){var s=$("#search-bar input").val();if(0!=s.length)null!=sim.options.collapse?sim.options.collapse=void 0:sim.options.collapse=s,sim.layout().start();else{sim.options.collapse=void 0;var a=d3.select("#graph #links");"none"===a.style("display")?a.style("display","inline"):a.style("display","none")}}),$("#shock").click(function(e,t){sim.layout().alpha(sim.layout().gravity()>=h.g?1.2:1.5)}),$("#sourcecode").sidebar("setting",{dimPage:!1,closable:!1,transition:"overlay"}),$("#source").state().click(function(e){$("#sourcecode").sidebar("toggle")}),$("#redex").sidebar("setting",{dimPage:!1,closable:!1,transition:"overlay"});var t=$('<div class="header item">Reactions <i class="icon close"></i></div>'),o={};function c(){o={tau:m.select("#nodes").append("rect").classed("redex",!0).attr("width",sim.options.procWidth+4).attr("height",sim.options.procHeight+4),sender:m.select("#nodes").append("rect").classed("redex",!0).attr("width",sim.options.procWidth+4).attr("height",sim.options.procHeight+4),receiver:m.select("#nodes").append("rect").classed("redex",!0).attr("width",sim.options.procWidth+4).attr("height",sim.options.procHeight+4),channel:m.select("#nodes").append("circle").classed("redex",!0).attr("r",sim.options.nameSize+2)},i()}function i(){o.tau.style("display","none"),o.receiver.style("display","none"),o.sender.style("display","none"),o.channel.style("display","none"),sim.layout().resume()}function d(){var e=$("#redex");e.empty(),t.appendTo(e),t.find(".close").click(function(){e.sidebar("hide")})}function u(){var e=$("#redex"),s=sim.q.redexes(),a=sim.options.procWidth/2,r=sim.options.procHeight/2;for(var t in d(),e.off("click").click(function(e){var t=$(e.target).closest("a.item").attr("data");void 0!==t&&(t=parseInt(t),sim.q.makeReact(s[t]),i(),sim.update(),u(),l())}),e.off("mousemove").on("mousemove",function(e){var t;if(void 0!==(t=$(e.target).closest("a.item").attr("data"))){t=parseInt(t);var t=parseInt($(e.target).attr("data"));sim.layout().stop(),"tau"==s[t].type?o.tau.style("display","").attr("x",s[t].process.x-a-2).attr("y",s[t].process.y-r-2):(o.channel.style("display","").attr("cx",s[t].sender.action.channel.x).attr("cy",s[t].sender.action.channel.y),o.sender.style("display","").attr("x",s[t].sender.process.x-a-2).attr("y",s[t].sender.process.y-r-2),o.receiver.style("display","").attr("x",s[t].receiver.process.x-a-2).attr("y",s[t].receiver.process.y-r-2))}}),s)"tau"==s[t].type?$('<a class="item"></a>').html('<span class="proc-name">'+s[t].process.call.proc_name+'</span> <span class="punct">–</span> τ <span class="punct">→</span> ').prepend('<div class="ui empty circular label" style="background-color:'+s[t].process.color+'"></div>').attr("data",t).appendTo(e):$('<a class="item"></a>').html('<span class="proc-name">'+s[t].sender.process.call.proc_name+'</span> <span class="punct">–</span> '+s[t].sender.action.channel.toPiCalc().replace(NAME_REGEX,"$1<sub>$2</sub>")+(s[t].sender.action.port?'<span class="punct">@</span>'+s[t].sender.action.port:"")+' <span class="punct">→</span> <span class="proc-name">'+s[t].receiver.process.call.proc_name+"</span>").attr("data",t).prepend('<div class="ui empty circular label" style="background-color:'+s[t].sender.process.color+'"></div>').prepend('<div class="ui empty circular label" style="margin-left:-.3em;background-color:'+s[t].receiver.process.color+'"></div>').appendTo(e)}$("#redex").on("mouseout",i),$("#step-simulation").click(function(){var e=$("#redex");e.sidebar("is visible")?e.sidebar("hide"):(u(),e.sidebar("show"))});var p=0,e;function a(e){e&&sim.q.addCalls(e)&&sim.update()}function r(){clearTimeout(e),e=setTimeout(g,250)}function g(){$(m.node()).height(function(){return $(this).parent().innerHeight()}).width(function(){return $(this).parent().innerWidth()}).attr("width",function(){return $(this).width()}).attr("height",function(){return $(this).height()}),sim&&sim.translate([m.attr("width")/2,m.attr("height")/2])}$("#take-screenshot").click(function(){var e='<style type="text/css">\n .node {}\n .name {\n fill: #5B7A8C;\n stroke-width:1.2px;\n stroke: white;\n }\n #lbl{display:none;}\n .link {\n stroke: #999;\n stroke-width: 1.8pt;\n }\n </style>',t=$("svg#graph"),s=t.html(),a='<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" height="'+t.height()+'" width="'+t.width()+'">'+e+s+"</svg>",r="data:image/svg+xml;base64,"+btoa(a),o=$("#screenshot .menu");0==p&&o.prepend('<div class="divider"></div>'),o.prepend('<a class="item" href="'+r+'" download="stargazer-'+p+'.svg"><i class="file image-outline icon"></i>Screenshot '+p+"</a>"),p++}),$("#screenshot").dropdown({direction:"upward",action:"nothing"}),$("#addcalls").click(function(e){var t;a(prompt("Insert the calls:"))}),$("#help").click(function(e){$("#help-dialog").modal("show")}),$(window).resize(r);var h={g:.1,c:-400},b={g:1e-5,c:-30},m=d3.select("body").select("#graph"),f,v,w;function _(){d(),sim.next(sim.randomStrategy),l()}function y(e){suiteFromGist(e,C)}function C(e){$("#message-dialog").modal("hide");var t=decodeURIComponent(location.hash.slice(1))||(e?e.default:void 0);if(e&&e.successful&&t in e.programs){v=e;var s=$("#program-select").add("#suite .menu");for(var a in s.empty(),e.programs)$('<a class="item" href="#'+encodeURIComponent(a)+'">'+a+"</a>").appendTo(s);$("#suite").show(),"gist"===e.source&&e.url?(x(e.id,e.description),$("#suite .menu").append('<div class="divider"></div>').append('<a class="item" target="_blank" href="'+e.url+'"><i class="github icon"></i>Open Gist</a>')):suiteSize(e)<=1&&$("#suite").hide(),z(e.programs[t])}else e?!e.successful||t in e.programs?e.reason||(e.reason="<p>The suite could not be loaded. Check your connection and the provided url.</p>",e.reason+="<p>Please note that Stargazer has only been tested on Firefox and Chrome.</p>"):e.reason="<p>Program '"+t+"' unknown.</p><p>Try with "+Object.keys(e.programs).map(function(e){return'<a href="#'+e+'">'+e+"</a>"}).join(" or ")+".</p>":e={error:"undefined",reason:"The program suite is undefined."},$("#message-dialog").find(".header").text("Loading Error"),$("#message-dialog").find(".content").html(e.reason),$("#message-dialog").modal("setting","closable",!1).modal("show")}function x(e,t){var s=k();s[e]=t||"",localStorage.setItem("gist-history",JSON.stringify(s))}function k(){var t=localStorage.getItem("gist-history");if(!t)return{};try{return t=JSON.parse(t)}catch(e){t=t.split(",");var s={};for(var a in t)s[t[a]]="";return localStorage.setItem("gist-history",s),s}}function S(e){var t=[];for(var s in e)t.push({title:s,description:e[s]});return t}function z(e,t){$("#validate-code").hide(),"string"==typeof e&&(t=e,e=v.programs[w]),void 0===t&&(t=e.sourceCode),w=e.name,$("#code-editor").val(t),$("#program-name").val(e.name);var s=void 0;try{s=parsePi.compileAndCheck(t),e.sourceCode=t}catch(e){if(e.location){$("#validate-code .header").text("Syntax Error at line "+e.location.start.line),$("#validate-code p").text(e.message);var a=e.location.start.offset,r=e.location.end.offset,o=$("#code-editor")[0];o.focus(),void 0!==o.selectionStart?(o.selectionStart=a,o.selectionEnd=r):o.setSelectionRange&&o.setSelectionRange(a,r)}else $("#validate-code .header").text("Oooops, your code is not quite right!"),$("#validate-code p").text(e+". Make sure you normalised your code!");return $("#validate-code").removeClass("hidden").show(),void $("#sourcecode").sidebar("show")}m.selectAll("*").remove();var i=e.options.palette?{palette:e.options.palette}:void 0;(sim=PiCalcSimulation(m,s,i)).init(function(){$("#simulation .dimmer").removeClass("active")}),$("#initial-config").text(sim.q.toPiCalc()),l(),u(),c(),n(!1!==e.options.gravity),m.classed("labels",!0===e.options.showLabels),$("#show-labels").state(!0===e.options.showLabels?"activate":"deactivate"),m.classed("globals",!0===e.options.showGlobals),$("#show-globals").state(!0===e.options.showGlobals?"activate":"deactivate"),e.options.showCode&&($("#source").state(!0===e.options.showCode?"activate":"deactivate"),$("#sourcecode").sidebar(!0===e.options.showCode?"show":"hide")),g()}function T(e){location.hash=e}function j(e){(e=!1!==e)?$("#open-suite .cancel, #open-suite .dialog.close").show():$("#open-suite .cancel, #open-suite .dialog.close").hide();var t=S(k());$("#open-suite .from-gist.search").search({source:t}),$("#open-suite").modal("setting","closable",e).modal("show")}function A(e){void 0===e&&(e={});var t=e.name||"New program",s=e.sourceCode||"0",a=e.options;void 0===a&&(a={});var r={source:"new",successful:!0,programs:{},default:t};return r.programs[t]={sourceCode:s,name:t,options:a},r}new SimulationCtrl("#simulator-controls",_).resetDelay(),$(".program-menu .close").click(function(){$("#source").state().click()}),$("#open").click(function(){j()});var L="http://stargazer.emanueledosualdo.com";function N(e,t){return"gist"!==v.source||t?(void 0===e&&(e=w),L+"?program="+encodeURIComponent(v.programs[e].sourceCode)):L+"?gist="+v.id+(e?"#"+encodeURIComponent(e):"")}$("#share-prog").click(function(){$("#share-link-dialog .dropdown.button .menu").empty().append(Object.keys(v.programs).map(function(e){return'<div class="item'+(w==e?" current":"")+'"">'+e+"</div>"})),"gist"!==v.source||v.changed?$("#share-link-dialog .dropdown.button .menu .item.current").click():($("#share-link-dialog .dropdown.button .menu").prepend('<div class="item" data-all="1">All</div><div class="divider"></div>'),$("#share-link-dialog .dropdown.button .menu .item[data-all]").click());var e=$("#share-link-dialog input").val();$("#share-link-dialog .facebook.button").attr("href","https://www.facebook.com/sharer/sharer.php?u="+e),$("#share-link-dialog .twitter.button").attr("href","https://twitter.com/home?status="+e),$("#share-link-dialog").modal("show")}),$("#share-link-dialog .dropdown.button").dropdown({action:"activate",onChange:function(e,t,s){$("#share-link-dialog input").val(N(s.attr("data-all")?void 0:t,"1"!==s.attr("data-all"))).select().focus()}}),$("#save-gist").click(function(e){$("#new-gist-dialog input").val(""),$("#new-gist-dialog .dimmer").addClass("active"),$("#new-gist-dialog .input").removeClass("error"),$("#new-gist-dialog .actions a.button").hide(),$("#new-gist-dialog").modal("show"),createGistFromSuite(v,function(e){$("#new-gist-dialog .dimmer").removeClass("active"),$("#new-gist-dialog .actions a.button").show(),$("#new-gist-dialog .actions a.open").attr("href",e.html_url),$("#new-gist-dialog .actions a.load").attr("href","?gist="+e.id),$("#new-gist-dialog input").val(e.html_url),x(e.id,e.description)},function(){$("#new-gist-dialog .dimmer").removeClass("active"),$("#new-gist-dialog .input").addClass("error"),$("#new-gist-dialog input").val("Creation of Gist failed, try again.")})}),$("#reload-code").click(function(){v.changed=!0,z($("#code-editor").val())}),$("#program-name").on("change",function(){var e=$("#program-name").val();return e===w||(e in v.programs?($("#program-name").val(w),!1):(v.programs[e]=v.programs[w],delete v.programs[w],v.programs[e].name=e,v.default===w&&(v.default=e),void T(w=e)))}),$(".program-menu .new").click(function(e){for(var t="New program",s=0;t in v.programs;)t="New program"+ ++s;v.programs[t]={sourceCode:"0",name:t,options:{gravity:sim.layout().gravity()>=h.g,showLabels:m.classed("labels"),showGlobals:m.classed("globals")}},v.changed=!0,T(t),$("#program-name").focus().select()}),$(".program-menu .del").click(function(e){if(1<suiteSize(v)){delete v.programs[w];var t=Object.keys(v.programs)[0];v.default===w&&(v.default=t),v.changed=!0,T(Object.keys(v.programs)[0])}else alert("You cannot delete the only program in a suite.")}),$("#open-suite .from-gist .button").click(function(){$("#open-suite").modal("hide");var e=$("#open-suite .from-gist input").val();location="?gist="+encodeURIComponent(e)}),$("#open-suite .from-gist .button").click(function(){$("#open-suite").modal("hide");var e=$("#open-suite .from-gist input").val(),t=e.match(gistUrlPattern);t&&($("#open-suite .from-gist .input").val(t[2]),e=t[2]),location="?gist="+encodeURIComponent(e)}),window.File&&window.FileReader?($("#open-suite .from-file .message").hide(),$("#open-suite .from-file .input").show()):($("#open-suite .from-file .message").show(),$("#open-suite .from-file .input").hide()),$("#open-suite .from-file .button").click(function(){var e=$("#open-suite .from-file input")[0].files;if(0!==e.length){e=e[0];var t=new FileReader,s;t.onload=function(e){try{s=JSON.parse(e.target.result)}catch(e){return void alert("This does not seem to be a valid Stargaze suite file")}C(s),$("#open-suite").modal("hide")};try{t.readAsText(e)}catch(e){alert("This does not seem to be a valid Stargaze suite file")}}else $("#open-suite .from-file input").click()}),$("#save").click(function(){var e=JSON.stringify(v);$("#save").attr("href","data:application/json;base64,"+btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function e(t,s){return String.fromCharCode("0x"+s)})))}),$(window).on("hashchange",function(){v&&C(v)});var q=parse_query_string();if(q.demo||q.experimental?$(".experimental.button").show():$(".experimental.button").hide(),q.gist)y(decodeURIComponent(q.gist));else if(q.demo)y(demo_gist);else{var M=location.hash.slice(1),R=void 0,E;q.program?R=decodeURIComponent(q.program.replace(/\+/g,"%20")).replace(/\r\n/g,"\n"):q.showCode=!0,C(A({name:M,sourceCode:R,options:{showCode:"0"!==q.showCode,gravity:"0"!==q.gravity,showLabels:"1"===q.showLabels,showGlobals:"1"===q.showGlobals}})),q.program||q.new||j(!1)}});