Where is the ejs download for browser support? - ejs

I followed the instructions and downloaded the build linked their. After expanding the download I used lib/ejs.js which leads to "ReferenceError: require is not defined" errors. So, that's a node.js build not a browser build (?). Can't locate any browser build nor Google helps. So probably I'm complete off, but anyway, could someone enlighten me? Thanks.

From the get started section on the docs under Browser support:
let people = ["geddy", "neil", "alex"];
let html = ejs.render('<%= people.join(", "); %>', { people: people });
document.getElementById("root").insertAdjacentHTML("afterend", html);
<script src="https://github.com/mde/ejs/releases/download/v3.0.2/ejs.min.js"></script>
<div id="root"></div>
codepen

Related

How to resolve Facebook Instant Games uploading.zip file error

I have uploaded my .zip file of my game to Facebook Instant Games when an error pop up. It says "Game must reference to one of our supported SDKs via CDN."
I already put the script tag in head and body
<script src="https://connect.facebook.com/en_US/fbinstant.7.0.js"></script>
and my fbapp-config.json
{
"instant_games": {
"platform_version": "RICH_GAMEPLAY",
"orientation": "PORTRAIT",
"navigation_menu_version": "NAV_BAR"
}
}
I also tried the CLI method in uploading the .zip file, but also gets the same error saying I must refer to their SDK via CDN.
Can anyone please guide me.
Can you try this script tag instead?
<script src="https://connect.facebook.net/en_US/fbinstant.latest.js"></script>
This worked for me when I just tried uploading a .zip file now.
Try to change the SDK URL to the following:
https://www.facebook.com/assets.php/en_US/fbinstant.latest.js
This works for me.
I found it in a sample file, I have just downloaded from facebook.
I hope it helps!

IBM's Watson Assistant has stopped responding

Just over a year ago I created a chatbot using IBM Watson Assistant. It is successfully interfacing with wordpress and facebook. it was working perfectly well in a web page too, but has now stopped outputting any text. I created the website integration by copying the code shown in the "preview link" page created by IBM when the bot is under development. That code includes a library file called "chat.0.0.4.js" and corresponding css. When the code runs now, the chatbot renders correctly, but when I look at the browser console I see at line 12990 in chat.0.0.4.js:
400 - {"error":"Invalid Request Body","errors":[{"message":"When source.type is not 'watson', source.id is required
Does anyone know how to fix this? I see that the integration code from the "preview link" is now totally different and I wonder if the mechanism I used a year ago is now depreciated?
Thanks.
I think you need to use the newer version, the script to integrate WA has changed and now looks like this:
<script>
window.watsonAssistantChatOptions = {
integrationID: 'YOUR_INTEGRATION_ID',
region: 'YOUR_REGION',
serviceInstanceID: 'YOUR_SERVICE_INSTANCE',
onLoad: function(instance) {
instance.updateUserID(L12345);
instance.render();
}
};
setTimeout(function(){
const t=document.createElement('script');
t.src="https://web-chat.global.assistant.watson.appdomain.cloud/loadWatsonAssistantChat.js";
document.head.appendChild(t);
});
</script>

Soundcloud track /download slug no longer working

Soundcloud has feature that allows any track to auto download if you add "/download" to the end of the track URL.
We have made use of that feature for many years on our soundcloud hosted podcast:
http://techzinglive.com
http://soundcloud.com/techzing
As of a few days ago the feature seems to have stopped working.
Now that we have 300 episodes it would be quite difficult to go back and retrospectively change the URLs by copy pasting the download link for each episode.
a) Is there any way Soundcloud could fix this?
b) Is there an alternative that does the same thing?
Example:
168: TZ Interview - Patrick Collison / Stripe
~~~
http://soundcloud.com/techzing/techzing-168 (regular link)
http://soundcloud.com/techzing/techzing-168/download (auto download link)
Note: I posted this here as directed by the soundcloud support page.
Well the answer to the question is that SoundCloud no longer support the download slug option. But you can get it to work using their API.
Backend (PHP)
<?php
$yourSoundCloudClientId = '<CLIENTID>';
$yourSoundCloudTrackUrl = 'http://soundcloud.com/techzing/techzing-001';
if ( ! $trackData = json_decode(file_get_contents("http://api.soundcloud.com/resolve?url={$yourSoundCloudTrackUrl}&client_id={$yourSoundCloudClientId}")) )
{
die('Could not get the track because Soundcloud is down, or somethign else weird is happening.');
}
header("Location: {$trackData->download_url}?client_id={$yourSoundCloudClientId}");
?>
Frontend (JS)
<head>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://connect.soundcloud.com/sdk/sdk-3.0.0.js"></script>
<script>
var yourSoundCloudClientId = '<CLIENTID>';
var yourSoundCloudTrackUrl = 'http://soundcloud.com/techzing/techzing-001';
SC.initialize
({
client_id: yourSoundCloudClientId
});
SC.get('/resolve?url='+yourSoundCloudTrackUrl).then
(
function(track)
{
$('#trackDiv').html('<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/'+track.id+'&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true"></iframe>');
}
);
</script>
</head>
<body>
<div id="trackDiv"></div>
</body>
Forgive the malformed HTML... but, you know, it works ;)

Redirecting index.html to an iOS setting (URL in Settings.bundle) for a phonegap project

I am new to phonegap and iPhone development, and am trying to get phonegap's index.html to redirect to a JQuery Mobile site that is located externally at a settings based URL which I have in my Settings.bundle, Root.plist, Server URL. I have my index.html page redirecting to a hard coded server in the index.html file, but how do I get it to go to the URL that I have in my application settings?
Thanks in advance for any help in steering me in the right direction
I've been trying to get the plugin applicationPreferences working to essentially do something similar. Currently to no avail. As soon as I come up with a solution I will post something here again.
UPDATE
This does work it seems. There is a small, nearly unnoticeable error in the readme example.
There needs to be a comma after the 'homer'.
¬
window.plugins.applicationPreferences.set('name_identifier','homer', function() {
alert("It is saved");
}, function(error) {
alert("Failed to retrieve a setting: " + error);
}
);

Connect to Facebook with Javascript Client Library using Adobe AIR

I'm having an issue connecting to Facebook through the Javascript Client Library in Adobe AIR. It works fine in the browser but in Adobe AIR it seems to not be able to find the Facebook functions. Here is some code I copied from the Facebook website: (Oh and I have the xd_receiver.htm file in the correct path too)
<textarea style="width: 1000px; height: 300px;" id="_traceTextBox">
</textarea>
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
//
var api = FB.Facebook.apiClient;
// require user to login
api.requireLogin(function(exception){
FB.FBDebug.logLevel=1;
FB.FBDebug.dump("Current user id is " + api.get_session().uid);
// Get friends list
//5-14-09: this code below is broken, correct code follows
//api.friends_get(null, function(result){
// Debug.dump(result, 'friendsResult from non-batch execution ');
// });
api.friends_get(new Array(), function(result, exception){
FB.FBDebug.dump(result, 'friendsResult from non-batch execution ');
});
});
});
//]]>
</script>
It's not that simple actually man, the problem with loading external script files from the application sandbox is that it's not supported. Technically, by using iframes, you should be able to do this and it works but it's still impossible to use XFBML in the root document after from my experience. After two days of trial and error, the easiest way to do use Facebook Connect in an html/ajax adobe air application is to download the actionscript library and include it as such:
<script type="application/x-shockwave-flash" src="lib/facebook.swf"></script>
<script type="text/javascript">
var FB = window.runtime.com.facebook;
var fb = new FB.Facebook();
var session = new FB.utils.DesktopSessionHelper();
//etc...
</script>
then just refer to the documentation. my only problem now it that I still haven't found an efficient enough way of using XFBML in adobe air, simply adding the facebook namespace to the html tag doesn't do the trick unfortunately. If any knows, please do share thanks
you also need to change xml namespace (main html tag) to this:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en-gb" lang="en-gb">