Add missing classes

This commit is contained in:
Zixaphir 2015-01-10 00:35:27 -07:00
parent ada2b5abd0
commit 872612ad9f
5 changed files with 165 additions and 3 deletions

View File

@ -115,7 +115,7 @@
'use strict';
(function() {
var $, $$, Anonymize, AntiAutoplay, ArchiveLink, Banner, Board, Build, Callbacks, Captcha, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, CrossOrigin, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, E, Embedding, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, IDHighlight, ImageCommon, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Linkify, Main, MarkNewIPs, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, ReportLink, RevealSpoilers, Rice, Sauce, Settings, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, editMascot, editTheme, g, userNavigation,
var $, $$, Anonymize, AntiAutoplay, ArchiveLink, Banner, Board, Build, Callbacks, Captcha, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, Connection, CrossOrigin, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, E, Embedding, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, IDHighlight, ImageCommon, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Linkify, Main, MarkNewIPs, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, ReportLink, RevealSpoilers, Rice, Sauce, Settings, ShimSet, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, editMascot, editTheme, g, userNavigation,
__slice = [].slice,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__hasProp = {}.hasOwnProperty,
@ -4228,6 +4228,70 @@
})();
ShimSet = (function() {
function ShimSet() {
this.elements = {};
this.size = 0;
}
ShimSet.prototype.has = function(value) {
return value in this.elements;
};
ShimSet.prototype.add = function(value) {
if (this.elements[value]) {
return;
}
this.elements[value] = true;
return this.size++;
};
ShimSet.prototype["delete"] = function(value) {
if (!this.elements[value]) {
return;
}
delete this.elements[value];
return this.size--;
};
return ShimSet;
})();
if (!('Set' in window)) {
window.Set = ShimSet;
}
Connection = (function() {
function Connection(target, origin, cb) {
this.target = target;
this.origin = origin;
this.cb = cb;
$.on(window, 'message', this.onMessage.bind(this));
}
Connection.prototype.send = function(data) {
return this.target.postMessage("" + g.NAMESPACE + (JSON.stringify(data)), this.origin);
};
Connection.prototype.onMessage = function(e) {
var data, type, value, _base;
if (!(e.source === this.target && e.origin === this.origin && typeof e.data === 'string' && e.data.slice(0, g.NAMESPACE.length) === g.NAMESPACE)) {
return;
}
data = JSON.parse(e.data.slice(g.NAMESPACE.length));
for (type in data) {
value = data[type];
if (typeof (_base = this.cb)[type] === "function") {
_base[type](value);
}
}
};
return Connection;
})();
Polyfill = {
init: function() {},
toBlob: function() {

View File

@ -88,7 +88,7 @@
'use strict';
(function() {
var $, $$, Anonymize, AntiAutoplay, ArchiveLink, Banner, Board, Build, Callbacks, Captcha, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, CrossOrigin, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, E, Embedding, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, IDHighlight, ImageCommon, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Linkify, Main, MarkNewIPs, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, ReportLink, RevealSpoilers, Rice, Sauce, Settings, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, editMascot, editTheme, g, userNavigation,
var $, $$, Anonymize, AntiAutoplay, ArchiveLink, Banner, Board, Build, Callbacks, Captcha, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, Connection, CrossOrigin, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, E, Embedding, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, IDHighlight, ImageCommon, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Linkify, Main, MarkNewIPs, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, ReportLink, RevealSpoilers, Rice, Sauce, Settings, ShimSet, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, editMascot, editTheme, g, userNavigation,
__slice = [].slice,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__hasProp = {}.hasOwnProperty,
@ -4255,6 +4255,70 @@
})();
ShimSet = (function() {
function ShimSet() {
this.elements = {};
this.size = 0;
}
ShimSet.prototype.has = function(value) {
return value in this.elements;
};
ShimSet.prototype.add = function(value) {
if (this.elements[value]) {
return;
}
this.elements[value] = true;
return this.size++;
};
ShimSet.prototype["delete"] = function(value) {
if (!this.elements[value]) {
return;
}
delete this.elements[value];
return this.size--;
};
return ShimSet;
})();
if (!('Set' in window)) {
window.Set = ShimSet;
}
Connection = (function() {
function Connection(target, origin, cb) {
this.target = target;
this.origin = origin;
this.cb = cb;
$.on(window, 'message', this.onMessage.bind(this));
}
Connection.prototype.send = function(data) {
return this.target.postMessage("" + g.NAMESPACE + (JSON.stringify(data)), this.origin);
};
Connection.prototype.onMessage = function(e) {
var data, type, value, _base;
if (!(e.source === this.target && e.origin === this.origin && typeof e.data === 'string' && e.data.slice(0, g.NAMESPACE.length) === g.NAMESPACE)) {
return;
}
data = JSON.parse(e.data.slice(g.NAMESPACE.length));
for (type in data) {
value = data[type];
if (typeof (_base = this.cb)[type] === "function") {
_base[type](value);
}
}
};
return Connection;
})();
Polyfill = {
init: function() {
return this.toBlob();

View File

@ -7,4 +7,6 @@
<%= grunt.file.read('src/General/lib/databoard.class') %>
<%= grunt.file.read('src/General/lib/notice.class') %>
<%= grunt.file.read('src/General/lib/randomaccesslist.class') %>
<%= grunt.file.read('src/General/lib/simpledict.class') %>
<%= grunt.file.read('src/General/lib/simpledict.class') %>
<%= grunt.file.read('src/General/lib/set.class') %>
<%= grunt.file.read('src/General/lib/connection.class') %>

View File

@ -0,0 +1,16 @@
class Connection
constructor: (@target, @origin, @cb) ->
$.on window, 'message', @onMessage.bind @
send: (data) ->
@target.postMessage "#{g.NAMESPACE}#{JSON.stringify data}", @origin
onMessage: (e) ->
return unless e.source is @target and
e.origin is @origin and
typeof e.data is 'string' and
e.data[...g.NAMESPACE.length] is g.NAMESPACE
data = JSON.parse e.data[g.NAMESPACE.length..]
for type, value of data
@cb[type]? value
return

16
src/General/lib/set.class Normal file
View File

@ -0,0 +1,16 @@
class ShimSet
constructor: ->
@elements = {}
@size = 0
has: (value) ->
value of @elements
add: (value) ->
return if @elements[value]
@elements[value] = true
@size++
delete: (value) ->
return unless @elements[value]
delete @elements[value]
@size--
window.Set = ShimSet unless 'Set' of window