За этот код, я бы от спасибо не отказался =))
Вообщем начнем делать якоря для системы uCoz :
1. Создаем .txt документ, в нем пишем такой код:
Код: Выделить всё
var apiWindowSize = 0;var api_id = id вашего приложения;var api_key = 'Защищенный ключ';var checkCallback = null; function checkApiSettings (callback) { callback = callback || null; checkCallback = callback; show('installBlock'); /* Not application user */ if (is_app_user == '0') {VK.External.showInstallBox(); return;} if (api_settings == null || (api_settings != null && (!(api_settings & 1) || !(api_settings & 2) || !(api_settings & 16) || !(api_settings & 4)))) {VK.External.showSettingsBox(279); return;} hide('installBlock'); show('waitBlock'); canGoToPage = true; /* Run callback function */ if (callback != null) {callback();}} function onApplicationAdded () { is_app_user = 1; checkApiSettings(checkCallback);} function onSettingsChanged (settings) { api_settings = settings; checkApiSettings(checkCallback);} function setApiWindowSize () { /* Get new window size */ var _newSize = document.body.offsetHeight + 20; if (apiWindowSize == _newSize) {return false;} /* Change size */ apiWindowSize = _newSize; VK.External.resizeWindow(820, _newSize); window.scroll(0, 0);} var curLocation = '';function setLocation (loc) { VK.External.setLocation(loc); curLocation = loc;}function showInviteBox () {VK.External.showInviteBox(); return false;}function scrollTop () {VK.External.scrollWindow(0, 150);}function onLocationChanged (loc) { if (curLocation == loc) {return;} document.location = loc; curLocation = loc;}function onWindowFocus () { }function onWindowBlur () { } var API = { callback: null, onerror: null, apiurl: 'http://api.vk.com/api.php', next: [], loading: false, /* Is app user */ isAppUser: function (uid, oc, oe) { uid = uid || false; this.sendRequest('isAppUser', uid ? {uid: uid} : null, oc, oe); }, getUserBalance: function (oc, oe) { this.sendRequest('getUserBalance', null, oc, oe); }, execute: function (code, oc, oe) { this.sendRequest('execute', {code: code}, oc, oe); }, /* Get user profiles */ getProfiles: function (uids, oc, oe) { var params = {}; if (uids.match(/^([0-9]+)$/)) {params.uids = uids;} else {params.domains = uids;} params.fields = 'photo_big,photo_medium,photo,sex,bdate,city,country,nickname,has_mobile'; this.sendRequest('getProfiles', params, oc, oe); }, getCountries: function (cids, oc, oe) { this.sendRequest('getCountries', {cids: cids}, oc, oe); }, getAds: function (oc, oe) { this.sendRequest('getAds', {count: 1}, oc, oe); }, getVideo: function (id, width, oc, oe) { width = width || 160; this.sendRequest('video.get', {videos: id, width: width}, oc, oe); }, getVideoById: function (id, oc, oe) { this.sendRequest('video.getById', {videos: id}, oc, oe); }, getCities: function (cids, oc, oe) { this.sendRequest('getCities', {cids: cids}, oc, oe); }, getUploadWallServer: function (oc, oe) { this.sendRequest('wall.getPhotoUploadServer', null, oc, oe); }, saveWallPhotoPost: function (uid, server, photo, hash, post_id, message, oc, oe) { this.sendRequest('wall.savePost', {wall_id: uid, server: server, photo: photo, hash: hash, post_id: post_id, message: message}, oc, oe); }, saveWallPost: function (uid, photo, message, oc, oe) { this.sendRequest('wall.savePost', {wall_id: uid, photo_id: photo, message: message}, oc, oe); }, video: { getComments: function (pid, offset, count, oc, oe) { offset = offset || 0; count = count || 10; API.sendRequest('video.getComments', {pid: pid, offset: offset, count: count}, oc, oe); }, createComment: function (pid, message, oc, oe) { API.sendRequest('video.createComment', {pid: pid, message: escape(message)}, oc, oe); }, getById: function (videos, oc, oe) { API.sendRequest('video.getById', {videos: videos}, oc, oe); } }, sendRequest: function (method, params, onComplete, onError) { if (API.loading) {API.next.push(function () {API.sendRequest(method, params, onComplete, onError);}); return;} API.loading = true; API.callback = onComplete || null; API.onerror = onError || null; /* Create request params */ var rparams = {method: method, api_id: api_id, v: '2.0', format: 'JSON', callback: 'API.methodLoaded'}; for (var p in params) {rparams[p] = params[p];} /* Generate signature */ rparams['sig'] = API.genSignature(rparams); /* Build get uri */ var auri = []; for (var p in rparams) {auri.push(p+"="+rparams[p]);} /* Send request */ API.attachScript(method + '_' + Math.random(), API.apiurl + "?" + auri.join("&")); }, genSignature: function (params) { var sorted = []; /* Sor params */ for (var key in params) {sorted.push(key + "=" + params[key]);} sorted.sort(); /* Hash sig */ return MD5(viewer_id + sorted.join('') + api_key); }, attachScript: function (id, src) { var element = document.createElement('script'); element.type = 'text/javascript'; element.src = src; element.id = id; document.getElementsByTagName('head')[0].appendChild(element); }, /* Method loaded */ methodLoaded: function (data) { var cb = API.callback; var oe = API.onerror; API.callback = null; API.onerror = null; if (cb != null && data['response'] != undefined) {cb(data['response']);} //else if (oe != null && data['error'] != undefined) {oe(data['error']);} API.loading = false; API.goNext(); }, /* Go next method */ goNext: function () { if (API.next.length == 0) {return;} var func = API.next.shift(); func(); }}
2. Создаем глобальный блок.
у меня глобальный блок называется JS.(У Вас может быть по другому.)
3. В ваш глобальный блок пихаем этот код:
Код: Выделить всё
<script type="text/javascript" src="/js/api.js?11"></script> <script type="text/javascript"> VK.init(); scrollTop(); setLocation('$ENTRY_URL$'); VK.addCallback("onLocationChanged", onLocationChanged); </script>
Должно выглядеть так:
Код: Выделить всё
$GLOBAL_JS$ </head>
P.S. Кто почистит код от мусора, киньте сюда =))