Initial commit
This commit is contained in:
206
masks/add_code.html
Normal file
206
masks/add_code.html
Normal file
@@ -0,0 +1,206 @@
|
||||
<div id="add_code_container">
|
||||
<form id="add_code" name="add_code">
|
||||
<div class="h1_wrap">
|
||||
<h1 class="round" id="add_code_title"><span>Ajouter du code</span></h1>
|
||||
<div id="loggued_name_container">
|
||||
<p id="logging_info" class="round_top">Vous êtes sur le point de poster sous le compte de <span id="loggued_name"></span> (<span id="loggued_company"></span>)</p>
|
||||
<p><input type="button" id="logout_btn" class="round" value="Ce n'est pas vous ?" /></p>
|
||||
</div>
|
||||
<textarea id="content" name="content" class="round"></textarea>
|
||||
</div>
|
||||
<table id="extra_data">
|
||||
<tr>
|
||||
<td>Description</td>
|
||||
<td><input type="text" name="description" id="description" class="round" maxlength="200" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Lien (facultatif)</td>
|
||||
<td>
|
||||
<input type="text" name="link" id="link" class="round" maxlength="200" />
|
||||
<span id="available_phrase" class="round"></span>
|
||||
<span id="link_result" class="share round"></span>
|
||||
<input type="hidden" name="link_escaped" id="link_escaped" value="" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="auth_name_container" style="display:none;">
|
||||
<td>Nom & prénom</td>
|
||||
<td><input type="text" name="auth_name" class="round" /></td>
|
||||
</tr>
|
||||
<tr id="auth_company_container" style="display:none;">
|
||||
<td>Société</td>
|
||||
<td><input type="text" name="auth_company" class="round" value="Micropole" /></td>
|
||||
</tr>
|
||||
<tr><td colspan="2" class="last"><input type="button" id="add_code_btn" name="add_code_btn" value="Envoyer" class="button heavy round" /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
databap.pageInit = function()
|
||||
{
|
||||
//Tmp
|
||||
databap.tmp('last_val', 'string');
|
||||
|
||||
//content
|
||||
databap.getMainElem('#content').text(databap.consts.add_code_text);
|
||||
databap.getMainElem('#content').click(function(){clearDefaultValue($(this), databap.consts.add_code_text);});
|
||||
|
||||
//link phrase
|
||||
databap.getMainElem('#link').bind
|
||||
(
|
||||
'keyup',
|
||||
function()
|
||||
{
|
||||
$link = databap.getMainElem('#link_result');
|
||||
var link = $.trim($(this).val());
|
||||
var escaped_link = link.replace(/ /g, '_');
|
||||
if(escaped_link!=databap.tmp('last_val'))
|
||||
{
|
||||
databap.tmp('last_val', escaped_link);
|
||||
$link.text(databap.getCodeLink(escaped_link));
|
||||
databap.getMainElem('#link_escaped').val(escaped_link);
|
||||
if(escaped_link!='')
|
||||
{
|
||||
//check availability
|
||||
checkUrlAvailability($.trim(escaped_link));
|
||||
}
|
||||
else
|
||||
{
|
||||
if($link.is(':visible')) $link.hide('fast');
|
||||
databap.getMainElem('#available_phrase').hide('fast');
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
//submit
|
||||
databap.getMainElem('#add_code').submit(function(event){event.preventDefault();});
|
||||
databap.getMainElem('#add_code_btn').click
|
||||
(
|
||||
function()
|
||||
{
|
||||
var code = databap.getMainElem('#content').val();
|
||||
|
||||
if
|
||||
(
|
||||
code!=databap.consts.add_code_text &&
|
||||
code!='' &&
|
||||
databap.getMainElem('#description').val()!='' &&
|
||||
databap.getMainElem('#auth_name').val()!='' &&
|
||||
databap.getMainElem('#auth_company').val()!=''
|
||||
)
|
||||
{
|
||||
databap.saveForm
|
||||
(
|
||||
'add_code',
|
||||
databap.getMainElem('#add_code'),
|
||||
function(iCodeId)
|
||||
{
|
||||
if(!iCodeId || iCodeId===null || iCodeId==0)
|
||||
{
|
||||
databap.addErrorBefore('Erreur d\'authentification', '#add_code_btn');
|
||||
databap.$main.find('#auth_name_container, #auth_company_container').show('fast');
|
||||
}
|
||||
else
|
||||
{
|
||||
var link = databap.getMainElem('#link_escaped').val();
|
||||
databap.vars.code = (link=='')?iCodeId:link;
|
||||
debug('returned : '+databap.vars.code);
|
||||
databap.switchPage(databap.pages.read_code);
|
||||
}
|
||||
},
|
||||
true
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
databap.addErrorBefore('Tous les champs ne sont pas remplis', '#add_code_btn');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
//Add logged in warning
|
||||
/*databap.getUserInfo
|
||||
(
|
||||
function(user)
|
||||
{
|
||||
//hide logon fields
|
||||
databap.getMainElem('#auth_name_container, #auth_company_container').hide();
|
||||
|
||||
//show loggued user information
|
||||
databap.getMainElem('#loggued_name').text(user.name);
|
||||
databap.getMainElem('#loggued_company').text(user.company);
|
||||
databap.getMainElem('#loggued_name_container').show();
|
||||
}
|
||||
);
|
||||
|
||||
//post re-login
|
||||
databap.getMainElem('#logout_btn').click
|
||||
(
|
||||
function()
|
||||
{
|
||||
databap.getMainElem('#auth_name_container, #auth_company_container').show();
|
||||
databap.getMainElem('#loggued_name_container').hide('fast');
|
||||
}
|
||||
);*/
|
||||
|
||||
//On resize
|
||||
//databap.resetSize = function(){databap.getMainElem('#content').height('300');};
|
||||
databap.onResize = function()
|
||||
{
|
||||
//TODO : to be replaced by tinyscrollbar
|
||||
databap.$main.css('overflow', 'auto');
|
||||
|
||||
var iCodeContainerHeight = $('#add_code_container').height();
|
||||
if(iCodeContainerHeight != databap.consts.pageMaxHeight)
|
||||
{
|
||||
databap.getMainElem('#content').height('+='+(databap.consts.pageMaxHeight-iCodeContainerHeight));
|
||||
}
|
||||
};
|
||||
|
||||
//Init's end
|
||||
databap.setInitEnd(true);
|
||||
};
|
||||
|
||||
function checkUrlAvailability(phrase, bTriggered)
|
||||
{
|
||||
if(bTriggered == true)
|
||||
{
|
||||
databap.getInfo
|
||||
(
|
||||
'url',
|
||||
function(bExist)
|
||||
{
|
||||
var availabilityClass, availabilityText;
|
||||
var $link = databap.getMainElem('#link_result');
|
||||
if(bExist=='0')
|
||||
{
|
||||
availabilityClass = 'available';
|
||||
availabilityText = 'Disponible';
|
||||
if($link.is(':hidden')) $link.show('fast');
|
||||
}
|
||||
else
|
||||
{
|
||||
availabilityClass = 'unavailable';
|
||||
availabilityText = 'Indisponible';
|
||||
if($link.is(':visible')) $link.hide('fast');
|
||||
}
|
||||
databap.getMainElem('#available_phrase')
|
||||
.removeClass('available unavailable')
|
||||
.addClass(availabilityClass)
|
||||
.text(availabilityText)
|
||||
.show('fast');
|
||||
},
|
||||
{link_escaped:phrase},
|
||||
'html',
|
||||
function(){},
|
||||
true
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
databap.addBufferIcon();
|
||||
if(typeof oCheckLinkTimer != "undefined") clearTimeout(oCheckLinkTimer);
|
||||
oCheckLinkTimer = setTimeout(function(){checkUrlAvailability(phrase, true);}, 500);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user