| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
-
- window.common = (function () {
- var common = {};
- common.getFragment = function getFragment() {
- if (window.location.hash.indexOf("#") === 0) {
- return parseQueryString(window.location.hash.substr(1));
- } else {
- return {};
- }
- };
- function parseQueryString(queryString) {
- var data = {},
- pairs, pair, separatorIndex, escapedKey, escapedValue, key, value;
- if (queryString === null) {
- return data;
- }
- pairs = queryString.split("&");
- for (var i = 0; i < pairs.length; i++) {
- pair = pairs[i];
- separatorIndex = pair.indexOf("=");
- if (separatorIndex === -1) {
- escapedKey = pair;
- escapedValue = null;
- } else {
- escapedKey = pair.substr(0, separatorIndex);
- escapedValue = pair.substr(separatorIndex + 1);
- }
- key = decodeURIComponent(escapedKey);
- value = decodeURIComponent(escapedValue);
- data[key] = value;
- }
- return data;
- }
- return common;
- })();
|