Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lgtm front-end fixes #650

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions static/js/bookmarklet.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ function straw() {

// then they came for the youtube videos
//if (document.domain == "youtube.com" || document.domain == "localhost" || document.domain == "www.youtube.com"){
/*
if (false){
player_holder = document.getElementById('watch-player');
nodes = player_holder.childNodes;
for(var k=0;k<nodes.length;k++){
this_node = nodes[k]
this_node = nodes[k];
if((this_node.nodeName) === "IFRAME"){
var width = this_node.offsetWidth;
var height = this_node.offsetHeight;
Expand All @@ -57,9 +58,10 @@ function straw() {
}
}
}

*/
// then they came for the vimeo videos
//if (document.domain == "vimeo.com" || document.domain == "localhost" || document.domain == "www.vimeo.com"){
/*
if (false){
possible_players = document.getElementsByTagName('div');

Expand All @@ -76,6 +78,7 @@ function straw() {
}

}
*/
}

this.create_overlay = function(type, width, height, pos, obj_id, url){
Expand Down Expand Up @@ -116,8 +119,8 @@ function straw() {
this.select_image = function(image_url){
//open a new window
//location is
left_location = screen.width/2-450;
top_location = screen.height/2-300;
var left_location = screen.width/2-450;
var top_location = screen.height/2-300;
var window_attributes = "width=850,height=650,menubar=yes,toolbar=yes,scrollbars=yes,resizable=yes,left=" + left_location + ",top=" + top_location + "screenX=" + left_location + ",screenY=" + top_location;
window.open('https://mltshp.com/tools/p?url=' + escape(image_url) + '&source_url=' + escape(location.href) ,'save image',window_attributes);
}
Expand Down
62 changes: 30 additions & 32 deletions static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ $(document).ready(function() {
submit_post_video: function() {
var url = $post_video_form.attr('action');
var data = $post_video_form.serialize();
var that = this;
$post_video_form_button.unbind('click').find('span').html('Posting...');
$.post(url, data, function(response) {
document.location = document.location.protocol + '//' + document.location.host + response['path'];
Expand All @@ -162,12 +161,12 @@ $(document).ready(function() {
init_dom();
init_events();
}
}
};
}();

var to_text = function(num, base) {
return (num == 1) ? num + ' ' + "<span>" + base + "</span>" : num + ' ' + "<span>" + base + 's' + "</span>";
}
};

var ShakesCache = {
fetch: function() {
Expand Down Expand Up @@ -280,13 +279,13 @@ $(document).ready(function() {
});

$(".save-this").each(function() {
var save_this_view = new SaveThisView(this);
SaveThisView(this);
});

// when we hit enter on a form, we want to submit it
// even though we don't have an type="submit" input
// available, since we're using a styled button.
$sign_in_form = $("#sign-in-form");
var $sign_in_form = $("#sign-in-form");
$("input", $sign_in_form).keydown(function(e) {
if (e.keyCode == 13) {
$sign_in_form.submit();
Expand Down Expand Up @@ -439,7 +438,7 @@ $(document).ready(function() {
save_count: 0,
like_count: 0
}
}
};

var SidebarStatsView = function(scope) {
// if we aren't on a permalink page, just expose a dummy public API
Expand All @@ -452,8 +451,8 @@ $(document).ready(function() {
}

var image_stats = new ImageStats();
$save_count = $('.save-count', scope);
$like_count = $('.like-count', scope);
var $save_count = $('.save-count', scope);
var $like_count = $('.like-count', scope);
image_stats.save_count = parseInt($save_count.html(), 10);
image_stats.like_count = parseInt($like_count.html(), 10);

Expand All @@ -480,7 +479,7 @@ $(document).ready(function() {
},

refresh_likes: function() {
$like_count = $('.like-count', scope);
var $like_count = $('.like-count', scope);
image_stats.like_count = parseInt($like_count.html(), 10);
if (likes_expanded) {
this.get_likes();
Expand All @@ -494,7 +493,7 @@ $(document).ready(function() {
},

refresh_saves: function() {
$save_count = $('.save-count', scope);
var $save_count = $('.save-count', scope);
image_stats.save_count = parseInt($save_count.html(), 10);
if (saves_expanded) {
this.get_saves();
Expand Down Expand Up @@ -619,7 +618,7 @@ $(document).ready(function() {
$content.removeClass('loading').html(html);
}

}
};
}("#sidebar-stats");
SidebarStatsView.init();

Expand Down Expand Up @@ -826,36 +825,36 @@ $(document).ready(function() {
this.files_on_page[view.share_key] = view;
},
refresh_likes: function(share_key) {
view = this.get_view(share_key);
var view = this.get_view(share_key);
if (view !== undefined) {
view.refresh_likes();
}
},
refresh_saves: function(share_key) {
view = this.get_view(share_key);
var view = this.get_view(share_key);
if (view !== undefined) {
view.refresh_saves();
}
},
get_view: function(share_key) {
return this.files_on_page[share_key];
}
}
};

function apply_hover_for_video(sel) {
sel.hover(function () {
if (this.hasAttribute("controls")) {
this.removeAttribute("controls")
this.removeAttribute("controls");
} else {
this.setAttribute("controls", "controls")
this.setAttribute("controls", "controls");
}
});
}

var NSFWCover = function($root) {
this.$root = $root;
this.init();
}
};

$.extend(NSFWCover.prototype, {
init: function() {
Expand All @@ -866,7 +865,7 @@ $(document).ready(function() {
var location = document.location,
host = location.host,
protocol = location.protocol,
base_path = location.protocol + "//" + location.host,
base_path = protocol + "//" + host,
file_path = $(ev.target).attr('href');
$.get(base_path + "/services/oembed?include_embed=1&url=" + escape(base_path + file_path), $.proxy(this.load_image, this), 'json');
return false;
Expand All @@ -893,7 +892,7 @@ $(document).ready(function() {
$nsfw_cover = $image_content.find(".nsfw-cover");
var stream_stats_view = new StreamStatsView($image_footer);
StreamStatsViewRegistry.register(stream_stats_view);
var nsfw_cover = new NSFWCover($nsfw_cover);
NSFWCover($nsfw_cover);
});

apply_hover_for_video($('.image-content video.autoplay'));
Expand Down Expand Up @@ -997,7 +996,6 @@ $(document).ready(function() {
var $block = $(this).parents('.notification');
var $header = $("#notifcation-block-shakeinvitation .notification-block-hd");

var that = this;
$.post(url, data, function(response) {
if (!response['error']) {
$block.remove();
Expand Down Expand Up @@ -1027,7 +1025,7 @@ $(document).ready(function() {
this.on_shake_page = this.$hd.hasClass('on-shake-page');
var that = this;
this.$root.find('.notification').each(function() {
var new_invitation_request = new NotificationInvitationRequest($(this), that);
NotificationInvitationRequest($(this), that);
});
},

Expand Down Expand Up @@ -1087,11 +1085,11 @@ $(document).ready(function() {
});

var init_notification_invitation_request = function() {
$notification_invitation_request = $("#notification-block-invitation-request");
var $notification_invitation_request = $("#notification-block-invitation-request");
if ($notification_invitation_request.length > 0) {
var invitation_requests = new NotificationInvitationContainer($notification_invitation_request);
NotificationInvitationContainer($notification_invitation_request);
}
}
};
init_notification_invitation_request();

// Expand all notifications.
Expand All @@ -1107,7 +1105,7 @@ $(document).ready(function() {
$(".field-submit .btn").click(function() {
$(this).closest("form").submit();
return false;
})
});

/* Site Nav dropdown */
$site_nav = $("#site-nav");
Expand Down Expand Up @@ -1171,8 +1169,8 @@ $(document).ready(function() {
// http://stackoverflow.com/questions/1125292/how-to-move-cursor-to-end-of-contenteditable-entity
function setCaret(el)
{
ctrl = el;
pos = ctrl.value.length;
var ctrl = el;
var pos = ctrl.value.length;
if(ctrl.setSelectionRange)
{
ctrl.focus();
Expand Down Expand Up @@ -1226,7 +1224,7 @@ $(document).ready(function() {

var $image_comments_permalink = $("#image-comments-permalink");
if ($image_comments_permalink.length > 0) {
var new_comment = new PermalinkCommentsView($image_comments_permalink);
PermalinkCommentsView($image_comments_permalink);
}

$("#nsfw-filter-button a").click(function() {
Expand Down Expand Up @@ -1300,7 +1298,7 @@ $(document).ready(function() {


$("#shake-categories .shake-category").each(function() {
var new_category = new RecommendedShakeCategory(this)
RecommendedShakeCategory(this)
});
}

Expand Down Expand Up @@ -1591,7 +1589,7 @@ $(document).ready(function() {
this.clear_input();
this.clear_results();
}
}
};
}();


Expand All @@ -1610,7 +1608,7 @@ $(document).ready(function() {
var $target = $(ev.target),
$li = $target.parents("li"),
$form = $target.next(),
url = $form.attr('action');
url = $form.attr('action'),
data = $form.serialize();

if (confirm("Are you sure you want to remove this user from a shake? If they have notifications on an email will be sent informing them of the change.")) {
Expand All @@ -1626,7 +1624,7 @@ $(document).ready(function() {

var $shake_member_list = $("#shake-members-list");
if ($shake_member_list.length > 0) {
var shake_member_list = new ShakeMemberList($shake_member_list);
ShakeMemberList($shake_member_list);
}

// support for dismissable "Vote 2020" banner; cookie naturally expires on Nov 4th
Expand Down
4 changes: 2 additions & 2 deletions static/js/paging_keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ var pagingKeys = (function() {
return a.y - b.y;
});

var last = item_map.length - 1;
//var last = item_map.length - 1;
if (getEl(config.nextPageSelector)[0]) {
if (getEl(config.nextPageSelector)[0].href)
item_map.push({ id: "next", y: document.body.scrollHeight });
Expand Down Expand Up @@ -284,7 +284,7 @@ var pagingKeys = (function() {
else if (
getWindowBounds().h + getScrollTop() ==
document.body.scrollHeight &&
0 < delta
0 < delta // is this always false?
)
p++;

Expand Down
2 changes: 1 addition & 1 deletion static/js/portal.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
left = e.touches[0].pageX - this.$element.offset().left;
top = e.touches[0].pageY - this.$element.offset().top;
}
else if (typeof e.changedTouches != 'undefined' && typeof e.changedTouches[0] != 'udefined') {
else if (typeof e.changedTouches != 'undefined' && typeof e.changedTouches[0] != 'undefined') {
left = e.changedTouches[0].pageX - this.$element.offset().left;
top = e.changedTouches[0].pageY - this.$element.offset().top;
} else {
Expand Down
10 changes: 5 additions & 5 deletions static/straw/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ java -jar ./tools/compiler.jar --js static/straw/source.js --js_output_file stat
if (width > 300 && height > 100) {
var left_margin = (width - 240) / 2,
top_margin = (height - 45) / 2;
html = '<span class="mltshp-sf-overlay-text" style="';
var html = '<span class="mltshp-sf-overlay-text" style="';
html = html + 'margin-top:' + top_margin + 'px;';
html = html + 'margin-left:' + left_margin + 'px;';
html = html + '">Save on MLTSHP</span>';
Expand All @@ -129,8 +129,8 @@ java -jar ./tools/compiler.jar --js static/straw/source.js --js_output_file stat
ev.cancelBubble = true;
}

left_location = screen.width/2-450;
top_location = screen.height/2-300;
var left_location = screen.width/2-450;
var top_location = screen.height/2-300;
var window_attributes = "width=850,height=650,menubar=yes,toolbar=yes,scrollbars=yes,resizable=yes,left=" + left_location + ",top=" + top_location + "screenX=" + left_location + ",screenY=" + top_location;
global.open('https://mltshp.com/tools/p?url=' + encodeURI(this.asset) + '&title=' + encodeURI(global.document.title) + '&source_url=' + encodeURI(global.location.href), 'save_image', window_attributes);
};
Expand Down Expand Up @@ -221,8 +221,8 @@ java -jar ./tools/compiler.jar --js static/straw/source.js --js_output_file stat
find_assets: function() {
var images = AssetFinder.images(),
images_length = images.length,
videos = AssetFinder.videos(),
videos_length = videos.length,
//videos = AssetFinder.videos(),
//videos_length = videos.length,
found = []

for (var i = 0; i < images_length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion templates/account/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ <h1>Create Account</h1>
<ul class="promotions">
{% for promo in promotions %}
{% set promo_shake = promo.shake() %}
<li><a href="{{ promo.promotion_url }}" rel="nofollow" target="_blank"><div class="promotion-avatar"><img src="{{promo_shake.page_image()}}" width="100" height="100" alt=""></div><span class="promotion-name">{{ xhtml_escape(promo.name) }}</span></a></li>
<li><a href="{{ promo.promotion_url }}" rel="nofollow noopener noreferrer" target="_blank"><div class="promotion-avatar"><img src="{{promo_shake.page_image()}}" width="100" height="100" alt=""></div><span class="promotion-name">{{ xhtml_escape(promo.name) }}</span></a></li>
{% end %}
</ul>
<div class="clear"><!-- --></div>
Expand Down
2 changes: 1 addition & 1 deletion templates/account/redeem.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h1>Redeem Coupon</h1>
<ul class="promotions">
{% for promo in promotions %}
{% set promo_shake = promo.shake() %}
<li><a href="{{ promo.promotion_url }}" rel="nofollow" target="_blank"><div class="promotion-avatar"><img src="{{promo_shake.page_image()}}" width="100" height="100" alt=""></div><span class="promotion-name">{{ xhtml_escape(promo.name) }}</span></a></li>
<li><a href="{{ promo.promotion_url }}" rel="nofollow noopener noreferrer" target="_blank"><div class="promotion-avatar"><img src="{{promo_shake.page_image()}}" width="100" height="100" alt=""></div><span class="promotion-name">{{ xhtml_escape(promo.name) }}</span></a></li>
{% end %}
</ul>
<div class="clear"><!-- --></div>
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/nsfw-users.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h4><a class="icon" href="/user/{{user.name}}">{{ escape(user.display_name()) }}
<p class="about">{{escape(user.about)}}
{% if user.website %}
<br>
<a class="website" rel="nofollow" target="_blank" href="{{escape(user.website)}}">{{escape(user.website)}}</a>
<a class="website" rel="nofollow noopener noreferrer" target="_blank" href="{{escape(user.website)}}">{{escape(user.website)}}</a>
{% end %}
</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/misc/promo.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</style>
</head>
<body>
<a target="_blank" href="{{banner['link']}}">
<a target="_blank" rel="noopener noreferrer" href="{{banner['link']}}">
<img
src="{{banner['img']}}"
width="100%"
Expand Down