Programming courses online

Intro

What is web monetization

How to implement web monetization

ng new web-monetization
<meta name="monetization" content="$twitter.xrptipbot.com/your-username"/>
<section class="section">
<div class="container">
<h1 class="title">Some coding tutorial <button class="button is-link" (click)="pay()">Simulate payment</button></h1>
<div class="box">
<h2 class="subtitle is-2">
The first example
</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque possimus
alias neque odit quia quos dolorum totam nemo odio, quibusdam
repudiandae voluptatum. Perferendis sunt non, nemo aut quos minus
deleniti!
</p>
<code class="is-block">
const text = 'Here is text for the first example'; console.log(text);
</code>
</div>
<div class="box">
<h2 class="subtitle is-2">
The second part
</h2>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque possimus
alias neque odit quia quos dolorum totam nemo odio, quibusdam
repudiandae voluptatum. Perferendis sunt non, nemo aut quos minus
deleniti!
</p>
<code class="is-block">
const text = 'Here is text for the second example'; console.log(text);
</code>
</div>
</div>
</section>
*ngIf="monetized"
<div *ngIf="!monetized" class="notification is-primary">
You need monetization to see the code
</div>
declare global {
interface Document {
monetization?: any;
}
}
export class AppComponent implements OnInit {
monetized = false;
ngOnInit() {
if (document.monetization) {
document.monetization.addEventListener('monetizationstart',()=>{
this.monetized = true;
});
}
}
pay() {
const event = new Event('monetizationstart');
document.monetization.dispatchEvent(event);
}
const event = new Event('monetizationstart');
document.monetization.dispatchEvent(event);
const event = new Event('monetizationstart');
document.monetization.dispatchEvent(event);
Programming courses online

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Radoslaw Fabisiak

Radoslaw Fabisiak

Core developer in www.duomly.com - Programming online courses