main.html rep JSON amb info
diff --git a/js/utils.js b/js/utils.js
new file mode 100644
index 0000000..9f0a166
--- /dev/null
+++ b/js/utils.js
@@ -0,0 +1,23 @@
+function getUrlParameter(name) {
+ name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
+ var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
+ var results = regex.exec(location.search);
+ return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
+};
+
+function b64EncodeUnicode(str) {
+ // first we use encodeURIComponent to get percent-encoded UTF-8,
+ // then we convert the percent encodings into raw bytes which
+ // can be fed into btoa.
+ return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
+ function toSolidBytes(match, p1) {
+ return String.fromCharCode('0x' + p1);
+ }));
+}
+
+function b64DecodeUnicode(str) {
+ // Going backwards: from bytestream, to percent-encoding, to original string.
+ return decodeURIComponent(atob(str).split('').map(function(c) {
+ return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
+ }).join(''));
+}