Disqus Universal Code is not working with new disqus_identifier - javascript

This code displays the comments when the thread disqus_identifier is pointing to returns comments, but when it's a thread with zero comments, I get an error message that reads "We were unable to load Disqus. If you are a moderator please see our troubleshooting guide."
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'my_short_name'; // required: replace example with your forum shortname
var disqus_identifier = 'random';
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
There has to be some way to create an empty thread. Thanks in advance.

Look like your site is inaccessible, you can use Disqus JavaScript configuration variables
var disqus_developer = 1; // developer mode is on
This tells the Disqus service that you are testing the system on an inaccessible website, e.g. secured staging server or a local environment
http://help.disqus.com/customer/portal/articles/472098-javascript-configuration-variables
Also verify your disqus_shortname variable

Related

Geoplugin SSL - Country undefined error

I am trying to disable my live chat from displaying by blocking countries India and Pakistan.
I used the tool from http://www.geoplugin.com and it worked great. However - I was using the typical http javascript. I just bought the SSL version from them so that there wouldn't be a conflict with my current website which uses HTTPS and the new javascript.
However - now that I use it - I get the error message
Uncaught ReferenceError: geoplugin_countryCode is not defined
My website is https://www.blueskychat.com
The code is as follows:
<script language="JavaScript" src="https://ssl.geoplugin.net/json.gp?k=..." type="text/javascript"></script>
<script type="text/javascript">
var countryCode = geoplugin_countryCode();
if (countryCode != 'IN' && countryCode != 'PK') {
window.__lc = window.__lc || {};
window.__lc.license = 8653536;
window.__lc.chat_between_groups = false;
window.__lc.ga_version = "ga";
(function() {
var lc = document.createElement('script');
lc.type = 'text/javascript';
lc.async = true;
lc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.livechatinc.com/tracking.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(lc, s);
})();
}
</script>
Any ideas as to what is the problem and how to resolve?
Thanks!!
You're loading json response, but attempting to use javascript method.
Just replace json.gp with javascript.gp in your src attribute of loading script and it will work.

Google login / Third party authentication provider

I'm developing an angularjs app where Google login is one of it's features.
I'm using this link to implement the feature
https://blog.codecentric.de/en/2014/06/angularjs-google-sign-integration/.
Here is also the script called when the page is loaded
`
<script type="text/javascript">
(function () {
var p = document.createElement('script');
p.type = 'text/javascript';
p.async = true;
p.src = 'https://apis.google.com/js/platform.js?onload=onLoadCallback';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(p, s);
})();
</script>
`
Is this the right way and how I can fetch data from google and show the data to the user and if he is happy to press sign up and then to be signed. I already have my app created into the google api service and tried many options but no success so far.
Thanks in advice.
Well this has a problem you would be login in directly with out being clicked so that might be a problem in future
Try something like this
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/client.js?onload=onLoadCallback';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
In the view
function login()
{
var myParams = {
'clientid' : 'YOUR_CLIENT_ID.apps.googleusercontent.com', //You need to set client id
'cookiepolicy' : 'single_host_origin',
'callback' : 'loginCallback', //callback function
'approvalprompt':'force',
'scope' : 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.profile.emails.read'
};
gapi.auth.signIn(myParams);
}
Convert this codes to Angular .
Please see this question for details

Client server javascript communication

I want to create 2 scripts, 1 for client 1 for server side.
I found snippet which allows call asyncrhonously js
<html>
<head>
</head>
<body>
<script>
(function() {
var projectId = "script";
var protocol = ('https:' == document.location.protocol ?
'https://' : 'http://');
var scriptTag = document.createElement('script');
scriptTag.type = 'text/javascript';
scriptTag.async = true;
scriptTag.src = protocol + 'localhost/wp/' +
projectId + '.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(scriptTag, s);
})();
function optimizelyTimeout() {
window.optimizely = window.optimizely|| [];
if (!window.optimizely.data) {
window.optimizely.push("timeout");
}
}
setTimeout(optimizelyTimeout, 1000);
</script>
</body>
</html>
This produces below code:
<script type="text/javascript" async="" src="http://localhost/wp/script.js"></script>
Now I would like script.js to return some custom js code which will be injected into original webpage. I tried with:
-return("code");
-response.write("code");
but non of that worked for me.
How script.js should look like in order to return some custom js code to be executed on client side?
How can I pass arguments from client to server side call?
How script.js should look like in order to return some custom js code
to be executed on client side?
if the javascript code returned by script tag has to be invoked immediately then you need to return a self invoking function
(function(){
/* code that you want to invoke immediately after the script has been loaded*/
})(this);
How can I pass arguments from client to server side call?
just push the parameters in the script src itself
scriptTag.src = protocol + 'localhost/wp/' + projectId + '.js?param1=value';
and intercept the same on your server side

Can I use location.href to generate the url for a variable?

I'm adding disqus to my website and I was wondering if there's a way to use the page's url to fill in the variable for disqus_url
I know that window.location.href will find the url, I just don't know how to use that inside of a function.
This is what I've tried:
<script type="text/javascript">
(function() {
var disqus_url = window.location.href;
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
Yes, you can. However, window.location.href is the default, so you really don't need to provide it.
Note that this will most likely treat http://example.com/helloworld.html and http://example.com/helloworld.html?123 as two different threads.
See https://help.disqus.com/customer/portal/articles/472098-javascript-configuration-variables#disqus_url

PHP Displaying an embed before a certain date only

I am trying to display a Disqus commenting embed on a website, but I only want it to display the embed if it's before 2nd February 2014 UK time.
EDIT: For clarity, It should always display the embed before the 2nd Feb 2014 on any date but never after.
The PHP code I have is:
<?php if (time() <= strtotime('2014-02-02 00:00:00')) { ?>
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = 'mysite'; // required: replace example with your forum shortname
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the comments powered by Disqus.</noscript>
comments powered by <span class="logo-disqus">Disqus</span>
<?php } else {
//do something else
}?>
However, it doesn't seem to be displaying on posts. I have replaced 'my site'. This is just for an example.

Categories

Resources