Changeset 497 for trunk/js/Utilities.js


Ignore:
Timestamp:
Sep 15, 2014 9:44:27 PM (10 years ago)
Author:
anonymous
Message:

Beginning the process of adapting codebase to foundation styles.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/js/Utilities.js

    r496 r497  
    1818*/
    1919
    20 // All Codebase functions will be under the Strangecode namespace.
     20// Codebase functions will be under the Strangecode namespace, unless they are added to the jQuery object for chaining.
    2121var Strangecode = Strangecode || {};
    2222
     
    6868    });
    6969};
     70
     71/*
     72* Encode HTML by proxying content via an in-memory div, setting its inner text which jQuery automatically encodes.
     73Then we pull the encoded contents back out. The div never exists on the page.
     74---------------------------------------------------------------------
     75$('select').append($('<option>', {
     76    value: value,
     77    text: htmlEncode(text)
     78}));
     79---------------------------------------------------------------------
     80*
     81* @access   public
     82* @version  1.0
     83* @since    30 Jun 2013
     84*/
     85Strangecode.htmlEncode = function(text) {
     86    return $('<div/>').text(text).html();
     87};
     88jQuery.fn.htmlEncode = Strangecode.htmlEncode;
Note: See TracChangeset for help on using the changeset viewer.