From 0743287f955fd19fd1a04c91f3b40a4ac2236423 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 9 Jun 2016 19:02:38 +0200 Subject: clean & lint stuff --- .../static/themes/_global/js/restoreScroll.js | 28 +-- app/Resources/static/themes/baggy/js/autoClose.js | 12 +- .../static/themes/baggy/js/autoCompleteTags.js | 35 ++-- .../static/themes/baggy/js/closeMessage.js | 36 ++-- app/Resources/static/themes/baggy/js/init.js | 99 +++++----- app/Resources/static/themes/baggy/js/popupForm.js | 167 ++++++++--------- app/Resources/static/themes/baggy/js/saveLink.js | 67 ++++--- app/Resources/static/themes/material/js/init.js | 201 +++++++++++---------- 8 files changed, 322 insertions(+), 323 deletions(-) (limited to 'app') diff --git a/app/Resources/static/themes/_global/js/restoreScroll.js b/app/Resources/static/themes/_global/js/restoreScroll.js index e63d06c6..9c4d7e20 100644 --- a/app/Resources/static/themes/_global/js/restoreScroll.js +++ b/app/Resources/static/themes/_global/js/restoreScroll.js @@ -1,25 +1,25 @@ function supportsLocalStorage() { - try { - return 'localStorage' in window && window['localStorage'] !== null; - } catch (e) { - return false; - } + try { + return 'localStorage' in window && window.localStorage !== null; + } catch (e) { + return false; + } } function savePercent(id, percent) { - if (!supportsLocalStorage()) { return false; } - localStorage["wallabag.article." + id + ".percent"] = percent; - return true; + if (!supportsLocalStorage()) { return false; } + localStorage['wallabag.article.' + id + '.percent'] = percent; + return true; } function retrievePercent(id) { - if (!supportsLocalStorage()) { return false; } + if (!supportsLocalStorage()) { return false; } - var bheight = $(document).height(); - var percent = localStorage["wallabag.article." + id + ".percent"]; - var scroll = bheight * percent; + var bheight = $(document).height(); + var percent = localStorage['wallabag.article.' + id + '.percent']; + var scroll = bheight * percent; - $('html,body').animate({scrollTop: scroll}, 'fast'); + $('html,body').animate({ scrollTop: scroll }, 'fast'); - return true; + return true; } diff --git a/app/Resources/static/themes/baggy/js/autoClose.js b/app/Resources/static/themes/baggy/js/autoClose.js index e9145b7e..b0dafab2 100644 --- a/app/Resources/static/themes/baggy/js/autoClose.js +++ b/app/Resources/static/themes/baggy/js/autoClose.js @@ -1,6 +1,8 @@ -$(document).ready(function() { - current_url = window.location.href - if (current_url.match("&closewin=true")) { - window.close(); - } +var $ = global.jquery = require('jquery'); + +$(document).ready(function () { + var currentUrl = window.location.href; + if (currentUrl.match('&closewin=true')) { + window.close(); + } }); diff --git a/app/Resources/static/themes/baggy/js/autoCompleteTags.js b/app/Resources/static/themes/baggy/js/autoCompleteTags.js index 90bc982c..edd0a421 100755 --- a/app/Resources/static/themes/baggy/js/autoCompleteTags.js +++ b/app/Resources/static/themes/baggy/js/autoCompleteTags.js @@ -1,47 +1,46 @@ -jQuery(function($) { +var $ = global.jquery = require('jquery'); - function split( val ) { - return val.split( /,\s*/ ); +jQuery(function ($) { + function split(val) { + return val.split(/,\s*/); } - function extractLast( term ) { - return split( term ).pop(); + function extractLast(term) { + return split(term).pop(); } - $("#value").bind("keydown", function(event) { - if (event.keyCode === $.ui.keyCode.TAB && $(this).data("ui-autocomplete").menu.active) { + $('#value').bind('keydown', function (event) { + if (event.keyCode === $.ui.keyCode.TAB && $(this).data('ui-autocomplete').menu.active) { event.preventDefault(); } }).autocomplete({ - source : function(request, response) { - $.getJSON("./?view=tags", { - term : extractLast(request.term), + source: function (request, response) { + $.getJSON('./?view=tags', { + term: extractLast(request.term), //id: $(':hidden#entry_id').val() }, response); }, - search : function() { + search: function () { // custom minLength var term = extractLast(this.value); if (term.length < 1) { return false; } }, - focus : function() { + focus: function () { // prevent value inserted on focus return false; }, - select : function(event, ui) { + select: function (event, ui) { var terms = split(this.value); // remove the current input terms.pop(); // add the selected item terms.push(ui.item.value); // add placeholder to get the comma-and-space at the end - terms.push(""); - this.value = terms.join(", "); + terms.push(''); + this.value = terms.join(', '); return false; - } + }, }); - - }); diff --git a/app/Resources/static/themes/baggy/js/closeMessage.js b/app/Resources/static/themes/baggy/js/closeMessage.js index 527719d5..ae4b1791 100644 --- a/app/Resources/static/themes/baggy/js/closeMessage.js +++ b/app/Resources/static/themes/baggy/js/closeMessage.js @@ -1,17 +1,19 @@ -$(function(){ - //--------------------------------------------------------------------------- - // Show the close icon when the user hover over a message - //--------------------------------------------------------------------------- - // $('.messages').on('mouseenter', function(){ - // $(this).find('a.closeMessage').stop(true, true).show(); - // }).on('mouseleave', function(){ - // $(this).find('a.closeMessage').stop(true, true).hide(); - // }); - //--------------------------------------------------------------------------- - // Close the message box when the user clicks the close icon - //--------------------------------------------------------------------------- - $('a.closeMessage').on('click', function(){ - $(this).parents('div.messages').slideUp(300, function(){ $(this).remove(); }); - return false; - }); -}); \ No newline at end of file +var $ = global.jquery = require('jquery'); + +$(function () { + //--------------------------------------------------------------------------- + // Show the close icon when the user hover over a message + //--------------------------------------------------------------------------- + // $('.messages').on('mouseenter', function(){ + // $(this).find('a.closeMessage').stop(true, true).show(); + // }).on('mouseleave', function(){ + // $(this).find('a.closeMessage').stop(true, true).hide(); + // }); + //--------------------------------------------------------------------------- + // Close the message box when the user clicks the close icon + //--------------------------------------------------------------------------- + $('a.closeMessage').on('click', function () { + $(this).parents('div.messages').slideUp(300, function () { $(this).remove(); }); + return false; + }); +}); diff --git a/app/Resources/static/themes/baggy/js/init.js b/app/Resources/static/themes/baggy/js/init.js index 1721ae41..d7d4b166 100755 --- a/app/Resources/static/themes/baggy/js/init.js +++ b/app/Resources/static/themes/baggy/js/init.js @@ -4,19 +4,18 @@ require('jquery-ui'); var annotator = require('annotator'); -$.fn.ready(function() { - - var $listmode = $('#listmode'), - $listentries = $("#list-entries"); +$.fn.ready(function () { + var $listmode = $('#listmode'); + var $listentries = $('#list-entries'); /* ========================================================================== Menu ========================================================================== */ - $("#menu").click(function(){ - $("#links").toggleClass('menu--open'); + $('#menu').click(function () { + $('#links').toggleClass('menu--open'); if ($('#content').hasClass('opacity03')) { - $('#content').removeClass('opacity03'); + $('#content').removeClass('opacity03'); } }); @@ -24,34 +23,32 @@ $.fn.ready(function() { List mode or Table Mode ========================================================================== */ - $listmode.click(function(){ - if ( jquery.cookie("listmode") == 1 ) { + $listmode.click(function () { + if (jquery.cookie('listmode') === 1) { // Cookie - $.removeCookie("listmode"); + $.removeCookie('listmode'); - $listentries.removeClass("listmode"); - $listmode.removeClass("tablemode"); - $listmode.addClass("listmode"); - } - else { + $listentries.removeClass('listmode'); + $listmode.removeClass('tablemode'); + $listmode.addClass('listmode'); + } else { // Cookie - jquery.cookie("listmode", 1, {expires: 365}); + jquery.cookie('listmode', 1, { expires: 365 }); - $listentries.addClass("listmode"); - $listmode.removeClass("listmode"); - $listmode.addClass("tablemode"); + $listentries.addClass('listmode'); + $listmode.removeClass('listmode'); + $listmode.addClass('tablemode'); } - }); /* ========================================================================== Cookie listmode ========================================================================== */ - if ( jquery.cookie("listmode") == 1 ) { - $listentries.addClass("listmode"); - $listmode.removeClass("listmode"); - $listmode.addClass("tablemode"); + if (jquery.cookie('listmode') === 1) { + $listentries.addClass('listmode'); + $listmode.removeClass('listmode'); + $listmode.addClass('tablemode'); } /* ========================================================================== @@ -59,43 +56,43 @@ $.fn.ready(function() { ========================================================================== */ - $('#nav-btn-add-tag').on('click', function(){ - $(".nav-panel-add-tag").toggle(100); - $(".nav-panel-menu").addClass('hidden'); - $("#tag_label").focus(); - return false; - }); + $('#nav-btn-add-tag').on('click', function () { + $('.nav-panel-add-tag').toggle(100); + $('.nav-panel-menu').addClass('hidden'); + $('#tag_label').focus(); + return false; + }); /* ========================================================================== Annotations & Remember position ========================================================================== */ - if ($("article").length) { - var app = new annotator.App(); + if ($('article').length) { + var app = new annotator.App(); - app.include(annotator.ui.main, { - element: document.querySelector('article') - }); + app.include(annotator.ui.main, { + element: document.querySelector('article'), + }); - var x = JSON.parse($('#annotationroutes').html()); - app.include(annotator.storage.http, x); + var x = JSON.parse($('#annotationroutes').html()); + app.include(annotator.storage.http, x); - app.start().then(function () { - app.annotations.load({entry: x.entryId}); - }); + app.start().then(function () { + app.annotations.load({ entry: x.entryId }); + }); - $(window).scroll(function(e){ - var scrollTop = $(window).scrollTop(); - var docHeight = $(document).height(); - var scrollPercent = (scrollTop) / (docHeight); - var scrollPercentRounded = Math.round(scrollPercent*100)/100; - savePercent(x.entryId, scrollPercentRounded); - }); + $(window).scroll(function (e) { + var scrollTop = $(window).scrollTop(); + var docHeight = $(document).height(); + var scrollPercent = (scrollTop) / (docHeight); + var scrollPercentRounded = Math.round(scrollPercent * 100) / 100; + savePercent(x.entryId, scrollPercentRounded); + }); - retrievePercent(x.entryId); + retrievePercent(x.entryId); - $(window).resize(function(){ - retrievePercent(x.entryId); - }); + $(window).resize(function () { + retrievePercent(x.entryId); + }); } }); diff --git a/app/Resources/static/themes/baggy/js/popupForm.js b/app/Resources/static/themes/baggy/js/popupForm.js index 0b478fad..95ba60ee 100644 --- a/app/Resources/static/themes/baggy/js/popupForm.js +++ b/app/Resources/static/themes/baggy/js/popupForm.js @@ -1,100 +1,101 @@ -$(document).ready(function() { +var $ = global.jquery = require('jquery'); - $("#search-form").hide(); - $("#bagit-form").hide(); - $("#filter-form").hide(); - $("#download-form").hide(); +$(document).ready(function () { + $('#search-form').hide(); + $('#bagit-form').hide(); + $('#filter-form').hide(); + $('#download-form').hide(); - //--------------------------------------------------------------------------- - // Toggle the "Search" popup in the sidebar - //--------------------------------------------------------------------------- - function toggleSearch() { - $("#search-form").toggle(); - $("#search").toggleClass("current"); - $("#search").toggleClass("active-current"); - $("#search-arrow").toggleClass("arrow-down"); - if ($("#search").hasClass("current")) { - $("#content").addClass("opacity03"); - } else { - $("#content").removeClass("opacity03"); - } + //--------------------------------------------------------------------------- + // Toggle the 'Search' popup in the sidebar + //--------------------------------------------------------------------------- + function toggleSearch() { + $('#search-form').toggle(); + $('#search').toggleClass('current'); + $('#search').toggleClass('active-current'); + $('#search-arrow').toggleClass('arrow-down'); + if ($('#search').hasClass('current')) { + $('#content').addClass('opacity03'); + } else { + $('#content').removeClass('opacity03'); } + } - //--------------------------------------------------------------------------- - // Toggle the "Filter" popup on entries list - //--------------------------------------------------------------------------- - function toggleFilter() { - $("#filter-form").toggle(); - } + //--------------------------------------------------------------------------- + // Toggle the 'Filter' popup on entries list + //--------------------------------------------------------------------------- + function toggleFilter() { + $('#filter-form').toggle(); + } - //--------------------------------------------------------------------------- - // Toggle the "Download" popup on entries list - //--------------------------------------------------------------------------- - function toggleDownload() { - $("#download-form").toggle(); - } + //--------------------------------------------------------------------------- + // Toggle the 'Download' popup on entries list + //--------------------------------------------------------------------------- + function toggleDownload() { + $('#download-form').toggle(); + } - //--------------------------------------------------------------------------- - // Toggle the "Save a Link" popup in the sidebar - //--------------------------------------------------------------------------- - function toggleBagit() { - $("#bagit-form").toggle(); - $("#bagit").toggleClass("current"); - $("#bagit").toggleClass("active-current"); - $("#bagit-arrow").toggleClass("arrow-down"); - if ($("#bagit").hasClass("current")) { - $("#content").addClass("opacity03"); - } else { - $("#content").removeClass("opacity03"); - } + //--------------------------------------------------------------------------- + // Toggle the 'Save a Link' popup in the sidebar + //--------------------------------------------------------------------------- + function toggleBagit() { + $('#bagit-form').toggle(); + $('#bagit').toggleClass('current'); + $('#bagit').toggleClass('active-current'); + $('#bagit-arrow').toggleClass('arrow-down'); + if ($('#bagit').hasClass('current')) { + $('#content').addClass('opacity03'); + } else { + $('#content').removeClass('opacity03'); } + } - //--------------------------------------------------------------------------- - // Close all #links popups in the sidebar - //--------------------------------------------------------------------------- - function closePopups() { - $("#links .messages").hide(); - $("#links > li > a").removeClass("active-current"); - $("#links > li > a").removeClass("current"); - $("[id$=-arrow]").removeClass("arrow-down"); - $("#content").removeClass("opacity03"); - } + //--------------------------------------------------------------------------- + // Close all #links popups in the sidebar + //--------------------------------------------------------------------------- + function closePopups() { + $('#links .messages').hide(); + $('#links > li > a').removeClass('active-current'); + $('#links > li > a').removeClass('current'); + $('[id$=-arrow]').removeClass('arrow-down'); + $('#content').removeClass('opacity03'); + } - $("#search").click(function(){ - closePopups(); - toggleSearch(); - $("#searchfield").focus(); - }); + $('#search').click(function () { + closePopups(); + toggleSearch(); + $('#searchfield').focus(); + }); - $(".filter-btn").click(function(){ - closePopups(); - toggleFilter(); - }); + $('.filter-btn').click(function () { + closePopups(); + toggleFilter(); + }); - $(".download-btn").click(function(){ - closePopups(); - toggleDownload(); - }); + $('.download-btn').click(function () { + closePopups(); + toggleDownload(); + }); - $("#bagit").click(function(){ - closePopups(); - toggleBagit(); - $("#plainurl").focus(); - }); + $('#bagit').click(function () { + closePopups(); + toggleBagit(); + $('#plainurl').focus(); + }); - $("#search-form-close").click(function(){ - toggleSearch(); - }); + $('#search-form-close').click(function () { + toggleSearch(); + }); - $("#filter-form-close").click(function(){ - toggleFilter(); - }); + $('#filter-form-close').click(function () { + toggleFilter(); + }); - $("#download-form-close").click(function(){ - toggleDownload(); - }); + $('#download-form-close').click(function () { + toggleDownload(); + }); - $("#bagit-form-close").click(function(){ - toggleBagit(); - }); + $('#bagit-form-close').click(function () { + toggleBagit(); + }); }); diff --git a/app/Resources/static/themes/baggy/js/saveLink.js b/app/Resources/static/themes/baggy/js/saveLink.js index 91cc2c3f..5c720886 100755 --- a/app/Resources/static/themes/baggy/js/saveLink.js +++ b/app/Resources/static/themes/baggy/js/saveLink.js @@ -1,60 +1,60 @@ -$.fn.ready(function() { +var $ = global.jquery = require('jquery'); - var $bagit = $('#bagit'), - $bagitForm = $('#bagit-form'), - $bagitFormForm = $('#bagit-form-form'); +$.fn.ready(function () { + var $bagit = $('#bagit'); + var $bagitForm = $('#bagit-form'); + var $bagitFormForm = $('#bagit-form-form'); /* ========================================================================== bag it link and close button ========================================================================== */ function toggleSaveLinkForm(url, event) { - $("#add-link-result").empty(); + $('#add-link-result').empty(); - $bagit.toggleClass("active-current"); + $bagit.toggleClass('active-current'); - //only if bag-it link is not presented on page - if ( $bagit.length === 0 ) { - if ( event !== 'undefined' && event ) { - $bagitForm.css( {position:"absolute", top:event.pageY, left:event.pageX-200}); - } - else { - $bagitForm.css( {position:"relative", top:"auto", left:"auto"}); + // only if bag-it link is not presented on page + if ($bagit.length === 0) { + if (event !== 'undefined' && event) { + $bagitForm.css({ position: 'absolute', top: event.pageY, left: event.pageX - 200 }); + } else { + $bagitForm.css({ position: 'relative', top: 'auto', left: 'auto' }); } } - if ($("#search-form").length != 0) { - $("#search").removeClass("current"); - $("#search-arrow").removeClass("arrow-down"); - $("#search-form").hide(); + if ($('#search-form').length !== 0) { + $('#search').removeClass('current'); + $('#search-arrow').removeClass('arrow-down'); + $('#search-form').hide(); } $bagitForm.toggle(); - $('#content').toggleClass("opacity03"); + $('#content').toggleClass('opacity03'); if (url !== 'undefined' && url) { $('#plainurl').val(url); } $('#plainurl').focus(); } - //send "bag it link" form request via ajax - $bagitFormForm.submit( function(event) { - $("body").css("cursor", "wait"); - $("#add-link-result").empty(); + // send 'bag it link' form request via ajax + $bagitFormForm.submit(function (event) { + $('body').css('cursor', 'wait'); + $('#add-link-result').empty(); $.ajax({ type: $bagitFormForm.attr('method'), url: $bagitFormForm.attr('action'), data: $bagitFormForm.serialize(), - success: function(data) { - $('#add-link-result').html("Done!"); + success: function (data) { + $('#add-link-result').html('Done!'); $('#plainurl').val(''); $('#plainurl').blur(''); - $("body").css("cursor", "auto"); + $('body').css('cursor', 'auto'); + }, + error: function (data) { + $('#add-link-result').html('Failed!'); + $('body').css('cursor', 'auto'); }, - error: function(data) { - $('#add-link-result').html("Failed!"); - $("body").css("cursor", "auto"); - } }); event.preventDefault(); @@ -64,15 +64,12 @@ $.fn.ready(function() { Process all links inside an article ========================================================================== */ - $("article a[href^='http']").after(function() { - return " "; + $('article a[href^="http"]').after(function () { + return ' '; }); - $(".add-to-wallabag-link-after").click(function(event){ + $('.add-to-wallabag-link-after').click(function (event) { toggleSaveLinkForm($(this).attr('href'), event); event.preventDefault(); }); - }); - - diff --git a/app/Resources/static/themes/material/js/init.js b/app/Resources/static/themes/material/js/init.js index 33019d3d..d6a87941 100755 --- a/app/Resources/static/themes/material/js/init.js +++ b/app/Resources/static/themes/material/js/init.js @@ -1,116 +1,117 @@ -var $ = require("jquery"), -materialize = require("materialize"); +var $ = require('jquery'); +require('materialize'); var annotator = require('annotator'); -function init_filters() { - // no display if filters not aviable - if ($("div").is("#filters")) { - $('#button_filters').show(); - $('.button-collapse-right').sideNav({ edge: 'right' }); - $('#clear_form_filters').on('click', function(){ - $('#filters input').val(''); - $('#filters :checked').removeAttr('checked'); - return false; - }); - } +function initFilters() { + // no display if filters not aviable + if ($('div').is('#filters')) { + $('#button_filters').show(); + $('.button-collapse-right').sideNav({ edge: 'right' }); + $('#clear_form_filters').on('click', function () { + $('#filters input').val(''); + $('#filters :checked').removeAttr('checked'); + return false; + }); + } } -function init_export() { - // no display if export not aviable - if ($("div").is("#export")) { - $('#button_export').show(); - $('.button-collapse-right').sideNav({ edge: 'right' }); - } +function initExport() { + // no display if export not aviable + if ($('div').is('#export')) { + $('#button_export').show(); + $('.button-collapse-right').sideNav({ edge: 'right' }); + } } -$(document).ready(function(){ - // sideNav - $('.button-collapse').sideNav(); - $('select').material_select(); - $('.collapsible').collapsible({ - accordion : false - }); - $('.datepicker').pickadate({ - selectMonths: true, - selectYears: 15, - formatSubmit: 'dd/mm/yyyy', - hiddenName: true, - format: 'dd/mm/yyyy', - }); - init_filters(); - init_export(); +$(document).ready(function () { + // sideNav + $('.button-collapse').sideNav(); + $('select').material_select(); + $('.collapsible').collapsible({ + accordion: false, + }); + $('.datepicker').pickadate({ + selectMonths: true, + selectYears: 15, + formatSubmit: 'dd/mm/yyyy', + hiddenName: true, + format: 'dd/mm/yyyy', + }); + initFilters(); + initExport(); - $('#nav-btn-add-tag').on('click', function(){ - $(".nav-panel-add-tag").toggle(100); - $(".nav-panel-menu").addClass('hidden'); - $("#tag_label").focus(); - return false; - }); - $('#nav-btn-add').on('click', function(){ - $(".nav-panel-buttom").hide(100); - $(".nav-panel-add").show(100); - $(".nav-panels .action").hide(100); - $(".nav-panel-menu").addClass('hidden'); - $(".nav-panels").css('background', 'white'); - $("#entry_url").focus(); - return false; - }); - $('#nav-btn-search').on('click', function(){ - $(".nav-panel-buttom").hide(100); - $(".nav-panel-search").show(100); - $(".nav-panels .action").hide(100); - $(".nav-panel-menu").addClass('hidden'); - $(".nav-panels").css('background', 'white'); - $("#searchfield").focus(); - return false; - }); - $('.close').on('click', function(){ - $(".nav-panel-add").hide(100); - $(".nav-panel-search").hide(100); - $(".nav-panel-buttom").show(100); - $(".nav-panels .action").show(100); - $(".nav-panel-menu").removeClass('hidden'); - $(".nav-panels").css('background', 'transparent'); - return false; - }); - $(window).scroll(function () { - var s = $(window).scrollTop(), - d = $(document).height(), - c = $(window).height(); - var scrollPercent = (s / (d-c)) * 100; - $(".progress .determinate").css('width', scrollPercent+'%'); - }); + $('#nav-btn-add-tag').on('click', function () { + $('.nav-panel-add-tag').toggle(100); + $('.nav-panel-menu').addClass('hidden'); + $('#tag_label').focus(); + return false; + }); + $('#nav-btn-add').on('click', function () { + $('.nav-panel-buttom').hide(100); + $('.nav-panel-add').show(100); + $('.nav-panels .action').hide(100); + $('.nav-panel-menu').addClass('hidden'); + $('.nav-panels').css('background', 'white'); + $('#entry_url').focus(); + return false; + }); + $('#nav-btn-search').on('click', function () { + $('.nav-panel-buttom').hide(100); + $('.nav-panel-search').show(100); + $('.nav-panels .action').hide(100); + $('.nav-panel-menu').addClass('hidden'); + $('.nav-panels').css('background', 'white'); + $('#searchfield').focus(); + return false; + }); + $('.close').on('click', function () { + $('.nav-panel-add').hide(100); + $('.nav-panel-search').hide(100); + $('.nav-panel-buttom').show(100); + $('.nav-panels .action').show(100); + $('.nav-panel-menu').removeClass('hidden'); + $('.nav-panels').css('background', 'transparent'); + return false; + }); + $(window).scroll(function () { + var s = $(window).scrollTop(); + var d = $(document).height(); + var c = $(window).height(); + var scrollPercent = (s / (d - c)) * 100; + $('.progress .determinate').css('width', scrollPercent + '%'); + }); + +/* ========================================================================== + Annotations & Remember position + ========================================================================== */ - /* ========================================================================== - Annotations & Remember position - ========================================================================== */ + if ($('article').length) { + var app = new annotator.App(); + var x = JSON.parse($('#annotationroutes').html()); - if ($("article").length) { - var app = new annotator.App(); - app.include(annotator.ui.main, { - element: document.querySelector('article') - }); + app.include(annotator.ui.main, { + element: document.querySelector('article'), + }); - var x = JSON.parse($('#annotationroutes').html()); - app.include(annotator.storage.http, x); + app.include(annotator.storage.http, x); - app.start().then(function () { - app.annotations.load({entry: x.entryId}); - }); + app.start().then(function () { + app.annotations.load({ entry: x.entryId }); + }); - $(window).scroll(function(e){ - var scrollTop = $(window).scrollTop(); - var docHeight = $(document).height(); - var scrollPercent = (scrollTop) / (docHeight); - var scrollPercentRounded = Math.round(scrollPercent*100)/100; - savePercent(x.entryId, scrollPercentRounded); - }); + $(window).scroll(function (e) { + var scrollTop = $(window).scrollTop(); + var docHeight = $(document).height(); + var scrollPercent = (scrollTop) / (docHeight); + var scrollPercentRounded = Math.round(scrollPercent * 100) / 100; + savePercent(x.entryId, scrollPercentRounded); + }); - retrievePercent(x.entryId); + retrievePercent(x.entryId); - $(window).resize(function(){ - retrievePercent(x.entryId); - }); - } + $(window).resize(function () { + retrievePercent(x.entryId); + }); + } }); -- cgit v1.2.3