PageSourceSearch

https://www.chinafile.com/sites/all/modules/custom/curlies/curlies.js?tm4wrs

js chinafile.com collected 2026-10-01 08:34:09 UTC 1,277 bytes, 53 lines download raw bytes

1/**
2 * Script to replace boring quotes with curly quotes.
3 *
4 * Unicode characters, plain
5 * " U+0022
6 * ' U+0027
7 *
8 * Unicode characters, curly
9 * ‘ U+2018
10 * ’ U+2019
11 * “ U+201c
12 * ” U+201d
13 */
14(function ($) {
15  $.fn.curlies = function( itemQuery ) {
16    function smarten(text) {
17      //console.log(text);
18      return text
19        /* opening singles */
20        .replace(/(^|[-\u2014\s(\["])'/g, "$1\u2018")
21
22        /* closing singles & apostrophes */
23        .replace(/'/g, "\u2019")
24
25        /* opening doubles */
26        .replace(/(^|[-\u2014/\[(\u2018\s])"/g, "$1\u201c")
27
28        /* closing doubles */
29        .replace(/"/g, "\u201d")
30
31        /* em-dashes */
32        .replace(/--/g, "\u2014");
33    };
34
35    return this.each(function(){
36      var $this = $(this);
37      var $children = $this.children();
38
39      // If there are children, loop again (skip code tags).
40      if ($children.not('code').length) {
41        $children.not('code').each(function(){
42          $(this).curlies();
43        });
44      }
45      // If there are no child elements, replace text.
46      else {
47        if ($this.text().match(/([-\u2014\s(\["])|(')|(([-\u2014/\[(\u2018\s])")|(")|(--)/)) {
48          $this.text( smarten( $this.text() ) );
49        }
50      }
51    });
52  };
53})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.