tripal.js 898 B

12345678910111213141516171819202122
  1. if (Drupal.jsEnabled) {
  2. function tripal_get_base_url() {
  3. // Get the base url. Drupal can not pass it through a form so we need
  4. // to get it ourself. Use different patterns to match the url in case
  5. // the Clean URL function is turned on
  6. var baseurl = location.href.substring(0,location.href.lastIndexOf('/?q=/node'));
  7. if(!baseurl) {
  8. var baseurl = location.href.substring(0,location.href.lastIndexOf('/node'));
  9. }
  10. if (!baseurl) {
  11. // This base_url is obtained when Clena URL function is off
  12. var baseurl = location.href.substring(0,location.href.lastIndexOf('/?q=node'));
  13. }
  14. if (!baseurl) {
  15. // The last possibility is we've assigned an alias path, get base_url til the last /
  16. var baseurl = location.href.substring(0,location.href.firstIndexOf('/'));
  17. }
  18. return baseurl;
  19. }
  20. }