diff --git a/plugins/bookmarks-by-zaso-css-desktop.css b/plugins/bookmarks-by-zaso-css-desktop.css deleted file mode 100644 index a738ffc1..00000000 --- a/plugins/bookmarks-by-zaso-css-desktop.css +++ /dev/null @@ -1,324 +0,0 @@ -#bookmarksBox *{ - display:block; - padding:0; - margin:0; - width:auto; - height:auto; - font-family:Verdana, Geneva, sans-serif; - font-size:13px; - line-height:22px; - text-indent:0; - text-decoration:none; -} -#bookmarksBox{ - margin-top:-200%; - position:absolute !important; - z-index:4001; - top:100px; - left:100px; -} -#bookmarksBox .addForm, #bookmarksBox #bookmarksTypeBar, #bookmarksBox h5{ - height:28px; - overflow:hidden; - color:#fff; - font-size:14px; -} -#bookmarksBox #topBar, #bookmarksBox #topBar *{ - height:15px !important; -} -#bookmarksBox #topBar *{ - float:left !important; -} -#bookmarksBox .handle{ - text-indent:-20px; - width:209px; - text-align:center; - color:#fff; - line-height:8px; - cursor:move; -} -#bookmarksBox #topBar .btn{ - display:block; - width:19px; - cursor:pointer; - color:#20a8b1; -} -#bookmarksBox #topBar #bookmarksMin{ - font-weight:bold; - text-align:center; - line-height:14px; - font-size:18px; -} -#bookmarksBox #topBar #bookmarksMin:hover{ - color:gold; -} -#bookmarksBox #bookmarksTypeBar{ - clear:both; -} -#bookmarksBox h5{ - padding:4px 0; - width:114px; - text-align:center; - color:#788; -} -#bookmarksBox h5.current{ - cursor:default; - background:0; - color:#fff !important; -} -#bookmarksBox h5:hover{ - color:gold; - background:rgba(0,0,0,0); -} -#bookmarksBox #topBar .btn, #bookmarksBox .addForm, #bookmarksBox .handle, #bookmarksBox #bookmarksTypeBar, #bookmarksBox .bookmarkList li.bookmarksEmpty, #bookmarksBox .bookmarkList li.bkmrk a, #bookmarksBox .bookmarkList li.bkmrk:hover{ - background-color:rgba(8,48,78,.85); -} -#bookmarksBox h5, #bookmarksBox .bookmarkList li.bkmrk:hover .bookmarksLink, #bookmarksBox .addForm *{ - background:rgba(0,0,0,.3); -} -#bookmarksBox .addForm *{ - display:block; - float:left; - padding:4px 8px 3px; -} -#bookmarksBox .addForm a{ - cursor:pointer; - color:#20a8b1; - font-size:12px; - width:65px; - text-align:center; - line-height:20px; - padding:4px 0 3px; -} -#bookmarksBox .addForm a:hover{ - background:gold; - color:#000; - text-decoration:none; -} -#bookmarksBox .addForm input{ - font-size:11px !important; - color:#ffce00; - width:81px; - line-height:11px; - font-size:12px; - -webkit-box-sizing:content-box; - -moz-box-sizing:content-box; - box-sizing:content-box; -} -#bookmarksBox #bkmrk_portals .addForm input{ - width:147px; -} -#bookmarksBox .addForm input:hover, #bookmarksBox .addForm input:focus{ - outline:0; - background:rgba(0,0,0,.6); -} -#bookmarksBox .bookmarkList>ul{ - width:231px; - clear:both; - list-style-type:none; - color:#fff; - overflow:hidden; - max-height:550px; -} -#bookmarksBox .sortable-placeholder{ - background:rgba(8,48,78,.55); - box-shadow:inset 1px 0 0 #20a8b1; -} -#bookmarksBox .ui-sortable-helper{ - border-top-width:1px; -} -#bookmarksBox .bookmarkList{ - display:none; -} -#bookmarksBox .bookmarkList.current{ - display:block; -} -#bookmarksBox h5, #bookmarksBox .addForm *, #bookmarksBox ul li.bkmrk, #bookmarksBox ul li.bkmrk a{ - height:22px; -} -#bookmarksBox h5, #bookmarksBox ul li.bkmrk a{ - overflow:hidden; - cursor:pointer; - float:left; -} -#bookmarksBox ul .bookmarksEmpty{ - text-indent:27px; - color:#eee; -} -#bookmarksBox ul .bookmarksRemoveFrom{ - width:19px; - text-align:center; - color:#fff; -} -#bookmarksBox ul .bookmarksLink{ - width:171px; - padding:0 10px 0 8px; - color:gold; -} -#bookmarksBox ul .bookmarksLink.selected{ - color:#03fe03; -} -#bookmarksBox ul .othersBookmarks .bookmarksLink{ - width:190px; -} -#bookmarksBox ul .bookmarksLink:hover{ - color:#03fe03; -} -#bookmarksBox ul .bookmarksRemoveFrom:hover{ - color:#fff; - background:#e22; -} -#bookmarksBox, #bookmarksBox *{ - border-color:#20a8b1; - border-style:solid; - border-width:0; -} -#bookmarksBox #topBar, #bookmarksBox ul .bookmarkFolder{ - border-top-width:1px; -} -#bookmarksBox #topBar, #bookmarksBox #bookmarksTypeBar, #bookmarksBox .addForm, #bookmarksBox ul .bookmarkFolder .folderLabel, #bookmarksBox ul li.bkmrk{ - border-bottom-width:1px; -} -#bookmarksBox ul .bookmarkFolder, #bookmarksBox ul .bookmarksRemoveFrom{ - border-right-width:1px; - border-left-width:1px; -} -#bookmarksBox #topBar *, #bookmarksBox #bookmarksTypeBar *, #bookmarksBox .addForm *{ - border-left-width:1px; -} -#bookmarksBox #topBar, #bookmarksBox #bookmarksTypeBar, #bookmarksBox .addForm{ - border-right-width:1px; -} -#bookmarksBox ul .othersBookmarks .bookmarksRemoveFrom, #bookmarksBox ul .bookmarkFolder .folderLabel .bookmarksRemoveFrom{ - border-left-width:0; -} -#bookmarksShow{ - display:block; - position:absolute; - top:0; - left:250px; - width:47px; - margin-top:-36px; - height:64px; - cursor:pointer; - z-index:2999; - background-position:center bottom; - background-repeat:no-repeat; - transition:margin-top 100ms ease-in-out; - background-image:url(@@INCLUDEIMAGE:plugins/bookmarks-by-zaso-logo.png@@); -} -#bookmarksShow:hover{ - margin-top:0 !important; -} -#sidebar #portaldetails h3.title{ - width:auto; -} -#bookmarkStar{ - display:inline-block; - float:left; - margin:3px 1px 0 4px; - width:16px; - height:15px; - overflow:hidden; - background-image:url(@@INCLUDEIMAGE:plugins/bookmarks-by-zaso-star.png@@); - background-position:left center; - background-repeat:no-repeat; -} -#bookmarkStar:hover, #bookmarkStar.favorite{ - background-position:right center; -} -#bookmarksBox .handleScroll{ - cursor:s-resize; - width:3px; - right:3px; - background:gold; - opacity:.7; -} -#bookmarksBox .bookmarkList .bookmarkFolder{ - overflow:hidden; - margin-top:-1px; - height:auto; - background:rgba(8,58,78,.7); -} -#bookmarksBox .bookmarkList ul li.sortable-placeholder{ - box-shadow:inset -1px 0 0 #20a8b1, inset 1px 0 0 #20a8b1, 0 -1px 0 #20a8b1; - background:rgba(8,58,78,.9); -} -#bookmarksBox .bookmarkList .bkmrk.ui-sortable-helper{ - border-right-width:1px; - border-left-width:1px; -} -#bookmarksBox .bookmarkList ul li ul li.sortable-placeholder{ - height:23px; - box-shadow:inset 0 -1px 0 #20a8b1, inset 1px 0 0 #20a8b1; -} -#bookmarksBox .bookmarkList ul li.bookmarkFolder.ui-sortable-helper, #bookmarksBox .bookmarkList ul li.othersBookmarks ul, #bookmarksBox .bookmarkList ul li.othersBookmarks ul li.sortable-placeholder{ - box-shadow:inset 0 -1px 0 #20a8b1; -} -#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel .bookmarksAnchor span, #bookmarksBox .bookmarkList .bookmarkFolder .folderLabel>span, #bookmarksBox .bookmarkList .bookmarkFolder .folderLabel>span>span, #bookmarksBox .bookmarkList .triangle{ - width:0; - height:0; -} -#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel{ - overflow:visible; - height:25px; - cursor:pointer; - background:#069; - text-indent:0; -} -#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel>*{ - height:25px; - float:left; -} -#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel .bookmarksAnchor{ - line-height:25px; - color:#fff; - width:209px; -} -#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel .bookmarksAnchor span{ - float:left; - border-width:5px 0 5px 7px; - border-color:transparent transparent transparent white; - margin:7px 7px 0 6px; -} -#bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel .bookmarksAnchor span{ - margin:9px 5px 0 5px; - border-width:7px 5px 0 5px; - border-color:white transparent transparent transparent; -} -#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel>span, #bookmarksBox .bookmarkList .bookmarkFolder .folderLabel>span>span{ - display:none; - border-width:0 12px 10px 0; - border-color:transparent #20a8b1 transparent transparent; - margin:-20px 0 0; - position:relative; - top:21px; - left:219px; -} -#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel>span>span{ - top:18px; - left:0; - border-width:0 10px 9px 0; - border-color:transparent #069 transparent transparent; -} -#bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel>span, #bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel>span>span{ - display:block; -} -#bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel:hover>span>span{ - border-color:transparent #036 transparent transparent; -} -#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel:hover .bookmarksAnchor{ - background:#036; -} -#bookmarksBox .bookmarkList .bookmarkFolder ul{ - display:none; - margin-left:19px; -} -#bookmarksBox .bookmarkList .bookmarkFolder.active ul{ - display:block; - min-height:22px; -} -#bookmarksBox .bookmarkFolder.othersBookmarks ul{ - margin-left:0; -} -) diff --git a/plugins/bookmarks-by-zaso-css-mobile.css b/plugins/bookmarks-by-zaso-css-mobile.css deleted file mode 100644 index ac2e79f4..00000000 --- a/plugins/bookmarks-by-zaso-css-mobile.css +++ /dev/null @@ -1,136 +0,0 @@ -#sidebar #bookmarksBox{ - position:static !important; - width:auto !important; - margin:0 !important; - width:100%; -} -#sidebar #bookmarksBox .bookmarkList > ul > li, #sidebar #bookmarksBox .bookmarkList > ul > li > ul, #sidebar #bookmarksBox .bookmarkList > ul > li > ul > li{ - width:100% !important; -} -#sidebar #bookmarksBox *{ - box-shadow:none !important; - border-width:0 !important -} -#sidebar #bookmarksBox #topBar{ - display:none !important; -} -#sidebar #bookmarksBox #bookmarksTypeBar h5{ - cursor:pointer; - text-align:center; - float:left; - width:50%; - padding:7px 0; -} -#sidebar #bookmarksBox #bookmarksTypeBar h5.current{ - cursor:default; - color:#fff; -} -#sidebar #bookmarksBox #bookmarksTypeBar, #sidebar #bookmarksBox .bookmarkList .addForm{ - border-bottom:1px solid #20a8b1 !important; -} -#sidebar #bookmarksBox .bookmarkList ul li ul li.bkmrk{ - height:36px !important; - clear:both; -} -#sidebar #bookmarksBox .bookmarkList li.bookmarkFolder .folderLabel{ - height:36px; -} -#sidebar #bookmarksBox .bookmarkList li.bookmarkFolder .folderLabel a, #sidebar #bookmarksBox .bookmarkList ul li ul li.bkmrk a{ - background:none; - padding:7px 0; - height:auto; - box-shadow:inset 0 1px 0 #20a8b1 !important; -} -#sidebar #bookmarksBox .bookmarkList li.bookmarkFolder a.bookmarksRemoveFrom, #sidebar #bookmarksBox .bookmarkList li.bkmrk a.bookmarksRemoveFrom{ - box-shadow:inset 0 1px 0 #20a8b1, inset -1px 0 0 #20a8b1 !important; - width:15%; -} -#sidebar #bookmarksBox .bookmarkList li.bookmarkFolder a.bookmarksAnchor, #sidebar #bookmarksBox .bookmarkList li.bkmrk a.bookmarksLink{ - text-indent:10px; - width:85%; - height:21px /*22*/; - overflow:hidden; -} -#sidebar #bookmarksBox .bookmarkList ul li.bookmarkFolder ul{ - margin-left:0 !important; -} -#sidebar #bookmarksBox .bookmarkList ul, #bookmarksBox .bookmarkList ul li, #sidebar #bookmarksBox .bookmarkList ul li ul, #sidebar #bookmarksBox .bookmarkList ul li ul li{ - display:block !important; -} -#sidebar #bookmarksBox .bookmarkList{ - display:none !important; -} -#sidebar #bookmarksBox .bookmarkList > ul{ - border-bottom:1px solid #20a8b1 !important; - border-right:1px solid #20a8b1 !important; -} -#sidebar #bookmarksBox .bookmarkList.current{ - display:block !important; -} -#sidebar #bookmarksBox .bookmarkList .bookmarkFolder.othersBookmarks ul{ - border-top:5px solid #20a8b1 !important; -} -#sidebar #bookmarksBox .bookmarkList li.bookmarkFolder, #sidebar #bookmarksBox .bookmarkList li.bkmrk{ - box-shadow:inset 0 1px 0 #20a8b1, 1px 0 0 #20a8b1, -1px 1px 0 #20a8b1 !important; -} -#sidebar #bookmarksBox .bookmarkList li.bookmarkFolder .bkmrk.sortable-placeholder{ - height:36px !important; -} -#sidebar #bookmarksBox .bookmarkList .sortable-placeholder{ - box-shadow:inset 0 1px 0 #20a8b1 !important; -} -#sidebar #bookmarksBox .ui-sortable .ui-sortable-helper{ - border-top:0; - width:85% !important; -} -#sidebar #bookmarksBox .bookmarkList > ul{ - max-height:none; - width:85% !important; -} -#sidebar #bookmarksBox .bookmarkList li.bookmarkFolder .folderLabel{ - box-shadow:0 1px 0 #20a8b1 !important; -} -#sidebar #bookmarksBox .bookmarkList ul li.bookmarkFolder ul{ - width:85% !important; - margin-left:15% !important; -} -#sidebar #bookmarksBox .bookmarkList ul li.bookmarkFolder.othersBookmarks ul{ - width:100% !important; - margin-left:0% !important; -} -#sidebar #bookmarksShowMobile{ - text-decoration:none; - display:block !important; - padding:11px 0 9px; - text-align:center; -} -#sidebar #portaldetails{ - margin-top:25px; -} -#sidebar #bookmarksBox #bookmarksTypeBar{ - height:auto; -} -#sidebar #bookmarksBox .addForm, #sidebar #bookmarksBox .addForm *{ - height:35px; - padding:0; -} -#sidebar #bookmarksBox .addForm a{ - line-height:37px; -} -#sidebar #bookmarksBox .addForm a{ - width:25% !important; -} -#sidebar #bookmarksBox .addForm input{ - width:50% !important; - text-indent:10px; -} -#sidebar #bookmarksBox #bkmrk_portals .addForm input{ - width:75% !important; -} -#sidebar #bookmarksBox #bookmarksTypeBar h5, #sidebar #bookmarksBox .bookmarkList .addForm a{ - box-shadow:-1px 0 0 #20a8b1 !important; -} -#sidebar #bookmarksBox .bookmarkList li.bookmarkFolder ul{ - display:block !important; - min-height:37px !important; -} \ No newline at end of file diff --git a/plugins/bookmarks-by-zaso-logo.png b/plugins/bookmarks-by-zaso-logo.png deleted file mode 100644 index 2b97556b..00000000 Binary files a/plugins/bookmarks-by-zaso-logo.png and /dev/null differ diff --git a/plugins/bookmarks-by-zaso-star.png b/plugins/bookmarks-by-zaso-star.png deleted file mode 100644 index 0d1c1cd7..00000000 Binary files a/plugins/bookmarks-by-zaso-star.png and /dev/null differ diff --git a/plugins/bookmarks-by-zaso.user.js b/plugins/bookmarks-by-zaso.user.js index b8396a9b..c107df76 100644 --- a/plugins/bookmarks-by-zaso.user.js +++ b/plugins/bookmarks-by-zaso.user.js @@ -2,533 +2,874 @@ // @id iitc-plugin-bookmarks@ZasoGD // @name IITC plugin: Bookmarks for maps and portals // @category Controls -// @version 0.1.55.@@DATETIMEVERSION@@ +// @version 0.2.2.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ -// @description [@@BUILDNAME@@-@@BUILDDATE@@] Save your favorite Maps and Portals and move the intelmap view in a second. The ingress world just a click. +// @description [@@BUILDNAME@@-@@BUILDDATE@@] Save your favorite Maps and Portals and move the intelmap with a click. Now sync. // @include https://www.ingress.com/intel* // @include http://www.ingress.com/intel* // @match https://www.ingress.com/intel* // @match http://www.ingress.com/intel* +// @grant none // ==/UserScript== @@PLUGINSTART@@ // PLUGIN START //////////////////////////////////////////////////////// +/*********************************************************************** + USEFUL FUNCTIONS: + + window.plugin.bookmarks.refreshBkmrks(): reloads the bookmarks into box; - // use own namespace for plugin - window.plugin.bookmarks = function() {}; - window.plugin.bookmarks.bkmrk_portals = {}; - window.plugin.bookmarks.bkmrk_maps = {}; + HOOKS: + + pluginBkmrksEdit: fired when a bookmarks/folder is removed, added or sorted, also when a folder is opened/closed; + + pluginBkmrksOpenOpt: fired when the "Bookmarks Options" panel is opened (you can add new options); - window.plugin.bookmarks.disabledMessage; - window.plugin.bookmarks.contentStarHTML; + CHANGELOG: + v 0.2.1-0.2.2: + + auto-drawer minor bug fix; + + auto-drawer improved UI; + + auto-drawer improved UI on mobile; + + fixed hidden box problem (I hope): sometimes the box and the ribbon hidden; - window.plugin.bookmarks.KEY_OTHER_BKMRK = 'idOthers'; - window.plugin.bookmarks.LOCAL_STORAGE_status_box = 'plugin-bookmarks-status-box'; - window.plugin.bookmarks.LOCAL_STORAGE_bkmrk_portals = 'plugin-bookmarks-portals-data'; - window.plugin.bookmarks.LOCAL_STORAGE_bkmrk_maps = 'plugin-bookmarks-maps-data'; + v 0.2.0: + + code rewritten from scratch: + ++ more optimization; + ++ less animated effects; + + Sync; + + Hooks (for developer); + + Option panel: + ++ manual import/export/reset of the data; + ++ sharing of the data (only IITCm); + ++ storage/reset the box position (only desktop); + + Auto-drawer feature: select two o three portals boomark to auto-draw a link or field (draw-tools required); + + IITCm: you can open/close the folders; + + IITCm: bookmarks/folders not sortable (the 'sortable' jquery function not work); + +***********************************************************************/ + + // use own namespace for plugin + window.plugin.bookmarks = function() {}; + + window.plugin.bookmarks.SYNC_DELAY = 5000; + + window.plugin.bookmarks.KEY_OTHER_BKMRK = 'idOthers'; + window.plugin.bookmarks.KEY_STORAGE = 'plugin-bookmarks'; + window.plugin.bookmarks.KEY_STATUS_BOX = 'plugin-bookmarks-box'; + + window.plugin.bookmarks.KEY = {key: window.plugin.bookmarks.KEY_STORAGE, field: 'bkmrksObj'}; + window.plugin.bookmarks.UPDATE_QUEUE = {key: 'plugin-bookmarks-queue', field: 'updateQueue'}; + window.plugin.bookmarks.UPDATING_QUEUE = {key: 'plugin-bookmarks-updating-queue', field: 'updatingQueue'}; + + window.plugin.bookmarks.bkmrksObj = {}; + window.plugin.bookmarks.statusBox = {}; + window.plugin.bookmarks.updateQueue = {}; + window.plugin.bookmarks.updatingQueue = {}; + + window.plugin.bookmarks.enableSync = false; + + window.plugin.bookmarks.isSmart = window.isSmartphone(); + window.plugin.bookmarks.isAndroid = function() { if(typeof android !== 'undefined' && android) { return true; } return false; } /*********************************************************************************************************************/ - //--------------------------------------------------------------------------------------- - // Append a 'star' flag in sidebar. - //--------------------------------------------------------------------------------------- - window.plugin.bookmarks.addToSidebar = function(){ - if(typeof(Storage) === "undefined"){ $('#portaldetails > .imgpreview').after(plugin.bookmarks.disabledMessage); return; } - $('#portaldetails > h3.title').before(plugin.bookmarks.contentStarHTML); - plugin.bookmarks.updateStarPortal(); - } + // Generate an ID for the bookmark (date time + random number) + window.plugin.bookmarks.generateID = function() { + var d = new Date(); + var ID = d.getTime()+(Math.floor(Math.random()*99)+1); + var ID = 'id'+ID.toString(); + return ID; + } - //--------------------------------------------------------------------------------------- - // Update the status of the star (when a portal is selected from the map/bookmarks-list) - //--------------------------------------------------------------------------------------- - window.plugin.bookmarks.updateStarPortal = function(){ - window.plugin.bookmarks.loadBookmarks('bkmrk_portals'); - var guid = window.selectedPortal; - $('#bookmarkStar').removeClass('favorite'); - $('.bkmrk a.bookmarksLink.selected').removeClass('selected'); + // Format the string + window.plugin.bookmarks.escapeHtml = function(text) { + return text + .replace(/&/g, "&") + .replace(//g, ">") + .replace(/"/g, """) + .replace(/'/g, "'") + .replace(/\//g, '/') + .replace(/\\/g, '\'); + } - //If current portal is into bookmarks: select bookmark portal from portals list and select the star - if(localStorage[window.plugin.bookmarks.LOCAL_STORAGE_bkmrk_portals].search(guid) != -1){ - $('#bookmarkStar').addClass('favorite'); - var list = plugin.bookmarks['bkmrk_portals']; - for(var idFolders in list){ - for(var idBkmrk in list[idFolders]['bkmrk']){ - var portalGuid = list[idFolders]['bkmrk'][idBkmrk]['guid']; - if(guid == portalGuid){ - $('.bkmrk#'+idBkmrk+' a.bookmarksLink').addClass('selected'); - } - } - } - } - } + // Update the localStorage + window.plugin.bookmarks.saveStorage = function() { + localStorage[plugin.bookmarks.KEY_STORAGE] = JSON.stringify(window.plugin.bookmarks.bkmrksObj); + } + // Load the localStorage + window.plugin.bookmarks.loadStorage = function() { + window.plugin.bookmarks.bkmrksObj = JSON.parse(localStorage[plugin.bookmarks.KEY_STORAGE]); + } - //--------------------------------------------------------------------------------------- - // Switch the status of the star - //--------------------------------------------------------------------------------------- - window.plugin.bookmarks.switchStarPortal = function(){ - var guid = window.selectedPortal; + window.plugin.bookmarks.saveStorageBox = function() { + localStorage[plugin.bookmarks.KEY_STATUS_BOX] = JSON.stringify(window.plugin.bookmarks.statusBox); + } + window.plugin.bookmarks.loadStorageBox = function() { + window.plugin.bookmarks.statusBox = JSON.parse(localStorage[plugin.bookmarks.KEY_STATUS_BOX]); + } - //If portal is saved in bookmarks: Remove this bookmark - if($('#bookmarkStar').hasClass('favorite')){ - var list = plugin.bookmarks['bkmrk_portals']; + window.plugin.bookmarks.upgradeToNewStorage = function() { + if(localStorage['plugin-bookmarks-portals-data'] && localStorage['plugin-bookmarks-maps-data']) { + var oldStor_1 = JSON.parse(localStorage['plugin-bookmarks-maps-data']); + var oldStor_2 = JSON.parse(localStorage['plugin-bookmarks-portals-data']); - for(var idFolders in list){ - for(var idBkmrk in list[idFolders]['bkmrk']){ - var portalGuid = list[idFolders]['bkmrk'][idBkmrk]['guid']; - if(guid == portalGuid){ - delete list[idFolders]['bkmrk'][idBkmrk]; - $('.bkmrk#'+idBkmrk+'').remove(); - } - } - } - } - //If portal isn't saved in bookmarks: Add this bookmark - else{ - // Get the bookmark data (name, coordinates, portal id) from the portal link - var linka = $('#portaldetails .linkdetails aside a:contains("Portal link")').attr('href'); - var namePortal = $('#portaldetails h3').text(); - var ID = window.plugin.bookmarks.generateID(); - var spac = linka.split('pll='); - var latlng = spac[1] ; + window.plugin.bookmarks.bkmrksObj.maps = oldStor_1.bkmrk_maps; + window.plugin.bookmarks.bkmrksObj.portals = oldStor_2.bkmrk_portals; + window.plugin.bookmarks.saveStorage(); - // Add bookmark in the localStorage - plugin.bookmarks['bkmrk_portals'][plugin.bookmarks.KEY_OTHER_BKMRK]['bkmrk'][ID] = {"guid":guid,"latlng":latlng,"label":namePortal}; - //Append the new bookmark to the map list - $('#bkmrk_portals li.othersBookmarks ul').append('
  • X'+namePortal+'
  • '); - } - window.plugin.bookmarks.storeBookmarks('bkmrk_portals'); - window.plugin.bookmarks.updateStarPortal(); - } + localStorage.removeItem('plugin-bookmarks-maps-data'); + localStorage.removeItem('plugin-bookmarks-portals-data'); + localStorage.removeItem('plugin-bookmarks-status-box'); + } + } - //--------------------------------------------------------------------------------------- - // Save a bookmark map - //--------------------------------------------------------------------------------------- - window.plugin.bookmarks.addBookmarkMap = function(elem){ - // Get the coordinates and zoom level from the permalink - var mapLink = $(elem).attr('href'); - var pars = new RegExp('[\\?&]ll=([^&#]*)[&]z=([^&#]*)').exec(mapLink); - var res = pars[1].split(','); - res[2] = pars[2]; - var latlng = res[0]+','+res[1]; - var zoom = res[2]; + window.plugin.bookmarks.createStorage = function() { + if(!localStorage[window.plugin.bookmarks.KEY_STORAGE]) { + window.plugin.bookmarks.bkmrksObj.maps = {idOthers:{label:"Others",state:1,bkmrk:{}}}; + window.plugin.bookmarks.bkmrksObj.portals = {idOthers:{label:"Others",state:1,bkmrk:{}}}; + window.plugin.bookmarks.saveStorage(); + } + if(!localStorage[window.plugin.bookmarks.KEY_STATUS_BOX]) { + window.plugin.bookmarks.statusBox.show = 1; + window.plugin.bookmarks.statusBox.page = 0; + window.plugin.bookmarks.statusBox.pos = {x:100,y:100}; + window.plugin.bookmarks.saveStorageBox(); + } + } - var ID = window.plugin.bookmarks.generateID(); + window.plugin.bookmarks.refreshBkmrks = function() { + $('#bkmrk_maps > ul, #bkmrk_portals > ul').remove(); - //Get the label | Convert some characters | Set the input (empty) - var nameMap = $(elem).siblings('input').val(); - nameMap = nameMap.replace(/\//g, '/').replace(/\\/g, '\').replace(/"/g, '"').replace(/"/g, '''); - $(elem).siblings('input').val(''); + window.plugin.bookmarks.loadStorage(); + window.plugin.bookmarks.loadList('maps'); + window.plugin.bookmarks.loadList('portals'); - // Add bookmark in the localStorage - plugin.bookmarks['bkmrk_maps'][plugin.bookmarks.KEY_OTHER_BKMRK]['bkmrk'][ID] = {"label":nameMap,"latlng":latlng,"z":parseInt(zoom)}; - plugin.bookmarks.storeBookmarks('bkmrk_maps'); - - //Append the new bookmark to the map list - if(nameMap==''){ nameMap = latlng+' ['+zoom+']'; } - $('#bkmrk_maps li.othersBookmarks ul').append('
  • X'+nameMap+'
  • '); - } - -/*********************************************************************************************************************/ - - //--------------------------------------------------------------------------------------- - // Generate an ID for the bookmark (date time + random number) - //--------------------------------------------------------------------------------------- - window.plugin.bookmarks.generateID = function(){ - var d = new Date(); - var ID = d.getTime()+(Math.floor(Math.random()*99)+1); - var ID = 'id'+ID.toString(); - return ID; - } - - //--------------------------------------------------------------------------------------- - // Switch the status folder to open/close (in the localStorage) - //--------------------------------------------------------------------------------------- - window.plugin.bookmarks.openFolder = function(elem){ - var typeList = $(elem).parent().parent().parent().parent('div').attr('id'); - var ID = $(elem).parent().parent('li').attr('id'); - var newFlag; - var flag = plugin.bookmarks[typeList][ID]['state']; - if(flag){ newFlag = 0; } - else if(!flag){ newFlag = 1; } - window.plugin.bookmarks[typeList][ID]['state'] = newFlag; - window.plugin.bookmarks.storeBookmarks(typeList); - } - - //--------------------------------------------------------------------------------------- - // Switch the status folder to open/close (in the localStorage) - //--------------------------------------------------------------------------------------- - window.plugin.bookmarks.addFolder = function(typeList){ - var ID = window.plugin.bookmarks.generateID(); - var input = '#'+typeList+' .addForm input'; - //Get the label | Convert some characters | Set the input (empty) - var nameFolder = $(input).val(); - nameFolder = nameFolder.replace(/\//g, '/').replace(/\\/g, '\').replace(/"/g, '"').replace(/"/g, '''); - if(nameFolder == ''){ nameFolder = 'Folder'; } - $(input).val(''); - - // Add new folder in the localStorage - plugin.bookmarks[typeList][ID] = {"label":nameFolder,"state":1,"bkmrk":{}}; - plugin.bookmarks.storeBookmarks(typeList); - //Append the new folder to the list - $('#'+typeList+' li.othersBookmarks').before('
  • X'+nameFolder+'
  • '); - } - - //--------------------------------------------------------------------------------------- - // Remove the bookmark (from the localStorage) - //--------------------------------------------------------------------------------------- - window.plugin.bookmarks.deletBookmark = function(elem){ - var typeList = $(elem).parent().parent().parent().parent().parent('div').attr('id'); - var ID = $(elem).parent('li').attr('id'); - var IDfold = $(elem).parent().parent().parent('li').attr('id'); - delete window.plugin.bookmarks[typeList][IDfold]['bkmrk'][ID]; - window.plugin.bookmarks.storeBookmarks(typeList); - if(typeList == 'bkmrk_portals'){ window.plugin.bookmarks.updateStarPortal(); } - } - - //--------------------------------------------------------------------------------------- - // Remove the folder (from the localStorage) - //--------------------------------------------------------------------------------------- - window.plugin.bookmarks.deletFolder = function(elem){ - var typeList = $(elem).parent().parent().parent().parent('div').attr('id'); - var ID = $(elem).parent().parent('li').attr('id'); - delete plugin.bookmarks[typeList][ID]; - window.plugin.bookmarks.storeBookmarks(typeList); - if(typeList == 'bkmrk_portals'){ window.plugin.bookmarks.updateStarPortal(); } - } - - //--------------------------------------------------------------------------------------- - // Saved the new sort of the folders (in the localStorage) - //--------------------------------------------------------------------------------------- - window.plugin.bookmarks.sortBookmarksFolder = function(typeList){ - window.plugin.bookmarks.loadBookmarks(typeList); - var newArr = {}; - $('#'+typeList+' li.bookmarkFolder').each(function(){ - var idFold = $(this).attr('id'); - newArr[idFold] = window.plugin.bookmarks[typeList][idFold]; - }); - window.plugin.bookmarks[typeList] = newArr; - window.plugin.bookmarks.storeBookmarks(typeList); - } - - //--------------------------------------------------------------------------------------- - // Saved the new sort of the bookmarks (in the localStorage) - //--------------------------------------------------------------------------------------- - window.plugin.bookmarks.sortBookmarks = function(typeList){ - window.plugin.bookmarks.loadBookmarks(typeList); - var list = window.plugin.bookmarks[typeList]; - var newArr = {}; - - $('#'+typeList+' li.bookmarkFolder').each(function(){ - var idFold = $(this).attr('id'); - newArr[idFold] = window.plugin.bookmarks[typeList][idFold]; - newArr[idFold].bkmrk = {}; - }); - - $('#'+typeList+' li.bkmrk').each(function(){ - window.plugin.bookmarks.loadBookmarks(typeList); - var idFold = $(this).parent().parent('li').attr('id'); - var id = $(this).attr('id'); - - var list = window.plugin.bookmarks[typeList]; - for(var idFoldersOrigin in list){ - for(var idBkmrk in list[idFoldersOrigin]['bkmrk']){ - if(idBkmrk == id){ - newArr[idFold].bkmrk[id] = window.plugin.bookmarks[typeList][idFoldersOrigin].bkmrk[id]; - } - } - } - }); - window.plugin.bookmarks[typeList] = newArr; - window.plugin.bookmarks.storeBookmarks(typeList); - } - - //--------------------------------------------------------------------------------------- - // Update the localStorage - //--------------------------------------------------------------------------------------- - window.plugin.bookmarks.storeBookmarks = function(typeList){ - var bookmarksObject = {}; - bookmarksObject[typeList] = plugin.bookmarks[typeList]; - var bookmarksObjectJSON = JSON.stringify(bookmarksObject); - localStorage[plugin.bookmarks['LOCAL_STORAGE_'+typeList]] = bookmarksObjectJSON; - } - - //--------------------------------------------------------------------------------------- - // Load the localStorage - //--------------------------------------------------------------------------------------- - window.plugin.bookmarks.loadBookmarks = function(typeList){ - var bookmarksObjectJSON = localStorage[plugin.bookmarks['LOCAL_STORAGE_'+typeList]]; - if(!bookmarksObjectJSON) return; - var bookmarksObject = JSON.parse(bookmarksObjectJSON); - plugin.bookmarks[typeList] = bookmarksObject[typeList]; - } - - //--------------------------------------------------------------------------------------- - // Load the bookmarks - //--------------------------------------------------------------------------------------- - window.plugin.bookmarks.loadList = function(typeList){ - window.plugin.bookmarks.loadBookmarks(typeList); - var element = ''; - var elementTemp = ''; - var elementExc = ''; - - // For each folder - var list = window.plugin.bookmarks[typeList]; - for(var idFolders in list){ - var folders = list[idFolders]; - var active = ''; - - // Create a label and a anchor for the sortable - var folderLabel = 'X'; - folderLabel += ''+folders['label']+''; - - if(folders['state']){ active = ' active'; } - if(idFolders == window.plugin.bookmarks.KEY_OTHER_BKMRK){ - folderLabel = ''; active= ' othersBookmarks active'; - } - // Create a folder - elementTemp = '
  • '+folderLabel+''; - - //Add folder 'Others' in last position - if(idFolders != window.plugin.bookmarks.KEY_OTHER_BKMRK){ element += elementTemp; } - else{ elementExc = elementTemp; } - } - element += elementExc; - - // Append all folders and bookmarks - $('#'+typeList+' ul').html(element); - } - -/*********************************************************************************************************************/ - - //--------------------------------------------------------------------------------------- - // Append the stylesheet - //--------------------------------------------------------------------------------------- - window.plugin.bookmarks.setupCSS = function(){ - $('