form_view_min.js 970 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. function openlink(menuitem){
  2. var menu = { name: menuitem };
  3. $.ajax({
  4. type: "PUT",
  5. url: window.name,
  6. contentType: "application/json",
  7. data: JSON.stringify(menu),
  8. success: function (data) {
  9. }
  10. });
  11. }
  12. //https://stackoverflow.com/questions/5717093/check-if-a-javascript-string-is-a-url
  13. function validURL(str) {
  14. var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol
  15. '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name
  16. '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address
  17. '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path
  18. '(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string
  19. '(\\#[-a-z\\d_]*)?$','i'); // fragment locator
  20. return !!pattern.test(str);
  21. }
  22. function convertLinks(){
  23. $("#form a").each(function() {
  24. if(!validURL($(this).attr('href'))){
  25. $(this).attr('href', "javascript:openlink('" + $(this).attr('href') + "');")
  26. }
  27. })
  28. }
  29. $(document).ready(function(){
  30. convertLinks();
  31. });