util.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. define(["parseuri"], function(parseUri){
  2. return {
  3. /**
  4. * @description Log messages and objects value into browser console
  5. */
  6. debug: function (message, object) {
  7. // Uncomment the lines below to enable debug.
  8. //object = object || "";
  9. //console.log(message, object);
  10. },
  11. /**
  12. * @description Returns all available parameters or empty object if no parameters in URL
  13. * @return {Object} Object containing {key: value} pairs where key is the parameter name and value is the value of parameter
  14. */
  15. getParameter : function (parameter) {
  16. this.debug("getParameter(" + parameter + ")");
  17. var whLocation = "";
  18. try {
  19. whLocation = window.location;
  20. var p = parseUri(whLocation);
  21. for (var param in p.queryKey) {
  22. if (p.queryKey.hasOwnProperty(param) && parameter.toLowerCase() == param.toLowerCase()){
  23. return p.queryKey[param];
  24. }
  25. }
  26. } catch (e) {
  27. this.debug(e);
  28. }
  29. },
  30. isLocal : function () {
  31. this.debug("isLocal()");
  32. var whLocation = "";
  33. try {
  34. whLocation = window.location;
  35. var p = parseUri(whLocation);
  36. if (p.protocol == "http" || p.protocol == "https") {
  37. return false;
  38. }
  39. } catch (e) {
  40. this.debug(e);
  41. }
  42. return true;
  43. }
  44. }
  45. });