Skip to content

Commit

Permalink
Merge branch 'v3' of git://github.com/MayhemYDG/4chan-x into v3
Browse files Browse the repository at this point in the history
Conflicts:
	Gruntfile.coffee
	src/Filtering/PostHiding.coffee
	src/General/Build.coffee
	src/General/lib/$.coffee
	src/Menu/Menu.coffee
	src/Posting/QuickReply.coffee
  • Loading branch information
zixaphir committed Dec 25, 2013
2 parents 6dd2e60 + a36806a commit b38f63e
Show file tree
Hide file tree
Showing 20 changed files with 5,987 additions and 5,953 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.coffee
Expand Up @@ -28,7 +28,7 @@ module.exports = (grunt) ->
'src/General/Notice.coffee'
'src/Filtering/**/*'
'src/Quotelinks/**/*'
'src/Linkification/**/*'
'src/Posting/QR.coffee'
'src/Posting/**/*'
'src/Images/**/*'
'src/Linkification/**/*'
Expand Down
5,295 changes: 2,661 additions & 2,634 deletions builds/4chan-X.user.js

Large diffs are not rendered by default.

5,307 changes: 2,673 additions & 2,634 deletions builds/crx/script.js

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions json/archives.json
Expand Up @@ -89,13 +89,4 @@
"software": "foolfuuka",
"boards": ["a", "co", "gd", "jp", "m", "s4s", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"],
"files": ["a", "gd", "jp", "m", "s4s", "tg", "u", "vg", "vp", "vr", "wsg"]
}, {
"uid": 14,
"name": "Bui's Archive",
"domain": "archive.bui.pm",
"http": true,
"https": true,
"software": "foolfuuka",
"boards": ["b"],
"files": ["b"]
}]
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -30,10 +30,10 @@
"grunt-bump": "~0.0.11",
"grunt-concurrent": "~0.4.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-coffee": "~0.7.0",
"grunt-contrib-coffee": "~0.8.0",
"grunt-contrib-compress": "~0.5.2",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-shell": "~0.6.0",
"load-grunt-tasks": "~0.2.0"
Expand Down
12 changes: 7 additions & 5 deletions src/Filtering/PostHiding.coffee
Expand Up @@ -136,10 +136,13 @@ PostHiding =
return

makeButton: (post, type) ->
span = $.el 'span',
className: "brackets-wrap"
textContent: "\u00A0#{if type is 'hide' then '-' else '+'}\u00A0"
a = $.el 'a',
className: "#{type}-reply-button"
innerHTML: "<span class=brackets-wrap>&nbsp;#{if type is 'hide' then '-' else '+'}&nbsp;</span>"
href: 'javascript:;'
$.add a, span
$.on a, 'click', PostHiding.toggle
a

Expand Down Expand Up @@ -186,10 +189,9 @@ PostHiding =
$.add a, $.tn " #{postInfo}"
post.nodes.stub = $.el 'div',
className: 'stub'
$.add post.nodes.stub, if Conf['Menu']
[a, $.tn(' '), button = Menu.makeButton post]
else
a
$.add post.nodes.stub, a
if Conf['Menu']
$.add post.nodes.stub, Menu.makeButton()
$.prepend post.nodes.root, post.nodes.stub

show: (post, showRecursively=Conf['Recursive Hiding']) ->
Expand Down
2 changes: 1 addition & 1 deletion src/Filtering/ThreadHiding.coffee
Expand Up @@ -164,7 +164,7 @@ ThreadHiding =
thread.stub = $.el 'div',
className: 'stub'
if Conf['Menu']
$.add thread.stub, [a, $.tn(' '), Menu.makeButton()]
$.add thread.stub, [a, Menu.makeButton()]
else
$.add thread.stub, a
$.prepend root, thread.stub
Expand Down
55 changes: 19 additions & 36 deletions src/General/Build.coffee
@@ -1,4 +1,6 @@
Build =
staticPath: '//s.4cdn.org/image/'
gifIcon: if window.devicePixelRatio >= 2 then '@2x.gif' else '.gif'
spoilerRange: {}
shortFilename: (filename, isReply) ->
# FILENAME SHORTENING SCIENCE:
Expand Down Expand Up @@ -65,12 +67,12 @@ Build =
file
} = o
isOP = postID is threadID
{staticPath, gifIcon} = Build

staticPath = '//s.4cdn.org/image/'
gifIcon = if window.devicePixelRatio >= 2
'@2x.gif'
tripcode = if tripcode
" <span class=postertrip>#{tripcode}</span>"
else
'.gif'
''

if email
emailStart = '<a href="mailto:' + email + '" class="useremail">'
Expand All @@ -79,41 +81,36 @@ Build =
emailStart = ''
emailEnd = ''

subject = " <span class=subject>#{subject or ''}</span> "

userID =
if !capcode and uniqueID
" <span class='posteruid id_#{uniqueID}'>(ID: " +
"<span class=hand title='Highlight posts by this ID'>#{uniqueID}</span>)</span> "
else
''

switch capcode
when 'admin', 'admin_highlight'
capcodeClass = " capcodeAdmin"
capcodeStart = " <strong class='capcode hand id_admin'" +
"title='Highlight posts by the Administrator'>## Admin</strong>"
capcode = " <img src='#{staticPath}adminicon#{gifIcon}' " +
"alt='This user is the 4chan Administrator.' " +
capcodeIcon = " <img src='#{staticPath}adminicon#{gifIcon}' " +
"title='This user is the 4chan Administrator.' class=identityIcon>"
when 'mod'
capcodeClass = " capcodeMod"
capcodeStart = " <strong class='capcode hand id_mod' " +
"title='Highlight posts by Moderators'>## Mod</strong>"
capcode = " <img src='#{staticPath}modicon#{gifIcon}' " +
"alt='This user is a 4chan Moderator.' " +
capcodeIcon = " <img src='#{staticPath}modicon#{gifIcon}' " +
"title='This user is a 4chan Moderator.' class=identityIcon>"
when 'developer'
capcodeClass = " capcodeDeveloper"
capcodeStart = " <strong class='capcode hand id_developer' " +
"title='Highlight posts by Developers'>## Developer</strong>"
capcode = " <img src='#{staticPath}developericon#{gifIcon}' " +
"alt='This user is a 4chan Developer.' " +
capcodeIcon = " <img src='#{staticPath}developericon#{gifIcon}' " +
"title='This user is a 4chan Developer.' class=identityIcon>"
else
capcodeClass = ''
capcodeStart = ''
capcode = ''
capcodeIcon = ''

userID =
if !capcode and uniqueID
" <span class='posteruid id_#{uniqueID}'>(ID: " +
"<span class=hand title='Highlight posts by this ID'>#{uniqueID}</span>)</span> "
else
''

flag = unless flagCode
''
Expand All @@ -132,13 +129,7 @@ Build =
"<img src='#{staticPath}filedeleted-res#{gifIcon}' alt='File deleted.' class=fileDeletedRes>" +
"</span></div>"
else if file
ext = file.name[-3..]
if !file.twidth and !file.theight and ext is 'gif' # wtf ?
file.twidth = file.width
file.theight = file.height

fileSize = $.bytesToString file.size

fileSize = $.bytesToString file.size
fileThumb = file.turl
if file.isSpoiler
fileSize = "Spoiler Image, #{fileSize}"
Expand All @@ -157,20 +148,17 @@ Build =
"<img src='#{fileThumb}' alt='#{fileSize}' data-md5=#{file.MD5} style='height: #{file.theight}px; width: #{file.twidth}px;'>" +
"</a>"

# Ha ha, filenames!
# html -> text, translate WebKit's %22s into "s
a = $.el 'a', innerHTML: file.name
filename = a.textContent.replace /%22/g, '"'

# shorten filename, get html
a.textContent = Build.shortFilename filename
shortFilename = a.innerHTML

# get html
a.textContent = filename
filename = a.innerHTML.replace /'/g, '&apos;'

fileDims = if ext is 'pdf' then 'PDF' else "#{file.width}x#{file.height}"
fileDims = if file.name[-3..] is 'pdf' then 'PDF' else "#{file.width}x#{file.height}"
fileInfo = "<div class=fileText id=fT#{postID}#{if file.isSpoiler then " title='#{filename}'" else ''}>File: <a href='#{file.url}' target=_blank>#{file.timestamp}</a>" +
"-(#{fileSize}, #{fileDims}#{
if file.isSpoiler
Expand All @@ -183,11 +171,6 @@ Build =
else
fileHTML = ''

tripcode = if tripcode
" <span class=postertrip>#{tripcode}</span>"
else
''

sticky = if isSticky
" <img src=#{staticPath}sticky#{gifIcon} alt=Sticky title=Sticky class=stickyIcon>"
else
Expand Down
7 changes: 3 additions & 4 deletions src/General/Get.coffee
Expand Up @@ -170,8 +170,8 @@ Get =
threadID = +data.thread_num
o =
# id
postID: "#{postID}"
threadID: "#{threadID}"
postID: postID
threadID: threadID
boardID: boardID
# info
name: data.name_processed
Expand Down Expand Up @@ -207,8 +207,7 @@ Get =
new Board boardID
thread = g.threads["#{boardID}.#{threadID}"] or
new Thread threadID, board
post = new Post Build.post(o, true), thread, board,
isArchived: true
post = new Post Build.post(o, true), thread, board, {isArchived: true}
Main.callbackNodes Post, [post]
Get.insert post, root, context
parseMarkup: (text) ->
Expand Down
2 changes: 1 addition & 1 deletion src/General/Main.coffee
Expand Up @@ -191,7 +191,7 @@ Main =
posts = []
for postRoot in $$ '.thread > .postContainer', threadRoot
try
posts.push new Post postRoot, thread, g.BOARD
posts.push post = new Post postRoot, thread, g.BOARD, {isOriginalMarkup: true}
catch err
# Skip posts that we failed to parse.
errors = [] unless errors
Expand Down
28 changes: 2 additions & 26 deletions src/General/html/Build/post.html
Expand Up @@ -6,33 +6,9 @@
''
}'>

<div class='postInfoM mobile' id=pim#{postID}>
<span class='nameBlock#{capcodeClass}'>
<span class=name>
#{name or ''}
</span>
#{tripcode + capcodeStart + capcode + userID + flag + sticky + closed}
<br>#{subject}
</span>
<span class='dateTime postNum' data-utc=#{dateUTC}>
#{date}
<a href=#{"/#{boardID}/res/#{threadID}#p#{postID}"}>
No.
</a>
<a href='#{
if g.VIEW is 'thread' and g.THREADID is +threadID then
"javascript:quote(#{postID})"
else
"/#{boardID}/res/#{threadID}#q#{postID}"
}'>
#{postID}
</a>
</span>
</div>

#{if isOP then fileHTML else ''}

<div class='postInfo desktop' id=pi#{postID}>
<div class='postInfo' id=pi#{postID}>
<input type=checkbox name=#{postID} value=delete>
#{subject}
<span class='nameBlock#{capcodeClass}'>
Expand All @@ -41,7 +17,7 @@
#{tripcode + capcodeStart + emailEnd + capcode + userID + flag}
</span>#{" "}
<span class=dateTime data-utc=#{dateUTC}>#{date}</span>#{" "}
<span class='postNum desktop'>
<span class='postNum'>
<a href=#{"/#{boardID}/res/#{threadID}#p#{postID}"} title='Highlight this post'>No.</a>
<a href='#{
if g.VIEW is 'thread' and g.THREADID is +threadID then
Expand Down
44 changes: 27 additions & 17 deletions src/General/lib/$.coffee
Expand Up @@ -316,9 +316,8 @@ $.get = (key, val, cb) ->

count = 0
done = (item) ->
{lastError} = chrome.runtime
if lastError
c.error lastError, lastError.message or 'No message.'
if chrome.runtime.lastError
c.error chrome.runtime.lastError.message
$.extend items, item
cb items unless --count

Expand All @@ -330,30 +329,41 @@ $.get = (key, val, cb) ->
chrome.storage.sync.get syncItems, done

$.set = do ->
items = {}
localItems = {}

set = $.debounce $.SECOND, ->
items =
sync: {}
local: {}
timeout = {}

setArea = (area) ->
return if timeout[area]
chrome.storage[area].set items[area], ->
if chrome.runtime.lastError
c.error chrome.runtime.lastError.message
timeout[area] = setTimeout setArea, $.MINUTE, area
return
items[area] = {}
delete timeout[area]

setAll = $.debounce $.SECOND, ->
for key in $.localKeys
if key of items
(localItems or= {})[key] = items[key]
delete items[key]
if key of items.sync
items.local[key] = items.sync[key]
delete items.sync[key]
try
chrome.storage.local.set localItems
chrome.storage.sync.set items
items = {}
localItems = {}
setArea 'local'
setArea 'sync'
catch err
c.error err.stack

(key, val) ->
if typeof key is 'string'
items[key] = val
items.sync[key] = val
else
$.extend items, key
set()
$.extend items.sync, key
setAll()

<% } else { %>

# http://wiki.greasespot.net/Main_Page
$.sync = do ->
$.on window, 'storage', ({key, newValue}) ->
Expand Down
8 changes: 8 additions & 0 deletions src/General/lib/post.class
Expand Up @@ -6,6 +6,7 @@ class Post
@ID = +root.id[2..]
@fullID = "#{@board}.#{@ID}"

@cleanup root if that.isOriginalMarkup
post = $ '.post', root
info = $ '.postInfo', post
@nodes =
Expand Down Expand Up @@ -149,6 +150,13 @@ class Post
if @file.isImage = /(jpg|png|gif)$/i.test @file.name
@file.dimensions = fileText.textContent.match(/\d+x\d+/)[0]

cleanup: (root) ->
for node in $$ '.mobile', root
$.rm node
for node in $$ '.desktop', root
$.rmClass node, 'desktop'
return

kill: (file, now) ->
now or= new Date()
if file
Expand Down
2 changes: 2 additions & 0 deletions src/General/lib/thread.class
Expand Up @@ -33,6 +33,8 @@ class Thread
className: "#{typeLC}Icon"
root = if type is 'Closed' and @isSticky
$ '.stickyIcon', @OP.nodes.info
else if g.VIEW is 'index'
$ '.page-num', @OP.nodes.info
else
$ '[title="Quote this post"]', @OP.nodes.info
$.after root, [$.tn(' '), icon]
Expand Down

0 comments on commit b38f63e

Please sign in to comment.