Merge branch 'master' into zixaphir-merge

Conflicts:
	src/Filtering/Filter.coffee
	src/General/Index.coffee
	src/Images/ImageExpand.coffee
	src/Images/ImageHover.coffee
	src/Miscellaneous/IDColor.coffee
	src/Monitoring/ThreadWatcher.coffee
	src/Posting/QR.coffee
This commit is contained in:
ccd0 2015-02-01 13:41:36 -08:00
commit c70921e176
27 changed files with 1154 additions and 363 deletions

View File

@ -2,7 +2,84 @@ The attributions below are for work that has been incorporated into the script a
The links to individual versions below are to copies of the script with the update URL removed. If you want automatic updates, install the script from the links on the [main page](https://github.com/ccd0/4chan-x). The links to individual versions below are to copies of the script with the update URL removed. If you want automatic updates, install the script from the links on the [main page](https://github.com/ccd0/4chan-x).
<!-- v1.9.22.x -->
### v1.9.22.4
*2015-02-01* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.4/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.4/builds/4chan-X-noupdate.crx "Chromium version")]
- Fix bugs in syncing of mute/volume settings between tabs.
### v1.9.22.3
*2015-02-01* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.3/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.3/builds/4chan-X-noupdate.crx "Chromium version")]
- Add option `Volume in New Tab` (on by default) to apply 4chan X mute/volume settings to videos opened in a new tab.
### v1.9.22.2
*2015-02-01* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.2/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.2/builds/4chan-X-noupdate.crx "Chromium version")]
- 4chan X will now remember your last index mode regardless of how it was chosen (previously only index modes chosen with the drop-down menu were considered permanent choices).
### v1.9.22.1
*2015-02-01* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.1/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.1/builds/4chan-X-noupdate.crx "Chromium version")]
- Add option `Mouse Wheel Volume` (on by default) to adjust the volume of hovering images with the mouse wheel.
- `Image Hover in Catalog` is now a suboption of `Image Hover`.
- Merge v1.9.21.10, v1.9.21.11: Add `Click Passthrough` option (off by default) to allow clicks on videos to perform the browser's default function. Restore dragging to the left to contract and the contract button (shown if `Click Passthrough` is on).
### v1.9.22.0
*2015-01-31* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.0/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.0/builds/4chan-X-noupdate.crx "Chromium version")]
Based on v1.9.21.9.
- Open new videos with the mute and volume settings of the last video adjusted.
- Add default volume control in the header menu, and duplicate "Allow Sounds" there.
- Minor fixes.
<!-- v1.9.21.x --> <!-- v1.9.21.x -->
### v1.9.21.11
*2015-01-31* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.11/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.11/builds/4chan-X-noupdate.crx "Chromium version")]
- Fix bug in `Click Passthrough`: was being applied to images.
### v1.9.21.10
*2015-01-31* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.10/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.10/builds/4chan-X-noupdate.crx "Chromium version")]
- Add `Click Passthrough` option (off by default) to allow clicks on videos to perform the browser's default function. Restore dragging to the left to contract and the contract button (shown if `Click Passthrough` is on).
### v1.9.21.9
*2015-01-31* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.9/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.9/builds/4chan-X-noupdate.crx "Chromium version")]
- Fix bug causing unmuting of videos in inline quotes.
### v1.9.21.8
*2015-01-31* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.8/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.8/builds/4chan-X-noupdate.crx "Chromium version")]
- Expanded WebMs with audio are no longer paused when offscreen.
### v1.9.21.7
*2015-01-31* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.7/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.7/builds/4chan-X-noupdate.crx "Chromium version")]
- Update WebM duration limit to 5 minutes on /gif/ and /wsg/.
- Restore audio check before posting on other boards.
### v1.9.21.6
*2015-01-31* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.6/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.6/builds/4chan-X-noupdate.crx "Chromium version")]
- Update for changes in WebM filesize limits.
### v1.9.21.5
*2015-01-30* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.5/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.5/builds/4chan-X-noupdate.crx "Chromium version")]
- Fix sound playing from replaced WebM thumbnails in previewed/inlined quotes.
### v1.9.21.4
*2015-01-30* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.4/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.4/builds/4chan-X-noupdate.crx "Chromium version")]
Posting WebMs with sound has recently been enabled, at least on /wsg/.
- Restore `Allow Sound` option.
- Fix sound playing from replaced WebM thumbnails.
- Remove check for sound before posting.
### v1.9.21.3 ### v1.9.21.3
*2015-01-28* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.3/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.3/builds/4chan-X-noupdate.crx "Chromium version")] *2015-01-28* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.3/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.3/builds/4chan-X-noupdate.crx "Chromium version")]
@ -17,7 +94,7 @@ The links to individual versions below are to copies of the script with the upda
*2015-01-26* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.1/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.1/builds/4chan-X-noupdate.crx "Chromium version")] *2015-01-26* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.1/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.1/builds/4chan-X-noupdate.crx "Chromium version")]
- Merge v1.9.20.9: Fix description of Thread Updater options in settings panel. - Merge v1.9.20.9: Fix description of Thread Updater options in settings panel.
- (hotdogman) `Pin Watched Threads` is now on by default. - (hotdogman) `Pin Watched Threads` (in header menu -> `Index Navigation`) is now on by default.
- Change mouse cursor over expanded WebMs to pointer. - Change mouse cursor over expanded WebMs to pointer.
### v1.9.21.0 ### v1.9.21.0

View File

@ -1,5 +1,5 @@
/* /*
* 4chan X - Version 1.9.21.3 * 4chan X - Version 1.9.22.4
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE * https://github.com/ccd0/4chan-x/blob/master/LICENSE

Binary file not shown.

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X beta // @name 4chan X beta
// @version 1.9.21.3 // @version 1.9.22.4
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.9.21.3 // @version 1.9.22.4
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'> <gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='lacclbnghgdicfifcamcmcnilckjamag'> <app appid='lacclbnghgdicfifcamcmcnilckjamag'>
<updatecheck codebase='https://ccd0.github.io/4chan-x/builds/4chan-X-beta.crx' version='1.9.21.3' /> <updatecheck codebase='https://ccd0.github.io/4chan-x/builds/4chan-X-beta.crx' version='1.9.22.4' />
</app> </app>
</gupdate> </gupdate>

View File

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'> <gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='lacclbnghgdicfifcamcmcnilckjamag'> <app appid='lacclbnghgdicfifcamcmcnilckjamag'>
<updatecheck codebase='https://ccd0.github.io/4chan-x/builds/4chan-X.crx' version='1.9.21.3' /> <updatecheck codebase='https://ccd0.github.io/4chan-x/builds/4chan-X.crx' version='1.9.22.4' />
</app> </app>
</gupdate> </gupdate>

View File

@ -3,7 +3,7 @@
"description": "Cross-browser userscript for maximum lurking on 4chan.", "description": "Cross-browser userscript for maximum lurking on 4chan.",
"meta": { "meta": {
"name": "4chan X", "name": "4chan X",
"version": "1.9.21.3", "version": "1.9.22.4",
"repo": "https://github.com/ccd0/4chan-x/", "repo": "https://github.com/ccd0/4chan-x/",
"page": "https://github.com/ccd0/4chan-x", "page": "https://github.com/ccd0/4chan-x",
"downloads": "https://ccd0.github.io/4chan-x/builds/", "downloads": "https://ccd0.github.io/4chan-x/builds/",

View File

@ -182,6 +182,12 @@ Config =
'Image Hover in Catalog': [ 'Image Hover in Catalog': [
false false
'Show full image / video on mouseover in <%= meta.name %> catalog.' 'Show full image / video on mouseover in <%= meta.name %> catalog.'
1
]
'Mouse Wheel Volume': [
true
'Adjust volume of hovering videos with mouse wheel.'
1
] ]
'Gallery': [ 'Gallery': [
true true
@ -245,10 +251,23 @@ Config =
true true
'Show controls on videos expanded inline.' 'Show controls on videos expanded inline.'
] ]
'Click Passthrough': [
false
'Clicks on videos trigger your browser\'s default behavior. Videos can be contracted with button / dragging to the left.'
1
]
'Allow Sound': [
true
'Open videos with the sound unmuted.'
]
'Loop in New Tab': [ 'Loop in New Tab': [
true true
'Loop videos opened in their own tabs.' 'Loop videos opened in their own tabs.'
] ]
'Volume in New Tab': [
true
'Apply <%= meta.name %> mute and volume settings to videos opened in their own tabs.'
]
'Menu': 'Menu':
'Menu': [ 'Menu': [
@ -556,6 +575,8 @@ Config =
6.0 6.0
] ]
'Default Volume': 1.0
threadWatcher: threadWatcher:
'Current Board': [ 'Current Board': [
false false

View File

@ -230,9 +230,13 @@ Index =
{search, mode} = e.state {search, mode} = e.state
page = Index.getCurrentPage() page = Index.getCurrentPage()
state = {} state = {}
state.search = Index.search = search if Index.search isnt search if Index.search isnt search
state.mode = Conf['Index Mode'] = mode if Conf['Index Mode'] isnt mode state.search = Index.search = search
state.page = Index.currentPage = page if Index.currentPage isnt page if Conf['Index Mode'] isnt mode
state.mode = mode
Index.saveMode mode
if Index.currentPage isnt page
state.page = Index.currentPage = page
if state.search? or state.mode? or state.page? if state.search? or state.mode? or state.page?
Index.pageLoad state Index.pageLoad state
else else
@ -306,7 +310,7 @@ Index =
if state.mode? if state.mode?
{mode} = state {mode} = state
delete state.mode if mode is Conf['Index Mode'] delete state.mode if mode is Conf['Index Mode']
Conf['Index Mode'] = mode Index.saveMode mode
state.page = 1 if mode in ['all pages', 'catalog'] state.page = 1 if mode in ['all pages', 'catalog']
hash = '' hash = ''
if state.page? if state.page?
@ -322,6 +326,13 @@ Index =
, '', pathname + hash , '', pathname + hash
state state
saveMode: (mode) ->
Conf['Index Mode'] = mode
$.set 'Index Mode', mode
unless mode is 'catalog'
Conf['Previous Index Mode'] = mode
$.set 'Previous Index Mode', mode
pageLoad: ({sort, search, mode, scroll}) -> pageLoad: ({sort, search, mode, scroll}) ->
if sort or search? if sort or search?
Index.sort() Index.sort()

View File

@ -63,11 +63,14 @@ Main =
boardID: g.BOARD.ID boardID: g.BOARD.ID
filename: pathname[pathname.length - 1] filename: pathname[pathname.length - 1]
Redirect.navigate URL Redirect.navigate URL
else if Conf['Loop in New Tab'] and video = $ 'video' else if video = $ 'video'
video.loop = true if Conf['Volume in New Tab']
video.controls = false Volume.setup video
video.play() if Conf['Loop in New Tab']
ImageCommon.addControls video video.loop = true
video.controls = false
video.play()
ImageCommon.addControls video
return return
if Conf['Normalize URL'] and g.VIEW is 'thread' if Conf['Normalize URL'] and g.VIEW is 'thread'
@ -338,6 +341,7 @@ Main =
['Reveal Spoiler Thumbnails', RevealSpoilers] ['Reveal Spoiler Thumbnails', RevealSpoilers]
['Image Loading', ImageLoader] ['Image Loading', ImageLoader]
['Image Hover', ImageHover] ['Image Hover', ImageHover]
['Volume Control', Volume]
['Comment Expansion', ExpandComment] ['Comment Expansion', ExpandComment]
['Thread Expansion', ExpandThread] ['Thread Expansion', ExpandThread]
['Thread Excerpt', ThreadExcerpt] ['Thread Excerpt', ThreadExcerpt]

View File

@ -928,6 +928,12 @@ span.hide-announcement {
.fileThumb > .warning { .fileThumb > .warning {
clear: both; clear: both;
} }
input[name="Default Volume"] {
width: 4em;
height: 1ex;
vertical-align: middle;
margin: 0px;
}
/* Fappe Tyme */ /* Fappe Tyme */
:root.fappeTyme .thread > .noFile, :root.fappeTyme .thread > .noFile,
:root.fappeTyme .threadContainer > .noFile { :root.fappeTyme .threadContainer > .noFile {

View File

@ -296,6 +296,9 @@ $.minmax = (value, min, max) ->
value value
) )
$.hasAudio = (video) ->
video.mozHasAudio or !!video.webkitAudioDecodedByteCount
$.item = (key, val) -> $.item = (key, val) ->
item = {} item = {}
item[key] = val item[key] = val

View File

@ -60,6 +60,9 @@ class Clone extends Post
@file.text = file.firstElementChild @file.text = file.firstElementChild
@file.thumb = $ '.fileThumb > [data-md5]', file @file.thumb = $ '.fileThumb > [data-md5]', file
@file.fullImage = $ '.full-image', file @file.fullImage = $ '.full-image', file
@file.videoControls = $ '.video-controls', @file.text
@file.thumb.muted = true if @file.videoThumb
# Contract thumbnails in quote preview # Contract thumbnails in quote preview
ImageExpand.contract @ if contractThumb ImageExpand.contract @ if contractThumb

View File

@ -156,6 +156,7 @@ Gallery =
$.replace nodes.current, file $.replace nodes.current, file
if elType is 'video' if elType is 'video'
file.loop = true file.loop = true
Volume.setup file
file.play() if Conf['Autoplay'] file.play() if Conf['Autoplay']
ImageCommon.addControls file if Conf['Show Controls'] ImageCommon.addControls file if Conf['Show Controls']
nodes.count.textContent = +thumb.dataset.id + 1 nodes.count.textContent = +thumb.dataset.id + 1

View File

@ -82,7 +82,8 @@ ImageCommon =
# XXX Estimate whether clicks are on the video controls and should be ignored. # XXX Estimate whether clicks are on the video controls and should be ignored.
onControls: (e) -> onControls: (e) ->
e.target.controls and e.target.getBoundingClientRect().bottom - e.clientY < 35 (Conf['Show Controls'] and Conf['Click Passthrough'] and e.target.nodeName is 'VIDEO') or
(e.target.controls and e.target.getBoundingClientRect().bottom - e.clientY < 35)
download: (e) -> download: (e) ->
return true if @protocol is 'blob:' return true if @protocol is 'blob:'

View File

@ -11,6 +11,8 @@ ImageExpand =
$.on @EAI, 'click', @cb.toggleAll $.on @EAI, 'click', @cb.toggleAll
Header.addShortcut @EAI, 3 Header.addShortcut @EAI, 3
$.on d, 'scroll visibilitychange', @cb.playVideos $.on d, 'scroll visibilitychange', @cb.playVideos
@videoControls = $.el 'span', className: 'video-controls'
$.extend @videoControls, <%= html('\u00A0<a href="javascript:;" title="You can also contract the video by dragging it to the left.">contract</a>') %>
Post.callbacks.push Post.callbacks.push
name: 'Image Expansion' name: 'Image Expansion'
@ -28,6 +30,8 @@ ImageExpand =
ImageExpand.expand @ ImageExpand.expand @
else if @file.isExpanded and @file.isVideo else if @file.isExpanded and @file.isVideo
Volume.setup @file.fullImage
ImageExpand.setupVideoCB @
ImageExpand.setupVideo @, !@origin.file.fullImage?.paused or @origin.file.wasPlaying, @file.fullImage.controls ImageExpand.setupVideo @, !@origin.file.fullImage?.paused or @origin.file.wasPlaying, @file.fullImage.controls
else if ImageExpand.on and !@isHidden and !@isFetchedQuote and else if ImageExpand.on and !@isHidden and !@isFetchedQuote and
@ -79,7 +83,7 @@ ImageExpand =
continue unless file and file.isVideo and file.isExpanded continue unless file and file.isVideo and file.isExpanded
video = file.fullImage video = file.fullImage
visible = Header.isNodeVisible video visible = ($.hasAudio(video) and not video.muted) or Header.isNodeVisible video
if visible and file.wasPlaying if visible and file.wasPlaying
delete file.wasPlaying delete file.wasPlaying
video.play() video.play()
@ -117,9 +121,10 @@ ImageExpand =
$.rmClass post.nodes.root, 'expanded-image' $.rmClass post.nodes.root, 'expanded-image'
$.rmClass file.thumb, 'expanding' $.rmClass file.thumb, 'expanding'
$.rm file.videoControls if file.videoControls
file.thumb.parentNode.href = file.URL file.thumb.parentNode.href = file.URL
file.thumb.parentNode.target = '_blank' file.thumb.parentNode.target = '_blank'
for x in ['isExpanding', 'isExpanded', 'wasPlaying', 'scrollIntoView'] for x in ['isExpanding', 'isExpanded', 'videoControls', 'wasPlaying', 'scrollIntoView']
delete file[x] delete file[x]
return unless el return unless el
@ -139,6 +144,8 @@ ImageExpand =
ImageCommon.pushCache el ImageCommon.pushCache el
if file.isVideo if file.isVideo
el.pause() el.pause()
for eventName, cb of ImageExpand.videoCB
$.off el, eventName, cb
ImageCommon.rewind file.thumb if Conf['Restart when Opened'] ImageCommon.rewind file.thumb if Conf['Restart when Opened']
delete file.fullImage delete file.fullImage
$.queueTask -> $.queueTask ->
@ -165,6 +172,7 @@ ImageExpand =
ImageCommon.rewind el if Conf['Restart when Opened'] and el.id isnt 'ihover' ImageCommon.rewind el if Conf['Restart when Opened'] and el.id isnt 'ihover'
el.removeAttribute 'id' el.removeAttribute 'id'
else else
isNew = true
el = file.fullImage = $.el (if isVideo then 'video' else 'img') el = file.fullImage = $.el (if isVideo then 'video' else 'img')
el.dataset.fullID = post.fullID el.dataset.fullID = post.fullID
$.on el, 'error', ImageExpand.error $.on el, 'error', ImageExpand.error
@ -174,11 +182,18 @@ ImageExpand =
$.after thumb, el $.after thumb, el
if isVideo if isVideo
# add contract link to file info
if Conf['Show Controls'] and Conf['Click Passthrough'] and !file.videoControls
file.videoControls = ImageExpand.videoControls.cloneNode true
$.add file.text, file.videoControls
# disable link to file so native controls can work # disable link to file so native controls can work
thumb.parentNode.removeAttribute 'href' thumb.parentNode.removeAttribute 'href'
thumb.parentNode.removeAttribute 'target' thumb.parentNode.removeAttribute 'target'
el.loop = true el.loop = true
Volume.setup el, isNew
ImageExpand.setupVideoCB post
if !isVideo if !isVideo
$.asap (-> el.naturalHeight), -> ImageExpand.completeExpand post $.asap (-> el.naturalHeight), -> ImageExpand.completeExpand post
@ -228,6 +243,20 @@ ImageExpand =
if controls if controls
ImageCommon.addControls fullImage ImageCommon.addControls fullImage
videoCB: do ->
# dragging to the left contracts the video
mousedown = false
mouseover: -> mousedown = false
mousedown: (e) -> mousedown = true if e.button is 0
mouseup: (e) -> mousedown = false if e.button is 0
mouseout: (e) -> ImageExpand.toggle(Get.postFromNode @) if mousedown and e.clientX <= @getBoundingClientRect().left
setupVideoCB: (post) ->
for eventName, cb of ImageExpand.videoCB
$.on post.file.fullImage, eventName, cb
if post.file.videoControls
$.on post.file.videoControls.firstElementChild, 'click', -> ImageExpand.toggle post
error: -> error: ->
post = Get.postFromNode @ post = Get.postFromNode @
$.rm @ $.rm @

View File

@ -1,10 +1,11 @@
ImageHover = ImageHover =
init: -> init: ->
return if g.VIEW not in ['index', 'thread'] return unless Conf['Image Hover'] and g.VIEW in ['index', 'thread']
if Conf['Image Hover']
Post.callbacks.push Post.callbacks.push
name: 'Image Hover' name: 'Image Hover'
cb: @node cb: @node
if Conf['Image Hover in Catalog'] if Conf['Image Hover in Catalog']
CatalogThread.callbacks.push CatalogThread.callbacks.push
name: 'Image Hover' name: 'Image Hover'
@ -13,11 +14,13 @@ ImageHover =
node: -> node: ->
return unless @file and (@file.isImage or @file.isVideo) return unless @file and (@file.isImage or @file.isVideo)
$.on @file.thumb, 'mouseover', ImageHover.mouseover @ $.on @file.thumb, 'mouseover', ImageHover.mouseover @
$.on @file.thumb, 'wheel', ImageHover.wheel if Conf['Mouse Wheel Volume'] and @file.isVideo
catalogNode: -> catalogNode: ->
{file} = @thread.OP {file} = @thread.OP
return unless file and (file.isImage or file.isVideo) return unless file and (file.isImage or file.isVideo)
$.on @nodes.thumb, 'mouseover', ImageHover.mouseover @thread.OP $.on @nodes.thumb, 'mouseover', ImageHover.mouseover @thread.OP
$.on @nodes.thumb, 'wheel', ImageHover.wheel if Conf['Mouse Wheel Volume'] and @thread.OP.file.isVideo
mouseover: (post) -> (e) -> mouseover: (post) -> (e) ->
return unless doc.contains @ return unless doc.contains @
@ -29,6 +32,7 @@ ImageHover =
el = ImageCommon.popCache() el = ImageCommon.popCache()
$.on el, 'error', error $.on el, 'error', error
else else
isNew = true
el = $.el (if isVideo then 'video' else 'img') el = $.el (if isVideo then 'video' else 'img')
el.dataset.fullID = post.fullID el.dataset.fullID = post.fullID
$.on el, 'error', error $.on el, 'error', error
@ -42,6 +46,7 @@ ImageHover =
if isVideo if isVideo
el.loop = true el.loop = true
el.controls = false el.controls = false
Volume.setup el, isNew
el.play() if Conf['Autoplay'] el.play() if Conf['Autoplay']
[width, height] = (+x for x in file.dimensions.split 'x') [width, height] = (+x for x in file.dimensions.split 'x')
{left, right} = @getBoundingClientRect() {left, right} = @getBoundingClientRect()
@ -73,3 +78,12 @@ ImageHover =
@src = URL + if @src is URL then '?' + Date.now() else '' @src = URL + if @src is URL then '?' + Date.now() else ''
else else
$.rm @ $.rm @
wheel: (e) ->
return unless el = $.id 'ihover'
return if el.muted or not $.hasAudio el
{volume} = el
volume += 0.1 if e.deltaY < 0
volume -= 0.1 if e.deltaY > 0
el.volume = $.minmax volume, 0, 1
e.preventDefault()

View File

@ -37,9 +37,11 @@ ImageLoader =
video = $.el 'video', video = $.el 'video',
preload: 'none' preload: 'none'
loop: true loop: true
muted: true
poster: thumb.src poster: thumb.src
textContent: thumb.alt textContent: thumb.alt
className: thumb.className className: thumb.className
video.setAttribute 'muted', 'muted'
video.dataset.md5 = thumb.dataset.md5 video.dataset.md5 = thumb.dataset.md5
video.style[attr] = thumb.style[attr] for attr in ['height', 'width', 'maxHeight', 'maxWidth'] video.style[attr] = thumb.style[attr] for attr in ['height', 'width', 'maxHeight', 'maxWidth']
video.src = file.URL video.src = file.URL

48
src/Images/Volume.coffee Normal file
View File

@ -0,0 +1,48 @@
Volume =
init: ->
return unless g.VIEW in ['index', 'thread'] and
(Conf['Image Expansion'] or Conf['Image Hover'] or Conf['Gallery'])
$.sync 'Allow Sound', (x) ->
Conf['Allow Sound'] = x
Volume.inputs?.unmute.checked = x
$.sync 'Default Volume', (x) ->
Conf['Default Volume'] = x
Volume.inputs?.volume.value = x
return unless g.BOARD.ID in ['gif', 'wsg']
unmuteEntry = UI.checkbox 'Allow Sound', ' Allow Sound'
unmuteEntry.title = Config.main['Images and Videos']['Allow Sound'][1]
volumeEntry = $.el 'label',
title: 'Default volume for videos.'
$.extend volumeEntry,
<%= html('<input name="Default Volume" type="range" min="0" max="1" step="0.01" value="${Conf["Default Volume"]}"> Volume') %>
@inputs =
unmute: unmuteEntry.firstElementChild
volume: volumeEntry.firstElementChild
$.on @inputs.unmute, 'change', $.cb.checked
$.on @inputs.volume, 'change', $.cb.value
Header.menu.addEntry {el: unmuteEntry, order: 200}
Header.menu.addEntry {el: volumeEntry, order: 201}
setup: (video, isNew=true) ->
video.muted = !Conf['Allow Sound']
video.volume = Conf['Default Volume']
$.on video, 'volumechange', Volume.change if isNew
change: ->
{muted, volume} = @
items =
'Allow Sound': !muted
'Default Volume': volume
$.set items
$.extend Conf, items
if Volume.inputs
Volume.inputs.unmute.checked = !muted
Volume.inputs.volume.value = volume

View File

@ -25,7 +25,7 @@ QR =
cb: @node cb: @node
if Conf['QR Shortcut'] if Conf['QR Shortcut']
sc = $.el 'a', @shortcut = sc = $.el 'a',
className: 'qr-shortcut fa fa-comment-o disabled' className: 'qr-shortcut fa fa-comment-o disabled'
textContent: 'QR' textContent: 'QR'
title: 'Quick Reply' title: 'Quick Reply'
@ -112,7 +112,7 @@ QR =
error: err error: err
return return
if Conf['QR Shortcut'] if Conf['QR Shortcut']
$.rmClass $('.qr-shortcut'), 'disabled' $.rmClass QR.shortcut, 'disabled'
close: -> close: ->
if QR.req if QR.req
@ -123,7 +123,7 @@ QR =
d.activeElement.blur() d.activeElement.blur()
$.rmClass QR.nodes.el, 'dump' $.rmClass QR.nodes.el, 'dump'
if Conf['QR Shortcut'] if Conf['QR Shortcut']
$.addClass $('.qr-shortcut'), 'disabled' $.addClass QR.shortcut, 'disabled'
new QR.post true new QR.post true
for post in QR.posts.splice 0, QR.posts.length - 1 for post in QR.posts.splice 0, QR.posts.length - 1
post.delete() post.delete()
@ -404,7 +404,7 @@ QR =
else if duration > QR.max_duration_video else if duration > QR.max_duration_video
QR.error "#{file.name}: Video too long (video: #{duration}s, max: #{QR.max_duration_video}s)" QR.error "#{file.name}: Video too long (video: #{duration}s, max: #{QR.max_duration_video}s)"
pass = false pass = false
if video.mozHasAudio or video.webkitAudioDecodedByteCount if g.BOARD.ID not in ['gif', 'wsg'] and $.hasAudio video
QR.error "#{file.name}: Audio not allowed" QR.error "#{file.name}: Audio not allowed"
pass = false pass = false
cb pass, video cb pass, video
@ -496,9 +496,13 @@ QR =
nodes.fileInput.max = $('input[name=MAX_FILE_SIZE]').value nodes.fileInput.max = $('input[name=MAX_FILE_SIZE]').value
QR.max_size_video = 3145728 QR.max_size_video = if m = Get.scriptData().match /\bmaxWebmFilesize *= *(\d+)\b/
+m[1]
else
+nodes.fileInput.max
QR.max_width_video = QR.max_height_video = 2048 QR.max_width_video = QR.max_height_video = 2048
QR.max_duration_video = 120 QR.max_duration_video = if g.BOARD.ID in ['gif', 'wsg'] then 300 else 120
if Conf['Show New Thread Option in Threads'] if Conf['Show New Thread Option in Threads']
$.addClass QR.nodes.el, 'show-new-thread-option' $.addClass QR.nodes.el, 'show-new-thread-option'