User:DannyS712 test/remind me.js

RemindMe_config = { name: "Remind me", version: 1.0, debug: true };

var user = "";

mw.loader.using( 'mediawiki.util', function {    importScript('User:DannyS712 test/JSON.js');    $(document).ready( function  { var link = mw.util.addPortletLink( 'p-cactions', null, 'Remind me', 'ca-add-reminder', 'Reminder to check this page'); $( link ).click( function ( event ) {           event.preventDefault;            add_reminder;        } ); } ); } ); function add_reminder{ user = mw.config.get( 'wgUserName' ); var location = "User:" + user + "/remind.json"; console.log( location ); var reminder_text = prompt("What would you like the reminder to say?", "Check this page"); var reminder_wait = parseInt(prompt("How many days from now would you like to be reminded?", "10"), 10); var new_reminder = { page: get_pretty_page, time: (new Date).getTime, wait: reminder_wait*86400000, text: reminder_text };	add_the_reminder ( location, new_reminder ); } function add_the_reminder ( location, new_reminder ){ var arr_JSONed = get_JSON( location ); if (RemindMe_config.debug) console.log( arr_JSONed ); arr_JSONed.push( {page: new_reminder.page, start: new_reminder.time + new_reminder.wait, custom: new_reminder.text, id: user + "_" + new_reminder.time} ); if (RemindMe_config.debug) console.log( "New: " ); if (RemindMe_config.debug) console.log( arr_JSONed ); var new_JSON = JSON.stringify( arr_JSONed, null, 2 ); if (RemindMe_config.debug) console.log( new_JSON ); set_JSON( location, new_JSON, "add a reminder for " + new_reminder.page, 'Reminder scheduled' ); } function get_pretty_page { var page_name = mw.config.get( 'wgPageName' ); var new_name = page_name.replace( /_/g, ' ' ); return new_name; }