User:Ftwm/JTSetc: Difference between revisions
Content added Content deleted
(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>...") |
|||
Line 1: | Line 1: | ||
==Pusher.com Channels client== |
==Pusher.com Channels client== |
||
https://gitlab.com/Markworthy/nodejs-express_baublegum0v1/-/raw/master/public/src/privtest.js |
|||
====HTM==== |
====HTM==== |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
====JS==== |
====JS==== |
||
var always = true; // const never= false; |
var always = true; // const never= false; |
||
; |
; |
||
; |
; |
||
var _ = { _: undefined }; |
var _ = { _: undefined }; |
||
_._ = _; |
_._ = _; |
||
; |
; |
||
; |
; |
||
/**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**75**/ |
/**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**75**/ |
||
/**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**75**/ |
/**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**75**/ |
||
var pusher = null; // var channel= null; // var pusher_= null; |
var pusher = null; // var channel= null; // var pusher_= null; |
||
var eventHandler = function (stuff) { |
var eventHandler = function (stuff) { |
||
stuff; |
stuff; |
||
var counter = 0; |
var counter = 0; |
||
var ret = function (data) { |
var ret = function (data) { |
||
var s = JSON.stringify(data); |
var s = JSON.stringify(data); |
||
document.body.innerText += |
document.body.innerText += |
||
"; msg#" + ++counter + ":" + s; |
"; msg#" + ++counter + ":" + s; |
||
}; |
}; |
||
return ret; |
return ret; |
||
}; |
}; |
||
function tryNewAppKey(val) { |
function tryNewAppKey(val) { |
||
if (val.length == 20) { } |
if (val.length == 20) { } |
||
else |
else |
||
return; |
return; |
||
pusher = new Pusher(val, { |
pusher = new Pusher(val, { |
||
cluster: 'eu', channelAuthorization: { |
cluster: 'eu', channelAuthorization: { |
||
// transport: "jsonp", |
// transport: "jsonp", |
||
endpoint: "http://localhost:8080/pusher/auth" |
endpoint: "http://localhost:8080/pusher/auth" |
||
} |
} |
||
}); |
}); |
||
Pusher.logToConsole = true; // Enable pusher logging - don't include this in production |
Pusher.logToConsole = true; // Enable pusher logging - don't include this in production |
||
var channel = pusher.subscribe('nonprivate-channel'); |
var channel = pusher.subscribe('nonprivate-channel'); |
||
channel.bind("pusher:subscription_error", function () { console.log("NOPE!"); }); |
channel.bind("pusher:subscription_error", function () { console.log("NOPE!"); }); |
||
channel.bind("pusher:subscription_succeeded", function () { channel.bind('unremarkable-event', eventHandler()); }); |
channel.bind("pusher:subscription_succeeded", function () { channel.bind('unremarkable-event', eventHandler()); }); |
||
} |
} |
||
/**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**75**/ |
/**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**75**/ |
||
/**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**75**/ |
/**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**\ \**/ /**75**/ |