2014-11-17 3 views
0

generates annotations within an ePub이라는 javascript 라이브러리를 사용하고 있습니다. HTML5 localStorage을 사용하여 주석 데이터를 저장하고 싶습니다.localStorage를 로컬 서버 대신 끝점으로 사용하도록 구성

localStorage와 연결된 끝점 URL을 갖는 방법이 있습니까? 현재 로컬 서버에 대한 URL로 설정되어있는 '서버'에 대한 변수가 라이브러리를 호출하는 후크에서

, 내가 로컬 스토리지에 몇 가지 포인터와 그 대체 바라고 5000

포트 ,하지만 어떤 종단점이 관련 될지 확신하지 못합니다. 정보를 추가하는 유일한 방법은 "localStorage.setItem"메서드 일 것입니다.이 메서드는 변수 이름을 인수로 필요로하므로 끝점으로 적합하지 않습니다.

EPUBJS.Hooks.register("beforeChapterDisplay").annotate = function(callback, chapter){ 

     var chap = chapter.bodyEl, 
      server = localStorage; 
      files = [ 
         EPUBJS.filePath + "annotator-full.js" 
        ]; 

     console.log(files);//show the pathways defined above 

     EPUBJS.core.load(files, chapter.doc.head); 
     $(chapter.doc.body).annotator().annotator('setupPlugins', {}, { 

      Filter:false, 
      Store: { 
       annotationData: { 
        'uri': chapter.path 
       }, 
       loadFromSearch: { 
        'limit': 100, 
        'uri': chapter.path 
       } 
      } 

     }); 

     Util.mousePosition = function(e, offsetEl) { 
      var offset; 
      offset = $(offsetEl).position(); 
      return { 
      top: e.pageY, 
      left: e.pageX 
      }; 
     }; 

      devAnnotator = new Annotator(chapter.doc.body) 
      // .addPlugin('Auth', { 
      //   tokenUrl: 'http://annotateit.org/api/token',//'http://localhost:5001/api/token' 
      //   }) 
      // .addPlugin('Unsupported') 
      // .addPlugin('AnnotateItPermissions') 
      // .addPlugin('Store', { 
      // prefix: 'http://annotateit.org/api',//'http://localhost:5000', 
      // loadFromSearch: { 
      //  uri: chapter.currentChapter.href 
      // }, 
      // annotationData: { 
      //  uri: chapter.currentChapter.href 
      // } 
      // }); 

     //   devAnnotator.plugins.Auth.withToken(function (tok) { 
     //   console.log(tok); 
     //   }) 

     // EPUBJS.core.addCss("../libs/annotator/css/annotator.css", false, chapter.doc.head); 

     if(callback) callback(); 

     function annotate(){ 
      // EPUBJS.core.addCss("css/annotator.css", false, chapter.doc.head); 

      var s = document.createElement("script"); 
      s.type = 'text/javascript'; 

      console.log(jQuery); 
      var a = "jQuery.migrateTrace = false;"; 
      a += "console.log(document.getElementById('c001p0002').getBoundingClientRect());"; 

      a += "var content = $('body').annotator().annotator('setupPlugins', {}, {Filter:false});"; 

      //-- Use Local Server: 

      a += "var content = $('body').annotator(),"; 
      a += " server = '" + server + "';"; 
      a += " path = '" + chapter.path + "';"; 

      a += " content.annotator('addPlugin', 'Store', {"; 
      // The endpoint of the store on your server. 
      a += " prefix: server,"; 

      // Attach the uri of the current page to all annotations to allow search. 
      a += " annotationData: {"; 
      a += " 'uri': path"; 
      a += " }"; 

       // This will perform a search action rather than read when the plugin 
       // loads. Will request the last 20 annotations for the current url. 
       // eg. /store/endpoint/search?limit=20&uri=http://this/document/only 
      a += "," 
      a += " loadFromSearch: {"; 
      a += " 'limit': 20,"; 
      a += " 'uri': path"; 
      a += " }"; 
      a += "});"; 

      s.innerHTML = a; 

      chapter.doc.body.appendChild(s); 

      if(callback) callback(); 
     } 



} 
+0

뭐 t 플랫폼에서 테스트 중이십니까? iBooks? –

+0

흠, 그냥 기본 ePub 리더와 함께 브라우저를 사용하거나, 적어도 미래의 프레스와 관련된 기본값이라고 생각합니다. https://github.com/futurepress/epub.js –

+1

아 기술적으로 이것은 isn이 아닙니다. 표준 ePub 파일 : ePub.js 용 파일 일뿐입니다. –

답변

1

그냥에서 루프를 닫습니다 다음과 같이

순정 후크, 나는 그것이 this github repo에 사용자 정의하기 전에, 편집 후

나의 현재 버전은 (어떤이 작동하지 않습니다)입니다 이 솔루션 :이 파일은 실제 ePub에없는

, 그것은 ... 사용자 정의 방식으로 표시 한 후 ePub.js와 함께 ePub에 섭취와의 "쉘"입니다

관련 문제