MediaWiki:Common.js

From SacredWiki
Revision as of 18:16, 15 December 2010 by Schot (talk | contribs)
Jump to navigation Jump to search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Any JavaScript here will be loaded for all users on every page load. */


 if (mwCustomEditButtons) {
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/align_center.png",
     "speedTip": "Will center highlighted text.",
     "tagOpen": "<center>",
     "tagClose": "</center>",
     "sampleText": ""};
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/S1internallink.jpg",
     "speedTip": "Make a Sacred Underworld Internal Link",
     "tagOpen": "[[Sacred:",
     "tagClose": "|]]",
     "sampleText": "Page Name you are linking to"};
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/S2internallink.jpg",
     "speedTip": "Make a Sacred 2:Fallen Angel Internal Link",
     "tagOpen": "[[Sacred 2:",
     "tagClose": "|]]",
     "sampleText": "Type here what you want the link to be read as..."};
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/questbutton.jpg",
     "speedTip": "Quest Template.  Push the preview to see results.",
     "tagOpen": "{{subst:Quest",
     "tagClose": "}}",
     "sampleText": ""};
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/chainquest.jpg",
     "speedTip": "ChainQuest Template.  Push the preview to see results.",
     "tagOpen": "{{subst:ChainQuest",
     "tagClose": "}}",
     "sampleText": ""};
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/place.jpg",
     "speedTip": "Place Template.  Push the preview to see results.",
     "tagOpen": "{{subst:Place",
     "tagClose": "}}",
     "sampleText": ""};
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/npc.jpg",
     "speedTip": "NPC Template.  Push the preview to see results.",
     "tagOpen": "{{subst:NPC",
     "tagClose": "}}",
     "sampleText": ""};
  }

function initialize() {
  // create the map
  var myOptions = {
    zoom: zoom,
    center: new google.maps.LatLng(lat,lng),
    backgroundColor: '#f0e0be',
    mapTypeId: maptype
}


  map = new google.maps.Map(document.getElementById("map_canvas"),
                                myOptions);
 
    var S2Options = { 
      getTileUrl: function(coord, zoom) { 
        return "http://www.darkmatters.org/Map/MainMap/"+zoom+"_"+coord.x+"_"+coord.y+".jpg";
      }, 
      tileSize: new google.maps.Size(256, 256), 
      isPng: false
    };

    var S2 = new google.maps.ImageMapType(S2Options);
    S2.name = "Main Map";
    S2.maxZoom = 7;
    S2.minZoom = 2;
    map.mapTypes.set('S2', S2);


var dungeonOptions = { 
      getTileUrl: function(coord, zoom) { 
        return "http://www.darkmatters.org/Map/Dungeons/"+zoom+"_"+coord.x+"_"+coord.y+".jpg";
      }, 
      tileSize: new google.maps.Size(256, 256), 
      isPng: false
    };

    var dungeons = new google.maps.ImageMapType(dungeonOptions);
    dungeons.name = "Dungeons";
    dungeons.maxZoom = 7;
    dungeons.minZoom = 2;
    map.mapTypes.set('dungeons', dungeons); 


    map.setOptions({
      mapTypeControl: true,
      mapTypeControlOptions: {
        style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
        mapTypeIds: ['S2', 'dungeons']
      }
    });

      // Make the link the first time when the page opens
      makeLink();

      // Make the link again whenever the map changes
      google.maps.event.addListener(map, 'maptypeid_changed', makeLink);
      google.maps.event.addListener(map, 'center_changed', makeLink);
      google.maps.event.addListener(map, 'bounds_changed', makeLink);
      google.maps.event.addListener(map, 'zoom_changed', makeLink);

  google.maps.event.addListener(map, 'click', function() {
        lastmarker = null;
        makeLink();
        infowindow.close();
        });
      // Read the data from example.xml
      downloadUrl("example.xml", function(doc) {
        var xmlDoc = xmlParse(doc);
        var markers = xmlDoc.documentElement.getElementsByTagName("marker");
        for (var i = 0; i < markers.length; i++) {
          // obtain the attribues of each marker
          var lat = parseFloat(markers[i].getAttribute("lat"));
          var lng = parseFloat(markers[i].getAttribute("lng"));
          var point = new google.maps.LatLng(lat,lng);
          var html = markers[i].getAttribute("description");
          var type = markers[i].getAttribute("type");
          var label = markers[i].getAttribute("label");
          // create the marker
          var marker = createMarker(point,label,html,type);
        }
        // put the assembled side_bar_html contents into the side_bar div
        document.getElementById("side_bar").innerHTML = side_bar_html;
          // ========= If a parameter was passed, open the info window ==========
          if (id) {
            if (idmarkers[id]) {
              google.maps.event.trigger(idmarkers[id],"click");
            } else {
              alert("id "+id+" does not match any marker");
            }
          }
          if (index > -1) {
            if (index < gmarkers.length) {
              google.maps.event.trigger(gmarkers[index],"click");
            } else {
              alert("marker "+index+" does not exist");
            }
          }
      });
    }

addOnloadHook(initialize);