From ada88090ead2c3b9d0804794c5f20f9b24d1c2b1 Mon Sep 17 00:00:00 2001 From: Nik Nyby Date: Sat, 17 Jan 2015 17:12:36 -0500 Subject: Import to new git repository The old repository was using almost 100mb of space because of all the unnecessary files in the history. So I've imported the code to a new git repository. Unfortunately the history isn't viewable from this repository anymore. To see what happened with LibreJS before 2015, see the old Bazaar repo here: http://bzr.savannah.gnu.org/lh/librejs/ --- data/settings/js/form-row.js | 118 ++++++++++++++++++++++++++ data/settings/js/form-types.js | 145 ++++++++++++++++++++++++++++++++ data/settings/js/pagescript-emitter.js | 14 +++ data/settings/js/pagescript-listener.js | 51 +++++++++++ data/settings/js/permafrost-info-box.js | 21 +++++ 5 files changed, 349 insertions(+) create mode 100644 data/settings/js/form-row.js create mode 100644 data/settings/js/form-types.js create mode 100644 data/settings/js/pagescript-emitter.js create mode 100644 data/settings/js/pagescript-listener.js create mode 100644 data/settings/js/permafrost-info-box.js (limited to 'data/settings/js') diff --git a/data/settings/js/form-row.js b/data/settings/js/form-row.js new file mode 100644 index 0000000..35ac85e --- /dev/null +++ b/data/settings/js/form-row.js @@ -0,0 +1,118 @@ +/** + * GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript. + * * + * Copyright (C) 2011, 2012, 2014 Loic J. Duros + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +var GenerateForm = { + $trContainer: null, // will jQuery element for rules table tboby + le: 0, + init: function () { + var that = this; + $(document).ready(function (e) { + that.$trContainer = $("#whitelist").children('tbody'); + + // listen for when data is ready to populate form. + document.documentElement.addEventListener( + "populate-form", + function (event) { + that.populateForm(event.detail.data); + }, false); + that.$trContainer.on("click", ".delete", function (event) { + that.deleteRow($(this)); + }); + $('.librejs-whitelist-reset').click(function (e) { + that.deleteAll(); + }); + }); + }, + + deleteAll: function () { + var event = document.createEvent("CustomEvent"); + event.initCustomEvent( + "librejs-settings-change", true, true, { + event: 'rules-form-delete-all' + }); + document.documentElement.dispatchEvent(event); + location.reload(); + }, + + deleteRow: function ($button) { + var hash = $button.parents('tr').children('.hash').text(); + this.le--; + this.changeTitle(); + $button.parents('tr').remove(); + var event = document.createEvent("CustomEvent"); + event.initCustomEvent( + "librejs-settings-change", true, true, { + event: 'rules-form-delete', value: hash + }); + document.documentElement.dispatchEvent(event); + }, + + createRow: function (key, url, reason) { + + var $tr = $(""); + var $td = $('').addClass('hash').text(key); + var $delete, $button; + $tr.append($td); + $td = $('').append($('').attr({ + "href": url, + "target": "_blank" + }).text(url)); + $tr.append($td); + $td = $('').text(reason); + $tr.append($td); + + $delete = $(""); + $button = $('