Reorder functions.
This commit is contained in:
parent
793e7a428f
commit
40bd083357
129
4chan_x.user.js
129
4chan_x.user.js
@ -20,7 +20,7 @@
|
|||||||
// @icon data:image/gif;base64,R0lGODlhEAAQAKECAAAAAGbMM////////yH5BAEKAAIALAAAAAAQABAAAAIxlI+pq+D9DAgUoFkPDlbs7lGiI2bSVnKglnJMOL6omczxVZK3dH/41AG6Lh7i6qUoAAA7
|
// @icon data:image/gif;base64,R0lGODlhEAAQAKECAAAAAGbMM////////yH5BAEKAAIALAAAAAAQABAAAAIxlI+pq+D9DAgUoFkPDlbs7lGiI2bSVnKglnJMOL6omczxVZK3dH/41AG6Lh7i6qUoAAA7
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
/* 4chan X Beta - Version 3.0.0 - 2013-02-26
|
/* 4chan X Beta - Version 3.0.0 - 2013-02-27
|
||||||
* http://mayhemydg.github.com/4chan-x/
|
* http://mayhemydg.github.com/4chan-x/
|
||||||
*
|
*
|
||||||
* Copyright (c) 2009-2011 James Campos <james.r.campos@gmail.com>
|
* Copyright (c) 2009-2011 James Campos <james.r.campos@gmail.com>
|
||||||
@ -6079,6 +6079,22 @@
|
|||||||
QR.posts.push(this);
|
QR.posts.push(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_Class.prototype.rm = function() {
|
||||||
|
var index;
|
||||||
|
$.rm(this.nodes.el);
|
||||||
|
index = QR.posts.indexOf(this);
|
||||||
|
if (QR.posts.length === 1) {
|
||||||
|
new QR.post().select();
|
||||||
|
} else if (this === QR.selected) {
|
||||||
|
(QR.posts[index - 1] || QR.posts[index + 1]).select();
|
||||||
|
}
|
||||||
|
QR.posts.splice(index, 1);
|
||||||
|
if (!window.URL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return URL.revokeObjectURL(this.url);
|
||||||
|
};
|
||||||
|
|
||||||
_Class.prototype.lock = function(lock) {
|
_Class.prototype.lock = function(lock) {
|
||||||
var name, _i, _len, _ref;
|
var name, _i, _len, _ref;
|
||||||
if (lock == null) {
|
if (lock == null) {
|
||||||
@ -6102,6 +6118,53 @@
|
|||||||
return this.lock(false);
|
return this.lock(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_Class.prototype.select = function() {
|
||||||
|
var name, rectEl, rectList, _i, _len, _ref;
|
||||||
|
if (QR.selected) {
|
||||||
|
QR.selected.nodes.el.id = null;
|
||||||
|
QR.selected.forceSave();
|
||||||
|
}
|
||||||
|
QR.selected = this;
|
||||||
|
this.lock(this.isLocked);
|
||||||
|
this.nodes.el.id = 'selected';
|
||||||
|
rectEl = this.nodes.el.getBoundingClientRect();
|
||||||
|
rectList = this.nodes.el.parentNode.getBoundingClientRect();
|
||||||
|
this.nodes.el.parentNode.scrollLeft += rectEl.left + rectEl.width / 2 - rectList.left - rectList.width / 2;
|
||||||
|
_ref = ['name', 'email', 'sub', 'com'];
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
name = _ref[_i];
|
||||||
|
QR.nodes[name].value = this[name];
|
||||||
|
}
|
||||||
|
this.showFileData();
|
||||||
|
return QR.characterCount();
|
||||||
|
};
|
||||||
|
|
||||||
|
_Class.prototype.save = function(input) {
|
||||||
|
var value, _ref;
|
||||||
|
value = input.value;
|
||||||
|
this[input.dataset.name] = value;
|
||||||
|
if (input.nodeName !== 'TEXTAREA') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.nodes.span.textContent = value;
|
||||||
|
QR.characterCount();
|
||||||
|
if (QR.cooldown.auto && this === QR.posts[0] && (0 < (_ref = QR.cooldown.seconds) && _ref <= 5)) {
|
||||||
|
return QR.cooldown.auto = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
_Class.prototype.forceSave = function() {
|
||||||
|
var name, _i, _len, _ref;
|
||||||
|
if (this !== QR.selected) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_ref = ['name', 'email', 'sub', 'com'];
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
name = _ref[_i];
|
||||||
|
this.save(QR.nodes[name]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
_Class.prototype.setFile = function(file) {
|
_Class.prototype.setFile = function(file) {
|
||||||
var fileURL, img, reader,
|
var fileURL, img, reader,
|
||||||
_this = this;
|
_this = this;
|
||||||
@ -6199,50 +6262,6 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_Class.prototype.select = function() {
|
|
||||||
var name, rectEl, rectList, _i, _len, _ref;
|
|
||||||
if (QR.selected) {
|
|
||||||
QR.selected.nodes.el.id = null;
|
|
||||||
QR.selected.forceSave();
|
|
||||||
}
|
|
||||||
QR.selected = this;
|
|
||||||
this.lock(this.isLocked);
|
|
||||||
this.nodes.el.id = 'selected';
|
|
||||||
rectEl = this.nodes.el.getBoundingClientRect();
|
|
||||||
rectList = this.nodes.el.parentNode.getBoundingClientRect();
|
|
||||||
this.nodes.el.parentNode.scrollLeft += rectEl.left + rectEl.width / 2 - rectList.left - rectList.width / 2;
|
|
||||||
_ref = ['name', 'email', 'sub', 'com'];
|
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
||||||
name = _ref[_i];
|
|
||||||
QR.nodes[name].value = this[name];
|
|
||||||
}
|
|
||||||
this.showFileData();
|
|
||||||
return QR.characterCount();
|
|
||||||
};
|
|
||||||
|
|
||||||
_Class.prototype.save = function(input) {
|
|
||||||
var value, _ref;
|
|
||||||
value = input.value;
|
|
||||||
this[input.dataset.name] = value;
|
|
||||||
if (input.nodeName !== 'TEXTAREA') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.nodes.span.textContent = value;
|
|
||||||
QR.characterCount();
|
|
||||||
if (QR.cooldown.auto && this === QR.posts[0] && (0 < (_ref = QR.cooldown.seconds) && _ref <= 5)) {
|
|
||||||
return QR.cooldown.auto = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
_Class.prototype.forceSave = function() {
|
|
||||||
var name, _i, _len, _ref;
|
|
||||||
_ref = ['name', 'email', 'sub', 'com'];
|
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
||||||
name = _ref[_i];
|
|
||||||
this.save(QR.nodes[name]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
_Class.prototype.dragStart = function() {
|
_Class.prototype.dragStart = function() {
|
||||||
return $.addClass(this, 'drag');
|
return $.addClass(this, 'drag');
|
||||||
};
|
};
|
||||||
@ -6282,22 +6301,6 @@
|
|||||||
return QR.posts.splice(newIndex, 0, post);
|
return QR.posts.splice(newIndex, 0, post);
|
||||||
};
|
};
|
||||||
|
|
||||||
_Class.prototype.rm = function() {
|
|
||||||
var index;
|
|
||||||
$.rm(this.nodes.el);
|
|
||||||
index = QR.posts.indexOf(this);
|
|
||||||
if (QR.posts.length === 1) {
|
|
||||||
new QR.post().select();
|
|
||||||
} else if (this === QR.selected) {
|
|
||||||
(QR.posts[index - 1] || QR.posts[index + 1]).select();
|
|
||||||
}
|
|
||||||
QR.posts.splice(index, 1);
|
|
||||||
if (!window.URL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return URL.revokeObjectURL(this.url);
|
|
||||||
};
|
|
||||||
|
|
||||||
return _Class;
|
return _Class;
|
||||||
|
|
||||||
})(),
|
})(),
|
||||||
@ -6558,9 +6561,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
post = QR.posts[0];
|
post = QR.posts[0];
|
||||||
if (post === QR.selected) {
|
post.forceSave();
|
||||||
post.forceSave();
|
|
||||||
}
|
|
||||||
if (g.BOARD.ID === 'f') {
|
if (g.BOARD.ID === 'f') {
|
||||||
if (g.VIEW === 'index') {
|
if (g.VIEW === 'index') {
|
||||||
filetag = QR.nodes.flashTag.value;
|
filetag = QR.nodes.flashTag.value;
|
||||||
|
|||||||
@ -379,6 +379,16 @@ QR =
|
|||||||
|
|
||||||
@unlock()
|
@unlock()
|
||||||
QR.posts.push @
|
QR.posts.push @
|
||||||
|
rm: ->
|
||||||
|
$.rm @nodes.el
|
||||||
|
index = QR.posts.indexOf @
|
||||||
|
if QR.posts.length is 1
|
||||||
|
new QR.post().select()
|
||||||
|
else if @ is QR.selected
|
||||||
|
(QR.posts[index-1] or QR.posts[index+1]).select()
|
||||||
|
QR.posts.splice index, 1
|
||||||
|
return unless window.URL
|
||||||
|
URL.revokeObjectURL @url
|
||||||
lock: (lock=true) ->
|
lock: (lock=true) ->
|
||||||
@isLocked = lock
|
@isLocked = lock
|
||||||
return unless @ is QR.selected
|
return unless @ is QR.selected
|
||||||
@ -390,6 +400,39 @@ QR =
|
|||||||
@nodes.el.draggable = !lock
|
@nodes.el.draggable = !lock
|
||||||
unlock: ->
|
unlock: ->
|
||||||
@lock false
|
@lock false
|
||||||
|
select: ->
|
||||||
|
if QR.selected
|
||||||
|
QR.selected.nodes.el.id = null
|
||||||
|
QR.selected.forceSave()
|
||||||
|
QR.selected = @
|
||||||
|
@lock @isLocked
|
||||||
|
@nodes.el.id = 'selected'
|
||||||
|
# Scroll the list to center the focused post.
|
||||||
|
rectEl = @nodes.el.getBoundingClientRect()
|
||||||
|
rectList = @nodes.el.parentNode.getBoundingClientRect()
|
||||||
|
@nodes.el.parentNode.scrollLeft += rectEl.left + rectEl.width/2 - rectList.left - rectList.width/2
|
||||||
|
# Load this post's values.
|
||||||
|
for name in ['name', 'email', 'sub', 'com']
|
||||||
|
QR.nodes[name].value = @[name]
|
||||||
|
@showFileData()
|
||||||
|
QR.characterCount()
|
||||||
|
save: (input) ->
|
||||||
|
{value} = input
|
||||||
|
@[input.dataset.name] = value
|
||||||
|
return if input.nodeName isnt 'TEXTAREA'
|
||||||
|
@nodes.span.textContent = value
|
||||||
|
QR.characterCount()
|
||||||
|
# Disable auto-posting if you're typing in the first post
|
||||||
|
# during the last 5 seconds of the cooldown.
|
||||||
|
if QR.cooldown.auto and @ is QR.posts[0] and 0 < QR.cooldown.seconds <= 5
|
||||||
|
QR.cooldown.auto = false
|
||||||
|
forceSave: ->
|
||||||
|
return unless @ is QR.selected
|
||||||
|
# Do this in case people use extensions
|
||||||
|
# that do not trigger the `input` event.
|
||||||
|
for name in ['name', 'email', 'sub', 'com']
|
||||||
|
@save QR.nodes[name]
|
||||||
|
return
|
||||||
setFile: (@file) ->
|
setFile: (@file) ->
|
||||||
@filename = "#{file.name} (#{$.bytesToString file.size})"
|
@filename = "#{file.name} (#{$.bytesToString file.size})"
|
||||||
@nodes.el.title = @filename
|
@nodes.el.title = @filename
|
||||||
@ -468,38 +511,6 @@ QR =
|
|||||||
$.addClass QR.nodes.fileSubmit, 'has-file'
|
$.addClass QR.nodes.fileSubmit, 'has-file'
|
||||||
else
|
else
|
||||||
$.rmClass QR.nodes.fileSubmit, 'has-file'
|
$.rmClass QR.nodes.fileSubmit, 'has-file'
|
||||||
select: ->
|
|
||||||
if QR.selected
|
|
||||||
QR.selected.nodes.el.id = null
|
|
||||||
QR.selected.forceSave()
|
|
||||||
QR.selected = @
|
|
||||||
@lock @isLocked
|
|
||||||
@nodes.el.id = 'selected'
|
|
||||||
# Scroll the list to center the focused post.
|
|
||||||
rectEl = @nodes.el.getBoundingClientRect()
|
|
||||||
rectList = @nodes.el.parentNode.getBoundingClientRect()
|
|
||||||
@nodes.el.parentNode.scrollLeft += rectEl.left + rectEl.width/2 - rectList.left - rectList.width/2
|
|
||||||
# Load this post's values.
|
|
||||||
for name in ['name', 'email', 'sub', 'com']
|
|
||||||
QR.nodes[name].value = @[name]
|
|
||||||
@showFileData()
|
|
||||||
QR.characterCount()
|
|
||||||
save: (input) ->
|
|
||||||
{value} = input
|
|
||||||
@[input.dataset.name] = value
|
|
||||||
return if input.nodeName isnt 'TEXTAREA'
|
|
||||||
@nodes.span.textContent = value
|
|
||||||
QR.characterCount()
|
|
||||||
# Disable auto-posting if you're typing in the first post
|
|
||||||
# during the last 5 seconds of the cooldown.
|
|
||||||
if QR.cooldown.auto and @ is QR.posts[0] and 0 < QR.cooldown.seconds <= 5
|
|
||||||
QR.cooldown.auto = false
|
|
||||||
forceSave: ->
|
|
||||||
# Do this in case people use extensions
|
|
||||||
# that do not trigger the `input` event.
|
|
||||||
for name in ['name', 'email', 'sub', 'com']
|
|
||||||
@save QR.nodes[name]
|
|
||||||
return
|
|
||||||
dragStart: ->
|
dragStart: ->
|
||||||
$.addClass @, 'drag'
|
$.addClass @, 'drag'
|
||||||
dragEnd: ->
|
dragEnd: ->
|
||||||
@ -522,16 +533,6 @@ QR =
|
|||||||
(if oldIndex < newIndex then $.after else $.before) @, el
|
(if oldIndex < newIndex then $.after else $.before) @, el
|
||||||
post = QR.posts.splice(oldIndex, 1)[0]
|
post = QR.posts.splice(oldIndex, 1)[0]
|
||||||
QR.posts.splice newIndex, 0, post
|
QR.posts.splice newIndex, 0, post
|
||||||
rm: ->
|
|
||||||
$.rm @nodes.el
|
|
||||||
index = QR.posts.indexOf @
|
|
||||||
if QR.posts.length is 1
|
|
||||||
new QR.post().select()
|
|
||||||
else if @ is QR.selected
|
|
||||||
(QR.posts[index-1] or QR.posts[index+1]).select()
|
|
||||||
QR.posts.splice index, 1
|
|
||||||
return unless window.URL
|
|
||||||
URL.revokeObjectURL @url
|
|
||||||
|
|
||||||
captcha:
|
captcha:
|
||||||
init: ->
|
init: ->
|
||||||
@ -763,7 +764,7 @@ QR =
|
|||||||
return
|
return
|
||||||
|
|
||||||
post = QR.posts[0]
|
post = QR.posts[0]
|
||||||
post.forceSave() if post is QR.selected
|
post.forceSave()
|
||||||
if g.BOARD.ID is 'f'
|
if g.BOARD.ID is 'f'
|
||||||
if g.VIEW is 'index'
|
if g.VIEW is 'index'
|
||||||
filetag = QR.nodes.flashTag.value
|
filetag = QR.nodes.flashTag.value
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user