User:Ftwm/JTSetc: Difference between revisions

m
(Created page with "==Pusher.com Channels client== ====HTM==== <code> <!DOCTYPE html><html><head> <title>Pusher Test</title> <script src="https://js.pusher.com/8.2.0/pusher.min.js"></script> <script src="./privtest.js"></script> <style> code { color: blue; } </style> </head><body> <h1>Pusher.com 'Channels' product test</h1> <p> <label for="ak_">Access Key</label> <input type="text" id="ak" name="ak_" onchange="tryNewAppKey(this.value)" > </p> <p>...")
 
 
(3 intermediate revisions by the same user not shown)
Line 1:
==Pusher.com Channels client==
 
https://gitlab.com/Markworthy/nodejs-express_baublegum0v1/-/raw/master/public/src/privtest.js
====HTM====
 
====HTMHTML====
<code>
 
<pre><nowiki>
<!DOCTYPE html><html><head>
 
<&lt;!DOCTYPE html><&gt;&lt;html><&gt;&lt;head>&gt;
<title>Pusher Test</title>
&lt;!--
<script src="https://js.pusher.com/8.2.0/pusher.min.js"></script>
https://nodejs-express-baublegum0v1a.onrender.com/baubles_
<script src="./privtest.js"></script>
https://www.textcompare.org/
--&gt;
 
<&lt;title>&gt;Pusher Test<&lt;/title>&gt;
<&lt;style>&gt; code { color: blue; } <&lt;/style>&gt;
<&lt;script src="https://js.pusher.com/8.2.0/pusher.min.js"><&gt;&lt;/script>&gt;
&lt;script src="https://gl.githack.com/Markworthy/nodejs-express_baublegum0v1/-/raw/master/public/src/privtest.js"&gt;&lt;/script&gt;
 
&lt;!--
</head><body>
<&lt;script src="./privtest.js"><&gt;&lt;/script>&gt;
&lt;script src="./privtest.js" type="module"&gt;&lt;/script&gt;
&lt;script src="https://raw.githack.com/Markworthy-37260/Next-JS_Pusher-com_Channels-server/main/public/JSBI_etc.js" type="module"&gt;&lt;/script&gt;
--&gt;
&lt;/head&gt;&lt;body&gt;
<&lt;h1>&gt;Pusher.com 'Channels' product test<&lt;/h1>&gt;
<&lt;p>&gt; <&lt;label for="ak_">&gt;Access Key<&lt;/label>&gt;
<&lt;input type="text" id="ak" name="ak_"
onchange="tryNewAppKey(this.value)" >&gt; <&lt;/p>&gt;
&lt;p&gt; &lt;label for="ck_"&gt;Option(s)&lt;/label&gt;
<p>
&lt;input type="textarea" id="ck" name="ck_"
Test by triggering an event on channel '<code>main-channel</code>'
onchange="tryNewCfgStr(this.value)" &gt; &lt;/p&gt;
with event name '<code>dumb-event</code>' - for example by:-<br />
&lt;!-- OUT: requires node (ATM)
(i) creating an account<br />
&lt;p&gt; &lt;label for="sk_"&gt;Secret Key&lt;/label&gt;
(ii) downloading the pusher CLI<br />
&lt;input type="text" id="sk" name="sk_"&gt; &lt;/p&gt;
(iii) logging in with your API key:<br />
---&gt;
"<code>pusher login</code>"<br />
&lt;p&gt;
(iv) triggering a dumb-event on the main-channel:<br />
Test by triggering an event on channel '<&lt;code>&gt;main-channel<&lt;/code>&gt;'
"<code>pusher channels apps trigger --app-id 1736956 --channel
main-channelwith --event name '&lt;code&gt;dumb-event&lt;/code&gt;' --message hellofor example by:-world</code>"<&lt;br />&gt;
(i) creating <an account&lt;br />&gt;
(ii) downloading the pusher CLI<&lt;br />&gt;
(iii) logging in with your API key:<&lt;br />&gt;
"<&lt;code>&gt;pusher login<&lt;/code>&gt;"<&lt;br />&gt;
(iv) triggering a dumb-event on the main-channel:<&lt;br />&gt;
"<&lt;code>&gt;pusher channels apps trigger --app-id 1736956 --channel
main-channel --event dumb-event --message hello-world&lt;/code&gt;"&lt;br /&gt;
return&lt;br /&gt;
[[waiting...]]
<&lt;/p>&gt;
 
<&lt;/body><&gt;&lt;/html>&gt;
 
</code>
 
====JS====
 
</nowiki></pre>
var always = true; // const never= false;
;
;
var _ = { _: undefined };
_._ = _;
;
;
/**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**75**/
/**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**75**/
var pusher = null; // var channel= null; // var pusher_= null;
var eventHandler = function (stuff) {
stuff;
var counter = 0;
var ret = function (data) {
var s = JSON.stringify(data);
document.body.innerText +=
"; msg#" + ++counter + ":" + s;
};
return ret;
};
function tryNewAppKey(val) {
if (val.length == 20) { }
else
return;
pusher = new Pusher(val, {
cluster: 'eu', channelAuthorization: {
// transport: "jsonp",
endpoint: "http://localhost:8080/pusher/auth"
}
});
Pusher.logToConsole = true; // Enable pusher logging - don't include this in production
var channel = pusher.subscribe('nonprivate-channel');
channel.bind("pusher:subscription_error", function () { console.log("NOPE!"); });
channel.bind("pusher:subscription_succeeded", function () { channel.bind('unremarkable-event', eventHandler()); });
}
/**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**75**/
/**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**75**/
8

edits