text: var script=document.createElement("script");script.onload=function(){var e=new Array,t=new Array,o=(new Array,new Array),n=new Array,i=function(e){console.log(e)},a=function(e){var t=function(e){return"string"!=typeof e&&(e=JSON.stringify(e,void 0,4)),e=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),e.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,function(e){var t="number";return/^"/.test(e)?t=/:$/.test(e)?"key":"string":/true|false/.test(e)?t="boolean":/null/.test(e)&&(t="null"),'<span class="'+t+'">'+e+"</span>"})};console.error(t(e))},d=function(e){void 0!==e.success&&e.success(e)},r=function(e){void 0!==e.error&&e.error(e),a(e.errorMessage)},s=function(t){i("getBoards()"),e=new Array,Trello.get("members/me/boards",function(o){e=o,d(t)},a)},l=function(e,o){i("getLists( "+e+" )"),t=new Array,Trello.get("boards/"+e+"/lists",function(e){t=t.concat(e),d(o)},function(e){o.errorMessage=e,r(o)})},c=function(e){i("getTokens()"),o=new Array,Trello.get("members/me/tokens?webhooks=true",function(t){o=t,d(e)},a)},p=function(e){i("getWebhooks()"),n=new Array,Trello.get("tokens/"+Trello.token()+"/webhooks",function(t){n=t,d(e)},a)},u=function(e){return i("createWebhook()"),void 0===e.description||void 0===e.callbackURL||void 0===e.idModel?void a("You must supply required settings (idWebhook, callbackURL, idModel)"):void Trello.post("webhooks/",{description:e.description,callbackURL:e.callbackURL,idModel:e.idModel},function(t){e.webhookItem=k(t),d(e)},function(t){e.errorMessage=t,r(e)})},b=function(e){return i("editWebhook()"),void 0===e.idWebhook||void 0===e.description||void 0===e.callbackURL||void 0===e.idModel?void a("You must supply required settings (idWebhook, description, callbackURL, idModel)"):void Trello.put("webhooks/"+e.idWebhook,{description:e.description,callbackURL:e.callbackURL,idModel:e.idModel},c({success:function(){var t=$("li[data-id="+e.idWebhook+"]");t.attr("data-description",e.description),t.attr("data-callbackURL",e.callbackURL),t.attr("data-idModel",e.idModel),d(e)}}),a)},f=function(e){return i("deleteWebhook()"),void 0===e.idWebhook?void a("You must supply required settings (idWebhook)"):void Trello.del("webhooks/"+e.idWebhook,{},p({success:function(){$(".webhook-list-item[data-id="+e.idWebhook+"]").remove(),d(e)}}),a)},k=function(e){var t,o,n,a,d,r,s,l,c,p,u,k,m,v;t=$("<div></div>",{"class":"webhook-list-item","data-id":e.id,"data-idModel":e.idModel,"data-description":e.description,"data-callbackURL":e.callbackURL,"data-active":e.active,"data-editmode":!1}),o=$("<div></div>",{"class":"webhook-display"}),n=$("<form></form>",{"class":"webhook-edit form-group",style:"display:none;"}).on("reset",function(e){e.preventDefault(),$(this).get(0).reset(),a()}).submit(function(t){i("submitted"),b({idWebhook:e.id,description:p.val(),callbackURL:u.val(),idModel:e.idModel,success:function(){h(),a(),g()}}),t.preventDefault()}),a=function(){var e=t,a=o,d=n,r="true"===e.attr("data-editmode");e.attr("data-editmode",!r),r="true"===e.attr("data-editmode"),r?a.slideUp(function(){d.slideDown()}):d.slideUp(function(){a.slideDown()}),i(e.attr("data-id")+" set to edit-mode: "+r)};var h=function(){d=$("<h3></h3>",{name:"description",text:t.attr("data-description")}),r=$("<p></p>",{name:"callbackURL",text:"["+t.attr("data-callbackURL")+"]"}),s=$("<button></button>",{text:"Edit","class":"btn btn-secondary","data-id":t.attr("data-id")}).click(function(){a()}),l=$("<button></button>",{text:"Remove","class":"btn","data-id":t.attr("data-id")}).btsConfirmButton({msg:"Confirm?",timeout:3e3,className:"btn-danger"},function(){f({idWebhook:$(this).attr("data-id")})}),c=$("<div></div>",{"class":"btn-group right"}).append(s).append(l),o.empty().append(c).append(d).append(r)},g=function(){p=$("<input>",{value:t.attr("data-description"),type:"text","class":"form-control",placeholder:"Enter webhook description"}),u=$("<input>",{value:t.attr("data-callbackURL"),type:"text","class":"form-control",placeholder:"Enter callback URL"}),k=$("<button></button>",{text:"Save",type:"submit","class":"btn btn-primary"}),m=$("<button></button>",{text:"Cancel",type:"reset","class":"btn btn-danger"}),v=$("<div></div>",{"class":"webhook-buttons btn-group"}),v.append(k).append(m),n.empty().append($("<fieldset>",{"class":"form-group"}).append(p)).append($("<fieldset>",{"class":"form-group"}).append(u)).append($("<fieldset>",{"class":"form-group"}).append(v))};return g(),h(),t.append(o).append(n),t},m=function(){p({success:function(){for(index in n)!function(){var e=n[index],t=k(e);$("#trello-existing-webhooks").append(t)}()}})},v=function(){s({success:function(t){var o,n,i,a,d,r,s,l,c,p,b=function(e,t){var o=$("<label>",{"class":"form-control-label col-sm-7",text:t});return o.append(e),o},f=function(e){var t=$("<div>",{"class":"form-group"});return t.append(e),t};o=$("<form></form>",{style:"overflow: auto;"}),n=$("<select>",{"class":"form-control"}).change(function(){h($(this).val(),i)}),i=$("<select>",{"class":"form-control"}),a=$("<input>",{type:"text","class":"form-control",placeholder:"Webhook description"}),d=$("<input>",{type:"text","class":"form-control",placeholder:"Webhook callback URL"}),p=$("<button>",{type:"submit","class":"btn btn-primary",text:"Create Webhook"}),resetFormButton=$("<button>",{type:"reset","class":"btn btn-default",text:"Reset"});for(index in e)n.append($("<option>",{value:e[index].id,text:e[index].name}));r=f(b(n,"Boards")),s=f(b(i,"Lists")),l=f(b(a,"Description")),c=f(b(d,"Callback URL")),o.append(r).append(s).append(l).append(c).append($("<div>",{"class":"form-group col-sm-7 btn-group"}).append(p).append(resetFormButton)).submit(function(e){u({description:a.val(),callbackURL:d.val(),idModel:i.val(),success:function(e){$("#trello-existing-webhooks").append(e.webhookItem)},error:function(e){void 0!==e.error}}),e.preventDefault()}),$("#trello-new-webhook").append(o),h(n.val(),i)}})},h=function(e,o){i("changeBoard( "+e+" )"),o.prop("disabled",!0),$("#loading").show(),l(e,{success:function(){o.find("*").remove();for(index in t)t[index].idBoard==e&&o.append($("<option>",{value:t[index].id,text:t[index].name}));o.prop("disabled",!1),$("#loading").hide()},error:function(){$("#loading").hide()}})},g=function(){i("intialise()"),$("#loading").show(),$.when(v(),m()).done(function(){$("#loading").hide(),$("#trello-new-webhook").show(0,"",function(){$("#trello-existing-webhooks").show()})})};$(function(){g()})},script.src="https://trello.com/1/client.js?key="+trelloWorldConfig.key+"&token="+trelloWorldConfig.token,document.body.appendChild(script);