window.onload = function() {
   var key = payloadSourceId + "|" + (new Date()).getTime();
   var payload = {};
   payload[key]=(new Date()).getTime();
   Pers.preinit();
   Pers.call("log_history", {"analytics": payload}, function(callback) {});
 };
 bulk_import_annotations: function (P, cb) {
   Pers.call('bulk_import_annotations', {
     locs_array: P.locs_array,
     from_source_id: P.from_source_id,
     to_source_id: P.to_source_id,
     import_type: P.import_type,
   }, cb);
 },
Example #3
0
 copy_file: function (P, cb) {
   Pers.call('copy_file', {
     source_id: P.source_id,
     target_name: P.target_name,
     target_id: P.target_id,
     target_type: P.target_type,
   }, cb);
 },
 Pers.init = function () {
   //get data:
   var payload_objects = { types: ['settings'] };
   Pers.call('getObjects', payload_objects, function(payload){
     $(".nb-widget-body").append(require("hbs!templates_dir/your_settings")({
       firstname: payload.settings.user.firstname, lastname: payload.settings.user.lastname}));
     Pers.createStore(payload);
   });
   $.concierge.addComponents({});
 };
Example #5
0
  Pers.createStore = function (payload) {
    Pers.store = new Models.Store();
    Pers.store.create(payload, {
      ensemble:    { pFieldName: 'ensembles' },
      section:    { pFieldName: 'sections', references: { id_ensemble: 'ensemble' } },
      file:    { pFieldName: 'files', references: { id_ensemble: 'ensemble', id_folder: 'folder' } },
      folder: { pFieldName: 'folders', references: { id_ensemble: 'ensemble', id_parent: 'folder' } },
      comment:{ pFieldName: 'comments', references: { id_location: 'location' } },
      location:{ pFieldName: 'locations', references: { id_ensemble: 'ensemble', id_source: 'file' } },
      link: { pFieldName: 'links' },
      mark: {},
      threadmark: { pFieldName: 'threadmarks', references: { location_id: 'location' } },
      draft: {},
      seen:{ pFieldName: 'seen', references: { id_location: 'location' } },
    });

    //get the section info as well as info whether user is admin:
    Pers.call('getSectionsInfo', { id_ensemble: Pers.store.get('ensemble', {}).first().ID }, function (P3) {
      var m = Pers.store;
      m.add('section', P3['sections']);
      Pers.store.get('ensemble', {}).first().admin = true; //we only get a callback if we're an admin for this ensemble
    });

    Pers.sequence = payload.sequence;

    //generate collection:
    var ids_location = [];
    var ids_location_idx = {};

    var items = Pers.sequence.data;
    var m = Pers.store;
    var c, l, id_comment, id_location;
    for (var i in items) {
      id_comment = items[i];
      id_location = m.o.comment[id_comment].ID_location;
      if (!(id_location in ids_location_idx)) {
        ids_location.push(id_location);
        ids_location_idx[id_location] = ids_location.length - 1;
      }
    }

    Pers.collection = { type: 'location', sequence: Pers.sequence, items: ids_location, index: ids_location_idx };
    $.concierge.setHistoryHelper(function (payload, cb) {Pers.call('log_history', payload, cb);}, 120000);

    $.concierge.trigger({ type:'collection', value: 1 });
    document.title = $.E(Pers.sequence.description);

    //now check if need to move to a given annotation:
    if ('c' in Pers.params) {
      var id =  Pers.params.c;
      c = m.get('comment', { ID: Pers.params.c }).items[id];
      $.concierge.trigger({ type: 'select_thread', value: c.ID_location });
    }
  };
Example #6
0
 f_trigger = function () {
   Pers.collection.items = L[id_source][id_author].items;
   Pers.collection.index = L[id_source][id_author].index;
   Pers.collection.meta = { id_user: id_author, id_source: id_source };
   $.concierge.trigger({ type:'collection', value: 1 });
   if (id_next_author !== null && id_author_readahead == null) {
     id_author_readahead = id_next_author;
     Pers.call('getMyNotes', { query: 'auth_admin', id_source:id_source, id_author:id_next_author }, function (P3) {
       //mark readahead available again and load data silently
       id_author_readahead = null;
       f_on_data(P3, id_next_author);
     });
   }
 };
Example #7
0
  Pers.createStore = function (payload) {
    Pers.store = new Models.Store();
    Pers.store.create(payload, {
      ensemble:    { pFieldName: 'ensembles' },
      section:    { pFieldName: 'sections', references: { id_ensemble: 'ensemble' } },
      file:    { pFieldName: 'files', references: { id_ensemble: 'ensemble', id_folder: 'folder' } },
      folder: { pFieldName: 'folders', references: { id_ensemble: 'ensemble', id_parent: 'folder' } },
      comment:{ references: { id_location: 'location' } },
      location:{ references: { id_ensemble: 'ensemble', id_source: 'file' } },
      link: { pFieldName: 'links' },
      file_stats:{ references: { id: 'file' } },
      mark: {},
      draft: {},
      question: { references: { location_id: 'location' } },
      seen:{ references: { id_location: 'location' } },
      basecomment:{ references: { id_location: 'location' } },
      replyrating:{ references: { comment_id: 'comment' } },
    });
    var cb2 = function (P2) {
      var m = Pers.store;
      m.set('location', P2['locations']);
      m.set('comment', P2['comments']);
      m.set('basecomment', P2['basecomments']);
      m.set('question', P2['questions']);
    };

    $.concierge.setHistoryHelper(function (_payload, cb) {
      _payload['__return'] = { type:'newPending', a:{} };
      Pers.call('log_history', _payload, cb);
    }, 120000, cb2, 600000);

    files.set_model(Pers.store);
    $.concierge.trigger({ type:'admin_init', value: 0 });

    //get more stats (pending stuff)
    Pers.call('getPending', {}, function (P) {
      Pers.store.add('location', P['locations']);
      Pers.store.add('comment', P['comments']);
      Pers.store.add('basecomment', P['basecomments']);
      Pers.store.add('question', P['questions']);
    });

  };
  Pers.init = function () {
    var url_parts = window.location.href.toString().split("/");
    var class_id = url_parts[url_parts.length - 1];

    var payload = {
    	"payload":{"id_ensemble":class_id},
    	"types":["sections", "ensembles", "section_participants"]};
    var cb = function(p) {
      var obj = {
        "ensemble": p.ensembles[class_id],
        "sections": p.sections,
        "class_sections": p.section_participants.class_sections,
        "no_section": p.section_participants.no_section,
        "error_message": p.error_message
      };
      $(".nb-widget-body").append(require('hbs!templates_dir/properties_ensemble_sections')(obj));
      setPageHandlers();
    };
    Pers.call('getObjects', payload, cb);
  };
    var f_cleanup = function (do_save) {
      if (do_save) {
        var passwd = $('#new_password1')[0].value;
        if (passwd !== '') {
          Pers.newSettings['__PASSWD__'] = passwd;
          $('#newpassword_msg').hide();
          $('#new_password1')[0].value = '';
          $('#new_password2')[0].value = '';
        }
        Pers.newSettings["firstname"] = $("#firstname")[0].value.trim();
        Pers.newSettings["lastname"] = $("#lastname")[0].value.trim();

        Pers.call('save_settings', Pers.newSettings, function (payload) {
          //update new settings
          Pers.store.add('us', payload.settings.us);
          // Reload the page to update Conf.userinfo if the user's name gets changed and also to
          // ensure the name displayed at the top of the page is correct.
          window.location.reload();
        });
      }
    };
Example #10
0
  Pers.init = function () {
    Pers._selectTimerID =  null;
    Pers.grade2litt = { 4: 'A', 3: 'B', 2: 'C', 1: 'D', 0: 'F' };
    Pers.id_author_readahead = null;
    Pers.collection = { items: [], index: {} };
    Pers.call('getParams', { name: ['RESOLUTIONS', 'RESOLUTION_COORDINATES'] }, function (p) {
      $.concierge.addConstants(p.value);
    });

    //Factories: methods called if an event calls for a function that's not yet present
    $.concierge.addFactory('spreadsheet', 'spreadsheet_viewer', function (id) {
      var pers_id        = 'pers_' + id;
      var $vp = $(".nb-viewport");
      var $pers        = $("<div id='" + pers_id + "'/>").appendTo($vp);
      var spreadsheetview = {
        priority: 1,
        min_width: 1000,
        desired_width: 60,
        content: function ($div) {
          $div.spreadsheetview();
          $div.spreadsheetview('set_model', Pers.store);
        },
      };
      var notesview =  {
        priority: 1,
        min_width: 800,
        desired_width:50,
        min_height: 800,
        desired_height: 70,
        content: function ($div) {
          $div.notepaneView();
          $div.notepaneView('set_model', Pers.store);
        },
      };
      var docview    = {
        priority: 1,
        min_width: 800,
        desired_width: 50,
        min_height: 300,
        desired_height: 30,
        content: function ($div) {
          $div.docView({ img_server: Conf.servers.img });
          $div.docView('set_model', Pers.store);
          /*
          window.setTimeout(function(){
                  $div.docView("set_model",Pers.store );
              }, 5000);
          */
        },
      };
      var editorview    =  {
        priority: 1,
        min_width: 950,
        desired_width: 50,
        min_height: 1000,
        desired_height: 50,
        transcient: true,
        content: function ($div) {
          $div.editorview({ allowStaffOnly: false, allowAnonymous: false });
          $div.editorview('set_model', Pers.store);
        },
      };
      var self = Pers;
      $pers.perspective({
        height: function () {return $vp.height() - $pers.offset().top;},

        listens: {
          successful_login: function (evt) {
            Auth.set_cookie('ckey', evt.value.ckey);
            document.location = 'http://' + document.location.host + document.location.pathname;
            $.I('Welcome !');
          },

          selection: function (evt) {
            var v = evt.value;
            var sel = v.sel;
            var m = Pers.store;
            var id_source = v.files[sel[1] - 1].id;
            var id_author = v.users[sel[0] - 1].id;
            var L =  m.meta.loadednotes;
            var f_trigger;
            var f_on_data = function (P, _id_author) {
              m.add('seen', P['seen']);
              m.add('comment', P['comments']);
              m.add('location', P['locations']);

              //generate collection:
              var ids_location = [];
              var ids_location_idx = {};
              var id_location;
              var items = P['locations'];
              var i;
              var f_sort = function (o1, o2) {
                var loc1 = m.o.location[o1];
                var loc2 = m.o.location[o2];
                return (loc1.page !== loc2.page) ? (loc1.page - loc2.page) : (loc1.top - loc2.top);
              };

              for (i in items) {
                id_location = items[i].ID;
                ids_location.push(id_location);
              }

              ids_location.sort(f_sort);
              for (i in ids_location) {
                ids_location_idx[ids_location[i]] = Number(i);
              }

              L[id_source][_id_author] = { items: ids_location, index: ids_location_idx };
            };

            if (!(id_source in L)) {
              L[id_source] = {};
            }

            var id_next_author = self.find_next_author(v);
            if (!(id_author + '_' + id_source in m.o.stat)) {
              //no need to call server if there's no note.
              return;
            }

            if (self._selectTimerID !== null) {
              window.clearTimeout(self._selectTimerID);
              self._selectTimerID =  null;
            }

            if (id_author in L[id_source]) {//use cached values
              f_trigger = function () {
                Pers.collection.items = L[id_source][id_author].items;
                Pers.collection.index = L[id_source][id_author].index;
                Pers.collection.meta = { id_user: id_author, id_source: id_source };
                $.concierge.trigger({ type:'collection', value: 1 });
                if (id_next_author !== null && id_author_readahead == null) {
                  id_author_readahead = id_next_author;
                  Pers.call('getMyNotes', { query: 'auth_admin', id_source:id_source, id_author:id_next_author }, function (P3) {
                    //mark readahead available again and load data silently
                    id_author_readahead = null;
                    f_on_data(P3, id_next_author);
                  });
                }
              };

              self._selectTimerID =  window.setTimeout(f_trigger);
            }            else {
              f_trigger = function () {
                var P2 =  { query: 'auth_admin', id_source:id_source, id_author:id_author };
                Pers.call('getMyNotes', P2, function (P) {
                  //var m = Pers.store;
                  f_on_data(P, id_author);
                  Pers.collection.items =     L[id_source][id_author].items;
                  Pers.collection.index =     L[id_source][id_author].index;
                  Pers.collection.meta = { id_user: id_author, id_source: id_source };
                  $.concierge.trigger({ type:'collection', value: 1 });
                  if (id_next_author !== null && id_author_readahead == null) {
                    Pers.call('getMyNotes', { query: 'auth_admin', id_source:id_source, id_author:id_next_author }, function (P3) {
                      //mark readahead available again and load data silently
                      id_author_readahead = null;
                      f_on_data(P3, id_next_author);
                    });
                  }
                });
              };

              self._selectTimerID =  window.setTimeout(f_trigger, 500);
            }
          },
        },
        views: {
        v1:{ data: spreadsheetview },
                v2:{ children: {
            v1:{ children: { v1:{ data:notesview }, v2: { data: editorview }, orientation: 'horizontal' } }, v2:{ data: docview }, orientation: 'horizontal', }, }, orientation: 'vertical', },
      });
    });

    $.concierge.addComponents({
      get_collection:        function (P, cb) {return Pers.collection;},

      set_grade_assignment: function (P, cb) {
        Pers.call('set_grade_assignment', P, cb);
      },

      grade2litt: function (P, cb) {return Pers.grade2litt[P];},

      splash_notepaneview: function (P, cb) {
        return "<div xmlns='http://www.w3.org/1999/xhtml' class='minisplashscreen ui-corner-all'> <div id='splash-welcome'>Welcome... </div><br/><i>Using the keyboard shortcuts below will likely speed up your grading task by a lot...</i><br/> <ul id='splash-list-instructions'> <li>Use the <b>arrow keys</b> to navigate between cells and display the comments for the selected assignment</li><li>Use the <b>&#60;</b> and <b>&#62;</b> keys to move between threads within the selected assignment</li><li>Use the <b>A,B,C,D,F</b> keys to let to assign the corresponding grade to the selected assignment </li></ul> </div>";
      },

      splash_docview: function (P, cb) {
        return "<div xmlns='http://www.w3.org/1999/xhtml' class='minisplashscreen ui-corner-all'> Select an assignment to see a preview of the material here</div>";
      },

      note_creator:    function (P, cb) {Pers.call('saveNote', P, cb);},

      note_editor:    function (P, cb) {Pers.call('editNote', P, cb);},

    });

    //get data:
    var P2 =  {};
    if ('id_ensemble' in Pers.params) {
      P2['id_ensemble'] = Pers.params.id_ensemble;
    }

    Pers.call('get_stats_ensemble', P2,  Pers.createStore);
  };
Example #11
0
 $.concierge.setHistoryHelper(function (payload, cb) {Pers.call('log_history', payload, cb);}, 120000);
Example #12
0
 note_creator:    function (P, cb) {Pers.call('saveNote', P, cb);},
Example #13
0
 note_editor:    function (P, cb) {Pers.call('editNote', P, cb);},
Example #14
0
 add_ensemble:        function (P, cb) {Pers.call('add_ensemble', P, cb);},
Example #15
0
 notes_loader:    function (P, cb) {Pers.call('getNotes', P, cb);},
 promote_location_by_copy: function (P, cb) {
   Pers.call('promote_location_by_copy', {
     id_location: P.id_location,
   }, cb);
 },
  Pers.createStore = function (payload) {
    Pers.store = new Models.Store();
    Pers.store.create(payload, {
      ensemble: { pFieldName: 'ensembles' },
      section: { pFieldName: 'sections', references: { id_ensemble: 'ensemble' } },
      file: { pFieldName: 'files', references: { id_ensemble: 'ensemble', id_folder: 'folder' } },
      folder: { pFieldName: 'folders', references: { id_ensemble: 'ensemble', id_parent: 'folder' } },
      comment: { references: { id_location: 'location' } },
      location: { references: { id_ensemble: 'ensemble', id_source: 'file' } },
      link: { pFieldName: 'links' },
      mark: {},
      threadmark: { pFieldName: 'threadmarks', references: { location_id: 'location' } },
      draft: {},
      seen: { references: { id_location: 'location' } },
      labelcategory: { references: { ensemble_id: 'ensemble' } },
      commentlabel: { references: { category_id: 'labelcategory' } },
      labelcategorycaption: { references: { category_id: 'labelcategory' } },
      members: {},
      tags: { references: { user_id: 'members', comment_id: 'comment' } },
    });

    var ensembleID = Pers.store.get('ensemble', {}).first().ID;

    Pers.call('getMembers', { id_ensemble: ensembleID }, function (P5) {
      console.log('getMembers callback');

      Pers.store.add('members', P5);
    });

    //get the section info as well as info whether user is admin:
    Pers.call('getSectionsInfo', { id_ensemble: Pers.store.get('ensemble', {}).first().ID }, function (P3) {
      var m = Pers.store;
      m.add('section', P3['sections']);
      Pers.store.get('ensemble', {}).first().admin = true; //we only get a callback if we're an admin for this ensemble
    });

    //here we override the callback so that we can get new notes.
    var cb2 = function (P2) {
      var m = Pers.store;
      m.add('comment', P2['comments']);
      m.add('location', P2['locations']);
      var msg = '';
      var l, c;
      for (var i in P2['comments']) {
        c = m.o.comment[i];
        l = m.o.location[c.ID_location];
        if (c.id_Author !==  $.concierge.get_component('get_userinfo')().id) {    //do nothing if I'm the Author:
          msg += "<a href='javascript:" + $str + '.concierge.trigger({type: "select_thread", value:"' + l.ID + "\"})'>New comment on page " + l.page + '</a><br/>';
        }
      }

      if (msg !== '') {
        $.I(msg, true);
      }
    };

    $.concierge.setHistoryHelper(function (_payload, cb) {
      _payload['__return'] = { type:'newNotesOnFile', a:{ id_source: Pers.id_source } };
      Pers.call('log_history', _payload, cb);
    }, 120000, cb2);

    var matches = document.location.pathname.match(/\/(\d*)$/);
    if (matches == null || matches.length !== 2) {
      alert("Can't open file b/c URL pathname doesn't with an integer: " + document.location.pathname);
    }

    var id_source =  parseInt(Pers.id_source, 10);
    $.concierge.trigger({ type:'file', value: id_source });
    var f = Pers.store.o.file[id_source];
    document.title = $.E(f.title + ' (' + f.numpages + ' pages)');
    $.concierge.get_component('notes_loader')({ file:id_source }, function (P) {
      var m = Pers.store;
      m.add('seen', P['seen']);
      m.add('comment', P['comments']);
      m.add('location', P['locations']);
      m.add('link', P['links']);
      m.add('threadmark', P['threadmarks']);

      //now check if need to move to a given annotation:
      if ('c' in Pers.params) {
        window.setTimeout(function () {
          var id =  Pers.params.c;
          var c = m.get('comment', { ID: id }).items[id];
          if ('reply' in Pers.params) {
            $.concierge.trigger({ type: 'reply_thread', value: c.ID });
          }

          $.concierge.trigger({ type: 'select_thread', value: c.ID_location });

        }, 300);
      }      else if ('p' in Pers.params) {
        window.setTimeout(function () {
          var page = Pers.params.p;
          $.concierge.trigger({ type: 'page', value: page });
        }, 300);
      }      else {
        window.setTimeout(function () {
          $.concierge.trigger({ type: 'page', value: 1 });
        }, 300);
      }

      if ('cl' in  Pers.params) { //load comment labels
        $.concierge.get_component('commentlabels_loader')({ file:id_source }, function (P) {
          m.add('labelcategory', P['labelcategories']);
          m.add('commentlabel', P['commentlabels']);
          m.add('labelcategorycaption', P['labelcategorycaptions']);

        });
      }
    });
  };
Example #18
0
 add_folder:        function (P, cb) {Pers.call('add_folder', P, cb);},
 var recordAction = function(control, value) {
   var key = payloadSourceId + "|"+control + "|" + value;
   var payload = {};
   payload[key]=(new Date()).getTime();
   Pers.call("log_history", {"analyticsClick": payload}, function(callback) {});
 }
Example #20
0
 source_id_getter:    function (P, cb) {Pers.call('request_source_id', P, cb);},
  Pers.init = function () {

    var matches = document.location.pathname.match(/\/(\d*)$/);
    if (matches == null || matches.length !== 2) {
      alert("Can't open file b/c URL pathname doesn't have an integer: " + document.location.pathname);
    }

    Pers.id_source = matches[1];
    Pers.call('getParams', { name: ['RESOLUTIONS', 'RESOLUTION_COORDINATES'], clienttime: (new Date()).getTime() }, function (p) {
      $.concierge.addConstants(p.value);
    });

    $.concierge.addListeners(Pers, {
      successful_login: function (evt) {
        Auth.set_cookie('ckey', evt.value.ckey);
        document.location = document.location.protocol + '//' + document.location.host + document.location.pathname;
        $.I('Welcome !');
      },
    }, 'globalPersObject');

    //Factories: methods called if an event calls for a function that's not yet present
    $.concierge.addFactory('file', 'doc_viewer', function (id) {
      var pers_id = 'pers_' + id;
      var $vp = $(".nb-viewport");
      var $pers = $("<div id='" + pers_id + "'/>").appendTo($vp);
      var docview = {
        priority: 1,
        min_width: 950,
        desired_width: 50,
        content: function ($div) {
          $div.docView({ img_server: Conf.servers.img });
          $div.docView('set_model', Pers.store);
        },
      };
      var notesview = {
        priority: 1,
        min_width: 650,
        desired_width: 35,
        min_height: 1000,
        desired_height: 50,
        content: function ($div) {
          $div.notepaneView();
          $div.notepaneView('set_model', Pers.store);
        },
      };
      var threadview = {
        priority: 1,
        min_width: 650,
        desired_width: 35,
        min_height: 1000,
        desired_height: 50,
        content: function ($div) {
          var opts = {};
          if ('cl' in  Pers.params) {
            opts['commentLabels'] = true;
          }

          $div.threadview(opts);
          $div.threadview('set_model', Pers.store);
        },
      };
      var editorview = {
        priority: 1,
        min_width: 650,
        desired_width: 35,
        min_height: 1000,
        desired_height: 50,
        transcient: true,
        content: function ($div) {
          var m = Pers.store;
          var ensemble = m.o.ensemble[m.o.file[id].id_ensemble];
          $div.editorview({ allowStaffOnly: ensemble.allow_staffonly, allowAnonymous: ensemble.allow_anonymous });
          $div.editorview('set_model', Pers.store);
        },
      };
      $pers.perspective({
        height: function () {return $vp.height() - $pers.offset().top;},

        listens: {
          page_peek: function (evt) {
            //need to add 1 value for uniqueness
            $.concierge.logHistory('page', evt.value + '|' + id + '|' + (new Date()).getTime());
          },

          close_view: function (evt) {
            if (evt.value === this.l.element[0].id) {
              delete($.concierge.features.doc_viewer[id]);
            }

            $.L('closeview: ', evt, this.l.element[0].id);
          },
        },
        views: {
          v1:{ data: docview },
          v2:{
            children: {
              v1:{ data: notesview },
              v2:{ children: { v1: { data: threadview }, v2: { data: editorview }, orientation: 'horizontal' } },  orientation: 'horizontal',
            },
          },
          orientation: 'vertical',
        },
      });
    });

    //get data:
    Pers.call('getGuestFileInfo', { id_source: Pers.id_source }, Pers.createStore, Pers.on_fileinfo_error);
    $.concierge.addConstants({ res: 288, scale: 25, QUESTION: 1, STAR: 2 });
    $.concierge.addComponents({
      set_comment_label: function (P, cb) {
        Pers.call('set_comment_label', P, cb);
      },

      notes_loader: function (P, cb) {Pers.call('getNotes', P, cb);},

      note_creator: function (P, cb) {Pers.call('saveNote', P, cb);},

      note_editor: function (P, cb) {Pers.call('editNote', P, cb);},

      commentlabels_loader: function (P, cb) {Pers.call('getCommentLabels', P, cb);},

      bulk_import_annotations: function (P, cb) {
        Pers.call('bulk_import_annotations', {
          locs_array: P.locs_array,
          from_source_id: P.from_source_id,
          to_source_id: P.to_source_id,
          import_type: P.import_type,
        }, cb);
      },

      set_location_section: function (P, cb) {
        Pers.call('set_location_section', {
          id_location: P.id_location,
          id_section: P.id_section,
        }, cb);
      },

      promote_location_by_copy: function (P, cb) {
        Pers.call('promote_location_by_copy', {
          id_location: P.id_location,
        }, cb);
      },

      delete_thread: function (P, cb) {
        Pers.call('deleteThread', {
          id_location: P.id_location,
        }, cb);
      },
    });
  };
 $.concierge.setHistoryHelper(function (_payload, cb) {
   _payload['__return'] = { type:'newNotesOnFile', a:{ id_source: Pers.id_source } };
   Pers.call('log_history', _payload, cb);
 }, 120000, cb2);
Example #23
0
  Pers.init = function () {
    if ('q' in Pers.params) {
      Pers.query = Pers.params.q;
    } else {
      Pers.query = 'auth';
    }

    Pers.call('getParams', { name: ['RESOLUTIONS', 'RESOLUTION_COORDINATES'] }, function (p) {
      $.concierge.addConstants(p.value);
    });

    //Factories: methods called if an event calls for a function that's not yet present
    $.concierge.addFactory('collection', 'collection_viewer', function (id) {
      var pers_id        = 'pers_' + id;
      var $vp        = $("<div class='nb-viewport'><div class='nb-widget-header'/></div>").prependTo('body');
      var $pers        = $("<div id='" + pers_id + "'/>").appendTo($vp);
      var docview        =  {
        priority: 1,
        min_width: 650,
        desired_width: 35,
        content: function ($div) {
          $div.docView({ img_server: Conf.servers.img });
          window.setTimeout(function () {
            $div.docView('set_model', Pers.store);
          }, 5000);
        },
      };
      var notesview    =  {
        priority: 1,
        min_width: 950,
        desired_width: 50,
        min_height: 1000,
        desired_height: 50,
        content: function ($div) {
          $div.notepaneView();
          $div.notepaneView('set_model', Pers.store);
        },
      };
      var threadview    = {
        priority: 1,
        min_width: 950,
        desired_width: 50,
        min_height: 1000,
        desired_height: 50,
        content: function ($div) {
          $div.threadview();
          $div.threadview('set_model', Pers.store);
        },
      };
      var editorview    =  {
        priority: 1,
        min_width: 950,
        desired_width: 50,
        min_height: 1000,
        desired_height: 50,
        transcient: true,
        content: function ($div) {
          /* TODO: this needs to be done at comment creation time since we can have notes spanning several ensembles */
          /*
            var m = Pers.store;
            var ensemble = m.o.ensemble[m.o.file[id].id_ensemble];
            $div.editorview({allowStaffOnly: ensemble.allow_staffonly, allowAnonymous: ensemble.allow_anonymous});
          */

          //temporary fix: restrict all
          $div.editorview({ allowStaffOnly: false, allowAnonymous: false });
          $div.editorview('set_model', Pers.store);
        },
      };
      $pers.perspective({
        height: function () {return $vp.height() - $pers.offset().top;},

        listens: {
          page_peek: function (evt) {
            //need to add 1 value for uniqueness
            var location = Pers.store.o.location[Pers.collection.items[Number(evt.value) - 1]];
            $.concierge.logHistory('page', location.page + '|' + location.id_source + '|' + (new Date()).getTime());
          },

          close_view: function (evt) {
            if (evt.value === this.l.element[0].id) {
              delete($.concierge.features.doc_viewer[id]);
            }

            $.L('closeview: ', evt, this.l.element[0].id);
          },

          successful_login: function (evt) {
            Auth.set_cookie('ckey', evt.value.ckey);
            document.location = 'http://' + document.location.host + document.location.pathname;
            $.I('Welcome !');
          },

        },
        views: {
          v1:{ data: docview },
          v2:{ children: {
            v1:{ data: notesview },
            v2:{ children: { v1: { data: threadview }, v2: { data: editorview }, orientation: 'horizontal' } },  orientation: 'horizontal',
          }, },
          orientation: 'vertical',
        },
      });
    });

    //get data:
    var P2 =  { query: Pers.query };
    if ('id_ensemble' in Pers.params) {
      P2['id_ensemble'] = Pers.params.id_ensemble;
    }

    if ('id_source' in Pers.params) {
      P2['id_source'] = Pers.params.id_source;
    }

    if ('id_author' in Pers.params) {
      P2['id_author'] = Pers.params.id_author;
    }

    if ('unread' in Pers.params) {
      P2['unread'] = Pers.params.unread;
    }

    Pers.call('getMyNotes', P2,  Pers.createStore);
    $.concierge.addConstants({ res: 288, scale: 25 });

    $.concierge.addComponents({
      add_file_menu:        function (P, cb) {Files.addFile(P.id_ensemble, P.id_folder);},

      source_id_getter:    function (P, cb) {Pers.call('request_source_id', P, cb);},

      add_folder_menu:    function (P, cb) {Files.addFolder(P.id_ensemble, P.id_folder);},

      add_folder:        function (P, cb) {Pers.call('add_folder', P, cb);},

      rename_file_menu:    function (P, cb) {Files.rename_file(P.id);},

      rename_file:        function (P, cb) {Pers.call('rename_file', P, cb);},

      delete_file_menu:    function (P, cb) {Files.delete_file(P.id);},

      delete_file:        function (P, cb) {Pers.call('delete_file', P, cb);},

      move_file_menu:        function (P, cb) {Files.move_file(P.id);},

      move_file:        function (P, cb) {Pers.call('move_file', P, cb);},

      update_file_menu:    function (P, cb) {Files.update_file(P.id);},

      add_ensemble:        function (P, cb) {Pers.call('add_ensemble', P, cb);},

      get_sequence:        function (P, cb) {return Pers.sequence;},

      get_collection:        function (P, cb) {return Pers.collection;},
    });

    $.concierge.addComponents({
      notes_loader:    function (P, cb) {Pers.call('getNotes', P, cb);},

      note_creator:    function (P, cb) {Pers.call('saveNote', P, cb);},

      note_editor:    function (P, cb) {Pers.call('editNote', P, cb);},
    });
  };
 commentlabels_loader: function (P, cb) {Pers.call('getCommentLabels', P, cb);},
 set_location_section: function (P, cb) {
   Pers.call('set_location_section', {
     id_location: P.id_location,
     id_section: P.id_section,
   }, cb);
 },
 delete_thread: function (P, cb) {
   Pers.call('deleteThread', {
     id_location: P.id_location,
   }, cb);
 },
Example #27
0
 delete_file:        function (P, cb) {Pers.call('delete_file', P, cb);},
Example #28
0
 move_file:        function (P, cb) {Pers.call('move_file', P, cb);},
Example #29
0
 rename_file:        function (P, cb) {Pers.call('rename_file', P, cb);},
 set_comment_label: function (P, cb) {
   Pers.call('set_comment_label', P, cb);
 },