File tree Expand file tree Collapse file tree
src/OrchardCoreContrib.Contents/Views Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3030 <button id =" copyButton" type =" button" class =" btn btn-outline-secondary mt-2" onclick =" copyUrl()" >
3131 Copy to Clipboard
3232 </button >
33- <p class =" text-muted mt-2" >Valid for 30 days</p >
33+ <p class =" text-muted mt-2" >
34+ Expires in <span id =" expiryCountdown" ></span >
35+ </p >
3436 </div >
3537 </div >
3638 </div >
3739</div >
3840
3941<script at =" Foot" >
42+ const copyButton = document .getElementById (' copyButton' );
43+ const expireyCountdown = document .getElementById (" expiryCountdown" );
44+
45+ const expiryDate = new Date (" @Model.Link.ExpirationUtc.ToString(" o" )" );
46+ const now = new Date ();
47+ const diff = expiryDate - now;
48+
49+ if (diff <= 0 ) {
50+ expireyCountdown .parentElement .setAttribute (' class' , ' text-danger mt-2' )
51+ expireyCountdown .parentElement .innerText = " Expired" ;
52+ copyButton .disabled = true ;
53+ }
54+ else {
55+ const days = Math .floor (diff / (1000 * 60 * 60 * 24 ));
56+
57+ expireyCountdown .innerText = ` ${ days} days` ;
58+ }
59+
4060 function copyUrl () {
4161 const link = document .getElementById (' linkInput' ).value ;
4262 navigator .clipboard .writeText (link);
4363
44- var copyButton = document .getElementById (' copyButton' );
4564 copyButton .setAttribute (' class' , ' btn btn-secondary mt-2' );
4665 copyButton .innerText = ' Copied!' ;
4766 }
You can’t perform that action at this time.
0 commit comments