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
|
||||
// ==/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/
|
||||
*
|
||||
* Copyright (c) 2009-2011 James Campos <james.r.campos@gmail.com>
|
||||
@ -6079,6 +6079,22 @@
|
||||
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) {
|
||||
var name, _i, _len, _ref;
|
||||
if (lock == null) {
|
||||
@ -6102,6 +6118,53 @@
|
||||
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) {
|
||||
var fileURL, img, reader,
|
||||
_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() {
|
||||
return $.addClass(this, 'drag');
|
||||
};
|
||||
@ -6282,22 +6301,6 @@
|
||||
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;
|
||||
|
||||
})(),
|
||||
@ -6558,9 +6561,7 @@
|
||||
return;
|
||||
}
|
||||
post = QR.posts[0];
|
||||
if (post === QR.selected) {
|
||||
post.forceSave();
|
||||
}
|
||||
post.forceSave();
|
||||
if (g.BOARD.ID === 'f') {
|
||||
if (g.VIEW === 'index') {
|
||||
filetag = QR.nodes.flashTag.value;
|
||||
|
||||
@ -379,6 +379,16 @@ QR =
|
||||
|
||||
@unlock()
|
||||
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) ->
|
||||
@isLocked = lock
|
||||
return unless @ is QR.selected
|
||||
@ -390,6 +400,39 @@ QR =
|
||||
@nodes.el.draggable = !lock
|
||||
unlock: ->
|
||||
@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) ->
|
||||
@filename = "#{file.name} (#{$.bytesToString file.size})"
|
||||
@nodes.el.title = @filename
|
||||
@ -468,38 +511,6 @@ QR =
|
||||
$.addClass QR.nodes.fileSubmit, 'has-file'
|
||||
else
|
||||
$.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: ->
|
||||
$.addClass @, 'drag'
|
||||
dragEnd: ->
|
||||
@ -522,16 +533,6 @@ QR =
|
||||
(if oldIndex < newIndex then $.after else $.before) @, el
|
||||
post = QR.posts.splice(oldIndex, 1)[0]
|
||||
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:
|
||||
init: ->
|
||||
@ -763,7 +764,7 @@ QR =
|
||||
return
|
||||
|
||||
post = QR.posts[0]
|
||||
post.forceSave() if post is QR.selected
|
||||
post.forceSave()
|
||||
if g.BOARD.ID is 'f'
|
||||
if g.VIEW is 'index'
|
||||
filetag = QR.nodes.flashTag.value
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user