<commit_before>/*   RSence
 *   Copyright 2008 Riassence Inc.
 *   http://riassence.com/
 *
 *   You should have received a copy of the GNU General Public License along
 *   with this software package. If not, contact <EMAIL>
 */

/*** = Description
  ** An application designed to display errors.
  **
  ** Used automatically by the server to report issues.
  ** Stops COMM.Transporter and displays a HWindow with the message contained.
  ** Has two buttons: *Reset Session* and *Reload*
  **
  ** = Usage
  **   jsLoader.load('servermessage');
  **   ReloadApp.nu( 'Session Timeout', 'Your session has timed out', '/' );
  **
**/
ReloadApp = HApplication.extend({
  
/** Reloads the page using the +_url+ given in the +constructor+.
  **/
  reload: function(){
    var _url = this._url;
    if((!_url)||(_url==='/')){
      window.location.reload(true);
    }
    else {
      window.location.href = _url;
    }
  },
  
/** = Description
  * Reset the session.
  *
  * Resets the session by calling the hello/goodbye url on the server.
  * The server reads the cookie key and deletes the session bound to it.
  *
  * Reloads the page after a successful request.
  *
  **/
  reset_session: function(){
    COMM.request(
      HCLIENT_HELLO + '/goodbye', {
        method: 'POST',
        body: ('ses_key='+COMM.Session.ses_key),
        async: true,
        onSuccess: function(){
          window.location.reload(true);
        },
        onFailure: function(){
          window.location.reload(true);
        }
    });
  },
  
/** = Description
  * Constructs the ReloadApp.
  *
  * Creates an application with a window titled +_title+,
  * containing the +_message+ and *Reset Session* and *Reload*
  * buttons. The +_url+ is the url to load when any of the
  * buttons are pressed.
  *
  * = Parameters
  * +_title+::    The title of the message.
  * +_message+::  The message text content.
  * +_url+::      The url the buttons load when pressed.
  *
  **/
  constructor: function( _title, _message, _url ){
    var _this = this;
    _this.base();
    _this._title = _title;
    _this._message = _message;
    _this._url = _url;
    var _winWidth  = ELEM.windowSize()[0],
        _winHeight = ELEM.windowSize()[1],
        _halfWidth = parseInt(_winWidth/2,10),
        _halfHeight = parseInt(_winHeight/2,10),
        _alertWidth  = 400,
        _alertHeight = 300,
        _alertX      = _halfWidth - 200,
        _alertY      = _halfHeight - 150;
    if(_alertX<10){_alertX = 10;}
    if(_alertY<10){_alertY = 10;}
    HWindow.extend({
      drawSubviews: function(){
        var _this = this,
            _elemId = _this.markupElemIds['subview'],
            _alertIcon = ELEM.make( _elemId ),
            _alertTitle = ELEM.make( _elemId ),
            _alertMessage = ELEM.make( _elemId ),
            _iconUrl = _this.getThemeGfxFile('reloadapp_warning.png');
        _this.setStyle('font-family','Arial, sans-serif');
        _this.setStyle('color','#000');
        _this.setStyle('font-size','13px');
        ELEM.setCSS(_alertIcon,'position:absolute;left:8px;top:8px;width:48px;height:48px;background-image:url('+_iconUrl+');');
        ELEM.setCSS(_alertTitle,'position:absolute;left:64px;top:8px;width:300px;height:24px;line-height:24px;vertical-align:middle;text-align:center;font-weight:bold;overflow:hidden;text-overflow:ellipsis;line-wrap:nowrap;');
        ELEM.setHTML(_alertTitle,_this.app._title);
        ELEM.setCSS(_alertMessage,'position:absolute;left:64px;top:42px;width:332px;height:186px;border-bottom:1px dotted #999;line-height:17px;vertical-align:middle;overflow:auto;');
        ELEM.setHTML(_alertMessage,_this.app._message);
        HButton.extend({
          click: this.app.reload
        }).nu(
          HRect.nu(280, 234, 380, 258 ),
          _this, {
            label: 'Reload',
            events: {
              click: true
            }
          }
        );
        HButton.extend({
          click: this.app.reset_session
        }).nu(
          HRect.nu(20, 234, 170, 258 ),
          _this, {
            label: 'Reset session',
            events: {
              click: true
            }
          }
        );
      }
    }).nu(
      HRect.nu( _alertX, _alertY, _alertX+_alertWidth, _alertY+_alertHeight ),
      _this, {
        label: _title,
        minSize: [_alertWidth,_alertHeight],
        maxSize: [_alertWidth,_alertHeight],
        enabled: true,
        closeButton: true,
        noResize: true
      }
    );
    
    COMM.Transporter.stop = true;<commit_msg>reloadapp uses sheet instead of window now<commit_after>/*   RSence
 *   Copyright 2008 Riassence Inc.
 *   http://riassence.com/
 *
 *   You should have received a copy of the GNU General Public License along
 *   with this software package. If not, contact <EMAIL>
 */

/*** = Description
  ** An application designed to display errors.
  **
  ** Used automatically by the server to report issues.
  ** Stops COMM.Transporter and displays a HWindow with the message contained.
  ** Has two buttons: *Reset Session* and *Reload*
  **
  ** = Usage
  **   jsLoader.load('servermessage');
  **   ReloadApp.nu( 'Session Timeout', 'Your session has timed out', '/' );
  **
**/
ReloadApp = HApplication.extend({
  
/** Reloads the page using the +_url+ given in the +constructor+.
  **/
  reload: function(){
    var _url = this._url;
    if((!_url)||(_url==='/')){
      window.location.reload(true);
    }
    else {
      window.location.href = _url;
    }
  },
  
/** = Description
  * Reset the session.
  *
  * Resets the session by calling the hello/goodbye url on the server.
  * The server reads the cookie key and deletes the session bound to it.
  *
  * Reloads the page after a successful request.
  *
  **/
  reset_session: function(){
    COMM.request(
      HCLIENT_HELLO + '/goodbye', {
        method: 'POST',
        body: ('ses_key='+COMM.Session.ses_key),
        async: true,
        onSuccess: function(){
          window.location.reload(true);
        },
        onFailure: function(){
          window.location.reload(true);
        }
    });
  },
  
/** = Description
  * Constructs the ReloadApp.
  *
  * Creates an application with a window titled +_title+,
  * containing the +_message+ and *Reset Session* and *Reload*
  * buttons. The +_url+ is the url to load when any of the
  * buttons are pressed.
  *
  * = Parameters
  * +_title+::    The title of the message.
  * +_message+::  The message text content.
  * +_url+::      The url the buttons load when pressed.
  *
  **/
  constructor: function( _title, _message, _url ){
    var _this = this;
    _this.base();
    _this._title = _title;
    _this._message = _message;
    _this._url = _url;
    var _winWidth  = ELEM.windowSize()[0],
        _winHeight = ELEM.windowSize()[1],
        _halfWidth = parseInt(_winWidth/2,10),
        _halfHeight = parseInt(_winHeight/2,10),
        _alertWidth  = 400,
        _alertHeight = 270,
        _alertX      = _halfWidth - 200,
        _alertY      = _halfHeight - 150;
    if(_alertX<10){_alertX = 10;}
    if(_alertY<10){_alertY = 10;}
    HSheet.extend({
      drawSubviews: function(){
        var _this = this,
            _elemId = _this.markupElemIds['subview'],
            _alertIcon = ELEM.make( _elemId ),
            _alertTitle = ELEM.make( _elemId ),
            _alertMessage = ELEM.make( _elemId ),
            _iconUrl = _this.getThemeGfxFile('reloadapp_warning.png');
        _this.setStyle('font-family','Arial, sans-serif');
        _this.setStyle('color','#000');
        _this.setStyle('font-size','13px');
        ELEM.setCSS(_alertIcon,'position:absolute;left:8px;top:8px;width:48px;height:48px;background-image:url('+_iconUrl+');');
        ELEM.setCSS(_alertTitle,'position:absolute;left:64px;top:8px;width:300px;height:24px;line-height:24px;vertical-align:middle;text-align:center;font-weight:bold;overflow:hidden;text-overflow:ellipsis;line-wrap:nowrap;');
        ELEM.setHTML(_alertTitle,_this.app._title);
        ELEM.setCSS(_alertMessage,'position:absolute;left:64px;top:42px;width:332px;height:186px;border-bottom:1px dotted #999;line-height:17px;vertical-align:middle;overflow:auto;');
        ELEM.setHTML(_alertMessage,_this.app._message);
        HButton.extend({
          click: this.app.reload
        }).nu(
          HRect.nu(280, 234, 380, 258 ),
          _this, {
            label: 'Reload',
            events: {
              click: true
            }
          }
        );
        HButton.extend({
          click: this.app.reset_session
        }).nu(
          HRect.nu(20, 234, 170, 258 ),
          _this, {
            label: 'Reset session',
            events: {
              click: true
            }
          }
        );
      }
    }).nu(
      HRect.nu( _alertX, _alertY, _alertX+_alertWidth, _alertY+_alertHeight ),
      _this, {
        label: _title,
        value: 0
        // minSize: [_alertWidth,_alertHeight],
        // maxSize: [_alertWidth,_alertHeight],
        // enabled: true,
        // closeButton: true,
        // noResize: true
      }
    );
    
    COMM.Transporter.stop = true;
{'fraction_non_alphanumeric': 0.13285870755750273, 'fraction_numerical': 0.020262869660460023, 'mean_word_length': 2.409634055265123, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2861208', 'n_tokens_mistral': 3059, 'n_tokens_neox': 2898, 'n_words': 641}