« Utilisateur:Pinocchio/timeline init.js » : différence entre les versions

De BoyWiki
Aucun résumé des modifications
(m)
 
(15 versions intermédiaires par le même utilisateur non affichées)
Ligne 6 : Ligne 6 :
if (wgPageName == 'Utilisateur:Pinocchio/Timeline' && wgAction == 'view') {
if (wgPageName == 'Utilisateur:Pinocchio/Timeline' && wgAction == 'view') {


   /* chargement appli Timeline depuis mit.edu */
   /* seulement si connexion boywiki sécure (problème referrer) */
   importScriptURI('http://static.simile.mit.edu/timeline/api-2.3.0/timeline-api.js?bundle=true');
   if (document.URL.match(/^https:/)) {


   /* chargement style timeline */
      if (confirm("Le chargement du code de Timeline s'effectue sur le site simile.mit.edu\nAccepter le téléchargement externe ?")) {
  importStylesheet('Utilisateur:Pinocchio/timeline_style.css');
    
        /* chargement appli Timeline depuis mit.edu */
        importScriptURI('http://static.simile.mit.edu/timeline/api-2.3.0/timeline-api.js?bundle=true');
        /* chargement style timeline */
        //importStylesheet('Utilisateur:Pinocchio/timeline_style.css');
        /* start */
        timeline_init();
      }
  } else {
      alert('Il est fortement recommandé de se connecter à BoyWiki avec le protocole sécurisé https');
  }
}
}




/* Après chargement */
/* Tempo chargement et init */
function timeline_init() {
function timeline_init() {
   var x = setTimeout("timeline_init_run()",800);
   var x = setTimeout("timeline_init_wait()",1500);
}
function timeline_init_wait() {
  if (typeof(Timeline) == 'object') timeline_init_run();
  else var x = setTimeout("timeline_init_wait()",500);
}
}


Ligne 30 : Ligne 44 :


   //var d = Timeline.DateTime.parseGregorianDateTime("1900");
   //var d = Timeline.DateTime.parseGregorianDateTime("1900");
  var d = Timeline.DateTime.parseGregorianDateTime();
   var bandInfos = [
   var bandInfos = [
       Timeline.createBandInfo({
       Timeline.createBandInfo({
Ligne 37 : Ligne 50 :
         intervalPixels: 200,
         intervalPixels: 200,
         eventSource:    eventSource,
         eventSource:    eventSource,
         date:          d,
         //date:          d,
         theme:          theme,
         theme:          theme,
         layout:        'original'  // original, overview, detailed
         layout:        'original'  // original, overview, detailed
Ligne 46 : Ligne 59 :
         intervalPixels: 200,
         intervalPixels: 200,
         eventSource:    eventSource,
         eventSource:    eventSource,
         date:          d,
         //date:          d,
         theme:          theme,
         theme:          theme,
         layout:        'overview'  // original, overview, detailed
         layout:        'overview'  // original, overview, detailed
Ligne 126 : Ligne 139 :
}
}


addOnloadHook(timeline_init);
//addOnloadHook(timeline_init);




var resizeTimerID = null;
var resizeTimerID = null;
if (wgPageName == 'Utilisateur:Pinocchio/Timeline' && wgAction == 'view') {
  document.body.onresize = timeline_resize;
}


function timeline_resize() {
function timeline_resize() {
   if (resizeTimerID == null) {
   if (resizeTimerID == null) {
       resizeTimerID = window.setTimeout(function() {
       resizeTimerID = window.setTimeout(function() {resizeTimerID = null; tmln.layout();}, 500);
        resizeTimerID = null;
        tmln.layout();
      }, 500);
   }
   }
}
if (wgPageName == 'Utilisateur:Pinocchio/Timeline' && wgAction == 'view') {
  if (document.body) document.body.onresize = timeline_resize;
}
}

Dernière version du 1 septembre 2009 à 11:29

/* Initialisation timeline */

var tmln;

/* seulement pour la page timeline */
if (wgPageName == 'Utilisateur:Pinocchio/Timeline' && wgAction == 'view') {

   /* seulement si connexion boywiki sécure (problème referrer) */
   if (document.URL.match(/^https:/)) {

      if (confirm("Le chargement du code de Timeline s'effectue sur le site simile.mit.edu\nAccepter le téléchargement externe ?")) {
   
         /* chargement appli Timeline depuis mit.edu */
         importScriptURI('http://static.simile.mit.edu/timeline/api-2.3.0/timeline-api.js?bundle=true');
         /* chargement style timeline */
         //importStylesheet('Utilisateur:Pinocchio/timeline_style.css');
         /* start */
         timeline_init();
      }
   } else {
      alert('Il est fortement recommandé de se connecter à BoyWiki avec le protocole sécurisé https');
   }
}


/* Tempo chargement et init */
function timeline_init() {
   var x = setTimeout("timeline_init_wait()",1500);
}
function timeline_init_wait() {
   if (typeof(Timeline) == 'object') timeline_init_run();
   else var x = setTimeout("timeline_init_wait()",500);
}

function timeline_init_run() {
   if (wgPageName != 'Utilisateur:Pinocchio/Timeline' || wgAction != 'view') return;
   
   var eventSource = new Timeline.DefaultEventSource(0);
   
   /* modif thème par défaut */
   var theme = Timeline.ClassicTheme.create();
   theme.event.bubble.width = 350;
   theme.event.bubble.height = 300;

   //var d = Timeline.DateTime.parseGregorianDateTime("1900");
   var bandInfos = [
      Timeline.createBandInfo({
         width:          "80%", 
         intervalUnit:   Timeline.DateTime.DECADE, 
         intervalPixels: 200,
         eventSource:    eventSource,
         //date:           d,
         theme:          theme,
         layout:         'original'  // original, overview, detailed
      }),
      Timeline.createBandInfo({
         width:          "20%", 
         intervalUnit:   Timeline.DateTime.CENTURY, 
         intervalPixels: 200,
         eventSource:    eventSource,
         //date:           d,
         theme:          theme,
         layout:         'overview'  // original, overview, detailed
      })
   ];
   bandInfos[1].syncWith = 0;
   bandInfos[1].highlight = true;

   /* creation dans div */
   tmln = Timeline.create(document.getElementById("tmln"), bandInfos, Timeline.HORIZONTAL);


/* redefinition des labels dates */

   Timeline.GregorianDateLabeller.prototype.defaultLabelInterval = function(date, intervalUnit) {
      var text;
      var emphasized = false;

      date = Timeline.DateTime.removeTimeZoneOffset(date, this._timeZone);

      switch(intervalUnit) {
      case Timeline.DateTime.MILLISECOND:
         text = date.getUTCMilliseconds();
         break;
      case Timeline.DateTime.SECOND:
         text = date.getUTCSeconds();
         break;
      case Timeline.DateTime.MINUTE:
         var m = date.getUTCMinutes();
         if (m == 0) {
            text = date.getUTCHours() + ":00";
            emphasized = true;
         } else {
            text = m;
         }
         break;
      case Timeline.DateTime.HOUR:
         text = date.getUTCHours() + "hr";
         break;
      case Timeline.DateTime.DAY:
         text = Timeline.GregorianDateLabeller.getMonthName(date.getUTCMonth(), this._locale) + " " + date.getUTCDate();
         break;
      case Timeline.DateTime.WEEK:
         text = Timeline.GregorianDateLabeller.getMonthName(date.getUTCMonth(), this._locale) + " " + date.getUTCDate();
         break;
      case Timeline.DateTime.MONTH:
         var m = date.getUTCMonth();
         if (m == 0) {
            text = this.labelInterval(date, Timeline.DateTime.YEAR).text;
            emphasized = true;
         } else {
            text = Timeline.GregorianDateLabeller.getMonthName(m, this._locale);
         }
         break;
      case Timeline.DateTime.YEAR:
      case Timeline.DateTime.DECADE:
      case Timeline.DateTime.CENTURY:
      case Timeline.DateTime.MILLENNIUM:
         var y = date.getUTCFullYear();
         if (y > 0) {
            text = date.getUTCFullYear();
         } else if (y == 0) {
            text = "1 av.J-C";
         } else {
            text = (0 - y) + "av.J-C";
         }
         break;
      default:
         text = date.toUTCString();
      }
      return { text: text, emphasized: emphasized };
   }


   /* chargement source données format json */
   tmln.loadJSON(wgScript + '?action=raw&ctype=text/javascript&title=Utilisateur:Pinocchio/timeline_data1.js', function(json, url) {
      eventSource.loadJSON(json, url);
   });
}

//addOnloadHook(timeline_init);


var resizeTimerID = null;

function timeline_resize() {
   if (resizeTimerID == null) {
      resizeTimerID = window.setTimeout(function() {resizeTimerID = null; tmln.layout();}, 500);
   }
}

if (wgPageName == 'Utilisateur:Pinocchio/Timeline' && wgAction == 'view') {
   if (document.body) document.body.onresize = timeline_resize;
}