Advertisement
patrickc

Untitled

Aug 1st, 2011
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function ChangelogAssistant(changelog)
  2. {
  3.     this.justChangelog = changelog;
  4.  
  5.     // on first start, this message is displayed, along with the current version message from below
  6.     this.firstMessage = $L('Welcome, and thank you for downloading Your Radio, the only radio for webOS that lets you decide what you play!');
  7.  
  8.     this.secondMessage = $L('Thank you for updating Your Radio, please read the changelog below.');
  9.  
  10.     // on new version start
  11.     this.newMessages =
  12.     [
  13.      // Don't forget the comma on all but the last entry
  14.      { version: '0.0.33',log: [ 'Added Changelog scene' ] }
  15.      ];
  16.  
  17.      // setup command menu
  18.      this.cmdMenuModel =
  19.     {
  20.         visible: false,
  21.         items:
  22.         [
  23.             {},
  24.             {
  25.                 label: $L("Ok, I've read this. Let's continue ..."),
  26.                 command: 'do-continue'
  27.             },
  28.             {}
  29.          ]
  30.     };
  31. }
  32.  
  33. ChangelogAssistant.prototype.setup = function() {
  34.     // set title
  35.     if (this.justChangelog)
  36.     {
  37.         this.titleContainer.innerHTML = $L('Changelog');
  38.     }
  39.     else
  40.     {
  41.         if (vers.isFirst) {
  42.             this.titleContainer.innerHTML = $L('Welcome To Your Radio');
  43.         }
  44.         else if (vers.isNew) {
  45.             this.titleContainer.innerHTML = $L('Your Radio Changelog');
  46.         }
  47.     }
  48.     // build data
  49.     var html = '';
  50.     if (this.justChangelog)
  51.     {
  52.         for (var m = 0; m < this.newMessages.length; m++)
  53.         {
  54.             html += Mojo.View.render({object: {title: 'v' + this.newMessages[m].version}, template: 'changelog/changeLog'});
  55.             html += '<ul>';
  56.             for (var l = 0; l < this.newMessages[m].log.length; l++)
  57.             {
  58.                 html += '<li>' + this.newMessages[m].log[l] + '</li>';
  59.             }
  60.             html += '</ul>';
  61.         }
  62.     }
  63.     else
  64.     {
  65.         if (vers.isFirst)
  66.         {
  67.             html += '<div class="text">' + this.firstMessage + '</div>';
  68.         }
  69.         if (vers.isNew)
  70.         {
  71.             if (!this.justChangelog)
  72.             {
  73.                 html += '<div class="text">' + this.secondMessage + '</div>';
  74.             }
  75.             for (var m = 0; m < this.newMessages.length; m++)
  76.             {
  77.                 html += Mojo.View.render({object: {title: 'v' + this.newMessages[m].version}, template: 'changelog/changeLog'});
  78.                 html += '<ul>';
  79.                 for (var l = 0; l < this.newMessages[m].log.length; l++)
  80.                 {
  81.                     html += '<li>' + this.newMessages[m].log[l] + '</li>';
  82.                 }
  83.                 html += '</ul>';
  84.             }
  85.         }
  86.     }
  87.  
  88.     // set data
  89.     this.dataContainer.innerHTML = html;
  90. };
  91.  
  92. ChangelogAssistant.prototype.activate = function(event) {
  93.     if (!this.justChangelog) {
  94.         // start continue button timer
  95.         this.timer = this.controller.window.setTimeout(this.showContinue.bind(this), 5 * 1000);
  96.     }
  97. };
  98.  
  99. ChangelogAssistant.prototype.showContinue = function() {
  100.     // show the command menu
  101.     this.controller.setMenuVisible(Mojo.Menu.commandMenu, true);
  102. };
  103.  
  104. ChangelogAssistant.prototype.handleCommand = function(event) {
  105.     if (event.type == Mojo.Event.command) {
  106.     switch (event.command) {
  107.     case 'do-continue':
  108.     this.controller.stageController.swapScene({name: 'main', transition: Mojo.Transition.crossFade});
  109.     break;
  110.     }
  111.     }
  112. }
  113.  
  114. ChangelogAssistant.prototype.deactivate = function(event) {
  115.     /* remove any event handlers you added in activate and do any other cleanup that should happen before
  116.        this scene is popped or another scene is pushed on top */
  117. };
  118.  
  119. ChangelogAssistant.prototype.cleanup = function(event) {
  120.     /* this function should do any cleanup needed before the scene is destroyed as
  121.        a result of being popped off the scene stack */
  122. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement