Skip to content
Permalink
Browse files

fix demo mode

access like this: pol.is/demo/2arcefpshi
or if embedding, add data-demo=true
  • Loading branch information...
mbjorkegren committed Feb 21, 2018
1 parent bf2d1e0 commit 4bc240dfaa8b873e52f858379d97d20dd6c75300
Showing with 30 additions and 33 deletions.
  1. +11 −10 api/embed.js
  2. +12 −10 api/embedPreprod.js
  3. +7 −13 js/stores/polis.js
@@ -90,12 +90,19 @@
function createPolisIframe(parent, o) {
var iframe = document.createElement("iframe");
var path = [];
if (o.demo) {
path.push("demo");
}
o.parent_url = o.parent_url || window.location+"";
var id = "polis_";
var paramStrings = [];

function appendIfPresent(name) {
if (o[name] !== null && o[name] !== void 0) {
paramStrings.push(name + "=" + encodeURIComponent(o[name]));
}
}
if (o.conversation_id) {
if (o.demo) {
path.push("demo");
}
path.push(o.conversation_id);
id += o.conversation_id;
} else if (o.site_id) {
@@ -107,18 +114,12 @@
}
path.push(o.page_id);
id += "_" + o.page_id;
appendIfPresent("demo");
} else {
alert("Error: need data-conversation_id or data-site_id");
return;
}
var src = polisUrl+ "/" + path.join("/");
var paramStrings = [];

function appendIfPresent(name) {
if (o[name] !== null && o[name] !== void 0) {
paramStrings.push(name + "=" + encodeURIComponent(o[name]));
}
}

appendIfPresent("parent_url");
if (o.parent_url) {
@@ -90,12 +90,20 @@
function createPolisIframe(parent, o) {
var iframe = document.createElement("iframe");
var path = [];
if (o.demo) {
path.push("demo");
}
o.parent_url = o.parent_url || window.location+"";
var id = "polis_";
var paramStrings = [];

function appendIfPresent(name) {
if (o[name] !== null && o[name] !== void 0) {
paramStrings.push(name + "=" + encodeURIComponent(o[name]));
}
}

if (o.conversation_id) {
if (o.demo) {
path.push("demo");
}
path.push(o.conversation_id);
id += o.conversation_id;
} else if (o.site_id) {
@@ -107,18 +115,12 @@
}
path.push(o.page_id);
id += "_" + o.page_id;
appendIfPresent("demo");
} else {
alert("Error: need data-conversation_id or data-site_id");
return;
}
var src = polisUrl+ "/" + path.join("/");
var paramStrings = [];

function appendIfPresent(name) {
if (o[name] !== null && o[name] !== void 0) {
paramStrings.push(name + "=" + encodeURIComponent(o[name]));
}
}

appendIfPresent("parent_url");
if (o.parent_url) {
@@ -89,7 +89,7 @@ module.exports = function(params) {

// collections
var votesByMe = params.votesByMe;
if (demoMode()) {
if (Utils.isDemoMode()) {
votesByMe.trigger("change", votesByMe);
}

@@ -127,10 +127,6 @@ module.exports = function(params) {
var usePreloadMath = true;
var usePreloadFamous = true;

function demoMode() {
return getPid() < 0;
}

function removeEmptyBucketsFromClusters(clusters) {
var buckets = projectionPeopleCache;
for (var i = 0; i < buckets.length; i++) {
@@ -274,8 +270,7 @@ module.exports = function(params) {
params.lang = Utils.uiLanguage();
}

if (demoMode()) {
// DEMO_MODE
if (Utils.isDemoMode()) {
params.without = votesByMe.pluck("tid");
}

@@ -316,7 +311,7 @@ module.exports = function(params) {
function submitComment(model) {


if (demoMode()) {
if (Utils.isDemoMode()) {
return $.Deferred().resolve();
}

@@ -376,7 +371,7 @@ module.exports = function(params) {
console.error("missing tid");
console.error(params);
}
if (demoMode()) {
if (Utils.isDemoMode()) {
return getNextComment({
notTid: params.tid // Also don't show the comment that was just voted on.
}).then(function(c) {
@@ -447,7 +442,7 @@ module.exports = function(params) {
function trash(tid) {
clearComment(tid, "trash");

if (demoMode()) {
if (Utils.isDemoMode()) {
return $.Deferred().resolve();
}

@@ -471,8 +466,7 @@ module.exports = function(params) {
console.error(params);
}

// DEMO_MODE
if (getPid() < 0) {
if (Utils.isDemoMode()) {
return $.Deferred().resolve();
}

@@ -1544,7 +1538,7 @@ module.exports = function(params) {
people = people || [];
people = _.clone(people); // shallow copy

// if(demoMode()) {
// if(Utils.isDemoMode()) {
// participantsOfInterestVotes[myPid] = {
// bid: -1,
// // created: "1416276055476"

0 comments on commit 4bc240d

Please sign in to comment.
You can’t perform that action at this time.