";
+ };
+}
diff --git a/app/components/client/playground-scripts.js b/app/components/client/playground-scripts.js
index 6173481..7a17f9f 100644
--- a/app/components/client/playground-scripts.js
+++ b/app/components/client/playground-scripts.js
@@ -111,7 +111,8 @@ function debounce(func, wait, immediate) {
const later = () => {
timeout = null;
- if (!immediate) func.apply(context, args);
+ if (!immediate)
+ func.apply(context, args);
};
const callNow = immediate && !timeout;
@@ -119,7 +120,8 @@ function debounce(func, wait, immediate) {
clearTimeout(timeout);
timeout = setTimeout(later, wait);
- if (callNow) func.apply(context, args);
+ if (callNow)
+ func.apply(context, args);
};
}
@@ -129,9 +131,9 @@ function initializePlayground() {
document.querySelector("#fetch-claim-uri").focus();
document.querySelector(".playground-navigation__example:nth-child(1)").classList.add("active");
- send(JSON.stringify({
+ send({
message: "landed on playground"
- }));
+ });
setTimeout(() => {
document.querySelector(".playground-navigation__example:nth-child(1)").click();
@@ -139,16 +141,17 @@ function initializePlayground() {
}
function fetchMetadata(exampleNumber, data) {
- if (!exampleNumber) return;
+ if (!exampleNumber)
+ return;
switch(exampleNumber) {
case 1:
- send(JSON.stringify({
+ send({
claim: data,
message: "fetch metadata",
method: "resolve",
example: exampleNumber
- }));
+ });
document.getElementById("fetch-claim-uri").value = data;
document.getElementById("playground-results").innerHTML = playgroundResponseForExample1(data);
@@ -156,24 +159,24 @@ function fetchMetadata(exampleNumber, data) {
break;
case 2:
- send(JSON.stringify({
+ send({
data: data,
message: "fetch metadata",
method: "publish",
example: exampleNumber
- }));
+ });
document.getElementById("playground-results").innerHTML = playgroundResponseForExample2(getMemeInfo());
document.getElementById("playground-loader").style.display = "none";
break;
case 3:
- send(JSON.stringify({
+ send({
claim: data,
message: "fetch metadata",
method: "claim_tip",
example: exampleNumber
- }));
+ });
document.getElementById("fetch-claim-uri").value = data;
document.getElementById("playground-results").innerHTML = playgroundResponseForExample3(data);
@@ -265,9 +268,7 @@ const handleExamples = debounce(event => {
if (document.getElementById("playground-url").style.display === "none")
document.getElementById("playground-url").removeAttribute("style");
- for (const example of document.querySelectorAll(".playground-navigation__example"))
- example.classList.remove("active");
-
+ document.querySelectorAll(".playground-navigation__example").forEach(example => example.classList.remove("active"));
document.querySelector(".playground-navigation__example:nth-child(1)").classList.add("active");
document.getElementById("playground-loader").innerHTML = "";
@@ -276,9 +277,9 @@ const handleExamples = debounce(event => {
document.getElementById("playground-loader").removeAttribute("style");
document.getElementById("playground-results").removeAttribute("style");
- send(JSON.stringify({
+ send({
message: `request for ${data.action}`
- }));
+ });
break;
@@ -291,9 +292,7 @@ const handleExamples = debounce(event => {
document.getElementById("fetch-claim-uri").value = ""; // reset URL bar
document.getElementById("playground-url").style.display = "none";
- for (const example of document.querySelectorAll(".playground-navigation__example"))
- example.classList.remove("active");
-
+ document.querySelectorAll(".playground-navigation__example").forEach(example => example.classList.remove("active"));
document.querySelector(".playground-navigation__example:nth-child(2)").classList.add("active");
document.getElementById("playground-loader").innerHTML = "";
@@ -302,9 +301,9 @@ const handleExamples = debounce(event => {
document.getElementById("playground-loader").removeAttribute("style");
document.getElementById("playground-results").removeAttribute("style");
- send(JSON.stringify({
+ send({
message: `request for ${data.action}`
- }));
+ });
break;
@@ -320,9 +319,7 @@ const handleExamples = debounce(event => {
if (document.getElementById("playground-url").style.display === "none")
document.getElementById("playground-url").removeAttribute("style");
- for (const example of document.querySelectorAll(".playground-navigation__example"))
- example.classList.remove("active");
-
+ document.querySelectorAll(".playground-navigation__example").forEach(example => example.classList.remove("active"));
document.querySelector(".playground-navigation__example:nth-child(3)").classList.add("active");
document.getElementById("playground-loader").innerHTML = "";
@@ -331,9 +328,9 @@ const handleExamples = debounce(event => {
document.getElementById("playground-loader").removeAttribute("style");
document.getElementById("playground-results").removeAttribute("style");
- send(JSON.stringify({
+ send({
message: `request for ${data.action}`
- }));
+ });
break;
diff --git a/app/components/developer-program.js b/app/components/developer-program.js
new file mode 100644
index 0000000..c69085f
--- /dev/null
+++ b/app/components/developer-program.js
@@ -0,0 +1,32 @@
+"use strict";
+
+
+
+// I M P O R T
+
+import html from "choo/html";
+
+
+
+// E X P O R T
+
+export default () => {
+ if (
+ !process.env.GITHUB_APP_ID ||
+ !process.env.GITHUB_APP_SECRET ||
+ !process.env.REWARD_URL
+ ) {
+ return html`
+
+
Environment variables required to enable functionality are missing.
+
+ `;
+ }
+
+ return html`
+
+
+ This will authenticate you with GitHub to prove eligibility as well as mark you as a follower of LBRY.
+
+ `;
+};
diff --git a/app/components/playground.js b/app/components/playground.js
index c4463a3..f0a60d7 100644
--- a/app/components/playground.js
+++ b/app/components/playground.js
@@ -28,10 +28,10 @@ export default () => dedent`
function example1() {
return html`
-
+ lbry://
-
+
diff --git a/app/dist/scripts/api.js b/app/dist/scripts/api.js
index bb6f8d2..f9869a7 100644
--- a/app/dist/scripts/api.js
+++ b/app/dist/scripts/api.js
@@ -45,14 +45,9 @@ function handleApiLanguageToggles(language) {
const examples = document.querySelectorAll("[data-api-example-type]");
const toggles = document.querySelectorAll("*[id^='toggle-']");
- for (const example of examples)
- example.classList.remove("active");
-
- for (const example of codeExamples)
- example.classList.add("active");
-
- for (const toggle of toggles)
- toggle.classList.remove("active");
+ examples.forEach(example => example.classList.remove("active"));
+ codeExamples.forEach(example => example.classList.add("active"));
+ toggles.forEach(example => example.classList.remove("active"));
document.getElementById(`toggle-${language}`).classList.add("active");
});
diff --git a/app/dist/scripts/app.js b/app/dist/scripts/app.js
index 3528f98..50a96f5 100755
--- a/app/dist/scripts/app.js
+++ b/app/dist/scripts/app.js
@@ -26,6 +26,9 @@ if (
// Smooth scroll
document.querySelectorAll("a[href^='#']").forEach(anchor => {
+ if (anchor.classList.contains("no-smooth")) // Ignore smooth scroll functionality
+ return;
+
anchor.addEventListener("click", event => {
event.preventDefault();
@@ -60,10 +63,10 @@ document.querySelector("[data-action='subscribe to newsletter']").onclick = () =
document.getElementById("emailMessage").classList.remove("error");
- send(JSON.stringify({
+ send({
email: email,
message: "subscribe"
- }));
+ });
};
@@ -87,6 +90,5 @@ function scrollToElementOnLoad() {
function validateEmail(email) {
const emailRegex = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\\.,;:\s@"]{2,})$/i;
-
- return emailRegex.test(String(email));
+ return emailRegex.test(String(email)); // eslint-disable-line padding-line-between-statements
}
diff --git a/app/dist/scripts/plugins/jets.js b/app/dist/scripts/plugins/jets.js
index 0b1a750..23eca43 100644
--- a/app/dist/scripts/plugins/jets.js
+++ b/app/dist/scripts/plugins/jets.js
@@ -224,7 +224,7 @@
;(function(doc, proto) {
try {
doc.querySelector(":scope body");
- } catch (err) {
+ } catch(err) {
["querySelector", "querySelectorAll"].forEach(method => {
const nativ = proto[method];
diff --git a/app/dist/scripts/sockets.js b/app/dist/scripts/sockets.js
index 409bca8..3e236a2 100644
--- a/app/dist/scripts/sockets.js
+++ b/app/dist/scripts/sockets.js
@@ -1,4 +1,4 @@
-"use strict"; /* global document, location, WebSocket */
+"use strict"; /* global document, location, WebSocket, window */
@@ -12,22 +12,36 @@ document.addEventListener("DOMContentLoaded", () => {
let ws = null;
function checkWebSocketConnection() {
- if (!ws || ws.readyState === 3) initializeWebSocketConnection();
+ if (!ws || ws.readyState === 3)
+ initializeWebSocketConnection();
}
function initializeWebSocketConnection() {
ws = new WebSocket(location.origin.replace(/^http/, "ws"));
- ws.onopen = () => {
- console.log("WebSocket connection established"); // eslint-disable-line
- };
+ // ws.onopen = () => console.log("WebSocket connection established"); // eslint-disable-line no-console
ws.onmessage = socket => {
const data = JSON.parse(socket.data);
switch(true) {
+ case data.message === "notification": // TODO: Make work with appending so multiple notifications can be sent
+ document.getElementById("flash-container").innerHTML =
+ `
${data.details}
`;
+
+ setTimeout(() => {
+ document.getElementById("flash-container").innerHTML = "";
+ }, 2100);
+
+ break;
+
+ case data.message === "redirect":
+ window.location.href = data.url;
+ break;
+
case data.message === "show result":
- if (!data.example) return;
+ if (!data.example)
+ return;
document.querySelector(data.selector).innerHTML = data.html;
@@ -60,8 +74,8 @@ function initializeWebSocketConnection() {
}
if (data.example === 2) {
- detectLanguageAndUpdate(); // eslint-disable-line
- initCanvas(); // eslint-disable-line
+ detectLanguageAndUpdate(); // eslint-disable-line no-undef
+ initCanvas(); // eslint-disable-line no-undef
setTimeout(() => {
document.querySelector(".playground-content__meme__canvas__thumbnail").click();
@@ -83,36 +97,24 @@ function initializeWebSocketConnection() {
break;
- case data.message === "notification": // TODO: Make work with appending so multiple notifications can be sent
- document.getElementById("flash-container").innerHTML =
- `
${data.details}
`;
-
- setTimeout(() => {
- document.getElementById("flash-container").innerHTML = "";
- }, 2100);
-
- break;
-
default:
- console.log(data); // eslint-disable-line
+ console.log(data); // eslint-disable-line no-console
break;
}
};
- ws.onclose = () => {
- console.log("WebSocket connection lost"); // eslint-disable-line
- checkWebSocketConnection(); // reconnect now
- };
+ ws.onclose = () => checkWebSocketConnection(); // reconnect now
}
-function send(msg) { // eslint-disable-line
- socketReady(ws, () => ws.send(msg));
+function send(msg) { // eslint-disable-line no-unused-vars
+ socketReady(ws, () => ws.send(JSON.stringify(msg)));
}
function socketReady(socket, callback) {
setTimeout(() => {
if (socket && socket.readyState === 1) {
- if (callback !== undefined) callback();
+ if (callback !== undefined)
+ callback();
return;
}
diff --git a/app/helpers/fetch-metadata.js b/app/helpers/fetch-metadata.js
index 7a957d0..0b16a3c 100644
--- a/app/helpers/fetch-metadata.js
+++ b/app/helpers/fetch-metadata.js
@@ -11,16 +11,16 @@ import stringifyObject from "stringify-object";
// U T I L S
-import randomString from "./random-string";
import messageSlack from "./slack";
-
import publishMeme from "./publish-meme";
+import randomString from "./random-string";
+import { send } from "@socket";
import uploadImage from "./upload-image";
const allowedQueryMethods = [
+ "claim_tip",
"publish",
- "resolve",
- "claim_tip"
+ "resolve"
];
const approvedContentIdsForTipping = [
@@ -60,11 +60,11 @@ export default async(data, socket) => {
const resolveMethod = data.method;
if (allowedQueryMethods.indexOf(resolveMethod) < 0) {
- return socket.send(JSON.stringify({
+ return send(socket, {
details: "Unallowed resolve method for tutorial",
message: "notification",
type: "error"
- }));
+ });
}
body.authorization = process.env.LBRY_DAEMON_ACCESS_TOKEN;
@@ -77,7 +77,7 @@ export default async(data, socket) => {
// E X A M P L E
case resolveMethod === "claim_tip":
if (!approvedContentIdsForTipping.includes(claimAddress)) {
- return socket.send(JSON.stringify({
+ return send(socket, {
example: data.example,
html: raw(`