RippleAPI QuickStart: add lodash dependency, update example code

resolves https://github.com/ripple/ripple-lib/issues/733
This commit is contained in:
mDuo13
2017-06-16 12:59:00 -07:00
parent c285a7a83c
commit 6b1fea3ed6
5 changed files with 34 additions and 69068 deletions

View File

@@ -1,7 +1,8 @@
<!DOCTYPE html>
<html>
<head>
<script src="ripple-0.16.5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.15.0/lodash.js"></script>
<script src="ripple-0.17.7-min.js"></script>
<script>
console.log(ripple);
var api = new ripple.RippleAPI({server:'wss://s1.ripple.com/'});

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -215,11 +215,11 @@ See [Reliable Transaction Submission](tutorial-reliable-transaction-submission.h
# RippleAPI in Web Browsers #
The process of using RippleAPI in a web browser is slightly different.
RippleAPI can also be used in a web browser if you compile a browser-compatible version and include [lodash](https://www.npmjs.com/package/lodash) as a dependency before the RippleAPI script.
## Build Instructions ##
Before you can use RippleAPI in a browser, you need to compile a browser-compatible version. The following process creates a single JavaScript file you can include in a webpage.
To use RippleAPI in a browser, you need to a browser-compatible version. The following process compiles RippleAPI into a single JavaScript file you can include in a webpage.
#### 1. Download a copy of the RippleAPI git repository.
@@ -288,6 +288,8 @@ The following HTML file demonstrates basic usage of the browser version of Rippl
To use this example, you must first [build RippleAPI](#build-instructions) and then copy one of the resulting output files to the same folder as this HTML file. (You can use either the minified or full-size version.) Change the first `<script>` tag in this example to use the correct file name for the version of RippleAPI you built.
[**browser-demo.html:**](https://github.com/ripple/ripple-dev-portal/blob/master/content/code_samples/rippleapi_quickstart/browser-demo.html "Source on GitHub")
```
{% include 'code_samples/rippleapi_quickstart/browser-demo.html' %}
```

View File

@@ -420,9 +420,9 @@ api.connect().then(() =&gt; {
<p>If you are the administrator of the <code>rippled</code> server, you can <a href="reference-rippled.html#ledger-request">manually request the missing ledger(s)</a>. Otherwise, you can try checking the ledger history using a different server. (Ripple runs a public full-history server at <code>s2.ripple.com</code> for this purpose.)</p>
<p>See <a href="tutorial-reliable-transaction-submission.html">Reliable Transaction Submission</a> for a more thorough explanation.</p>
<h1 id="rippleapi-in-web-browsers">RippleAPI in Web Browsers</h1>
<p>The process of using RippleAPI in a web browser is slightly different.</p>
<p>RippleAPI can also be used in a web browser if you compile a browser-compatible version and include <a href="https://www.npmjs.com/package/lodash">lodash</a> as a dependency before the RippleAPI script.</p>
<h2 id="build-instructions">Build Instructions</h2>
<p>Before you can use RippleAPI in a browser, you need to compile a browser-compatible version. The following process creates a single JavaScript file you can include in a webpage.</p>
<p>To use RippleAPI in a browser, you need to a browser-compatible version. The following process compiles RippleAPI into a single JavaScript file you can include in a webpage.</p>
<h4 id="1-download-a-copy-of-the-rippleapi-git-repository">1. Download a copy of the RippleAPI git repository.</h4>
<p>If you have <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">Git</a> installed, you can clone the repository and check out the <strong>release</strong> branch, which always has the latest official release:</p>
<pre><code>git clone https://github.com/ripple/ripple-lib.git
@@ -463,10 +463,12 @@ npm WARN notsup Not compatible with your operating system or architecture: fseve
<h2 id="example-browser-usage">Example Browser Usage</h2>
<p>The following HTML file demonstrates basic usage of the browser version of RippleAPI to connect to a public <code>rippled</code> server and report information about that server. Instead of using Node.js's "require" syntax, the browser version creates a global variable named <code>ripple</code>, which contains the <code>RippleAPI</code> class.</p>
<p>To use this example, you must first <a href="#build-instructions">build RippleAPI</a> and then copy one of the resulting output files to the same folder as this HTML file. (You can use either the minified or full-size version.) Change the first <code>&lt;script&gt;</code> tag in this example to use the correct file name for the version of RippleAPI you built.</p>
<p><a href="https://github.com/ripple/ripple-dev-portal/blob/master/content/code_samples/rippleapi_quickstart/browser-demo.html" title="Source on GitHub"><strong>browser-demo.html:</strong></a></p>
<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;script src="ripple-0.16.5.js"&gt;&lt;/script&gt;
&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.15.0/lodash.js"&gt;&lt;/script&gt;
&lt;script src="ripple-0.17.7-min.js"&gt;&lt;/script&gt;
&lt;script&gt;
console.log(ripple);
var api = new ripple.RippleAPI({server:'wss://s1.ripple.com/'});