• Главная
  • » PHP
  • » Браузерное расширение для форума

#171 2012.03.26 12:41

IMPEXINVINE
Участник
Откуда: Russia
Зарегистрирован: 2012.03.02
Сообщений: 10
Карма: 0
Профиль Веб-сайт

Re: Браузерное расширение для форума

не ну согласен. но скрипты ведь еще и не идеал. их нужно дорабатыва. я ведь не выкладывал полые сценарии. эти скрипты еще дописывать и дописывать. но для начала вполне хватит, даже больше чем надо. Ну надоже подтолкнуть, помочь человеку  или вы не согласны?

Половину могу убрать

Неактивен

#172 2012.03.27 12:26

TLENS
Moderator
Откуда: Украина
Зарегистрирован: 2009.04.05
Сообщений: 2402
Карма: 14
Профиль

Re: Браузерное расширение для форума

Время мало сейчас заннялся делом и за своим сайтром не успеваю следить. На этих выходных попробую закончить релиз.
Что я испривил:
Сделал один главный файл background.html и с ним настроил все порты. Тоесть чтобы подключится к апи с popup надо позвонить в бекгроунд потом с бакгроунда при ответе звоню назад в popup и отправляю результаты. Собственно данные все тоже лежат в бекгроунде и получаются с через порт.
Вот пару методов для в вода в курс блин десигнер 8 истек. Щас лиценцзию возьму

Неактивен

#173 2012.03.27 12:43

TLENS
Moderator
Откуда: Украина
Зарегистрирован: 2009.04.05
Сообщений: 2402
Карма: 14
Профиль

Re: Браузерное расширение для форума

Усовершенствована база форумов.

Код:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
forums = {
get array () {
var arr = {3:{},4:{},5:{},6:{},7:{}};
for (var i = 3; i <= 7; i++) {
arr[i].last_post_time = this[i].last_post_time;
arr[i].last_post_id = this[i].last_post_id;
arr[i].last_poster = this[i].last_poster;
arr[i].subject = this[i].subject;
arr[i].icon = this[i].icon;
}
return arr;
}
};
for (var i = 3; i <= 7; i++) {
forums[i] = prototype = {
i: i,
get last_post_time () {
return localStorage['forum[' + this.i + '][last_post_time]'] ?
parseInt(localStorage['forum[' + this.i + '][last_post_time]']) :
0;
},
set last_post_time (v) {
localStorage['forum[' + this.i + '][last_post_time]'] = v;
},
get last_post_id () {
return localStorage['forum[' + this.i + '][last_post_id]'] ?
parseInt(localStorage['forum[' + this.i + '][last_post_id]']) :
0;
},
set last_post_id (v) {
localStorage['forum[' + this.i + '][last_post_id]'] = v;
},
get last_poster () {
return localStorage['forum[' + this.i + '][last_poster]'];
},
set last_poster (v) {
localStorage['forum[' + this.i + '][last_poster]'] = v;
},
get subject () {
return localStorage['forum[' + this.i + '][subject]'];
},
set subject (v) {
localStorage['forum[' + this.i + '][subject]'] = v;
},
get icon () {
return (localStorage['forum[' + this.i + '][icon]']) ? true : false;
},
set icon (v) {
localStorage['forum[' + this.i + '][icon]'] = v;
}
}
}

Метод для упрощение работы с апи

Код:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var api = {
call: function (method, value, callback, error) {
var variable = '';
if (typeof value === 'object') {
for (v in value) {
variable += '' + v + '=' + value[v] + '&';
}
}
switch (method) {
case 'getMessage':
case 'getPrivateMessage':
case 'getPrivateMessages':
case 'getConfig':
case 'setMessage':
case 'getForums':
return $.getJSON('http://' + configs.host + '' + configs.patch_api + 'method=' + method + '&' + variable)
.success(callback)
.error(error);
break;
default:
return null;
}
}
};

Ну и собственно пример работы с портами

Код:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
ports = {
popup: null,
notification: null,
contentscript: null
};
 
 
 
 
 
chrome.extension.onConnect.addListener(function(port) {
if (port.sender.id === window.location.hostname) {
if (port.name === 'popup')
ports.popup = port;
else if (port.name === 'notification')
ports.notification = port;
else if (port.name === 'contentscript')
ports.contentscript = port;
else return;
port.onMessage.addListener(function (msg) {
// Проверка на соединение портов. Чет умнее не придумал.
if (typeof msg.connected !== 'undefined')
port.postMessage({connected: true});
// Получение и изминение настроек см. method.settingInPort
else if (typeof msg.setting !== 'undefined')
port.postMessage({setting: method.settingInPort(msg.setting)});
// Получение данных. А также их изменение (например отмерка как прочитаное)
else if (typeof msg.forum !== 'undefined')
port.postMessage({forum: method.forumInPort(msg.forum)});
// Прямой доступ к апи.
else if (typeof msg.api !== 'undefined')
api.call(msg.method, msg.value, function (data) {
if (data.status === true)
port.postMessage({api: true, data: data.data});
else
port.postMessage({api: true, error: data.data});
},
function (data) {
port.postMessage({api: true, error: data});
});
else if (typeof msg.reload !== 'undefined')
api.call('getForums', null, method.updateData);
});
// Событие на разрыв соединения.
port.onDisconnect.addListener(function () {
ports[port.name] = null;
});
}
});
 
 
 
 
api.call('getConfig', null, settings.update);
method.startUpdateData();

Неактивен

#174 2012.03.27 14:49

Gemorroj
Administrator
Откуда: Белоруссия
Зарегистрирован: 2007.11.03
Сообщений: 6593
Карма: 107
Профиль Веб-сайт

Re: Браузерное расширение для форума

так комить в свн

Неактивен

  • Главная
  • » PHP
  • » Браузерное расширение для форума

Дополнительно

forum.wapinet.ru

PunBB Mod v0.6.2
0.012 s