add test of HTML building

This commit is contained in:
ccd0 2014-06-16 19:29:10 -07:00
parent 00c5b55704
commit 65048751ad
4 changed files with 31 additions and 0 deletions

View File

@ -28,6 +28,7 @@ module.exports = (grunt) ->
'src/General/UI.coffee'
'src/General/Notice.coffee'
'src/General/CrossOrigin.coffee'
'src/General/BuildTest.coffee'
'src/Filtering/**/*.coffee'
'src/Quotelinks/**/*.coffee'
'src/Posting/QR.coffee'

View File

@ -0,0 +1,25 @@
BuildTest =
init: ->
return if !Conf['Menu']
a = $.el 'a',
textContent: 'Test HTML building'
$.on a, 'click', @runTest
$.event 'AddMenuEntry',
type: 'post'
el: a
open: (post) ->
a.dataset.fullID = post.fullID
runTest: ->
post = g.posts[@dataset.fullID]
c.log post.originalHTML
$.cache "//a.4cdn.org/#{post.board.ID}/thread/#{post.thread.ID}.json", ->
for postData in @response.posts
if postData.no is post.ID
root = Build.postFromObject postData, post.board.ID
post2 = new Post root, post.thread, post.board
c.log post2.originalHTML

View File

@ -345,6 +345,7 @@ Main =
['Keybinds', Keybinds]
['Show Dice Roll', Dice]
['Banner', Banner]
['Build Test', BuildTest]
]
Main.init()

View File

@ -3,6 +3,10 @@ class Post
toString: -> @ID
constructor: (root, @thread, @board, that={}) ->
root2 = root.cloneNode true
$.rm el for el in $$ '.mobile', root2
@originalHTML = root2.outerHTML
@ID = +root.id[2..]
@fullID = "#{@board}.#{@ID}"