chore: update documentation

This commit is contained in:
Jacob Heun 2020-08-11 16:18:49 +02:00
parent 089e58f88b
commit 8c87e59caf
No known key found for this signature in database
GPG Key ID: CA5A94C15809879F
3 changed files with 32 additions and 59 deletions

View File

@ -6,7 +6,7 @@
/* eslint-env amd, node */
// https://github.com/umdjs/umd/blob/master/templates/returnExports.js
(function(root, factory) {
(function (root, factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
@ -21,7 +21,7 @@
root.AnchorJS = factory();
root.anchors = new root.AnchorJS();
}
})(this, function() {
})(this, function () {
'use strict';
function AnchorJS(options) {
this.options = options || {};
@ -51,7 +51,7 @@
* https://github.com/Modernizr/Modernizr/blob/da22eb27631fc4957f67607fe6042e85c0a84656/feature-detects/touchevents.js#L40
* @returns {Boolean} - true if the current device supports touch.
*/
this.isTouchDevice = function() {
this.isTouchDevice = function () {
return !!(
'ontouchstart' in window ||
(window.DocumentTouch && document instanceof DocumentTouch)
@ -64,7 +64,7 @@
* to. Also accepts an array or nodeList containing the relavant elements.
* @returns {this} - The AnchorJS object
*/
this.add = function(selector) {
this.add = function (selector) {
var elements,
elsWithIds,
idList,
@ -193,7 +193,7 @@
* OR a nodeList / array containing the DOM elements.
* @returns {this} - The AnchorJS object
*/
this.remove = function(selector) {
this.remove = function (selector) {
var index,
domAnchor,
elements = _getElements(selector);
@ -216,7 +216,7 @@
/**
* Removes all anchorjs links. Mostly used for tests.
*/
this.removeAll = function() {
this.removeAll = function () {
this.remove(this.elements);
};
@ -229,7 +229,7 @@
* @param {String} text - Any text. Usually pulled from the webpage element we are linking to.
* @returns {String} - hyphen-delimited text for use in IDs and URLs.
*/
this.urlify = function(text) {
this.urlify = function (text) {
// Regex for finding the nonsafe URL characters (many need escaping): & +$,:;=?@"#{}|^~[`%!'<>]./()*\
var nonsafeChars = /[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\]/g,
urlText;
@ -260,7 +260,7 @@
* @param {HTMLElemnt} el - a DOM node
* @returns {Boolean} true/false
*/
this.hasAnchorJSLink = function(el) {
this.hasAnchorJSLink = function (el) {
var hasLeftAnchor =
el.firstChild &&
(' ' + el.firstChild.className + ' ').indexOf(' anchorjs-link ') > -1,

View File

@ -7,7 +7,7 @@ anchors.add('h3');
// Filter UI
var tocElements = document.getElementById('toc').getElementsByTagName('li');
document.getElementById('filter-input').addEventListener('keyup', function(e) {
document.getElementById('filter-input').addEventListener('keyup', function (e) {
var i, element, children;
// enter key
@ -22,14 +22,14 @@ document.getElementById('filter-input').addEventListener('keyup', function(e) {
}
}
var match = function() {
var match = function () {
return true;
};
var value = this.value.toLowerCase();
if (!value.match(/^\s*$/)) {
match = function(element) {
match = function (element) {
var html = element.firstChild.innerHTML;
return html && html.toLowerCase().indexOf(value) !== -1;
};
@ -114,12 +114,12 @@ var cw_without_sb = split_left.clientWidth;
split_left.style.overflow = '';
Split(['#split-left', '#split-right'], {
elementStyle: function(dimension, size, gutterSize) {
elementStyle: function (dimension, size, gutterSize) {
return {
'flex-basis': 'calc(' + size + '% - ' + gutterSize + 'px)'
};
},
gutterStyle: function(dimension, gutterSize) {
gutterStyle: function (dimension, gutterSize) {
return {
'flex-basis': gutterSize + 'px'
};
@ -152,9 +152,9 @@ function loadState(ev) {
}
}
window.addEventListener('load', function() {
window.addEventListener('load', function () {
// Restore after Firefox scrolls to hash.
setTimeout(function() {
setTimeout(function () {
loadState();
// Update with initial scroll position.
updateState();

View File

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset='utf-8'>
<title>libp2p-websockets 0.13.6 | Documentation</title>
<title>libp2p-websockets 0.14.0 | Documentation</title>
<meta name='description' content='JavaScript implementation of the WebSockets module that libp2p uses and that implements the interface-transport spec'>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<link href='assets/bass.css' rel='stylesheet'>
@ -15,26 +15,19 @@
<div id='split-left' class='overflow-auto fs0 height-viewport-100'>
<div class='py1 px2'>
<h3 class='mb0 no-anchor'>libp2p-websockets</h3>
<div class='mb1'><code>0.13.6</code></div>
<div class='mb1'><code>0.14.0</code></div>
<input
placeholder='Filter'
id='filter-input'
class='col12 block input'
spellcheck='false'
autocapitalize='off'
autocorrect='off'
type='text' />
<div id='toc'>
<ul class='list-reset h5 py1-ul'>
<li><a
href='#intro'
class="h5 bold black caps">
Intro
</a>
</li>
<li><a
href='#websockets'
class=" toggle-sibling">
@ -84,34 +77,6 @@
<div id='split-right' class='relative overflow-auto height-viewport-100'>
<div class='keyline-top-not py2'><section class='py2 clearfix'>
<h2 id='intro' class='mt0'>
Intro
</h2>
<p>Installable via <code>npm install --save libp2p-websockets</code>, it can also be used directly in the browser.</p>
<h2>Download</h2>
<p>The source is available for download from <a href="git+https://github.com/libp2p/js-libp2p-websockets.git">GitHub</a>. Alternatively, you can install using npm:</p>
<pre class='hljs'>$ npm install --save libp2p-websockets</pre>
<p>You can then <code>require()</code> libp2p-websockets as normal:</p>
<pre class='hljs'><span class="hljs-keyword">const</span> libp2PWebsockets = <span class="hljs-built_in">require</span>(<span class="hljs-string">'libp2p-websockets'</span>)</pre>
<h2>In the Browser</h2>
<p><code>libp2p-websockets</code> should work in any ECMAScript 2018 environment out of the box.</p>
<p>Usage:</p>
<pre class='hljs'><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text/javascript"</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"index.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></pre>
<p>The portable versions of <code>libp2p-websockets</code>, including <code>index.js</code> and <code>index.min.js</code>, are included in the <code>/dist</code> folder. <code>libp2p-websockets</code> can also be found on <a href="https://unpkg.com">unpkg.com</a> under</p>
<ul>
<li><a href="https://unpkg.com/libp2p-websockets/dist/index.min.js">https://unpkg.com/libp2p-websockets/dist/index.min.js</a></li>
<li><a href="https://unpkg.com/libp2p-websockets/dist/index.js">https://unpkg.com/libp2p-websockets/dist/index.js</a></li>
</ul>
</section></div>
<section class='p2 mb2 clearfix bg-white minishadow'>
@ -122,7 +87,7 @@
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-websockets/blob/a37c2bd7f78b4ff671e20f7af5db4a494cb995f6/src/index.js#L18-L131'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-websockets/blob/662d04128cedcadad63a937a9d20dc14ca5c6713/src/index.js#L18-L131'>
<span>src/index.js</span>
</a>
@ -151,6 +116,8 @@
@ -171,7 +138,7 @@
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-websockets/blob/a37c2bd7f78b4ff671e20f7af5db4a494cb995f6/src/index.js#L38-L48'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-websockets/blob/662d04128cedcadad63a937a9d20dc14ca5c6713/src/index.js#L38-L48'>
<span>src/index.js</span>
</a>
@ -262,6 +229,8 @@
</section>
</div>
@ -281,7 +250,7 @@
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-websockets/blob/a37c2bd7f78b4ff671e20f7af5db4a494cb995f6/src/index.js#L105-L112'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-websockets/blob/662d04128cedcadad63a937a9d20dc14ca5c6713/src/index.js#L105-L112'>
<span>src/index.js</span>
</a>
@ -375,6 +344,8 @@ anytime a new incoming Connection has been successfully upgraded via
</section>
</div>
@ -394,7 +365,7 @@ anytime a new incoming Connection has been successfully upgraded via
<div class='clearfix'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-websockets/blob/a37c2bd7f78b4ff671e20f7af5db4a494cb995f6/src/index.js#L119-L130'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-websockets/blob/662d04128cedcadad63a937a9d20dc14ca5c6713/src/index.js#L119-L130'>
<span>src/index.js</span>
</a>
@ -452,6 +423,8 @@ anytime a new incoming Connection has been successfully upgraded via
</section>
</div>