Created
August 15, 2014 20:49
-
-
Save rivant/9001d777a3b89cc8dcc6 to your computer and use it in GitHub Desktop.
app.cm.checkChanList
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.cm.checkChanList = function(Params,D){ | |
| for (var i=0;i < D.name.length; i++){ | |
| if (D.name[i] === Params.With){ | |
| return [D.name[i], true]; | |
| } | |
| } | |
| } | |
| // Clicked on Import. Receives Channel name to check for existing and, | |
| // site + credentials for the server to send to | |
| // with = repo channel name | |
| PAGE.confirmAddChannel = function(Params) { | |
| $.post('remote-channels', {url: Params.url, username: Params.username, password: Params.password}, | |
| function(D){ //D.name = list of channel names | |
| var H = cm.help.header(); | |
| if (Object.keys(D).length > 1){ | |
| var ChannelExists = true; //app.cm.checkChanList(Params,D)[1]; | |
| H += cm.help.breadCrumb('Confirm Add Channel') + 'Add Channel: ' + | |
| '<input type="text" name="channel" value="'+Params.With+'" class="iguana-color" size="' + (Params.With.length+2) +'"> ? '; | |
| if (ChannelExists){ | |
| H += "<p><span class='warning'>This will result in replacing the existing channel by the same name.</span></p>"; | |
| } | |
| H += "<span id='click' class='anchor button'> Execute</span>"; | |
| H += "<pre style='display:inline'> </pre>"; // Add white space | |
| H += "<a href='#Page=addChannel'><span class='button'>Cancel</span></a>"; | |
| } | |
| else { | |
| H += cm.help.breadCrumb("<a href='#Page=addChannel'>Add Channel</a>") + "<p>" + D[0] + "</p>"; | |
| } | |
| H += cm.help.footer(); | |
| $('body').html(H); | |
| //Pre-load animated progress bar gif so its loading doesn't compete with adding the channel. | |
| var bar = new Image(); | |
| bar.src = 'libe/jquery-ui-1.11.0/images/animated-overlay.gif'; | |
| console.log('ccl 1: ' + app.cm.checkChanList(Params,D)); | |
| //Toggle channel name replacement warning | |
| //var original = $('input[name="channel"]').val(); | |
| $('input[name="channel"]').keyup(function(){ | |
| Params.With = $(this).val(); | |
| console.log('params.with: '+ Params.With); | |
| //var search = app.cm.checkChanList(Params,D)[0]; | |
| console.log('ccl 2: ' + app.cm.checkChanList(Params,D)); | |
| /* | |
| if (Params.With != search){ | |
| $('p span.warning').hide(); | |
| } | |
| else { | |
| $('p span.warning').show(); | |
| }*/ | |
| }); | |
| //Excecute Button assignment | |
| $('span#click').click(function(){ | |
| var current = $('input[name="channel"]').val(); | |
| PAGE.progress(); | |
| PAGE.executeAddChannel({ | |
| 'Name': Params.With, | |
| 'With': current, | |
| 'Site': Params.url, | |
| 'User': Params.username, | |
| 'Pass': Params.password | |
| }); | |
| }); | |
| } | |
| ); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment