2017-02-09 11:45:42 +00:00
|
|
|
import fm from '../entry.js';
|
|
|
|
import $ from 'jquery';
|
|
|
|
import ng from 'angular';
|
2016-10-20 08:26:17 +00:00
|
|
|
|
2017-05-11 01:47:46 +00:00
|
|
|
fm.app.controller("PadCtrl", function($scope, $timeout, $element) {
|
2017-02-09 11:45:42 +00:00
|
|
|
$scope.padId = decodeURIComponent(location.pathname.match(/[^\/]*$/)[0]);
|
2016-10-20 08:26:17 +00:00
|
|
|
|
2017-02-09 11:45:42 +00:00
|
|
|
if(location.search && (!location.hash || location.hash == "#"))
|
|
|
|
history.replaceState(null, "", fm.URL_PREFIX + ($scope.padId || "") + "#" + location.search.replace(/^\?/, ""));
|
2016-10-20 11:48:40 +00:00
|
|
|
|
2017-02-09 11:45:42 +00:00
|
|
|
$timeout(function() {
|
2017-05-11 01:47:46 +00:00
|
|
|
var map = angular.element($("facilmap", $element)).controller("facilmap");
|
2016-10-20 08:26:17 +00:00
|
|
|
|
2017-05-11 01:47:46 +00:00
|
|
|
$scope.$watch(() => (map.client.padData && map.client.padData.name), function(newVal) {
|
2017-02-09 11:45:42 +00:00
|
|
|
$scope.padName = newVal;
|
|
|
|
});
|
2016-10-20 08:26:17 +00:00
|
|
|
|
2017-05-11 01:47:46 +00:00
|
|
|
$scope.$watch(() => (map.client.padId), function(padId) {
|
2017-02-09 11:45:42 +00:00
|
|
|
if(padId)
|
|
|
|
history.replaceState(null, "", fm.URL_PREFIX + padId + location.hash);
|
2016-10-20 08:26:17 +00:00
|
|
|
});
|
2017-02-09 11:45:42 +00:00
|
|
|
}, 0);
|
|
|
|
|
|
|
|
// Dereferrer
|
|
|
|
$(document).on("click", "a", function(e) {
|
2017-02-10 21:40:37 +00:00
|
|
|
var el = $(this);
|
2017-02-09 11:45:42 +00:00
|
|
|
var href = el.attr("href");
|
|
|
|
if(href && href.match(/^\s*(https?:)?\/\//i)) {
|
|
|
|
el.attr("href", "deref.html?"+encodeURIComponent(href));
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
el.attr("href", href);
|
|
|
|
}, 0);
|
|
|
|
}
|
2016-10-20 08:26:17 +00:00
|
|
|
});
|
2017-02-09 11:45:42 +00:00
|
|
|
});
|