NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name metadev-forms-sce // @namespace https://openuserjs.org/users/mchdev // @description enhanced screenscript editor for form scripts // @homepageURL https://openuserjs.org/scripts/mchdev/metadev-forms-sce // @updateURL https://openuserjs.org/meta/mchdev/metadev-forms-sce.meta.js // @downloadURL https://openuserjs.org/install/mchdev/metadev-forms-sce.user.js // @copyright 2020-2021, mchdev (https://openuserjs.org/users/mchdev) // @license MIT // @version 0.1 // @grant none // @author mchdev // @match https://meta.vub.sk/*Form/*FormScript* // @match https://meta2.vub.sk/*Form/*FormScript* // @require https://storage.googleapis.com/sce-editor/sce.js // ==/UserScript== (function() { 'use strict'; function getMetaUrl() { var form = $('form.edit-form'); var queryParameters = getBoxParams(form); queryParameters['noredirect'] = 'true'; var link = ''; if ($(form).parents('div.boxloader').length > 0) { link = $(form).parents('div.boxloader').first().attr('data-link').split('?'); link[1] = jQuery.param(queryParameters, true); link = link[0] + '?' + link[1]; } else { link = location.pathname + '?' + jQuery.param(queryParameters); } return link; } function getNewUrl(uri) { var url = new URL(uri); var queryParameters = deParamFromString(url.search.substring(1)); var action = getActionFromPath(queryParameters['p']); if (action == 'create') { queryParameters['p'] = setActionInPath(queryParameters['p'], ''); if (queryParameters['p'] != '') { queryParameters['p'] = queryParameters['p'] + ';' + 'newid'; return url.pathname + '?' + jQuery.param(queryParameters); } else { return url.pathname + 'newid' + '?' + jQuery.param(queryParameters); } } } function getNewMetaUrl(metaUrl) { return getNewUrl(metaUrl); } function getRedirectUrl() { return getNewUrl(location.href); } function getModules() { var modules = [ { path: 'Form Logic', code: $('textarea[id$="svc:formlogic"]').text() || '', param: $('textarea[id$="svc:formlogic"]').attr('id'), }, { path: 'Form Validations', code: $('textarea[id$="svc:formvalidation"]').text() || '', param: $('textarea[id$="svc:formvalidation"]').attr('id'), }, ]; return modules; } $(document).ready(function() { setTimeout(function() { var metaUrl = getMetaUrl(); console.log('metaUrl: ', metaUrl); var newMetaUrl = getNewMetaUrl(metaUrl); console.log('newMetaUrl: ', newMetaUrl); var redirectUrl = getRedirectUrl(); console.log('redirectUrl: ', redirectUrl); var modules = getModules(); console.log('modules: ', modules); if (!metaUrl || !modules) { console.log('invalid input'); return; } var chrome = navigator.userAgent.indexOf('Chrome') > -1; var firefox = navigator.userAgent.indexOf('Firefox') > -1; firefox && $('#main').css('height', '100%'); firefox && $('#inside').css('display', 'flex').css('flex-direction', 'row').css('height', '100%'); $(document.body).css('overflow', 'hidden'); $('#content').css('display', 'flex').css('flex-direction', 'column').css('margin-left', 0).css('height', '100%').css('width', '100%').css('padding-bottom', '10px'); $('.boxloader').css('margin-bottom', 0); $('.box-head').width('100%'); $('.tab.tbl1').css('padding', 0); $('.box[data-prop="svc:FormScript"]').hide(); var app = document.createElement('div'); app.style.height = '100%'; app.style.width = '100%'; app.style.flex = '1'; $('.boxloader').after(app); sce_mount(app, modules, metaUrl, newMetaUrl, redirectUrl); }, 1000); }); })();