Skip to content

Commit 952f0e3

Browse files
author
raul
committed
added facebook support (comments, like button)
also added new questions
1 parent 2f24ce4 commit 952f0e3

File tree

4 files changed

+236
-158
lines changed

4 files changed

+236
-158
lines changed

BeliefExplorer.html

Lines changed: 0 additions & 158 deletions
This file was deleted.

BeliefExplorer.php

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1"/>
6+
<meta property="og:type" content="article" />
7+
<meta property="og:image" content="https://semap.duckdns.org/BeliefExplorer_200x200.png" />
8+
<meta property="og:description" content="Explore your belief here" />
9+
<meta property="fb:app_id" content="106897846035392"/>
10+
<meta property="og:title" content="<?php
11+
12+
//<meta property="og:url" content="https://semap.duckdns.org/BeliefExplorer.php"/>
13+
14+
// Create connection
15+
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
16+
if ($lang=="es")
17+
$conn = new SQLite3("SEMap_es.sqlite");
18+
else
19+
$conn = new SQLite3("SEMap_en.sqlite");
20+
21+
$results = $conn->query("SELECT * FROM NODES where id='".$_GET['q']."';");
22+
$row = $results->fetchArray(1);
23+
if ($row["label"]=="No question")
24+
{
25+
$results = $conn->query("SELECT * FROM EDGES where target='".$row["id"]."';");
26+
$row = $results->fetchArray(1);
27+
//echo $row["source"];
28+
29+
$results = $conn->query("SELECT label FROM NODES where id='".$row["source"]."';");
30+
$row = $results->fetchArray(1);
31+
32+
}
33+
echo $row["label"];
34+
$conn->close();
35+
?>" />
36+
<title>Belief Explorer</title>
37+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
38+
<link rel="stylesheet" href="https://gitcdn.link/repo/Chalarangelo/mini.css/master/dist/mini-default.min.css">
39+
<!-- Global site tag (gtag.js) - Google Analytics -->
40+
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-3425939-8"></script>
41+
<script>
42+
43+
function gtag(){dataLayer.push(arguments);}
44+
45+
var Database = {};
46+
var locationNoVars = "";
47+
var variables = {}
48+
49+
function ProcessWithPush(sectionName, itemChosen)
50+
{
51+
history.pushState(sectionName, "", locationNoVars + "?q="+sectionName);
52+
Process(sectionName, itemChosen)
53+
}
54+
55+
function ShowDialog(sectionName)
56+
{
57+
//find answer that lead to this question
58+
for(var q in Database)
59+
{
60+
var entry = Database[q];
61+
var answers = entry.answers;
62+
for(var a in answers)
63+
{
64+
if (answers[a]==sectionName)
65+
{
66+
$("#cardTitle").html("<br/><b>OPPSS!! We don't have a good question for this claim, could you recommend a good one? Please let us know in the comment's section.</b><br/>");
67+
$("#question").html(" - " + entry.question);
68+
$("#answers").html(" - " + a);
69+
break;
70+
}
71+
}
72+
}
73+
}
74+
75+
var firstTime = true;
76+
77+
function Process(sectionName, itemChosen)
78+
{
79+
gtag('event', 'page', {'id':sectionName});
80+
81+
variables[sectionName] = itemChosen;
82+
var item = Database[sectionName];
83+
84+
var comments = $("#comments");
85+
if (firstTime)
86+
{
87+
$("#comments").html("<div class='fb-comments' data-href='"+window.location.href+"' width='450' data-numposts='5'></div>");
88+
firstTime = false;
89+
}
90+
else
91+
{
92+
$("#comments").html("<div class='fb-comments' data-href='"+window.location.href+"' width='450' data-numposts='5'></div>");
93+
FB.XFBML.parse($("#comments")[0]);
94+
}
95+
96+
97+
if (item.question =="No question")
98+
{
99+
ShowDialog(sectionName)
100+
return;
101+
}
102+
103+
$("cardTitle").html("");
104+
var question = item.question.replace(/\n/g, "<br/>");
105+
$("#question").html(question);
106+
var a="<ul>";
107+
for(var key in item.answers)
108+
{
109+
var res = "";
110+
var match = key.match(/\$(.*)\$/);
111+
if (match!=null && match.length==2)
112+
res = match[1]
113+
114+
var answer = key.replace(/(\$)/g,"");
115+
var nextSectionName = item.answers[key];
116+
117+
var onClick = 'ProcessWithPush("'+nextSectionName+'", "'+res+'");return false;';
118+
119+
a+="<li>";
120+
if (Database[nextSectionName]!=undefined)
121+
a+="<a href=''onclick='"+onClick+"'>"+answer+"</a>";
122+
else
123+
a+="<div>"+answer+"</div>";
124+
a+="</li>";
125+
}
126+
a+="</ul>";
127+
$("#answers").html(a)
128+
}
129+
130+
window.onpopstate = function(event)
131+
{
132+
if (event.state!==null)
133+
Process(event.state, "");
134+
};
135+
136+
$(document).ready(function()
137+
{
138+
window.dataLayer = window.dataLayer || [];
139+
gtag('js', new Date());
140+
gtag('config', 'UA-3425939-8');
141+
142+
$.ajax({
143+
type: "GET",
144+
url: "./SEMapDatabase.php",
145+
dataType: "json",
146+
success: function(data)
147+
{
148+
if (data.res!="OK")
149+
{
150+
alert(data.res);
151+
}
152+
else
153+
{
154+
Database = {}
155+
156+
var nodes = data["nodes"];
157+
for(var node in nodes)
158+
{
159+
var n = nodes[node];
160+
Database[n["id"]]={question:n["q"], answers:{}};
161+
}
162+
163+
var edges = data["edges"];
164+
for(var edge in edges)
165+
{
166+
var e = edges[edge];
167+
if (Database[e["s"]]!==undefined)
168+
Database[e["s"]].answers[e["l"]] = e["t"];
169+
}
170+
171+
var startingPoint = "0244388211625568";
172+
173+
splitUrl = window.location.href.split("?");
174+
locationNoVars = splitUrl[0]
175+
if (splitUrl.length==2)
176+
{
177+
startingPoint = splitUrl[1].split("=")[1];
178+
}
179+
180+
history.replaceState(startingPoint, "", locationNoVars + "?q="+startingPoint);
181+
182+
Process(startingPoint, "");
183+
}
184+
}
185+
});
186+
})
187+
188+
</script>
189+
</head>
190+
<body>
191+
<div id="fb-root"></div>
192+
<script>(function(d, s, id) {
193+
var js, fjs = d.getElementsByTagName(s)[0];
194+
if (d.getElementById(id)) return;
195+
js = d.createElement(s); js.id = id;
196+
js.src = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.11&appId=106897846035392';
197+
fjs.parentNode.insertBefore(js, fjs);
198+
}(document, 'script', 'facebook-jssdk'));</script>
199+
200+
<header class="sticky">
201+
<img src="BeliefExplorer_200x200.png" style="max-height: 100%;max-width: 100%;position: relative;padding-top: 0;margin-top: 0;" alt="thinker logo" class="button">
202+
<a href="https://semap.duckdns.org/BeliefExplorer.php" class="logo">&nbsp;Belief Explorer</a>
203+
<div class="fb-like" data-href="https://semap.duckdns.org/BeliefExplorer.php" data-layout="button_count" data-action="like" data-size="large" data-show-faces="false" data-share="false" ></div> </header>
204+
<div class="container">
205+
<div class="row">
206+
<div class="col-lg-6 col-lg-offset-3 col-md-6 col-md-offset-3 col-sm-12">
207+
<div style='text-align: center;' id="cardTitle"></div>
208+
<br>
209+
<form>
210+
<fieldset>
211+
<div id="question"></div>
212+
<br>
213+
<div class="input-group" id="answers"></div>
214+
</fieldset>
215+
</form>
216+
</div>
217+
</div>
218+
</div>
219+
<br>
220+
<br>
221+
<div class="container">
222+
<div class="row">
223+
<div class="col-lg-6 col-lg-offset-3 col-md-6 col-md-offset-3 col-sm-12">
224+
<div style='text-align: center;' >Enjoy the comment section, please keep it constructive!</div>
225+
</div>
226+
<div style='text-align: center;' class="col-lg-12 col-md-12 col-sm-12" id="comments">
227+
</div>
228+
</div>
229+
</div>
230+
231+
<footer>
232+
<p>MIT License | <a href="#">About</a> | <a href="https://github.com/aguaviva/SEMap">Github code</a> | <a href="PrivacyPolicy.html">Privacy</a></p>
233+
</footer>
234+
</body>
235+
</html>
236+

BeliefExplorer_200x200.png

66.3 KB
Loading

SEMap_en.sqlite

8 KB
Binary file not shown.

0 commit comments

Comments
 (0)