-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
78 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,2 @@ | ||
import QRCode from "qrcode-svg" | ||
import QRCodeTerminal from "./src/terminal" | ||
|
||
|
||
import { isBrowser, isNode, isWebWorker, isJsDom, isDeno } from "browser-or-node"; | ||
function parseOptions(args) { | ||
/* | ||
content: "https://github.com/", | ||
padding: 4, | ||
width: 256, | ||
height: 256, | ||
color: "#000000", | ||
background: "#ffffff", | ||
ecl: "M", | ||
*/ | ||
let content = "algorand://" | ||
let amount = args.amount; | ||
let wallet = args.wallet; | ||
let label = args.label; | ||
let asset = args.asset; | ||
let note = args.note; | ||
if (!!label && !!wallet) { | ||
content = "algorand://" + wallet+ "?" + "&label=" + label; | ||
} else if (!!asset && !!wallet) { | ||
if (!!note && amount > 0) { | ||
content = "algorand://" + wallet+ "?" + "&amount=" + amount + "&asset=" + asset + "¬e=" + note; | ||
} else if (amount > 0) { | ||
content = "algorand://" + wallet+ "?" + "&amount=" + amount + "&asset=" + asset; | ||
} else if (amount === 0) { | ||
content = "algorand://?" + "amount=0" + "&asset=" + asset; | ||
} | ||
|
||
} else if (!!note && !!wallet && !!amount) { | ||
content = "algorand://" + wallet+ "?" + "&amount=" + amount + "¬e=" + note; | ||
} else if ( !!wallet && !!amount){ | ||
content = "algorand://" + wallet+ "?" + "&amount=" + amount; | ||
} | ||
let options = { | ||
content: content, | ||
container: "svg-viewbox", | ||
ecl: args.ecl || "H", | ||
file: args.file || "algorand-qrcode.svg", | ||
padding: args.margin || 4, | ||
width: args.width || 256, | ||
height: args.height || 256, | ||
output: args.output || "terminal", | ||
background: args.background || "#e1dede", | ||
color: args.color || "#000000" | ||
} | ||
return options | ||
} | ||
const algoqrcode = (options) =>{ | ||
if (isBrowser) { | ||
let opts = parseOptions(options) | ||
let qrcode = new QRCode(opts); | ||
return qrcode | ||
|
||
} else if (isNode) { | ||
if (options.output === 'svg') { | ||
let opts = parseOptions(options) | ||
let qrcode = new QRCode(opts); | ||
return qrcode | ||
} else { | ||
let opts = parseOptions(options) | ||
return QRCodeTerminal.generate(opts.content); | ||
} | ||
|
||
|
||
} | ||
|
||
} | ||
export default algoqrcode | ||
|
||
import algoqrcode from "./src/index.mjs"; | ||
export default algoqrcode |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import QRCode from "qrcode-svg" | ||
import QRCodeTerminal from "./terminal" | ||
|
||
|
||
import { isBrowser, isNode, isWebWorker, isJsDom, isDeno } from "browser-or-node"; | ||
function parseOptions(args) { | ||
/* | ||
content: "https://github.com/", | ||
padding: 4, | ||
width: 256, | ||
height: 256, | ||
color: "#000000", | ||
background: "#ffffff", | ||
ecl: "M", | ||
*/ | ||
let content = "algorand://" | ||
let amount = args.amount; | ||
let wallet = args.wallet; | ||
let label = args.label; | ||
let asset = args.asset; | ||
let note = args.note; | ||
if (!!label && !!wallet) { | ||
content = "algorand://" + wallet+ "?" + "&label=" + label; | ||
} else if (!!asset && !!wallet) { | ||
if (!!note && amount > 0) { | ||
content = "algorand://" + wallet+ "?" + "&amount=" + amount + "&asset=" + asset + "¬e=" + note; | ||
} else if (amount > 0) { | ||
content = "algorand://" + wallet+ "?" + "&amount=" + amount + "&asset=" + asset; | ||
} else if (amount === 0) { | ||
content = "algorand://?" + "amount=0" + "&asset=" + asset; | ||
} | ||
|
||
} else if (!!note && !!wallet && !!amount) { | ||
content = "algorand://" + wallet+ "?" + "&amount=" + amount + "¬e=" + note; | ||
} else if ( !!wallet && !!amount){ | ||
content = "algorand://" + wallet+ "?" + "&amount=" + amount; | ||
} | ||
let options = { | ||
content: content, | ||
container: "svg-viewbox", | ||
ecl: args.ecl || "H", | ||
file: args.file || "algorand-qrcode.svg", | ||
padding: args.margin || 4, | ||
width: args.width || 256, | ||
height: args.height || 256, | ||
output: args.output || "terminal", | ||
background: args.background || "#e1dede", | ||
color: args.color || "#000000" | ||
} | ||
return options | ||
} | ||
const algoqrcode = (options) =>{ | ||
if (isBrowser) { | ||
let opts = parseOptions(options) | ||
let qrcode = new QRCode(opts); | ||
return qrcode | ||
|
||
} else if (isNode) { | ||
if (options.output === 'svg') { | ||
let opts = parseOptions(options) | ||
let qrcode = new QRCode(opts); | ||
return qrcode | ||
} else { | ||
let opts = parseOptions(options) | ||
return QRCodeTerminal.generate(opts.content); | ||
} | ||
|
||
|
||
} | ||
|
||
} | ||
export default algoqrcode | ||
|