/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ function addPermission(permcode, permdesc) { permcode = permcode.trim().toUpperCase(); if (permcode == "") { return false; } if ($("#permslist div[data-permcode=" + permcode + "]").length) { $("#permslist .list-group-item[data-permcode=" + permcode + "]").animate({ backgroundColor: "#ff0000", }, 500, "linear", function () { $("#permslist .list-group-item[data-permcode=" + permcode + "]").animate({ backgroundColor: "#ffffff", }, 500); }); return false; } if (typeof permdesc == "undefined") { $.post("action.php", { action: 'autocomplete_permission', q: $("#perms-box").val() }, function (resp) { if (resp.length === 0) { return; } if (resp.length === 1) { permdesc = resp[0].info; } else { for (var i = 0; i < resp.length; i++) { if (resp[i].name == permcode) { permdesc = resp[i].info; break; } } if (typeof permdesc == "undefined") { return; } } $('#permslist').append("
" + permdesc + "
" + permdesc + "