Changeset 6563


Ignore:
Timestamp:
Oct 14, 2014, 8:15:24 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1868: Warn about using deprecated javascript API

Location:
branches/3.3-stable/www/include/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-stable/www/include/scripts/main-2.js

    r6559 r6563  
    226226  {
    227227    console.log(message);
     228  }
     229 
     230  /**
     231    Log usage of a deprecated method. A call to this method
     232    should be included as the first line in a deprecated method.
     233    @param method The name of the method (eg. Main.openPopup())
     234    @param voidVersion The version number of BASE in which the method will be removed
     235   */
     236  app.deprecatedMethod = function(method, voidVersion)
     237  {
     238    var msg = 'Deprecated method "' + method + '" will be removed in BASE ' + voidVersion;
     239    console.error(msg);
    228240  }
    229241 
     
    22162228 
    22172229  // Kept for backwards compatibility
     2230  // @Deprecated
    22182231  forms.createHidden = function(frm, name, value, doc)
    22192232  {
     2233    App.deprecatedMethod('Forms.createHidden()', '3.5');
    22202234    Forms.addHidden(frm, name, value);
    22212235  }
     
    28832897
    28842898  // Kept for backwards compatibility
     2899  // @Deprecated
    28852900  numbers.numberOnly = function(event)
    28862901  {
     2902    App.deprecatedMethod('Numbers.numberOnly()', '3.5');
    28872903    Events.numberOnly(event);
    28882904  }
    28892905 
    28902906  // Kept for backwards compatibility
     2907  // @Deprecated
    28912908  numbers.integerOnly = function(event)
    28922909  {
     2910    App.deprecatedMethod('Numbers.integerOnly()', '3.5');
    28932911    Events.integerOnly(event);
    28942912  }
     
    33613379    @param callback Deprecated, onchange event is sent instead
    33623380  */
     3381  // @Deprecated
    33633382  dates.selectDate = function(title, form, input, callback, format)
    33643383  {
     3384    App.deprecatedMethod('Dates.selectDate()', '3.5');
    33653385    var textarea = document.forms[form][input];
    33663386    if (!textarea.id) textarea.id = 't'+(new Date()).getTime();
     
    33783398    @param callback Deprecated, onchange event is sent instead
    33793399  */
     3400  // @Deprecated
    33803401  dates.selectDateTime = function(title, form, input, callback, format)
    33813402  {
     3403    App.deprecatedMethod('Dates.selectDateTime()', '3.5');
    33823404    var textarea = document.forms[form][input];
    33833405    if (!textarea.id) textarea.id = 't'+(new Date()).getTime();
  • branches/3.3-stable/www/include/scripts/main.js

    r6419 r6563  
    2929*/
    3030
     31
    3132/**
    3233  Get the root URL path of this BASE installation. Always ends with a '/' (eg. /base/)
    3334*/
     35// @Deprecated
    3436function getRoot()
    3537{
     38  App.deprecatedMethod('getRoot()', '3.5');
    3639  return App.getRoot();
    3740}
     
    4144  (should only happen on the top frameset of the login page)
    4245*/
     46//@Deprecated
    4347function getSessionId()
    4448{
     49  App.deprecatedMethod('getSessionId()', '3.5');
    4550  return App.getSessionId();
    4651}
     
    5055  require scaling to fit).
    5156*/
     57//@Deprecated
    5258function getScale()
    5359{
     60  App.deprecatedMethod('getScale()', '3.5');
    5461  return App.getScale();
    5562}
     
    6067  value of '0' disable the rewriting.
    6168*/
     69//@Deprecated
    6270function getMaxUrlLength()
    6371{
     72  App.deprecatedMethod('getMaxUrlLength()', '3.5');
    6473  return App.getMaxUrlLength();
    6574}
     
    7786    in the reverse order as they were added to this method.
    7887  */
     88  // @Deprecated
    7989  this.onLoad = function(f)
    8090  {
     91    App.deprecatedMethod('Main.onLoad()', '3.5');
    8192    Doc.onLoad(f);
    8293  }
     
    95106    @see http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1202731
    96107  */
     108  // @Deprecated
    97109  this.openPopup = function(url, name, width, height, options, parentWin)
    98110  {
     111    App.deprecatedMethod('Main.openPopup()', '3.5');
    99112    Dialogs.openPopup(url, name, width, height);
    100113  }
     
    103116    Brings a named window to focus.
    104117  */
     118  // @Deprecated
    105119  this.focusWindow = function(windowName)
    106120  {
     121    App.deprecatedMethod('Main.focusWindow()', '3.5');
    107122    var win = this.getWindow(windowName);
    108123    if (win) win.focus();
     
    114129    the current window is returned.
    115130   */
     131  // @Deprecated
    116132  this.getWindow = function(windowName)
    117133  {
     134    App.deprecatedMethod('Main.getWindow()', '3.5');
    118135    var win = Dialogs.getDialog(windowName);
    119136    if (!win || win.closed) win = window;
     
    130147    @param textarea The name of the textarea to zoom
    131148  */
     149  // @Deprecated
    132150  this.zoom = function(title, form, textarea, disabled, callback)
    133151  {
     152    App.deprecatedMethod('Main.zoom()', '3.5');
    134153    var tmp = document.forms[form][textarea];
    135154    if (!tmp.id) tmp.id = 'z'+(new Date()).getTime();
     
    148167      instead of by setting the form field
    149168  */
     169  // @Deprecated
    150170  this.selectColor = function(title, form, input, callback)
    151171  {
     172    App.deprecatedMethod('Main.selectColor()', '3.5');
    152173    var tmp = document.forms[form][input];
    153174    if (!tmp.id) tmp.id = 'z'+(new Date()).getTime();
     
    161182      @param helpid The id of the helptext to be displayed.
    162183  */
     184  // @Deprecated
    163185  this.openHelp = function(ID, helpid) 
    164186  {
     187    App.deprecatedMethod('Main.openHelp()', '3.5');
    165188    Dialogs.openHelp(helpid);
    166189  }
     
    175198        used if the current tab doesn't specify a help id
    176199  */
     200  // @Deprecated
    177201  this.openTabControlHelp = function(ID, tabcontrol, helpId) 
    178202  {
     203    App.deprecatedMethod('Main.openTabControlHelp()', '3.5');
    179204    Dialogs.openTabControlHelp(tabcontrol, helpId);
    180205  }
     
    189214    @param maxLength The maximum length
    190215  */
     216  // @Deprecated
    191217  this.cutString = function(value, maxLength)
    192218  {
     219    App.deprecatedMethod('Main.cutString()', '3.5');
    193220    return Strings.cut(value, maxLength);
    194221  }
     
    199226    @return The trimmed string
    200227  */
     228  // @Deprecated
    201229  this.trimString = function(value)
    202230  {
     231    App.deprecatedMethod('Main.trimString()', '3.5');
    203232    return Strings.trim(value);
    204233  }
    205234 
    206235  // Show or hide an element with the given ID attribute as a block element
     236  // @Deprecated
    207237  this.showHide = function(id, show)
    208238  {
     239    App.deprecatedMethod('Main.showHide()', '3.5');
    209240    Doc.showHide(id, show);
    210241  }
    211242 
    212243  // Shows an element with the given ID attribute as a block element
     244  // @Deprecated
    213245  this.show = function(id)
    214246  {
     247    App.deprecatedMethod('Main.show()', '3.5');
    215248    Doc.show(id);
    216249  }
    217250  // Shows an element with the given ID attribute as an inline element
     251  // @Deprecated
    218252  this.showInline = function(id)
    219253  {
     254    App.deprecatedMethod('Main.showInline()', '3.5');
    220255    Doc.show(id, 'inline');
    221256  }
    222257  // Hides an element with the given ID attribute
     258  // @Deprecated
    223259  this.hide = function(id)
    224260  {
     261    App.deprecatedMethod('Main.hide()', '3.5');
    225262    Doc.hide(id);
    226263  }
    227264 
     265  // @Deprecated
    228266  this.addClass = function(obj, className)
    229267  {
     268    App.deprecatedMethod('Main.addClass()', '3.5');
    230269    Doc.addClass(obj, className);
    231270  }
    232271 
     272  // @Deprecated
    233273  this.removeClass = function(obj, className)
    234274  {
     275    App.deprecatedMethod('Main.removeClass()', '3.5');
    235276    Doc.removeClass(obj, className);
    236277  }
    237278 
     279  // @Deprecated
    238280  this.addOrRemoveClass = function(obj, className, addIfTrue)
    239281  {
     282    App.deprecatedMethod('Main.addOrRemoveClass()', '3.5');
    240283    Doc.addOrRemoveClass(obj, className, addIfTrue);
    241284  }
    242285 
     286  // @Deprecated
    243287  this.toggleClass = function(obj, className)
    244288  {
     289    App.deprecatedMethod('Main.toggleClass()', '3.5');
    245290    Doc.addOrRemoveClass(obj, className);
    246291  }
     
    248293  // Get the character code of an event that invloves a key, returns 0 if no code can be found
    249294  // Use this method for onKeyPress events only. See also: getEventKeyCode()
     295  // @Deprecated
    250296  this.getEventCharCode = function(event)
    251297  {
     298    App.deprecatedMethod('Main.getEventCharCode()', '3.5');
    252299    var charCode = event.charCode;
    253300    if (event.ctrlKey)
     
    273320  // Get the key code of an event that invloves a key, returns 0 if no code can be found
    274321  // Use this method for onKeyDown and onKeyUp events only. See also: getEventCharCode();
     322  // @Deprecated
    275323  this.getEventKeyCode = function(event)
    276324  {
     325    App.deprecatedMethod('Main.getEventKeyCode()', '3.5');
    277326    return event.keyCode;
    278327  }
     
    280329  // Handle keypress events on focused elements:
    281330  //  * Send a 'click' event to the same target if the 'ENTER' key was pressed
     331  // @Deprecated
    282332  this.handleFocusedKeypress = function(event)
    283333  {
     334    App.deprecatedMethod('Main.handleFocusedKeypress()', '3.5');
    284335    Events.handleFocusedKeypress(event);
    285336  }
    286337 
    287338  // Try to get the window height
     339  // @Deprecated
    288340  this.getWindowHeight = function(theWin)
    289341  {
     342    App.deprecatedMethod('Main.getWindowHeight()', '3.5');
    290343    return App.getWindowPosition(theWin).height;
    291344  }
    292345 
    293346  // Try to get the window width
     347  // @Deprecated
    294348  this.getWindowWidth = function(theWin)
    295349  {
     350    App.deprecatedMethod('Main.getWindowWidth()', '3.5');
    296351    return App.getWindowPosition(theWin).width;
    297352  }
     
    300355  // returns an object with 'left', 'top', 'width' and 'height' properties
    301356  // If 'rightAndBottom' is true, then 'right' and 'bottom' properties are also calculated
     357  // @Deprecated
    302358  this.getElementPosition = function(theElement, rightAndBottom)
    303359  {
     360    App.deprecatedMethod('Main.getElementPosition()', '3.5');
    304361    return Doc.getElementPosition(theElement);
    305362  }
    306363 
    307364 
     365  // @Deprecated
    308366  this.encodeURI = function(value)
    309367  {
     368    App.deprecatedMethod('Main.encodeURI()', '3.5');
    310369    return encodeURIComponent(value);
    311370  }
    312371
     372  // @Deprecated
    313373  this.encodeTags = function(value)
    314374  {
     375    App.deprecatedMethod('Main.encodeTags()', '3.5');
    315376    return Strings.encodeTags(value);
    316377  }
    317378 
     379  // @Deprecated
    318380  this.viewFile = function(ID, fileId)
    319381  {
     382    App.deprecatedMethod('Main.viewFile()', '3.5');
    320383    Files.viewFile(fileId);
    321384  }
    322385
     386  // @Deprecated
    323387  this.downloadFile = function(ID, fileId)
    324388  {
     389    App.deprecatedMethod('Main.downloadFile()', '3.5');
    325390    Files.downloadFile(fileId);
    326391  }
    327392 
    328393 
     394  // @Deprecated
    329395  this.getController = function(itemType)
    330396  {
     397    App.deprecatedMethod('Main.getController()', '3.5');
    331398    return Items.getController(itemType);
    332399  }
    333400 
     401  // @Deprecated
    334402  this.listItems = function(ID, itemType, extraUrl)
    335403  {
     404    App.deprecatedMethod('Main.listeItems()', '3.5');
    336405    Items.list(itemType, extraUrl);
    337406  }
    338407   
     408  // @Deprecated
    339409  this.viewOrEditItem = function(ID, itemType, itemId, edit, extraUrl, popupOptions)
    340410  {
     411    App.deprecatedMethod('Main.viewOrEditItem()', '3.5');
    341412    if (edit)
    342413    {
     
    350421  }
    351422 
     423  // @Deprecated
    352424  this.selectItem = function(ID, itemType, mode, callback, extraUrl, popupOptions)
    353425  {
     426    App.deprecatedMethod('Main.selectItem()', '3.5');
    354427    Dialogs.selectItem(itemType, callback, mode.indexOf('ultiple') > 0, extraUrl);
    355428  }
    356429 
     430  // @Deprecated
    357431  this.deleteItemPermanently = function(ID, ask, itemType, itemId, extraUrl, popupOptions)
    358432  {
     433    App.deprecatedMethod('Main.deleteItemPermanently()', '3.5');
    359434    Items.deleteItemPermanently(itemType, itemId, ask);
    360435  }
    361436
     437  // @Deprecated
    362438  this.showUsingItems = function(ID, itemType, itemId, extraUrl)
    363439  {
     440    App.deprecatedMethod('Main.showUsingItems()', '3.5');
    364441    Items.showUsingItems(itemType, itemId);
    365442  }
     
    369446    @return A request object or null if the browser doesn't support ajax
    370447  */
     448  // @Deprecated
    371449  this.getAjaxRequest = function()
    372450  {
     451    App.deprecatedMethod('Main.getAjaxRequest()', '3.5');
    373452    return Ajax.getXmlHttpRequest();
    374453  }
     
    388467      (only if url is not too long)
    389468  */
     469  // @Deprecated
    390470  this.safeSetLocation = function(url, win, replace)
    391471  {
     472    App.deprecatedMethod('Main.safeSetLocation()', '3.5');
    392473    App.safeSetLocation(url, win, replace);
    393474  }
     
    396477    Check if the URL is longer than the configured max URL length.
    397478  */
     479  // @Deprecated
    398480  this.isTooLongURL = function(url)
    399481  {
     482    App.deprecatedMethod('Main.isTooLongURL()', '3.5');
    400483    return App.isTooLongUrl(url);
    401484  }
     
    412495      window.
    413496  */
     497  // @Deprecated
    414498  this.convertToPostForm = function(url, win)
    415499  {
     500    App.deprecatedMethod('Main.convertToPostForm()', '3.5');
    416501    return Forms.convertUrlToForm(url, win);
    417502  }
     
    420505    Save a key-value pair for a page.
    421506  */
     507  // @Deprecated
    422508  this.setPageValue = function(page, key, value)
    423509  {
     510    App.deprecatedMethod('Main.setPageValue()', '3.5');
    424511    Data.setPageValue(key, value, page);
    425512  }
     
    428515    Get the saved value for the given key on a page
    429516  */
     517  // @Deprecated
    430518  this.getPageValue = function(page, key)
    431519  {
     520    App.deprecatedMethod('Main.getPageValue()', '3.5');
    432521    return Data.getPageValue(key,  page);
    433522  }
    434523
    435524
     525  // @Deprecated
    436526  this.debug = function(message, clearOutput)
    437527  {
     528    App.deprecatedMethod('Main.debug()', '3.5');
    438529    App.debug(message);
    439530  }
    440531 
     532  // @Deprecated
    441533  this.hideDebug = function()
    442   {}
     534  {
     535    App.deprecatedMethod('Main.hideDebug()', '3.5');
     536  }
    443537 
    444538}
Note: See TracChangeset for help on using the changeset viewer.