JS-URL-Variable is a javascript code used for parse url query string into an object.
This is the code I wrote for my another project paginate-blogger-posts
-
Documentation generated by JSDoc 3.
The newest version is used docdash as the documentation template but ver. 1.0 was jsdoc3Template.
<script src="/The/Path/of/The/File/url_variable.js"></script>
<script>
var urlVariables = new URLVariables("http://example.com/?var1=A&var2=B&var3=https%3A%2F%2Fexample.com");
console.log(urlVariables); // will log an object:
// {
// "var1": ["A"],
// "var2": ["B"],
// "var3": ["https://example.com"]
// }
</script>
<script src="/The/Path/of/The/File/url_variable.js"></script>
<script>
var urlVariables = new URLVariables({"var1":"A", "var2":"B", "var3":"https://example.com"});
console.log(urlVariables); // will log an object:
// {
// "var1": ["A"],
// "var2": ["B"],
// "var3": ["https://example.com"]
// }
</script>
<script src="/The/Path/of/The/File/url_variable.js"></script>
<script>
var urlVariables = new URLVariables({"var2":"B", "var1":"A", "var3":"https://example.com"});
console.log(urlVariables.toString()); // will log a String: "var1=A&var2=B&var3=https%3A%2F%2Fexample.com"
</script>
<script src="/The/Path/of/The/File/url_variable.js"></script>
<script>
var urlVariables = new URLVariables({"var1":"A", "var2":"B", "var3":"https://example.com"});
urlVariables.decode("var1=A2") // add url string
urlVariables.decode({var2: "B2"}) // add an object
console.log(urlVariables); // will log an object:
// {
// "var1": ["A", "A2"],
// "var2": ["B", "B2"],
// "var3": ["https://example.com"]
// }
console.log(urlVariables.toString()); // will log a String: "var1=A&var1=A2&var2=B&var2=B2&var3=https%3A%2F%2Fexample.com"
</script>