Merge pull request #476 from 8n-tech/master

Removed dead file, fixed dio_ reliance for Windows, Infinite scroll
This commit is contained in:
Fredrick Brennan 2015-04-20 20:44:03 -04:00
commit 89e16bc0da
7 changed files with 120 additions and 110 deletions

View File

@ -1,31 +0,0 @@
<?php
function get_country( $code ){
$country = '';
if( $code == 'en' ) $country = 'English';
if( $code == 'cz' ) $country = 'Czech';
if( $code == 'dk' ) $country = 'Danish';
if( $code == 'de' ) $country = 'German';
if( $code == 'au' ) $country = 'Australian';
if( $code == 'eo' ) $country = 'Esperanto';
if( $code == 'es' ) $country = 'Spanish';
if( $code == 'fi' ) $country = 'Finnish';
if( $code == 'fr' ) $country = 'French';
if( $code == 'hu' ) $country = 'Hungarian';
if( $code == 'it' ) $country = 'Italian';
if( $code == 'jp' ) $country = 'Japanese';
if( $code == 'jbo' ) $country = 'Lojban';
if( $code == 'lt' ) $country = 'Lithuanian';
if( $code == 'lv' ) $country = 'Latvian';
if( $code == 'no' ) $country = 'Norwegian';
if( $code == 'nl' ) $country = 'Dutch';
if( $code == 'pl' ) $country = 'Polish';
if( $code == 'br' ) $country = 'Brazilian';
if( $code == 'pt' ) $country = 'Portuguese';
if( $code == 'ru' ) $country = 'Russian';
if( $code == 'sk' ) $country = 'Slovak';
if( $code == 'tw' ) $country = 'Taiwanese';
if( $country == '') $country = $code;
return $country;
}

View File

@ -640,29 +640,55 @@ function file_write($path, $data, $simple = false, $skip_purge = false) {
error('Invalid remote server: ' . $m[1]); error('Invalid remote server: ' . $m[1]);
} }
} }
if (!$fp = dio_open($path, O_WRONLY | O_CREAT, 0644)) if (!function_exists("dio_truncate")) {
error('Unable to open file for writing: ' . $path); if (!$fp = fopen($path, $simple ? 'w' : 'c'))
error('Unable to open file for writing: ' . $path);
// File locking
if (dio_fcntl($fp, F_SETLKW, array('type' => F_WRLCK)) === -1) { // File locking
error('Unable to lock file: ' . $path); if (!$simple && !flock($fp, LOCK_EX))
error('Unable to lock file: ' . $path);
// Truncate file
if (!$simple && !ftruncate($fp, 0))
error('Unable to truncate file: ' . $path);
// Write data
if (($bytes = fwrite($fp, $data)) === false)
error('Unable to write to file: ' . $path);
// Unlock
if (!$simple)
flock($fp, LOCK_UN);
// Close
if (!fclose($fp))
error('Unable to close file: ' . $path);
} }
else {
// Truncate file if (!$fp = dio_open($path, O_WRONLY | O_CREAT, 0644))
if (!dio_truncate($fp, 0)) error('Unable to open file for writing: ' . $path);
error('Unable to truncate file: ' . $path);
// File locking
// Write data if (dio_fcntl($fp, F_SETLKW, array('type' => F_WRLCK)) === -1) {
if (($bytes = dio_write($fp, $data)) === false) error('Unable to lock file: ' . $path);
error('Unable to write to file: ' . $path); }
// Unlock // Truncate file
dio_fcntl($fp, F_SETLK, array('type' => F_UNLCK)); if (!dio_truncate($fp, 0))
error('Unable to truncate file: ' . $path);
// Close
dio_close($fp); // Write data
if (($bytes = dio_write($fp, $data)) === false)
error('Unable to write to file: ' . $path);
// Unlock
dio_fcntl($fp, F_SETLK, array('type' => F_UNLCK));
// Close
dio_close($fp);
}
/** /**
* Create gzipped file. * Create gzipped file.
* *

View File

@ -9,9 +9,10 @@
*/ */
if (active_page == 'thread' || active_page == 'index') { if (active_page == 'thread' || active_page == 'index') {
$(document).ready(function(){ $(document).on('menu_ready', function(){
if ($('#delete-fields #password').length) { if ($('#delete-fields #password').length) {
var Menu = window.Menu;
Menu.add_item("delete_post_menu", _("Delete post")); Menu.add_item("delete_post_menu", _("Delete post"));
Menu.add_item("delete_file_menu", _("Delete file")); Menu.add_item("delete_file_menu", _("Delete file"));
Menu.onclick(function(e, $buf) { Menu.onclick(function(e, $buf) {
@ -57,4 +58,9 @@ $(document).on('new_post', function(){
}); });
$('input.delete').hide(); $('input.delete').hide();
$('#post-moderation-fields').hide(); $('#post-moderation-fields').hide();
})} });
if (typeof window.Menu !== "undefined") {
$(document).trigger('menu_ready');
}
}

View File

@ -21,7 +21,7 @@ var activate = function() {
if (document.location.hash != '#all') return false; if (document.location.hash != '#all') return false;
$(window).on("scroll", function() { $(window).on("scroll", function() {
scrolltest(); scrolltest();
}); });
scrolltest(); scrolltest();
@ -30,53 +30,54 @@ var activate = function() {
var scrolltest = function() { var scrolltest = function() {
if ($(window).scrollTop() + $(window).height() + 1000 > $(document).height() && !loading) { if ($(window).scrollTop() + $(window).height() + 1000 > $(document).height() && !loading) {
load_next_page(); load_next_page();
} }
}; };
var load_next_page = function() { var load_next_page = function() {
if (loading) return; if (loading) return;
loading = true; loading = true;
var this_page = $(".pages a.selected:last"); var this_page = $(".pages a.selected:last");
var next_page = this_page.next(); var next_page = this_page.next();
var href = next_page.prop("href"); var href = next_page.prop("href");
if (!href) return; if (!href) return;
var boardheader = $('<h2>'+_('Page')+' '+next_page.html()+'</h2>'); var boardheader = $('<h2>'+_('Page')+' '+next_page.html()+'</h2>');
var loading_ind = $('<h2>'+_('Loading...')+'</h2>').insertBefore('form[name="postcontrols"]>.delete:first'); var loading_ind = $('<h2>'+_('Loading...')+'</h2>').insertBefore('#post-moderation-fields');
$.get(href, function(data) { $.get(href, function(data) {
var doc = $(data); var doc = $(data);
loading_ind.remove(); loading_ind.remove();
boardheader.insertBefore('form[name="postcontrols"]>.delete:first'); boardheader.insertBefore('#post-moderation-fields');
var i = 0; var i = 0;
doc.find('div[id*="thread_"]').each(function() { doc.find('div[id*="thread_"]').each(function() {
var checkout = $(this).attr('id').replace('thread_', ''); var checkout = $(this).attr('id').replace('thread_', '');
var $this = this; var $this = this;
if ($('div#thread_' + checkout).length == 0) { if ($('div#thread_' + checkout).length == 0) {
// Delay DOM insertion to lessen the lag. // Delay DOM insertion to lessen the lag.
setTimeout(function() { setTimeout(function() {
$($this).insertBefore('form[name="postcontrols"]>.delete:first'); $($this).insertBefore('#post-moderation-fields');
$(document).trigger('new_post', $this); $(document).trigger('new_post', $this);
$($this).hide().slideDown(); $($this).hide().slideDown();
}, 500*i); }, 500*i);
i++;
} i++;
}); }
setTimeout(function() { });
loading = false;
scrolltest(); setTimeout(function() {
}, 500*(i+1)); loading = false;
scrolltest();
next_page.addClass('selected'); }, 500*(i+1));
});
next_page.addClass('selected');
});
}; };
var button = $("<a href='#all'>"+_("All")+" </a>").prependTo(".pages"); var button = $("<a href='#all'>"+_("All")+" </a>").prependTo(".pages");

View File

@ -1,6 +1,7 @@
if (active_page === 'thread' || active_page === 'index' || active_page === 'catalog') { if (active_page === 'thread' || active_page === 'index' || active_page === 'catalog') {
$(document).ready(function () { $(document).on('menu_ready', function () {
'use strict'; 'use strict';
// returns blacklist object from storage // returns blacklist object from storage
function getList() { function getList() {
return JSON.parse(localStorage.postFilter); return JSON.parse(localStorage.postFilter);
@ -200,7 +201,7 @@ if (active_page === 'thread' || active_page === 'index' || active_page === 'cata
* create filter menu when the button is clicked * create filter menu when the button is clicked
*/ */
function initPostMenu(pageData) { function initPostMenu(pageData) {
var Menu = window.Menu;
var submenu; var submenu;
Menu.add_item('filter-menu-hide', _('Hide post')); Menu.add_item('filter-menu-hide', _('Hide post'));
Menu.add_item('filter-menu-unhide', _('Unhide post')); Menu.add_item('filter-menu-unhide', _('Unhide post'));
@ -836,4 +837,8 @@ if (active_page === 'thread' || active_page === 'index' || active_page === 'cata
} }
init(); init();
}); });
if (typeof window.Menu !== "undefined") {
$(document).trigger('menu_ready');
}
} }

View File

@ -26,7 +26,7 @@
* $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/jquery.min.js';
* $config['additional_javascript'][] = 'js/post-menu.js'; * $config['additional_javascript'][] = 'js/post-menu.js';
*/ */
onready(function () { $(document).ready(function () {
var List = function (menuId, text) { var List = function (menuId, text) {
this.id = menuId; this.id = menuId;
@ -133,6 +133,8 @@ Menu.get_submenu = function (id) {
return mainMenu.get_submenu(id); return mainMenu.get_submenu(id);
}; };
window.Menu = Menu;
/* * * * * * * * /* * * * * * * *
Initialize Initialize
@ -205,5 +207,5 @@ $(document).on('new_post', function (e, post) {
addButton(post); addButton(post);
}); });
window.Menu = Menu; $(document).trigger('menu_ready');
}); });

View File

@ -560,12 +560,13 @@ fieldset label {
} }
div.pages { div.pages {
color: #89A; color: #89A;
background: #D6DAF0; background: #D6DAF0;
display: inline; display: inline-block;
padding: 8px; padding: 8px;
border-right: 1px solid #B7C5D9; margin: 8px 0 4px 0;
border-bottom: 1px solid #B7C5D9; border-right: 1px solid #B7C5D9;
border-bottom: 1px solid #B7C5D9;
} }
div.pages.top { div.pages.top {