BEM wrap for History API:
- supports browsers with a native History API and hashchange event;
- provides manipulations with url, browser location and history in the terms of BEM (http://bem.info/).
graph = [[0, 7, 9, -1, -1, 14], [7, 0, 10, 15, -1, -1], [9, 10, 0, 11, -1, 2], [-1, 15, 11, 0, 6, -1], [-1, -1, -1, 6, 0, 9], [14, -1, 2, -1, 9, 0]] | |
start = 3 | |
def dijkstra(graph, start): | |
r = range(len(graph)) | |
def perform(results, work_results, visited, path, current): | |
tested = set(filter(lambda i: (graph[current][i] >= 0) and not visited[i] and ((results[current] + graph[current][i]) < results[i]), r)) |
BEM wrap for History API:
function parseByRegEx (url) { | |
var parser = /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, | |
parserKeys = ['source', 'protocol', 'authority', | |
'userInfo', 'user', 'password', 'host', 'port', | |
'relative', 'path', 'directory', 'file', 'query', 'anchor'], | |
m = parser.exec(url || ''), | |
parts = {}; | |
parserKeys.forEach(function(key, i) { | |
parts[key] = m[i] || ''; |