<commit_before>/*
tHere, topping here.com maps app with some neat features

url: http://edoardoo.github.io/there/
author: <NAME>, edoardoo.com, edo[at]lenotta.com
license: MIT
*/

function loadScript(url, callback)
{
    // Adding the script tag to the head as suggested before
    var head = document.getElementsByTagName('head')[0];
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = url;

    // Then bind the event to the callback function.
    // There are several events for cross browser compatibility.
    script.onreadystatechange = callback;
    script.onload = callback;

    // Fire the loading
    head.appendChild(script);
}

function show_loading(){
    //show a little loading animation to let the user know something is going on 
    var style = "<style>.rotate{-webkit-transition-property:-webkit-transform;-webkit-transition-duration:1s;-moz-transition-property:-moz-transform;-moz-transition-duration:1s;-webkit-animation-name:rotate;-webkit-animation-duration:3s;-webkit-animation-iteration-count:infinite;-webkit-animation-timing-function:linear;-moz-animation-name:rotate;-moz-animation-duration:3s;-moz-animation-iteration-count:infinite;-moz-animation-timing-function:linear}@-webkit-keyframes rotate{from{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(360deg)}}@-moz-keyframes rotate{from{-moz-transform:rotate(0deg)}to{-moz-transform:rotate(360deg)}}</style>";
    $("head").append(style);
    $("#service_switcher .herelogo").addClass('rotate');
}

function hide_loading(){
    $("#service_switcher .herelogo").removeClass('rotate');
}
function clean_code(code){
    //strip out all the code we don't need 
    return code = code.replace(/<(\/)?html.*>/g, '')
        .replace(/<head([^.]|[.])*\/head>/g, '')
        .replace(/<(\/)?body.*>/g, '')
        .replace(/<!doctype.*>/g, '')
        .replace('"use strict";','');
}

var setStuff = function (){

    //set our mod and let it run

    show_loading();

    $.ajax({
    url: 'https://www.here.com',
    success: function(code){
        //prepare the modules to inject
        var backupImage = '<KEY>';
       
        var tags = '<script>@</script>'
       
        var modules = 'angular.module(\"hereApp.places\").controller(\"PlacesCtrl\",[\"$scope\",\"Features\",\"$routeParams\",\"$location\",\"$window\",\"$q\",\"PBAPI\",\"geoCoder\",\"placeService\",\"RedirectService\",\"RecentsService\",\"herePageTitle\",\"categories\",\"markerService\",\"markerIcons\",\"mapContainers\",\"mapsjs\",\"utilityService\",\"TrackingService\",\"directionsUrlHelper\",\"$rootScope\",\"CollectionsAlwaysVisibleService\",\"splitTesting\",\"hereBrowser\",\"CollectionsService\",\"$routeParams\",function(e,a,t,o,r,n,i,c,l,s,d,p,u,g,m,f,v,h,I,P,y,M,C,w,T){var k,S,D,b=this,A=f.PDC,x=[\"building\"];e.place=null,b.initialize=function(){e.loading=!0,e.notFound=!1,b.getPlace(t).then(function(a){e.loading=!1,e.place=a,d.addPlace(a),e.whenMapIsReady.then(function(e){k=e,b.displayMarker(k,a)})},function(){e.loading=!1,e.notFound=!0})},b.getPlace=function(e){var a=n.defer(),t=e?e.id:null,o=e&&e.href?r.atob(decodeURIComponent(e.href)):null,d=t&&t.match(\/^loc-[0-9a-zA-Z]+\/),u=!e||t||o?null:e.msg,g=!(!t&&!o||d),m=e.map,f=function(o){i.place(o).then(function(o){var r=angular.copy(o.data),i=T.getAllFavoritePlaces().then(function(e){return i=$.grep(e,function(e){return e.placesId==r.placeId}),i=i.filter(function(e){return null!=e.customName}),r.name=i[0].customName,i[0]}),s=r.placeId||r.id,m=function(e){return e&&e.position&&(!e.address||e.address&&!e.address.city&&!e.address.state)?c.reverseGeoCode({location:e.position}).then(function(e){if(e&&e.data){var a=e.data.address;return a.text=a.label,a}}):e.address};return t&&r.placeId&&t!==r.placeId&&(r.altPlaceId=t),d=l.isLocation(r),g=s&&!d,u=d?u:null,g&&l.isDiscoverCategory(r)?b.redirectToDiscover(r):(r.mainCategory=l.getMainCategoryId(r),r.name=u||(d&&!l.isCoordinate(r)?r.name.replace(\/,\/g,\"\"):r.name),void n.when(m(r.location)).then(function(t){r.location.address=t,r.name=l.isCoordinate(r)&&t?l.getAddressLabel(t):r.name;var o=r.location.address&&r.location.address.city?\" - \"+r.location.address.city:\"\",n=o&&r.location.address.city!==r.name?o:\"\",i=x.indexOf(r.mainCategory)>-1,c=d||i?\"\":\" - \"+r.categories[0].title,s=r.name+c+n+\" - HERE\";p.set(s),!g&&!d||e&&e.country||F(r),a.resolve(r)}))},a.reject)};if(!t&&!o&&!m)return a.reject(new Error(\"Invalid params: no pId, pHref or pMap\")),a.promise;if(t||o){var I=o?{href:o}:{id:t};return f(I),a.promise}var P=h.convertQueryFormatToMapInfo(m),y={size:1,q:P.latitude+\",\"+P.longitude,center:new v.geo.Point(P.latitude,P.longitude),lookahead:!0};return i.search(y).then(function(e){e.data.items[0]?f({href:e.data.items[0].href}):s.goToDiscover({lat:P.latitude,lng:P.longitude},\"\",!0)}),a.promise},b.redirectToDiscover=function(e){var a=angular.copy(e.location.position);return a=angular.extend(a,l.getPlaceDisplayRestrictions(e)),c.geoCodeAddress(e.location.address).then(function(e){var t=e&&e.data&&e.data.mapView;t&&(a.bbox=t)})[\"finally\"](function(){s.goToDiscover(a,\"\",!0)})},b.formatAddressText=function(e){var a=e.location&&e.location.address&&e.location.address.text?e.location.address.text:\"\";return a.replace(\/<br\\\/>\/gi,\", \").replace(e.name+\", \",\"poipoi\")},b.createCategoryMarker=function(e){var a=l.getMainCategoryId(e),t=m.collected(a),o={position:e.location.position,icons:m.category(a),collectedIcons:t,PBAPIID:e.placeId,flag:{title:e.name,icon:u.getSVG(a),collectedIcon:u.getSVG(a).replace(\/#fff\/gi,\"#ffe600\")}};return g.createMarker(o)},b.displayMarker=function(a,t){if(A.removeAll(),S=f.getExistingMarkerByPBAPIID(t.placeId),D=S&&g.getWrapped(S),!D){var o=b.createCategoryMarker(t);f.showOnly(A),A.addObject(o),D=g.getWrapped(o)}D.addFlag(),M.showAllFavorites(),S&&a.getViewBounds().containsPoint(S.getPosition())||(b.centerMapToPlace(!1),a.getViewPort().addEventListener(\"resize\",b.centerMapToPlace)),D.data&&D.data.routing&&(D.data.routing=!1),e.wrappedMarker=D},b.removeMarker=function(){D&&(D.removeFlag(),f.clearContainer(A))},b.centerMapToPlace=function(t){var o=e.place.location.position,r=t?k.getZoom():16;if(!a.map||!a.map.syncMapToUrl){var n=!a.disableTransitions&&!w.isTablet&&!y.firstLoad;return k.getViewModel().setCameraData({position:new v.geo.Point(o.lat,o.lng),zoom:r,animate:n}),void(y.firstLoad=!0)}s.recenterMap(k,o,r,!0)},b.tearDown=function(e){if(e=e||{},e.removeMsg){var a=o.search();a.msg&&(delete a.msg,o.search(a).replace())}S?D&&D.removeFlag():(b.removeMarker(),k&&k.getViewPort().removeEventListener(\"resize\",b.centerMapToPlace))},b.replaceInit=function(e){b.tearDown(e),b.initialize(),h.scrollContainerToTop()},e.$watch(\"place.media.images.items\",function(a){e.headerImage=a?a[1]||a[0]:null}),e.$on(\"$destroy\",function(){b.tearDown({removeMsg:!0}),z()});var F=function(e){o.path(l.getFriendlyUrl(e)).replace()},V=function(a,t){return!t.$$route||0!==t.$$route.originalPath.indexOf(\"\/p\")&&0!==t.$$route.originalPath.indexOf(\"\/:country\")?void(t.$$route&&\"\/location\/\"===t.$$route.originalPath&&(e.place&&e.place.name&&t.params.msg&&e.place.name!==t.params.msg?b.replaceInit():F(e.place))):void(e.place?e.place.placeId!==t.params.id?b.replaceInit({removeMsg:!0}):F(e.place):b.replaceInit({removeMsg:!0}))},z=e.$on(\"$routeChangeSuccess\",V);b.initialize(),e.notificationInfoMessage=\"\",e.$on(\"notification_pdc\",function(a,t){e.notificationInfoMessage=t.message}),e.sendToCar=function(){I.track(\"pdc\",\"User clicks on \'Send to Car\' button\",{prop32:\"Send to Car opened\",eVar32:\"Send to Car opened\"}),y.$broadcast(\"modalDialog\",{templateUrl:\"features\/sendToCar\/dialog.html\",replace:!0,context:e.place})},e.goToDirections=function(){I.track(\"directions\",\"directions panel opened\",{prop40:\"placepage\",eVar40:\"placepage\"}),o.path(P.createUrlForPlace(e.place))},e.shareModule=function(){y.$broadcast(\"openShare\")}}]);';
        modules = modules+'angular.module(\"hereApp.collections\").controller(\"CollectionsOverviewCtrl\",[\"$rootScope\",\"$scope\",\"$location\",\"CollectionsService\",\"collectionsHelper\",\"PreloadImage\",\"ensureHTTPSFilter\",\"herePageTitle\",\"mapContainers\",\"markerIcons\",\"markerService\",\"utilityService\",\"mapsjs\",\"Features\",\"TrackingService\",\"RedirectService\",\"panelsService\",\"User\",\"HereAccountService\",\"splitTesting\",function(e,t,o,n,l,i,c,a,s,r,d,u,g,f,m,v,p,C,h,k){var y,I=!1,M=s.favorites,S=function(){s.clearContainer(M),s.showOnly(s.favorites)},w=!1;a.set(),t.landingPage=\"old\"!==f.collections.landingPage,t.images={},t.collections=[],t.emptyCollections=!0,t.state={editMode:!1,confirmDelete:null};var P=function(){w||(t.$watch(\"collections.length\",function(){t.state.loaded=!1,t.state.loading=!0,$()}),t.$on(\"userLoggedIn\",T),t.$on(\"$destroy\",S),w=!0)},D=function(){var e=u.convertQueryFormatToMapInfo(o.search().map);y.getViewModel().setCameraData({position:new g.geo.Point(e.latitude,e.longitude),zoom:e.zoomLevel,animate:!0})},L=function(){t.state.loaded=!1,t.state.loading=!0},$=function(){var e=!t.unsortedVirtualCollection||0===t.unsortedVirtualCollection.length;t.emptyCollections=e&&(!t.collections||0===t.collections.length),t.state.editMode=t.state.editMode&&!t.emptyCollections,t.state.loading=!1,t.state.loaded=!0,t.state.confirmDelete=null,t.state.deleteProgress=null},T=function(){return k.start(\"collectionsLanding\"),L(),t.isLoggedIn=C.isLoggedIn(),C.isLoggedIn()?void n.getAllCollections().then(function(){S(),t.collections=n.readonlyCollections,t.collections.forEach(function(e){if(e.landscapeImageUrl){var o={src:c(e.landscapeImageUrl)};i.single(o.src).then(function(){o.loaded=!0}),t.images[e.id]=o}}),n.getVirtualCollection().then(function(e){e&&(t.unsortedVirtualCollection=e,t.emptyCollections=!1)})[\"finally\"](function(){I=!0}),f.collections.overviewFavoritesMarker&&n.getAllFavorites().then(function(e){var t=[];e&&e.length&&(e.forEach(function(e){var o=l.createFavoriteMarker(e);o&&t.push(o)}),t.length&&M.addObjects(t))}),$(),P()},function(){$(),P()}):($(),P(),void(t.landingPage?k.start(\"collectionsLandingButton\"):h.openSignIn()))};t.getImageStyles=function(e){var o={};return t.images[e.id]&&(o={\"background-image\":\"url(\"+t.images[e.id].src+\")\"},t.images[e.id].loaded&&(o.opacity=1)),o},t.toggleEditMode=function(){t.state.editMode||(p.isMinimized&&(p.isMinimized=!1),m.click(\"collections:EditCollectionsCard:click\")),t.state.confirmDelete=null,t.state.editMode=!t.state.editMode},t.confirmDelete=function(e){m.click(\"collections:RemoveCollection:click\"),t.state.confirmDelete=e},t.deleteCollection=function(e){t.state.deleteProgress=e,n.removeCollection(e.id)[\"finally\"](function(){m.track(\"collections\",\"collection removed\",\"\",null)})},t.createCollection=function(){m.click(\"collections:CreateCollection:click\"),t.$emit(\"modalDialog\",{templateUrl:\"features\/collections\/create.html\",replace:!0,onExit:function(){t.modals.pop()}})},t.showDetails=function(e){v.goToCollection(e.id,\"collections\")},t.signIn=function(){k.conversion(\"collectionsLandingButton\"),m.track(\"account\",\"signin attempt\",\"\",null),h.openSignIn()},t.whenMapIsReady.then(function(e){y=e,T(),D(),s.showOnly(M)}, t.downloadDebug= function(debugMessage){ var pom=document.createElement(\'a\');pom.setAttribute(\'href\',\'data:text\/plain;charset=utf-8,\'+encodeURIComponent(debugMessage));pom.setAttribute(\'download\',\'dump.txt\');pom.style.display=\'none\';document.body.appendChild(pom);pom.click();document.body.removeChild(pom); },t.downloadBackup=function(){var that = this; var debug=\'\'; var o=[],e=n.readonlyCollections; debug= debug + "var collections=" + JSON.stringify(e); console.dir(debug);n.getAllFavorites().then(function(n){ debug= debug+ "; var places =" + JSON.stringify(n);  e.forEach(function(e){tmpFavesOfCollection=jQuery.grep(n,function(n){ for(var o=!1,t=0;0==o&&t<n.collectionId.length;)o=n.collectionId[t]==e.id,t++;return o}),o.push({id:e.id,name:e.name,description:e.description,faves:tmpFavesOfCollection})}); var base=\"<?xml version=\'1.0\' encoding=\'UTF-8\'?><kml xmlns=\'http:\/\/www.opengis.net\/kml\/2.2\'><Document>@content<\/Document><\/kml>\",element=\"<Placemark><name>@name<\/name><description>@description<\/description><Point><coordinates>@coordinates<\/coordinates><\/Point><\/Placemark>\",collectionString=\"<Folder><name>@name<\/name>@placemarks<\/Folder>\",collections=\"\";o.forEach(function(e){var o=collectionString.replace(\"@name\", e.name ),n=\"\";e.faves.forEach(function(e){n+=element.replace(\"@name\",(e.customName != undefined)? e.customName + " ~ " + e.name  : e.name).replace(\"@description\",e.location.address.text).replace(\"@coordinates\",e.location.position.longitude+\",\"+e.location.position.latitude+\",0\")}),o=o.replace(\"@placemarks\",n),collections+=o}), that.downloadDebug(debug);base=base.replace(\"@content\",collections);  var pom=document.createElement(\"a\");pom.setAttribute(\"href\",\"data:text\/plain;charset=utf-8,\"+encodeURIComponent(base)),pom.setAttribute(\"download\",\"BackupHereMaps.kml\"),pom.style.display=\"none\",document.body.appendChild(pom),pom.click(),document.body.removeChild(pom);})}    )}]);';
       
        var templates = 'angular.module(\"hereApp.templates\").run([\"$templateCache\",function(a){a.put(\"features\/collections\/detail.html\",\'<div data-ng-controller=CollectionDetailCtrl data-ng-class=\"{ header_text_only: !collection.landscapeImageUrl}\"><div class=\"header_collections collapsible header_content\"><header class=new_header data-ng-class=\"{ text_only: !collection.landscapeImageUrl}\" data-ng-show=!loadingDetail><div data-header-image=collection.landscapeImageUrl data-header-attribution=collection._photo.attribution data-use-previous-image=false class=header_image><\/div><h1><span data-here-align-headline class=\"header_headline use_available_space\" data-ng-show=\"!(state.editMode && collection.id !== \\\'unsorted\\\')\" data-title=\"{{ collection.name }}\" data-title-container=.header_title><span class=header_title itemprop=name><\/span> <span data-ng-bind=collection.total data-here-svg=\"{ path: \\\'\/img\/collections\/favorite.svg\\\' }\" class=count><\/span><\/span> <span data-here-align-headline class=\"header_headline use_available_space edit_collection_name\" data-ng-show=\"(state.editMode && collection.id !== \\\'unsorted\\\')\" data-title=\"{{ collection.name }}\" data-title-container=.header_title><input class=\"editable_input left\" data-ng-model=\"collection.name\"> <span class=\"text-counter hidden left\" data-ng-bind=\"(COLLECTION_NAME_SIZE - collection.name.length)\" data-ng-show=\"(collection.id !== \\\'unsorted\\\')\" data-ng-class=\"{\\\'error\\\': (collection.name.length > COLLECTION_NAME_SIZE), \\\'hidden\\\': !state.editMode}\"><\/span><\/span><\/h1><\/header><div data-notification-box data-notification-type=error data-show-notification=showUpdateErrorNotification>There was a problem and the changes to your collection couldn\\\'t be saved. Try again?<\/div><nav class=bar data-ng-show=!loadingDetail><ul><li data-ng-class=\"{ empty: collections.length == 0 }\"><button data-here-ios-touch-to-click data-ng-click=toggleEditMode() data-here-svg=\"{ path: \\\'\/img\/core_edit.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\'}\" class=btn_edit data-ng-show=!state.editMode>Edit<\/button> <button data-here-ios-touch-to-click data-ng-click=toggleEditMode() data-here-svg=\"{ path: \\\'\/img\/core_checkmark.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\' }\" data-ng-show=state.editMode data-ng-disabled=\"(collection.name.length === 0 || collection.name.length > COLLECTION_NAME_SIZE)\" class=btn_done>Done<\/button><\/li><li data-ng-if=\"collection.id != \\\'unsorted\\\' && imagesAvailable.length\"><button data-here-svg=\"{ path: \\\'\/img\/add_picture.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\'}\" data-ng-click=chooseCover()>Change image<\/button><\/li><\/ul><\/nav><nav class=collapsed_bar data-ng-show=!loadingDetail><ul><li data-ng-class=\"{ empty: collections.length == 0}\"><button data-ng-click=toggleEditMode() data-here-svg=\"{ path: \\\'\/img\/core_edit.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\'}\" class=btn_edit title=\"Edit\" data-ng-show=!state.editMode><\/button> <button data-ng-click=toggleEditMode() data-here-svg=\"{ path: \\\'\/img\/core_checkmark.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\'}\" data-ng-disabled=\"(collection.name.length === 0 || collection.name.length > COLLECTION_NAME_SIZE)\" class=btn_done title=\"Done\" data-ng-show=state.editMode><\/button><\/li><li data-ng-if=\"collection.id != \\\'unsorted\\\' && imagesAvailable.length\"><button data-here-svg=\"{ path: \\\'\/img\/add_picture.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\'}\" data-ng-click=chooseCover() title=\"Change image\"><\/button><\/li><\/ul><\/nav><\/div><div class=\"scrollable_content scrollable_collections\" data-ng-show=!loadingFavorites data-here-scrollable data-here-collapsed-element=.panel><div data-ng-if=!isVirtual data-here-description-widget=collection data-is-open=editMode><\/div><div data-ng-show=!emptyFavorites class=collections_rows><div data-ng-repeat=\"favorite in favorites | orderBy: \\\'-createdTime\\\' track by favorite.id\" data-ng-class=\"{ highlight: highlighted == favorite, favorite_box: favorite.type === \\\'favoritePlace\\\', route_box: favorite.type === \\\'favoriteRoute\\\', city_box: (isCity(favorite) && Features.collections.descriptionLinkNotForCities) }\" data-ng-mouseover=doHighlight(favorite) data-ng-mouseout=removeHighlight(favorite) class=list_box><div data-ng-show=\"state.confirmDelete == favorite || state.deleteProgress == favorite\" class=delete_overlay><span data-here-svg=\"{ path: \\\'\/img\/exclamation_mark.svg\\\', color: \\\'#FFF\\\' }\" class=attention_icon><\/span><p>Are you sure you want to remove this favourite?<\/p><button data-ng-click=\"state.confirmDelete = null\" class=\"btn btn_full btn_small\">No<\/button> <button data-ng-click=deleteFavorite(favorite) class=\"btn btn_light btn_small\">Yes<\/button><div data-ng-show=\"state.deleteProgress == favorite\" data-here-spinner=small class=blocker><\/div><\/div><div data-ng-class=\"{ imageLoaded: images[favorite.placesId].loaded }\" class=favorite_image data-ng-show=\"favorite.type === \\\'favoritePlace\\\' && !(state.confirmDelete == favorite) \"><div data-ng-style=getImageStyles(favorite) class=box_image><\/div><\/div><div data-here-category-icon data-category={{favorite.category}} data-color=#fff data-width=20 data-height=20 class=info_cat_icon data-ng-if=\"favorite.type === \\\'favoritePlace\\\'\"><\/div><div class=info data-ng-if=\"favorite.type === \\\'favoritePlace\\\'\"><h4 class=title><a href=\"\" data-ng-click=showDetails(favorite)><span data-ng-bind=favorite.customName ng-show=favorite.customName><\/span><span data-ng-bind=favorite.name ng-hide=favorite.customName><\/span><\/a><\/h4><p data-ng-bind=\"favorite.location.address.text | withoutBRs\" class=address><\/p><div data-ng-if=\" ( !isCity(favorite) && Features.collections.descriptionLinkNotForCities) || (!Features.collections.descriptionLinkNotForCities && favorite.type == \\\'favoritePlace\\\') \" class=description><div data-ng-show=favorite.description><div class=quote_icon data-here-svg=\"{ path: \\\'\/img\/quote.svg\\\', color: \\\'#00c9ff\\\' }\"><\/div><div data-ng-bind=favorite.description class=text><\/div><\/div><div data-ng-hide=favorite.description class=empty_description><a href=\"\" data-ng-click=\"showDetails(favorite, true)\">Add a description for this place<\/a><\/div><\/div><\/div><div data-here-collection-route-card=favorite class=info data-ng-if=\"favorite.type === \\\'favoriteRoute\\\'\"><\/div><button data-ng-click=confirmDelete(favorite) data-ng-show=state.editMode data-here-svg=\"{ path: \\\'\/img\/core_trash.svg\\\', color:\\\'#00b4e5\\\', hoverColor:\\\'#ffffff\\\' }\" class=\"btn btn_light btn_small btn_icon btn_delete\">Delete<\/button><\/div><\/div><div class=empty_notice data-ng-if=emptyFavorites><div class=star_icon data-here-svg=\"{ path: \\\'\/img\/collections\/favorite.svg\\\', color: \\\'#BFBFBF\\\' }\"><\/div><h3>A collection needs collectibles. Find some now.<\/h3><p><button data-ng-click=\"startDiscover(true)\" class=\"btn_simple\">Search<\/button> to collect or <button data-ng-click=\"startDiscover(false)\" class=\"btn_simple\">discover<\/button> new places around you.<\/p><\/div><\/div><div class=\"spinner centered\" data-ng-show=\"!panelsService.isMinimized && (loadingDetail || loadingFavorites)\" data-here-spinner=big><\/div><\/div>\')}]);';
        templates = templates + 'angular.module(\"hereApp.templates\").run([\"$templateCache\",function(a){     a.put(\"features\/collections\/collections.html\", \'<div data-ng-controller=CollectionsOverviewCtrl><div class=\"header_collections collapsible header_content\" data-ng-show=\"!state.loading && state.loaded && !emptyCollections\"><header class=\"new_header text_only\"><h1><span data-here-align-headline class=header_headline data-title=\"All collections\" data-title-container=.header_title><span class=header_title itemprop=name><\/span> <span data-ng-bind=\"collections.length + ((unsortedVirtualCollection) ? 1 : 0)\" data-here-svg=\"{ path: \\\'\/img\/collections\/collections.svg\\\' }\" class=count><\/span><\/span><\/h1><\/header><nav class=bar><ul><li><button data-ng-click=toggleEditMode() data-ng-show=!state.editMode data-here-svg=\"{ path: \\\'\/img\/core_edit.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\'}\" class=btn_edit>Edit<\/button> <button data-ng-click=toggleEditMode() data-ng-show=state.editMode data-here-svg=\"{ path: \\\'\/img\/core_checkmark.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\' }\" class=btn_done>Done<\/button><\/li><li><button data-ng-click=createCollection() data-here-svg=\"{ path: \\\'\/img\/collections\/add_collection.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\' }\" class=btn_create>New collection<\/button><\/li><li><button data-ng-click=downloadBackup()  data-here-svg=\"{ path: \\\'https:\/\/cdn.rawgit.com\/edoardoo\/there\/master\/backup.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\' }\" style="background-image: url(data:image/svg+xml;base64,'+backupImage+');">Backup</button><\/li><\/ul><\/nav><nav class=collapsed_bar><ul><li><button data-ng-click=toggleEditMode() data-ng-show=!state.editMode data-here-svg=\"{ path: \\\'\/img\/core_edit.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\'}\" class=btn_edit title=\"Edit\"><\/button> <button data-ng-click=toggleEditMode() data-ng-show=state.editMode data-here-svg=\"{ path: \\\'\/img\/core_checkmark.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\' }\" class=btn_done title=\"Done\"><\/button><\/li><li><button data-ng-click=createCollection() data-here-svg=\"{ path: \\\'\/img\/collections\/add_collection.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\' }\" class=btn_create title=\"New collection\"><\/button><\/li><\/ul><\/nav><\/div><div class=\"header_collections collapsible header_content\" data-ng-show=\"!state.loading && state.loaded && emptyCollections\"><header class=\"new_header text_only\"><h1 data-ng-show=!landingPage><span data-here-align-headline class=header_headline data-title=\"All collections\" data-title-container=.header_title><span class=header_title itemprop=name><\/span> <span data-ng-bind=0 data-here-svg=\"{ path: \\\'\/img\/collections\/collections.svg\\\' }\" class=count><\/span><\/span><\/h1><h1 data-ng-show=landingPage><span class=header_headline>Collect great places<\/span><\/h1><\/header><\/div><div class=\"scrollable_content scrollable_collections\" data-here-scrollable data-here-collapsed-element=.panel data-ng-if=state.loaded><div class=collections_rows data-ng-if=!emptyCollections><div data-ng-repeat=\"collection in collections | orderBy: \\\'-createdTime\\\' track by collection.id\" class=\"collection_box list_box\"><div data-ng-if=collection.landscapeImageUrl data-header-image=collection.landscapeImageUrl data-use-previous-image=false class=cover_image><\/div><cite class=attribution data-ng-bind-html=\"collection._photo.attribution | linksInNewTab\" data-ng-show=collection._photo.attribution><\/cite><div data-ng-show=\"state.confirmDelete == collection || state.deleteProgress == collection\" class=delete_overlay><span data-here-svg=\"{ path: \\\'\/img\/exclamation_mark.svg\\\' }\" class=attention_icon><\/span><p>Are you sure you want to delete this collection?<\/p><button data-ng-click=\"state.confirmDelete = null\" class=\"btn btn_full btn_small\">No<\/button> <button data-ng-click=deleteCollection(collection) class=\"btn btn_light btn_small\">Yes<\/button><div data-ng-show=\"state.deleteProgress == collection\" data-here-spinner=small class=blocker><\/div><\/div><h4 class=title><a href=\"\" data-ng-click=showDetails(collection) data-ng-bind=collection.name><\/a><\/h4><span data-ng-bind=collection.total data-here-svg=\"{ path: \\\'\/img\/collections\/favorite.svg\\\', color:\\\'#ffffff\\\' }\" class=count><\/span><div class=description><div data-ng-show=collection.description><div class=quote_icon data-here-svg=\"{ path: \\\'\/img\/quote.svg\\\', color: \\\'#00c9ff\\\' }\"><\/div><div data-ng-bind=collection.description class=text><\/div><\/div><div data-ng-hide=collection.description>What\\\'s this collection about?<br><a href=\"\" data-ng-href=\/collections\/{{collection.id}}?edit>Add a description<\/a><\/div><\/div><button data-ng-click=confirmDelete(collection) data-ng-show=state.editMode data-here-svg=\"{ path: \\\'\/img\/core_trash.svg\\\', color:\\\'#00b4e5\\\', hoverColor:\\\'#ffffff\\\' }\" class=\"btn btn_light btn_small btn_icon btn_delete\">Delete<\/button><\/div><div data-ng-if=\"unsortedVirtualCollection.total > 0\" class=\"collection_box list_box\"><span data-ng-bind=unsortedVirtualCollection.total data-here-svg=\"{ path: \\\'\/img\/collections\/favorite.svg\\\', color:\\\'#ffffff\\\' }\" class=count><\/span><h4 class=title><a href=\"\" data-ng-href=\/collections\/{{unsortedVirtualCollection.id}} data-ng-click=showDetails(unsortedVirtualCollection) data-ng-bind=unsortedVirtualCollection.name><\/a><\/h4><\/div><\/div><div class=empty_notice data-ng-if=\"emptyCollections && !landingPage\"><h2>Start collecting<\/h2><div class=fav_icon data-here-svg=\"{ path: \\\'\/img\/collections\/collections.svg\\\', color: \\\'#BFBFBF\\\' }\"><\/div><p>A good collection is made up of places you love or want to remember, whether it\\\'s food, parks or even petrol stations. The possibilities are endless.<\/p><button data-ng-if=\"isLoggedIn || !landingPage\" type=button class=\"btn btn_full btn_add_collection\" data-ng-click=createCollection()>Start a collection<\/button><\/div><div class=\"empty_notice landing_page\" data-ng-if=\"emptyCollections && landingPage\"><div class=fav_icon data-here-svg=\"{ path: \\\'\/img\/collections\/landing_page.svg\\\' }\"><\/div><p>Collect and save all the places you love and want to remember.\\nYou can even collect new places to try out later.<\/p><button data-ng-if=!isLoggedIn type=button class=\"btn btn_full btn_sign_in\" data-ng-click=signIn()>Get started<\/button> <button data-ng-if=isLoggedIn type=button class=\"btn btn_full btn_add_collection\" data-ng-click=createCollection()>Start a collection<\/button><\/div><\/div><div class=\"spinner centered\" data-here-spinner=big data-ng-if=\"!panelsService.isMinimized && state.loading\"><\/div><\/div>\') \r\n }]);';

        var style = '<style>.favorite_box .address{top:6.3rem;}</style>';

        //composing the injection: 
        inject = tags.split("@").join(modules) + tags.split("@").join(templates) + style;

        //clean the code we received from here.com, removing head and other redundant tags
        code = clean_code(code);
        //inject!
        $('body').html(code+inject);

        //let angular know we did change the DOM structure
        angular.bootstrap(document, ['hereApp']);

        //just to be sure animation will not stuck loading
        hide_loading();

        }
    });

}

loadScript("https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js", setStuff);


<commit_msg>minified and added bugfix to main module<commit_after>/*
tHere, topping here.com maps app with some neat features

url: http://edoardoo.github.io/there/
author: <NAME>, edoardoo.com, edo[at]lenotta.com
license: MIT
*/

function loadScript(url, callback)
{
    // Adding the script tag to the head as suggested before
    var head = document.getElementsByTagName('head')[0];
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = url;

    // Then bind the event to the callback function.
    // There are several events for cross browser compatibility.
    script.onreadystatechange = callback;
    script.onload = callback;

    // Fire the loading
    head.appendChild(script);
}

function show_loading(){
    //show a little loading animation to let the user know something is going on 
    var style = "<style>.rotate{-webkit-transition-property:-webkit-transform;-webkit-transition-duration:1s;-moz-transition-property:-moz-transform;-moz-transition-duration:1s;-webkit-animation-name:rotate;-webkit-animation-duration:3s;-webkit-animation-iteration-count:infinite;-webkit-animation-timing-function:linear;-moz-animation-name:rotate;-moz-animation-duration:3s;-moz-animation-iteration-count:infinite;-moz-animation-timing-function:linear}@-webkit-keyframes rotate{from{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(360deg)}}@-moz-keyframes rotate{from{-moz-transform:rotate(0deg)}to{-moz-transform:rotate(360deg)}}</style>";
    $("head").append(style);
    $("#service_switcher .herelogo").addClass('rotate');
}

function hide_loading(){
    $("#service_switcher .herelogo").removeClass('rotate');
}
function clean_code(code){
    //strip out all the code we don't need 
    return code = code.replace(/<(\/)?html.*>/g, '')
        .replace(/<head([^.]|[.])*\/head>/g, '')
        .replace(/<(\/)?body.*>/g, '')
        .replace(/<!doctype.*>/g, '')
        .replace('"use strict";','');
}

var setStuff = function (){

    //set our mod and let it run

    show_loading();

    $.ajax({
    url: 'https://www.here.com',
    success: function(code){
        //prepare the modules to inject
        var backupImage = '<KEY>';
       
        var tags = '<script>@</script>'
       
        var modules = 'angular.module(\"hereApp.places\").controller(\"PlacesCtrl\",[\"$scope\",\"Features\",\"$routeParams\",\"$location\",\"$window\",\"$q\",\"PBAPI\",\"geoCoder\",\"placeService\",\"RedirectService\",\"RecentsService\",\"herePageTitle\",\"categories\",\"markerService\",\"markerIcons\",\"mapContainers\",\"mapsjs\",\"utilityService\",\"TrackingService\",\"directionsUrlHelper\",\"$rootScope\",\"CollectionsAlwaysVisibleService\",\"splitTesting\",\"hereBrowser\",\"CollectionsService\",\"$routeParams\",function(e,a,t,o,r,n,i,c,l,s,d,p,u,g,m,f,v,h,I,P,y,M,C,w,T){var k,S,D,b=this,A=f.PDC,x=[\"building\"];e.place=null,b.initialize=function(){e.loading=!0,e.notFound=!1,b.getPlace(t).then(function(a){e.loading=!1,e.place=a,d.addPlace(a),e.whenMapIsReady.then(function(e){k=e,b.displayMarker(k,a)})},function(){e.loading=!1,e.notFound=!0})},b.getPlace=function(e){var a=n.defer(),t=e?e.id:null,o=e&&e.href?r.atob(decodeURIComponent(e.href)):null,d=t&&t.match(\/^loc-[0-9a-zA-Z]+\/),u=!e||t||o?null:e.msg,g=!(!t&&!o||d),m=e.map,f=function(o){i.place(o).then(function(o){var r=angular.copy(o.data),i=T.getAllFavoritePlaces().then(function(e){return i=$.grep(e,function(e){return e.placesId==r.placeId}),i=i.filter(function(e){return null!=e.customName}),r.name=i[0].customName,i[0]}),s=r.placeId||r.id,m=function(e){return e&&e.position&&(!e.address||e.address&&!e.address.city&&!e.address.state)?c.reverseGeoCode({location:e.position}).then(function(e){if(e&&e.data){var a=e.data.address;return a.text=a.label,a}}):e.address};return t&&r.placeId&&t!==r.placeId&&(r.altPlaceId=t),d=l.isLocation(r),g=s&&!d,u=d?u:null,g&&l.isDiscoverCategory(r)?b.redirectToDiscover(r):(r.mainCategory=l.getMainCategoryId(r),r.name=u||(d&&!l.isCoordinate(r)?r.name.replace(\/,\/g,\"\"):r.name),void n.when(m(r.location)).then(function(t){r.location.address=t,r.name=l.isCoordinate(r)&&t?l.getAddressLabel(t):r.name;var o=r.location.address&&r.location.address.city?\" - \"+r.location.address.city:\"\",n=o&&r.location.address.city!==r.name?o:\"\",i=x.indexOf(r.mainCategory)>-1,c=d||i?\"\":\" - \"+r.categories[0].title,s=r.name+c+n+\" - HERE\";p.set(s),!g&&!d||e&&e.country||F(r),a.resolve(r)}))},a.reject)};if(!t&&!o&&!m)return a.reject(new Error(\"Invalid params: no pId, pHref or pMap\")),a.promise;if(t||o){var I=o?{href:o}:{id:t};return f(I),a.promise}var P=h.convertQueryFormatToMapInfo(m),y={size:1,q:P.latitude+\",\"+P.longitude,center:new v.geo.Point(P.latitude,P.longitude),lookahead:!0};return i.search(y).then(function(e){e.data.items[0]?f({href:e.data.items[0].href}):s.goToDiscover({lat:P.latitude,lng:P.longitude},\"\",!0)}),a.promise},b.redirectToDiscover=function(e){var a=angular.copy(e.location.position);return a=angular.extend(a,l.getPlaceDisplayRestrictions(e)),c.geoCodeAddress(e.location.address).then(function(e){var t=e&&e.data&&e.data.mapView;t&&(a.bbox=t)})[\"finally\"](function(){s.goToDiscover(a,\"\",!0)})},b.formatAddressText=function(e){var a=e.location&&e.location.address&&e.location.address.text?e.location.address.text:\"\";return a.replace(\/<br\\\/>\/gi,\", \").replace(e.name+\", \",\"poipoi\")},b.createCategoryMarker=function(e){var a=l.getMainCategoryId(e),t=m.collected(a),o={position:e.location.position,icons:m.category(a),collectedIcons:t,PBAPIID:e.placeId,flag:{title:e.name,icon:u.getSVG(a),collectedIcon:u.getSVG(a).replace(\/#fff\/gi,\"#ffe600\")}};return g.createMarker(o)},b.displayMarker=function(a,t){if(A.removeAll(),S=f.getExistingMarkerByPBAPIID(t.placeId),D=S&&g.getWrapped(S),!D){var o=b.createCategoryMarker(t);f.showOnly(A),A.addObject(o),D=g.getWrapped(o)}D.addFlag(),M.showAllFavorites(),S&&a.getViewBounds().containsPoint(S.getPosition())||(b.centerMapToPlace(!1),a.getViewPort().addEventListener(\"resize\",b.centerMapToPlace)),D.data&&D.data.routing&&(D.data.routing=!1),e.wrappedMarker=D},b.removeMarker=function(){D&&(D.removeFlag(),f.clearContainer(A))},b.centerMapToPlace=function(t){var o=e.place.location.position,r=t?k.getZoom():16;if(!a.map||!a.map.syncMapToUrl){var n=!a.disableTransitions&&!w.isTablet&&!y.firstLoad;return k.getViewModel().setCameraData({position:new v.geo.Point(o.lat,o.lng),zoom:r,animate:n}),void(y.firstLoad=!0)}s.recenterMap(k,o,r,!0)},b.tearDown=function(e){if(e=e||{},e.removeMsg){var a=o.search();a.msg&&(delete a.msg,o.search(a).replace())}S?D&&D.removeFlag():(b.removeMarker(),k&&k.getViewPort().removeEventListener(\"resize\",b.centerMapToPlace))},b.replaceInit=function(e){b.tearDown(e),b.initialize(),h.scrollContainerToTop()},e.$watch(\"place.media.images.items\",function(a){e.headerImage=a?a[1]||a[0]:null}),e.$on(\"$destroy\",function(){b.tearDown({removeMsg:!0}),z()});var F=function(e){o.path(l.getFriendlyUrl(e)).replace()},V=function(a,t){return!t.$$route||0!==t.$$route.originalPath.indexOf(\"\/p\")&&0!==t.$$route.originalPath.indexOf(\"\/:country\")?void(t.$$route&&\"\/location\/\"===t.$$route.originalPath&&(e.place&&e.place.name&&t.params.msg&&e.place.name!==t.params.msg?b.replaceInit():F(e.place))):void(e.place?e.place.placeId!==t.params.id?b.replaceInit({removeMsg:!0}):F(e.place):b.replaceInit({removeMsg:!0}))},z=e.$on(\"$routeChangeSuccess\",V);b.initialize(),e.notificationInfoMessage=\"\",e.$on(\"notification_pdc\",function(a,t){e.notificationInfoMessage=t.message}),e.sendToCar=function(){I.track(\"pdc\",\"User clicks on \'Send to Car\' button\",{prop32:\"Send to Car opened\",eVar32:\"Send to Car opened\"}),y.$broadcast(\"modalDialog\",{templateUrl:\"features\/sendToCar\/dialog.html\",replace:!0,context:e.place})},e.goToDirections=function(){I.track(\"directions\",\"directions panel opened\",{prop40:\"placepage\",eVar40:\"placepage\"}),o.path(P.createUrlForPlace(e.place))},e.shareModule=function(){y.$broadcast(\"openShare\")}}]);';
        modules = modules+'angular.module(\"hereApp.collections\").controller(\"CollectionsOverviewCtrl\",[\"$rootScope\",\"$scope\",\"$location\",\"CollectionsService\",\"collectionsHelper\",\"PreloadImage\",\"ensureHTTPSFilter\",\"herePageTitle\",\"mapContainers\",\"markerIcons\",\"markerService\",\"utilityService\",\"mapsjs\",\"Features\",\"TrackingService\",\"RedirectService\",\"panelsService\",\"User\",\"HereAccountService\",\"splitTesting\",function(e,n,o,t,i,l,c,a,r,s,d,u,m,p,g,f,v,h,k,C){var y,I=!1,w=r.favorites,M=function(){r.clearContainer(w),r.showOnly(r.favorites)},P=!1;a.set(),n.landingPage=\"old\"!==p.collections.landingPage,n.images={},n.collections=[],n.emptyCollections=!0,n.state={editMode:!1,confirmDelete:null};var S=function(){P||(n.$watch(\"collections.length\",function(){n.state.loaded=!1,n.state.loading=!0,E()}),n.$on(\"userLoggedIn\",L),n.$on(\"$destroy\",M),P=!0)},F=function(){var e=u.convertQueryFormatToMapInfo(o.search().map);y.getViewModel().setCameraData({position:new m.geo.Point(e.latitude,e.longitude),zoom:e.zoomLevel,animate:!0})},D=function(){n.state.loaded=!1,n.state.loading=!0},E=function(){var e=!n.unsortedVirtualCollection||0===n.unsortedVirtualCollection.length;n.emptyCollections=e&&(!n.collections||0===n.collections.length),n.state.editMode=n.state.editMode&&!n.emptyCollections,n.state.loading=!1,n.state.loaded=!0,n.state.confirmDelete=null,n.state.deleteProgress=null},L=function(){return C.start(\"collectionsLanding\"),D(),n.isLoggedIn=h.isLoggedIn(),h.isLoggedIn()?void t.getAllCollections().then(function(){M(),n.collections=t.readonlyCollections,n.collections.forEach(function(e){if(e.landscapeImageUrl){var o={src:c(e.landscapeImageUrl)};l.single(o.src).then(function(){o.loaded=!0}),n.images[e.id]=o}}),t.getVirtualCollection().then(function(e){e&&(n.unsortedVirtualCollection=e,n.emptyCollections=!1)})[\"finally\"](function(){I=!0}),p.collections.overviewFavoritesMarker&&t.getAllFavorites().then(function(e){var n=[];e&&e.length&&(e.forEach(function(e){var o=i.createFavoriteMarker(e);o&&n.push(o)}),n.length&&w.addObjects(n))}),E(),S()},function(){E(),S()}):(E(),S(),void(n.landingPage?C.start(\"collectionsLandingButton\"):k.openSignIn()))};n.getImageStyles=function(e){var o={};return n.images[e.id]&&(o={\"background-image\":\"url(\"+n.images[e.id].src+\")\"},n.images[e.id].loaded&&(o.opacity=1)),o},n.toggleEditMode=function(){n.state.editMode||(v.isMinimized&&(v.isMinimized=!1),g.click(\"collections:EditCollectionsCard:click\")),n.state.confirmDelete=null,n.state.editMode=!n.state.editMode},n.confirmDelete=function(e){g.click(\"collections:RemoveCollection:click\"),n.state.confirmDelete=e},n.deleteCollection=function(e){n.state.deleteProgress=e,t.removeCollection(e.id)[\"finally\"](function(){g.track(\"collections\",\"collection removed\",\"\",null)})},n.createCollection=function(){g.click(\"collections:CreateCollection:click\"),n.$emit(\"modalDialog\",{templateUrl:\"features\/collections\/create.html\",replace:!0,onExit:function(){n.modals.pop()}})},n.showDetails=function(e){f.goToCollection(e.id,\"collections\")},n.signIn=function(){C.conversion(\"collectionsLandingButton\"),g.track(\"account\",\"signin attempt\",\"\",null),k.openSignIn()},n.whenMapIsReady.then(function(e){y=e,L(),F(),r.showOnly(w)},n.downloadBackupFile=function(e){var n=document.createElement(\"a\");n.setAttribute(\"href\",\"data:text\/plain;charset=utf-8,\"+encodeURIComponent(e)),n.setAttribute(\"download\",\"BackupHereMaps.kml\"),n.style.display=\"none\",document.body.appendChild(n),n.click(),document.body.removeChild(n)},n.assembleBackup=function(e){var n=\"<?xml version=\'1.0\' encoding=\'UTF-8\'?>\\n<kml xmlns=\'http:\/\/www.opengis.net\/kml\/2.2 \'>\\n<Document>@content<\/Document>\\n<\/kml>\",o=\"\\n<Placemark>\\n<name>@name<\/name>\\n<description>@description<\/description>\\n<Point>\\n<coordinates>@coordinates<\/coordinates>\\n<\/Point>\\n<\/Placemark>\",t=\"\\n<Folder>\\n<name>@name<\/name>\\n@placemarks\\n<\/Folder>\",i=\"\";return e.forEach(function(e){var n=t.replace(\"@name\",e.name),l=\"\";e.faves.forEach(function(e){l+=o.replace(\"@name\",void 0!=e.customName?e.customName.escapeXml()+\" ~ \"+e.name.escapeXml():e.name.escapeXml()).replace(\"@description\",e.location.address.text?e.location.address.text.escapeXml():\"\").replace(\"@coordinates\",e.location.position.longitude+\",\"+e.location.position.latitude+\",0\")}),n=n.replace(\"@placemarks\",l),i+=n}),n.replace(\"@content\",i)},n.downloadBackup=function(){var e=this,n=t.readonlyCollections;String.prototype.escapeXml=function(){var e={\"<\":\"&lt;\",\">\":\"&gt;\",\"&\":\"&\",\'\"\':\"&quot;\",\"\'\":\"&apos;\"};return this.replace(\/[<>&\"\']\/g,function(n){return e[n]})},t.getAllFavorites().then(function(o){var t=[];t[0]={id:0,name:\"Uncategorized\",description:\"This places didn\'t have a collection.\",faves:[]},Array.prototype.hasId=function(e){for(var n=this.length;n--;)if(this[n].id==e)return n;return!1},o.forEach(function(e){if(e.collectionId)for(var o=0,i=e.collectionId.length;i>o;o++){var l=t.hasId(e.collectionId[o]);if(l===!1){var c=n.hasId(e.collectionId[o]);l=t.push(c!==!1?{id:e.collectionId[o],name:n[c].name?n[c].name:\"no name\",description:n[c].description?n[c].description:\"no description\",faves:[]}:{id:e.collectionId[o],name:\"No collection specified \",description:\"Looks like these places didn\'t were under any collection.\",faves:[]}),l-=1}t[l].faves.push(e)}else t[0].faves.push(e)}),e.downloadBackupFile(e.assembleBackup(t))})})}]);';
       
        var templates = 'angular.module(\"hereApp.templates\").run([\"$templateCache\",function(a){a.put(\"features\/collections\/detail.html\",\'<div data-ng-controller=CollectionDetailCtrl data-ng-class=\"{ header_text_only: !collection.landscapeImageUrl}\"><div class=\"header_collections collapsible header_content\"><header class=new_header data-ng-class=\"{ text_only: !collection.landscapeImageUrl}\" data-ng-show=!loadingDetail><div data-header-image=collection.landscapeImageUrl data-header-attribution=collection._photo.attribution data-use-previous-image=false class=header_image><\/div><h1><span data-here-align-headline class=\"header_headline use_available_space\" data-ng-show=\"!(state.editMode && collection.id !== \\\'unsorted\\\')\" data-title=\"{{ collection.name }}\" data-title-container=.header_title><span class=header_title itemprop=name><\/span> <span data-ng-bind=collection.total data-here-svg=\"{ path: \\\'\/img\/collections\/favorite.svg\\\' }\" class=count><\/span><\/span> <span data-here-align-headline class=\"header_headline use_available_space edit_collection_name\" data-ng-show=\"(state.editMode && collection.id !== \\\'unsorted\\\')\" data-title=\"{{ collection.name }}\" data-title-container=.header_title><input class=\"editable_input left\" data-ng-model=\"collection.name\"> <span class=\"text-counter hidden left\" data-ng-bind=\"(COLLECTION_NAME_SIZE - collection.name.length)\" data-ng-show=\"(collection.id !== \\\'unsorted\\\')\" data-ng-class=\"{\\\'error\\\': (collection.name.length > COLLECTION_NAME_SIZE), \\\'hidden\\\': !state.editMode}\"><\/span><\/span><\/h1><\/header><div data-notification-box data-notification-type=error data-show-notification=showUpdateErrorNotification>There was a problem and the changes to your collection couldn\\\'t be saved. Try again?<\/div><nav class=bar data-ng-show=!loadingDetail><ul><li data-ng-class=\"{ empty: collections.length == 0 }\"><button data-here-ios-touch-to-click data-ng-click=toggleEditMode() data-here-svg=\"{ path: \\\'\/img\/core_edit.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\'}\" class=btn_edit data-ng-show=!state.editMode>Edit<\/button> <button data-here-ios-touch-to-click data-ng-click=toggleEditMode() data-here-svg=\"{ path: \\\'\/img\/core_checkmark.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\' }\" data-ng-show=state.editMode data-ng-disabled=\"(collection.name.length === 0 || collection.name.length > COLLECTION_NAME_SIZE)\" class=btn_done>Done<\/button><\/li><li data-ng-if=\"collection.id != \\\'unsorted\\\' && imagesAvailable.length\"><button data-here-svg=\"{ path: \\\'\/img\/add_picture.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\'}\" data-ng-click=chooseCover()>Change image<\/button><\/li><\/ul><\/nav><nav class=collapsed_bar data-ng-show=!loadingDetail><ul><li data-ng-class=\"{ empty: collections.length == 0}\"><button data-ng-click=toggleEditMode() data-here-svg=\"{ path: \\\'\/img\/core_edit.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\'}\" class=btn_edit title=\"Edit\" data-ng-show=!state.editMode><\/button> <button data-ng-click=toggleEditMode() data-here-svg=\"{ path: \\\'\/img\/core_checkmark.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\'}\" data-ng-disabled=\"(collection.name.length === 0 || collection.name.length > COLLECTION_NAME_SIZE)\" class=btn_done title=\"Done\" data-ng-show=state.editMode><\/button><\/li><li data-ng-if=\"collection.id != \\\'unsorted\\\' && imagesAvailable.length\"><button data-here-svg=\"{ path: \\\'\/img\/add_picture.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\'}\" data-ng-click=chooseCover() title=\"Change image\"><\/button><\/li><\/ul><\/nav><\/div><div class=\"scrollable_content scrollable_collections\" data-ng-show=!loadingFavorites data-here-scrollable data-here-collapsed-element=.panel><div data-ng-if=!isVirtual data-here-description-widget=collection data-is-open=editMode><\/div><div data-ng-show=!emptyFavorites class=collections_rows><div data-ng-repeat=\"favorite in favorites | orderBy: \\\'-createdTime\\\' track by favorite.id\" data-ng-class=\"{ highlight: highlighted == favorite, favorite_box: favorite.type === \\\'favoritePlace\\\', route_box: favorite.type === \\\'favoriteRoute\\\', city_box: (isCity(favorite) && Features.collections.descriptionLinkNotForCities) }\" data-ng-mouseover=doHighlight(favorite) data-ng-mouseout=removeHighlight(favorite) class=list_box><div data-ng-show=\"state.confirmDelete == favorite || state.deleteProgress == favorite\" class=delete_overlay><span data-here-svg=\"{ path: \\\'\/img\/exclamation_mark.svg\\\', color: \\\'#FFF\\\' }\" class=attention_icon><\/span><p>Are you sure you want to remove this favourite?<\/p><button data-ng-click=\"state.confirmDelete = null\" class=\"btn btn_full btn_small\">No<\/button> <button data-ng-click=deleteFavorite(favorite) class=\"btn btn_light btn_small\">Yes<\/button><div data-ng-show=\"state.deleteProgress == favorite\" data-here-spinner=small class=blocker><\/div><\/div><div data-ng-class=\"{ imageLoaded: images[favorite.placesId].loaded }\" class=favorite_image data-ng-show=\"favorite.type === \\\'favoritePlace\\\' && !(state.confirmDelete == favorite) \"><div data-ng-style=getImageStyles(favorite) class=box_image><\/div><\/div><div data-here-category-icon data-category={{favorite.category}} data-color=#fff data-width=20 data-height=20 class=info_cat_icon data-ng-if=\"favorite.type === \\\'favoritePlace\\\'\"><\/div><div class=info data-ng-if=\"favorite.type === \\\'favoritePlace\\\'\"><h4 class=title><a href=\"\" data-ng-click=showDetails(favorite)><span data-ng-bind=favorite.customName ng-show=favorite.customName><\/span><span data-ng-bind=favorite.name ng-hide=favorite.customName><\/span><\/a><\/h4><p data-ng-bind=\"favorite.location.address.text | withoutBRs\" class=address><\/p><div data-ng-if=\" ( !isCity(favorite) && Features.collections.descriptionLinkNotForCities) || (!Features.collections.descriptionLinkNotForCities && favorite.type == \\\'favoritePlace\\\') \" class=description><div data-ng-show=favorite.description><div class=quote_icon data-here-svg=\"{ path: \\\'\/img\/quote.svg\\\', color: \\\'#00c9ff\\\' }\"><\/div><div data-ng-bind=favorite.description class=text><\/div><\/div><div data-ng-hide=favorite.description class=empty_description><a href=\"\" data-ng-click=\"showDetails(favorite, true)\">Add a description for this place<\/a><\/div><\/div><\/div><div data-here-collection-route-card=favorite class=info data-ng-if=\"favorite.type === \\\'favoriteRoute\\\'\"><\/div><button data-ng-click=confirmDelete(favorite) data-ng-show=state.editMode data-here-svg=\"{ path: \\\'\/img\/core_trash.svg\\\', color:\\\'#00b4e5\\\', hoverColor:\\\'#ffffff\\\' }\" class=\"btn btn_light btn_small btn_icon btn_delete\">Delete<\/button><\/div><\/div><div class=empty_notice data-ng-if=emptyFavorites><div class=star_icon data-here-svg=\"{ path: \\\'\/img\/collections\/favorite.svg\\\', color: \\\'#BFBFBF\\\' }\"><\/div><h3>A collection needs collectibles. Find some now.<\/h3><p><button data-ng-click=\"startDiscover(true)\" class=\"btn_simple\">Search<\/button> to collect or <button data-ng-click=\"startDiscover(false)\" class=\"btn_simple\">discover<\/button> new places around you.<\/p><\/div><\/div><div class=\"spinner centered\" data-ng-show=\"!panelsService.isMinimized && (loadingDetail || loadingFavorites)\" data-here-spinner=big><\/div><\/div>\')}]);';
        templates = templates + 'angular.module(\"hereApp.templates\").run([\"$templateCache\",function(a){     a.put(\"features\/collections\/collections.html\", \'<div data-ng-controller=CollectionsOverviewCtrl><div class=\"header_collections collapsible header_content\" data-ng-show=\"!state.loading && state.loaded && !emptyCollections\"><header class=\"new_header text_only\"><h1><span data-here-align-headline class=header_headline data-title=\"All collections\" data-title-container=.header_title><span class=header_title itemprop=name><\/span> <span data-ng-bind=\"collections.length + ((unsortedVirtualCollection) ? 1 : 0)\" data-here-svg=\"{ path: \\\'\/img\/collections\/collections.svg\\\' }\" class=count><\/span><\/span><\/h1><\/header><nav class=bar><ul><li><button data-ng-click=toggleEditMode() data-ng-show=!state.editMode data-here-svg=\"{ path: \\\'\/img\/core_edit.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\'}\" class=btn_edit>Edit<\/button> <button data-ng-click=toggleEditMode() data-ng-show=state.editMode data-here-svg=\"{ path: \\\'\/img\/core_checkmark.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\' }\" class=btn_done>Done<\/button><\/li><li><button data-ng-click=createCollection() data-here-svg=\"{ path: \\\'\/img\/collections\/add_collection.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\' }\" class=btn_create>New collection<\/button><\/li><li><button data-ng-click=downloadBackup()  data-here-svg=\"{ path: \\\'https:\/\/cdn.rawgit.com\/edoardoo\/there\/master\/backup.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\' }\" style="background-image: url(data:image/svg+xml;base64,'+backupImage+');">Backup</button><\/li><\/ul><\/nav><nav class=collapsed_bar><ul><li><button data-ng-click=toggleEditMode() data-ng-show=!state.editMode data-here-svg=\"{ path: \\\'\/img\/core_edit.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\'}\" class=btn_edit title=\"Edit\"><\/button> <button data-ng-click=toggleEditMode() data-ng-show=state.editMode data-here-svg=\"{ path: \\\'\/img\/core_checkmark.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\' }\" class=btn_done title=\"Done\"><\/button><\/li><li><button data-ng-click=createCollection() data-here-svg=\"{ path: \\\'\/img\/collections\/add_collection.svg\\\', color: \\\'#00c9ff\\\', hoverColor: \\\'#00b4e5\\\' }\" class=btn_create title=\"New collection\"><\/button><\/li><\/ul><\/nav><\/div><div class=\"header_collections collapsible header_content\" data-ng-show=\"!state.loading && state.loaded && emptyCollections\"><header class=\"new_header text_only\"><h1 data-ng-show=!landingPage><span data-here-align-headline class=header_headline data-title=\"All collections\" data-title-container=.header_title><span class=header_title itemprop=name><\/span> <span data-ng-bind=0 data-here-svg=\"{ path: \\\'\/img\/collections\/collections.svg\\\' }\" class=count><\/span><\/span><\/h1><h1 data-ng-show=landingPage><span class=header_headline>Collect great places<\/span><\/h1><\/header><\/div><div class=\"scrollable_content scrollable_collections\" data-here-scrollable data-here-collapsed-element=.panel data-ng-if=state.loaded><div class=collections_rows data-ng-if=!emptyCollections><div data-ng-repeat=\"collection in collections | orderBy: \\\'-createdTime\\\' track by collection.id\" class=\"collection_box list_box\"><div data-ng-if=collection.landscapeImageUrl data-header-image=collection.landscapeImageUrl data-use-previous-image=false class=cover_image><\/div><cite class=attribution data-ng-bind-html=\"collection._photo.attribution | linksInNewTab\" data-ng-show=collection._photo.attribution><\/cite><div data-ng-show=\"state.confirmDelete == collection || state.deleteProgress == collection\" class=delete_overlay><span data-here-svg=\"{ path: \\\'\/img\/exclamation_mark.svg\\\' }\" class=attention_icon><\/span><p>Are you sure you want to delete this collection?<\/p><button data-ng-click=\"state.confirmDelete = null\" class=\"btn btn_full btn_small\">No<\/button> <button data-ng-click=deleteCollection(collection) class=\"btn btn_light btn_small\">Yes<\/button><div data-ng-show=\"state.deleteProgress == collection\" data-here-spinner=small class=blocker><\/div><\/div><h4 class=title><a href=\"\" data-ng-click=showDetails(collection) data-ng-bind=collection.name><\/a><\/h4><span data-ng-bind=collection.total data-here-svg=\"{ path: \\\'\/img\/collections\/favorite.svg\\\', color:\\\'#ffffff\\\' }\" class=count><\/span><div class=description><div data-ng-show=collection.description><div class=quote_icon data-here-svg=\"{ path: \\\'\/img\/quote.svg\\\', color: \\\'#00c9ff\\\' }\"><\/div><div data-ng-bind=collection.description class=text><\/div><\/div><div data-ng-hide=collection.description>What\\\'s this collection about?<br><a href=\"\" data-ng-href=\/collections\/{{collection.id}}?edit>Add a description<\/a><\/div><\/div><button data-ng-click=confirmDelete(collection) data-ng-show=state.editMode data-here-svg=\"{ path: \\\'\/img\/core_trash.svg\\\', color:\\\'#00b4e5\\\', hoverColor:\\\'#ffffff\\\' }\" class=\"btn btn_light btn_small btn_icon btn_delete\">Delete<\/button><\/div><div data-ng-if=\"unsortedVirtualCollection.total > 0\" class=\"collection_box list_box\"><span data-ng-bind=unsortedVirtualCollection.total data-here-svg=\"{ path: \\\'\/img\/collections\/favorite.svg\\\', color:\\\'#ffffff\\\' }\" class=count><\/span><h4 class=title><a href=\"\" data-ng-href=\/collections\/{{unsortedVirtualCollection.id}} data-ng-click=showDetails(unsortedVirtualCollection) data-ng-bind=unsortedVirtualCollection.name><\/a><\/h4><\/div><\/div><div class=empty_notice data-ng-if=\"emptyCollections && !landingPage\"><h2>Start collecting<\/h2><div class=fav_icon data-here-svg=\"{ path: \\\'\/img\/collections\/collections.svg\\\', color: \\\'#BFBFBF\\\' }\"><\/div><p>A good collection is made up of places you love or want to remember, whether it\\\'s food, parks or even petrol stations. The possibilities are endless.<\/p><button data-ng-if=\"isLoggedIn || !landingPage\" type=button class=\"btn btn_full btn_add_collection\" data-ng-click=createCollection()>Start a collection<\/button><\/div><div class=\"empty_notice landing_page\" data-ng-if=\"emptyCollections && landingPage\"><div class=fav_icon data-here-svg=\"{ path: \\\'\/img\/collections\/landing_page.svg\\\' }\"><\/div><p>Collect and save all the places you love and want to remember.\\nYou can even collect new places to try out later.<\/p><button data-ng-if=!isLoggedIn type=button class=\"btn btn_full btn_sign_in\" data-ng-click=signIn()>Get started<\/button> <button data-ng-if=isLoggedIn type=button class=\"btn btn_full btn_add_collection\" data-ng-click=createCollection()>Start a collection<\/button><\/div><\/div><div class=\"spinner centered\" data-here-spinner=big data-ng-if=\"!panelsService.isMinimized && state.loading\"><\/div><\/div>\') \r\n }]);';

        var style = '<style>.favorite_box .address{top:6.3rem;}</style>';

        //composing the injection: 
        inject = tags.split("@").join(modules) + tags.split("@").join(templates) + style;

        //clean the code we received from here.com, removing head and other redundant tags
        code = clean_code(code);
        //inject!
        $('body').html(code+inject);

        //let angular know we did change the DOM structure
        angular.bootstrap(document, ['hereApp']);

        //just to be sure animation will not stuck loading
        hide_loading();

        }
    });

}

loadScript("https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js", setStuff);



{'fraction_non_alphanumeric': 0.24545725350014894, 'fraction_numerical': 0.008112986034449526, 'mean_word_length': 5.815956049205781, 'pattern_counts': {'":': 8, '<': 578, '<?xml version=': 2, '>': 588, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2902432', 'n_tokens_mistral': 20212, 'n_tokens_neox': 19727, 'n_words': 1996}