Wednesday 22 August 2018

Ckeditor add force download option in dialog

CKEDITOR.on( 'dialogDefinition', function( evt ) {
   var dialog = evt.data;

   if ( dialog.name == 'link' ) {
       // Get dialog definition.
       var def = evt.data.definition;         
       // Add some stuff to definition.
       
       
       
       var infoTab = def.getContents( 'info' );
       
       infoTab.add( {
type: 'checkbox',
id: 'download',
requiredContent: 'a[download]',
label: "Force Download",
setup: function( data ) {
if ( data.download !== undefined )
this.setValue( 'checked', 'checked' );
},
commit: function( data ) {
if ( this.getValue() ) {
data.download = this.getValue();
}
}
});

   }
} );

CKEDITOR.replace( 'editor' );

Easypaginate integration


<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="jquery.easyPaginate.js"></script>
<link href="http://localhost/es/bootstrap.css" rel="stylesheet" />

<style type="text/css">
/* Cosmetic only */
#easyPaginate {width:300px;}
#easyPaginate div {display:block;margin-bottom:10px;}
.easyPaginateNav a {padding:5px;}
.easyPaginateNav a.current {font-weight:bold;text-decoration:underline;}
</style>
<a href="http://192.168.1.66/temp.php"><h1>Home</h1></a><br><br><br><hr>
<div id="easyPaginate">
<?php
for($i=1;$i<=100;$i++)
{
?>
<div class='cool' style='border:1px solid red;width:100%;height:20px;'>
<div style='color: #FFF;background: green;width: 40%;float: left;height:auto;'>
<strong><?=$i?></strong>
</div>
<div style='color: #000;background:  yellow;width: 40%;float: right;height:auto;'>
<strong><?=$i?></strong>
</div>
</div>
<?php
} ?> 
</div>
<div class="easyPaginate1" style='border:1px solid red;width:100%;height:20px;'>
</div>

<script type='text/javascript'>
// input array contain some elements.
var array = ['10', '20', '30', '40', '50'];
var fruits = ["Banana", "Orange", "Apple", "Mango"];
var a = array.indexOf("10");
// Printing desired values.
console.log(a);



$(function() {
$('#easyPaginate').easyPaginate({
paginateElement: 'div.cool',
elementsPerPage: 2,
firstButtonText : '',
lastButtonText: '',
prevButtonText:'',
nextButtonText : '→',
items:100,
edges:2,
});
var nav  = $('.easyPaginateNav').clone(true,true);
$(".easyPaginateNav").remove();
nav.prependTo('div.easyPaginate1');

});
</script>

JS cookie handling

<script type='text/javascript'>
function setCookie(name,value,days) {
    var expires = "";
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days*24*60*60*1000));
        expires = "; expires=" + date.toUTCString();
    }
    document.cookie = name + "=" + (value || "")  + expires + "; path=/";
}
function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return false;
}
function eraseCookie(name) { 
    document.cookie = name+'=; Max-Age=-99999999;'; 
}
setCookie('TEST','Goal',7);
alert(getCookie('TEST'));
eraseCookie('TEST');
alert(getCookie('TEST'));
</script>