ep_adminpads2
Advanced tools
Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "ep_adminpads2", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Etherpad plugin to list and delete pads in /admin.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/rhansen/ep_adminpads2", |
exports.documentReady = function(hooks, context, cb) { | ||
if (context !== "admin/pads") { | ||
if (context !== 'admin/pads') { | ||
return cb; | ||
@@ -8,10 +8,10 @@ } | ||
loc = document.location, | ||
port = loc.port == "" ? (loc.protocol == "https:" ? 443 : 80) : loc.port, | ||
url = loc.protocol + "//" + loc.hostname + ":" + port + "/", | ||
pathComponents = location.pathname.split("/"), | ||
port = loc.port == '' ? (loc.protocol == 'https:' ? 443 : 80) : loc.port, | ||
url = loc.protocol + '//' + loc.hostname + ':' + port + '/', | ||
pathComponents = location.pathname.split('/'), | ||
// Strip admin/plugins | ||
baseURL = pathComponents.slice(0, pathComponents.length - 2).join("/") + "/", | ||
resource = baseURL.substring(1) + "socket.io"; | ||
baseURL = pathComponents.slice(0, pathComponents.length - 2).join('/') + '/', | ||
resource = baseURL.substring(1) + 'socket.io'; | ||
var room = url + "pluginfw/admin/pads"; | ||
var room = url + 'pluginfw/admin/pads'; | ||
@@ -21,6 +21,6 @@ var changeTimer; | ||
//connect | ||
socket = io.connect(room, {path: baseURL + "socket.io", resource: resource}); | ||
socket = io.connect(room, {path: baseURL + 'socket.io', resource: resource}); | ||
$(".search-results").data("query", { | ||
pattern: "", | ||
$('.search-results').data('query', { | ||
pattern: '', | ||
offset: 0, | ||
@@ -32,3 +32,3 @@ limit: 12, | ||
var doAutoUpdate = function () { | ||
return $("#results-autoupdate").prop("checked"); | ||
return $('#results-autoupdate').prop('checked'); | ||
}; | ||
@@ -38,12 +38,12 @@ | ||
clearTimeout(changeTimer); | ||
socket.emit("search", $(".search-results").data("query")); | ||
socket.emit('search', $('.search-results').data('query')); | ||
}; | ||
var htmlEntities = function (padName) { | ||
return $("<div/>").text(padName).html(); | ||
return $('<div/>').text(padName).html(); | ||
}; | ||
var submitSearch = function () { | ||
var query = $(".search-results").data("query"); | ||
query.pattern = $("#search-query")[0].value; | ||
var query = $('.search-results').data('query'); | ||
query.pattern = $('#search-query')[0].value; | ||
query.offset = 0; | ||
@@ -54,11 +54,11 @@ search(); | ||
var isInt = function (input) { | ||
return typeof input === "number" && input % 1 === 0; | ||
return typeof input === 'number' && input % 1 === 0; | ||
}; | ||
var formatDate = function (longtime) { | ||
var formattedDate = ""; | ||
var formattedDate = ''; | ||
if (longtime != null && isInt(longtime)) { | ||
var date = new Date(longtime); | ||
var month = date.getMonth() + 1; | ||
formattedDate = date.getFullYear() + "-" + fillZeros(month) + "-" + fillZeros(date.getDate()) + " " + fillZeros(date.getHours()) + ":" + fillZeros(date.getMinutes()) + ":" + fillZeros(date.getSeconds()); | ||
formattedDate = date.getFullYear() + '-' + fillZeros(month) + '-' + fillZeros(date.getDate()) + ' ' + fillZeros(date.getHours()) + ':' + fillZeros(date.getMinutes()) + ':' + fillZeros(date.getSeconds()); | ||
} | ||
@@ -69,11 +69,11 @@ return formattedDate; | ||
var fillZeros = function (fillForm) { | ||
return isInt(fillForm) ? (fillForm < 10 ? "0" + fillForm : fillForm) : ""; | ||
return isInt(fillForm) ? (fillForm < 10 ? '0' + fillForm : fillForm) : ''; | ||
}; | ||
function updateHandlers() { | ||
$("#progress.dialog .close").off("click").click(function () { | ||
$("#progress.dialog").hide(); | ||
$('#progress.dialog .close').off('click').click(function () { | ||
$('#progress.dialog').hide(); | ||
}); | ||
$("#search-form").off("submit").on("submit", function (e) { | ||
$('#search-form').off('submit').on('submit', function (e) { | ||
e.preventDefault(); | ||
@@ -83,5 +83,5 @@ submitSearch(); | ||
$("#do-search").off("click").click(submitSearch); | ||
$('#do-search').off('click').click(submitSearch); | ||
$("#search-query").off("change paste keyup").on("change paste keyup", function (e) { | ||
$('#search-query').off('change paste keyup').on('change paste keyup', function (e) { | ||
clearTimeout(changeTimer); | ||
@@ -94,13 +94,13 @@ changeTimer = setTimeout(function () { | ||
$(".do-delete").off("click").click(function (e) { | ||
var row = $(e.target).closest("tr"); | ||
var padID = row.find(".padname").text(); | ||
if (confirm("Do you really want to delete the pad " + padID + "?")) { | ||
$('.do-delete').off('click').click(function (e) { | ||
var row = $(e.target).closest('tr'); | ||
var padID = row.find('.padname').text(); | ||
if (confirm('Do you really want to delete the pad ' + padID + '?')) { | ||
doUpdate = true; | ||
socket.emit("delete", padID); | ||
socket.emit('delete', padID); | ||
} | ||
}); | ||
$(".do-prev-page").off("click").click(function (e) { | ||
var query = $(".search-results").data("query"); | ||
$('.do-prev-page').off('click').click(function (e) { | ||
var query = $('.search-results').data('query'); | ||
query.offset -= query.limit; | ||
@@ -112,5 +112,5 @@ if (query.offset < 0) { | ||
}); | ||
$(".do-next-page").off("click").click(function (e) { | ||
var query = $(".search-results").data("query"); | ||
var total = $(".search-results").data("total"); | ||
$('.do-next-page').off('click').click(function (e) { | ||
var query = $('.search-results').data('query'); | ||
var total = $('.search-results').data('total'); | ||
if (query.offset + query.limit < total) { | ||
@@ -125,20 +125,20 @@ query.offset += query.limit; | ||
socket.on("progress", function (data) { | ||
$("#progress .close").hide(); | ||
$("#progress").show(); | ||
socket.on('progress', function (data) { | ||
$('#progress .close').hide(); | ||
$('#progress').show(); | ||
$("#progress").data("progress", data.progress); | ||
$('#progress').data('progress', data.progress); | ||
var message = "Unknown status"; | ||
var message = 'Unknown status'; | ||
if (data.message) { | ||
message = "<span class=\"status\">" + data.message.toString() + "</span>"; | ||
message = '<span class="status">' + data.message.toString() + '</span>'; | ||
} | ||
if (data.error) { | ||
message = "<span class=\"error\">" + data.error.toString() + "<span>"; | ||
message = '<span class="error">' + data.error.toString() + '<span>'; | ||
} | ||
$("#progress .message").html(message); | ||
$('#progress .message').html(message); | ||
if (data.progress >= 1) { | ||
if (data.error) { | ||
$("#progress").show(); | ||
$('#progress').show(); | ||
} else { | ||
@@ -149,3 +149,3 @@ if (doUpdate || doAutoUpdate()) { | ||
} | ||
$("#progress").hide(); | ||
$('#progress').hide(); | ||
} | ||
@@ -155,4 +155,4 @@ } | ||
socket.on("search-result", function (data) { | ||
var widget = $(".search-results") | ||
socket.on('search-result', function (data) { | ||
var widget = $('.search-results') | ||
, limit = data.query.offset + data.query.limit | ||
@@ -164,11 +164,11 @@ ; | ||
widget.data("query", data.query); | ||
widget.data("total", data.total); | ||
widget.data('query', data.query); | ||
widget.data('total', data.total); | ||
widget.find(".offset").html(data.query.offset); | ||
widget.find(".limit").html(limit); | ||
widget.find(".total").html(data.total); | ||
widget.find('.offset').html(data.query.offset); | ||
widget.find('.limit').html(limit); | ||
widget.find('.total').html(data.total); | ||
widget.find(".results *").remove(); | ||
var resultList = widget.find(".results"); | ||
widget.find('.results *').remove(); | ||
var resultList = widget.find('.results'); | ||
@@ -180,12 +180,12 @@ if (data.results.length > 0) { | ||
var userCount = resultset.userCount; | ||
var row = widget.find(".template tr").clone(); | ||
row.find(".padname").html("<a href=\"../p/" + encodeURIComponent(padName) + "\">" + htmlEntities(padName) + "</a>" | ||
var row = widget.find('.template tr').clone(); | ||
row.find('.padname').html('<a href="../p/' + encodeURIComponent(padName) + '">' + htmlEntities(padName) + '</a>' | ||
) | ||
; | ||
row.find(".last-edited").html(formatDate(lastEdited)); | ||
row.find(".user-count").html(userCount); | ||
row.find('.last-edited').html(formatDate(lastEdited)); | ||
row.find('.user-count').html(userCount); | ||
resultList.append(row); | ||
}); | ||
} else { | ||
resultList.append("<tr><td colspan=\"4\" class=\"no - results\">No results</td></tr>"); | ||
resultList.append('<tr><td colspan="4" class="no - results">No results</td></tr>'); | ||
} | ||
@@ -196,5 +196,5 @@ | ||
socket.emit("load"); | ||
socket.emit('load'); | ||
search(); | ||
return cb; | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38051