PageSourceSearch

https://codelamp.co.uk/js/makeshift.pockets.js?build=BUILDTOKEN

js codelamp.co.uk collected 2026-10-04 13:34:35 UTC 3,846 bytes, 149 lines download raw bytes

1var makeshift = makeshift || {};
2makeshift.getPocketsBuilder = function($, global, parallax){
3
4  var pockets = {
5
6    display: {
7
8      create: function(){
9        return this.prep.apply(Object.create(this), arguments);
10      },
11
12      prep: function(source, name){
13        return this.reset().processFromElement(source);
14      },
15
16      reset: function(){
17        this.style = [];
18        this.script = {};
19        this.markup = {};
20        return this;
21      },
22
23      bind: function(method){
24        return method.bind(this);
25      },
26
27      processFromElement: function(element){
28        element && $(element)
29          .find('xmp[data-tag=html]').each(this.bind(this.collectMarkup)).end()
30          .find('xmp[data-tag=script]').each(this.bind(this.collectScript)).end()
31          .find('xmp[data-tag=style]').each(this.bind(this.collectStyle)).end()
32        ;
33        return this;
34      },
35
36      collectMarkup: function(i, elm){
37        var jse = $(elm), text = jse.text();
38        this.markup.content = this.parseMarkup(text);
39        return this;
40      },
41
42      collectScript: function(i, elm){
43        var jse = $(elm), type = jse.attr('data-event'), text = $(elm).text();
44        this.script[type] = {
45          type: type,
46          content: this.parseScript(text)
47        };
48        return this;
49      },
50
51      collectStyle: function(i, elm){
52        var jse = $(elm), text = jse.text();
53        this.style.push({
54          attributes: this.tagAttributes(elm),
55          content: this.parseScript(text)
56        });
57        return this;
58      },
59
60      tagAttributes: function(elm){
61        for ( var o = {}, i=0, a=elm.attributes, l=a.length, item; i<l; i++ ) {
62          item = a[i];
63          if (item.name == 'data-tag') continue;
64          o[item.name] = item.value;
65        }
66        return o;
67      },
68
69      parseMarkup: function(v){ return v; },
70      parseScript: function(v){ return v; },
71      parseStyle: function(v){ return v; },
72
73      replaceStyleTokens: function(token, name){
74        switch ( name ) {
75          case 'local':
76
77          break;
78        }
79      },
80
81      /**
82       *
83       */
84      getMarkup: function(){
85        return this.markup.content;
86      },
87
88      /**
89       *
90       */
91      getScript: function(){
92        return this.script;
93      },
94
95      /**
96       *
97       */
98      getStyle: function(groupClass, tokens){
99        var i = 0, l = this.style.length, tags = '', item;
100        for ( i; i<l; i++ ) {
101          item = this.style[i];
102          if ( groupClass ) {
103            if ( !item.attributes ) { item.attributes = {}; }
104            if ( !item.attributes['class'] ) { item.attributes['class'] = ''; }
105            item.attributes['class'] += groupClass;
106          }
107          tags += '<style' + this.renderAttributes(item.attributes) + '>' + this.parseTokens(item.content, tokens) + '</style>';
108        }
109        return tags;
110      },
111      
112      parseTokens: function(content, tokens){
113        return content.replace(/\{\{([a-z0-9+_\-]+)\}\}/gi, function(full, name){
114          if ( tokens[name] !== undefined ) {
115            return tokens[name];
116          }
117          else {
118            return '';
119          }
120        });
121      },
122
123      /**
124       *
125       */
126      renderAttributes: function(attrs){
127        var markup = '';
128        for ( var key in attrs ) {
129          markup += ' ' + key + '="' + attrs[key] + '"';
130        }
131        return markup;
132      }
133
134    },
135
136    cleanPocketSource: function(source){
137      return source.replace(/<(\/?)(style|script|html)( |>)/g, '<$1xmp data-tag="$2"$3');
138    },
139    parsePocketTemplate: function(templateData){
140      return jQuery().pushStack($.parseHTML(pockets.cleanPocketSource(templateData)));
141    },
142    parsePocketDisplay: function(element, name){
143      return this.display.create(element, name);
144    }
145  };
146
147  return pockets;
148
149};

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.