Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
taufik-nurrohman committed Mar 10, 2021
1 parent 9d503f5 commit fa163fc
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 51 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ Contribute
Release Notes
-------------

### 1.1.15
### 1.1.16

- Allowed to disable AJAX features by adding `data-f3h` or `f3h` attribute with `false` value to the source elements.

### 1.1.12, 1.1.13, 1.1.14
### 1.1.14

- Maintenance.

### 1.1.11

- Restructured the test files.

### 1.1.5, 1.1.6, 1.1.7, 1.1.8, 1.1.9, 1.1.10
### 1.1.10

- Maintenance.

Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><html dir="ltr"><head><meta charset="utf-8"><meta content="#000" name="theme-color"><meta content="width=device-width" name="viewport"><meta content="Load pages asynchronously using AJAX while maintaining the principles of progressive enhancement." name="description"><title>Fetch 1.1.15</title><style>* {
<!DOCTYPE html><html dir="ltr"><head><meta charset="utf-8"><meta content="#000" name="theme-color"><meta content="width=device-width" name="viewport"><meta content="Load pages asynchronously using AJAX while maintaining the principles of progressive enhancement." name="description"><title>Fetch 1.1.16</title><style>* {
box-sizing: border-box;
}
:root {
Expand Down Expand Up @@ -49,7 +49,7 @@
border: 1px dashed;
margin-top: 0;
padding: .75em 1em;
}</style></head><body><p>Do you like this project? Please support my <a href="https://github.com/mecha-cms">Mecha CMS</a> project too. Thank you!</p><header><h1>Fetch 1.1.15</h1><p>You can read <abbr title="Fetch">F3H</abbr> as how you would read <abbr title="Accessibility">A11Y</abbr> and <abbr title="Internationalization">I18N</abbr>.</p><p>Your job is to make a website that works traditionally: clicking on a link will direct you to a new page, sending and uploading data through a form will store it to the web storage. After you finish making it, this application will serve as a feature enhancer, which is, to enable AJAX features to your traditional web pages automatically, so that your web pages can load faster because you can specify which parts of the destination page you want to load into the current page.</p><hr></header><main><p>Progressive enhancement is a design principle that is focused in ensuring the availability of web page content in the most limited conditions, and if possible, to provide the most advanced features when the conditions are supportive. By enhancing features while maintaining the basic functions of HTML pages, this concept will ensure that if your advanced JavaScript features cannot work optimally under certain conditions, then at least the web page content that you want to provide is still accessible to most users.</p><p><a href="test/1/index.html" target="_blank"><b>Demo</b></a></p><h2>Features</h2><ul><li>Light-weight, no dependencies. It uses vanilla JavaScript.</li><li>Simple <abbr title="Application Programming Interface">API</abbr>. Easy to master.</li><li>Accessible AJAX response as HTML elements (by default).</li><li>Instant click with native HTML5 Prefetch, improved by the power of JavaScript.</li><li>Progressively enhanced. If at any time the JavaScript fails to load, or if users are using an old web browser, or if users decide to disable the JavaScript features, or if some third-party JavaScript makes this application fail to work, your website will still be able to work as when it didn&rsquo;t have any AJAX features.</li></ul><h2>Usage</h2><h3>Browser</h3><p>With the basic knowledge of accessing the DOM and manipulating it using JavaScript, you can use this application like a pro.</p><pre><code>&lt;!DOCTYPE html&gt;
}</style></head><body><p>Do you like this project? Please support my <a href="https://github.com/mecha-cms">Mecha CMS</a> project too. Thank you!</p><header><h1>Fetch 1.1.16</h1><p>You can read <abbr title="Fetch">F3H</abbr> as how you would read <abbr title="Accessibility">A11Y</abbr> and <abbr title="Internationalization">I18N</abbr>.</p><p>Your job is to make a website that works traditionally: clicking on a link will direct you to a new page, sending and uploading data through a form will store it to the web storage. After you finish making it, this application will serve as a feature enhancer, which is, to enable AJAX features to your traditional web pages automatically, so that your web pages can load faster because you can specify which parts of the destination page you want to load into the current page.</p><hr></header><main><p>Progressive enhancement is a design principle that is focused in ensuring the availability of web page content in the most limited conditions, and if possible, to provide the most advanced features when the conditions are supportive. By enhancing features while maintaining the basic functions of HTML pages, this concept will ensure that if your advanced JavaScript features cannot work optimally under certain conditions, then at least the web page content that you want to provide is still accessible to most users.</p><p><a href="test/1/index.html" target="_blank"><b>Demo</b></a></p><h2>Features</h2><ul><li>Light-weight, no dependencies. It uses vanilla JavaScript.</li><li>Simple <abbr title="Application Programming Interface">API</abbr>. Easy to master.</li><li>Accessible AJAX response as HTML elements (by default).</li><li>Instant click with native HTML5 Prefetch, improved by the power of JavaScript.</li><li>Progressively enhanced. If at any time the JavaScript fails to load, or if users are using an old web browser, or if users decide to disable the JavaScript features, or if some third-party JavaScript makes this application fail to work, your website will still be able to work as when it didn&rsquo;t have any AJAX features.</li></ul><h2>Usage</h2><h3>Browser</h3><p>With the basic knowledge of accessing the DOM and manipulating it using JavaScript, you can use this application like a pro.</p><pre><code>&lt;!DOCTYPE html&gt;
&lt;html dir="ltr"&gt;
&lt;head&gt;
&lt;meta charset="utf-8"&gt;
Expand Down
74 changes: 41 additions & 33 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,27 +109,27 @@
return "" + x;
};

var toCaseLower = function toCaseLower(x) {
var toCaseLower$1 = function toCaseLower(x) {
return x.toLowerCase();
};

var toNumber = function toNumber(x, base) {
var toNumber$1 = function toNumber(x, base) {
if (base === void 0) {
base = 10;
}

return parseInt(x, base);
};

var toValue = function toValue(x) {
var toValue$1 = function toValue(x) {
if (isArray(x)) {
return x.map(function (v) {
return toValue(v);
});
}

if (isNumeric(x)) {
return toNumber(x);
return toNumber$1(x);
}

if (isObject(x)) {
Expand Down Expand Up @@ -168,7 +168,7 @@
}

var value = node.getAttribute(attribute);
return parseValue ? toValue(value) : value;
return parseValue ? toValue$1(value) : value;
};

var getAttributes = function getAttributes(node, parseValue) {
Expand All @@ -182,7 +182,7 @@

for (var i = 0, j = attributes.length; i < j; ++i) {
value = attributes[i].value;
values[attributes[i].name] = parseValue ? toValue(value) : value;
values[attributes[i].name] = parseValue ? toValue$1(value) : value;
}

return values;
Expand Down Expand Up @@ -213,7 +213,7 @@
};

var getName = function getName(node) {
return toCaseLower(node && node.nodeName || "") || null;
return toCaseLower$1(node && node.nodeName || "") || null;
};

var getNext = function getNext(node) {
Expand Down Expand Up @@ -421,10 +421,10 @@
}

var $ = context({});
var fire = $.fire;
var off$1 = $.off;
var on$1 = $.on;
var hooks = $.hooks;
$.fire;
$.off;
$.on;
$.hooks;

var isPattern = function isPattern(pattern) {
return isInstance(pattern, RegExp);
Expand All @@ -450,7 +450,7 @@
return node;
};

var toCaseLower$1 = function toCaseLower(x) {
var toCaseLower = function toCaseLower(x) {
return x.toLowerCase();
};

Expand All @@ -462,7 +462,7 @@
return x.length;
};

var toNumber$1 = function toNumber(x, base) {
var toNumber = function toNumber(x, base) {
if (base === void 0) {
base = 10;
}
Expand All @@ -478,15 +478,15 @@
return Object.keys(x);
};

var toValue$1 = function toValue(x) {
var toValue = function toValue(x) {
if (isArray(x)) {
return x.map(function (v) {
return toValue(v);
});
}

if (isNumeric(x)) {
return toNumber$1(x);
return toNumber(x);
}

if (isObject(x)) {
Expand All @@ -497,11 +497,19 @@
return x;
}

return {
'false': false,
'null': null,
'true': true
}[x] || x;
if ('false' === x) {
return false;
}

if ('null' === x) {
return null;
}

if ('true' === x) {
return true;
}

return x;
};

var name = 'F3H',
Expand Down Expand Up @@ -610,9 +618,9 @@
}

function isLinkForF3H(node) {
var n = toCaseLower$1(name); // Exclude `<link rel="*">` tag that contains `data-f3h` or `f3h` attribute with `false` value
var n = toCaseLower(name); // Exclude `<link rel="*">` tag that contains `data-f3h` or `f3h` attribute with `false` value

return toValue$1(getAttribute(node, 'data-' + n) || getAttribute(node, n)) ? 1 : 0;
return toValue(getAttribute(node, 'data-' + n) || getAttribute(node, n)) ? 1 : 0;
}

function isScriptForF3H(node) {
Expand All @@ -621,9 +629,9 @@
return 1;
}

var n = toCaseLower$1(name); // Exclude JavaScript tag that contains `data-f3h` or `f3h` attribute with `false` value
var n = toCaseLower(name); // Exclude JavaScript tag that contains `data-f3h` or `f3h` attribute with `false` value

if (toValue$1(getAttribute(node, 'data-' + n) || getAttribute(node, n))) {
if (toValue(getAttribute(node, 'data-' + n) || getAttribute(node, n))) {
return 1;
} // Exclude JavaScript that contains `F3H` instantiation

Expand All @@ -636,20 +644,20 @@
}

function isSourceForF3H(node) {
var n = toCaseLower$1(name);
var n = toCaseLower(name);

if (!hasAttribute(node, 'data-' + n) && !hasAttribute(node, n)) {
return 1; // Default value is `true`
} // Exclude anchor tag that contains `data-f3h` or `f3h` attribute with `false` value


return toValue$1(getAttribute(node, 'data-' + n) || getAttribute(node, n)) ? 1 : 0;
return toValue(getAttribute(node, 'data-' + n) || getAttribute(node, n)) ? 1 : 0;
}

function isStyleForF3H(node) {
var n = toCaseLower$1(name); // Exclude CSS tag that contains `data-f3h` or `f3h` attribute with `false` value
var n = toCaseLower(name); // Exclude CSS tag that contains `data-f3h` or `f3h` attribute with `false` value

return toValue$1(getAttribute(node, 'data-' + n) || getAttribute(node, n)) ? 1 : 0;
return toValue(getAttribute(node, 'data-' + n) || getAttribute(node, n)) ? 1 : 0;
}

function letHash(ref) {
Expand Down Expand Up @@ -691,17 +699,17 @@

for (header in headers) {
h = headers[header].split(': ');
k = toCaseLower$1(h.shift());
out[k] = toValue$1(h.join(': '));
k = toCaseLower(h.shift());
out[k] = toValue(h.join(': '));
} // Use proxy to make case-insensitive response header’s key


return new Proxy(out, {
get: function get(o, k) {
return o[toCaseLower$1(k)] || null;
return o[toCaseLower(k)] || null;
},
set: function set(o, k, v) {
o[toCaseLower$1(k)] = v;
o[toCaseLower(k)] = v;
}
});
}
Expand Down Expand Up @@ -1261,6 +1269,6 @@
'JSON': responseTypeJSON
}
};
F3H.version = '1.1.15';
F3H.version = '1.1.16';
return F3H;
});
Loading

0 comments on commit fa163fc

Please sign in to comment.